Posts

Showing posts from February, 2005

Angular Material Table Dynamic Columns Without Model

Answer : I found solution :) It is very very easy but i could't see at first :) only like that : <mat-cell *matCellDef="let element "> {{element[disCol]}} </mat-cell> I must use {{element[disCol]}} only in HTML. Now , everything is ok:) For a full working example based on @mevaka's Where jobDetails$ is the array of items. columns$ is equvilent to Object.keys(jobDetails$[0]) so is just an string[] <table mat-table [dataSource]="jobDetails$ | async"> <ng-container *ngFor="let disCol of (columns$ | async); let colIndex = index" matColumnDef="{{disCol}}"> <th mat-header-cell *matHeaderCellDef>{{disCol}}</th> <td mat-cell *matCellDef="let element">{{element[disCol]}}</td> </ng-container> <tr mat-header-row *matHeaderRowDef="(columns$ | async)"></tr> <tr mat-row *matRowDef="let row

Vector Pop Front In C++ Return Value Code Example

Example 1: c++ vector pop first element std :: vector < int > vect ; vect . erase ( vect . begin ( ) ) ; Example 2: delete from front in vector c++ // Deleting first element vector_name . erase ( vector_name . begin ( ) ) ; // Deleting xth element from start vector_name . erase ( vector_name . begin ( ) + ( x - 1 ) ) ; // Deleting from the last vector_name . pop_back ( ) ;

4chan A Code Example

Example 1: 4chan Tumblr is worst and i dont even use either. Example 2: 4chan Remember, this website is the dark hairy asshole of the internet. But sometimes cool stuff happens here.

Codeigniter Query Builder Show Sql Code Example

Example: how to print mysql query of codeigniter query builder To display the query string: print_r ( $this - > db - > last_query ( ) ) ; To display the query result: print_r ( $query ) ;

Bat File Wait For 10 Seconds Code Example

Example 1: how to wait for seconds in batch file Windows version: w10 Set LoopVar to whatever number you want. Not exactly 1 second per loop but roughly 1 second. This will count down till it hits zero the below example waits for 3 seconds and counts down to 1 (not zero) --------------------------------CODE--------------------------------- @echo off set LoopVar=3 :Loop PING localhost -n 2 >NUL ::\/ optional line echo %LoopVar% set /a LoopVar=%LoopVar%-1 if not %LoopVar%==0 goto Loop ::\/ optional line pause ---------------------------------------------------------------------- below is simplifed delay without extra bits for pasting convence :) ---------------------------------------------------------------------- @echo off set LoopVar=3 :Loop PING localhost -n 2 >NUL echo %LoopVar% set /a LoopVar=%LoopVar%-1 if not %LoopVar%==0 goto Loop Example 2: windows batch file wait 5 seconds SLEEP X_NUMBER_SECONDS

Apple Web Code Example

Example 1: apple Apple is Linux in worse. Example 2: apple best_fruit = 'Apple' straight_facts = True

Auto Scale Fargate Service Based On SQS ApproximateNumberOfMessagesVisible

Answer : Yes you can do this. You have to use a step scaling policy, and you need to have an alarm created already for your SQS queue depth (ApproximateNumberOfMessagesVisible). Go to CloudWatch, create a new alarm. We'll call this alarm sqs-queue-depth-high , and have it trigger when the approximate number of messages visible is 1000. With that done, go to ECS to the service you want to autoscale. Click Update for the service. Add a scaling policy and choose the Step Tracking variety. You'll see there's an option to create a new alarm (which only lets you choose between CPU or MemoryUtilization), or use an existing alarm. Type sqs-queue-depth-high in the "Use existing alarm" field and press enter, you should see a green checkmark that lets you know the name is valid (i.e. the alarm exists). You'll see new dropdowns where you can adjust the step policy now. This works for any metric alarm and ECS services. If you're going to be trying to scale this

Automating The InvokeRequired Code Pattern

Answer : Lee's approach can be simplified further public static void InvokeIfRequired(this Control control, MethodInvoker action) { // See Update 2 for edits Mike de Klerk suggests to insert here. if (control.InvokeRequired) { control.Invoke(action); } else { action(); } } And can be called like this richEditControl1.InvokeIfRequired(() => { // Do anything you want with the control here richEditControl1.RtfText = value; RtfHelpers.AddMissingStyles(richEditControl1); }); There is no need to pass the control as parameter to the delegate. C# automatically creates a closure. UPDATE : According to several other posters Control can be generalized as ISynchronizeInvoke : public static void InvokeIfRequired(this ISynchronizeInvoke obj, MethodInvoker action) { if (obj.InvokeRequired) { var args = new object[0]; obj.Invoke(action, args); } else { action

Does Not Name A Type Error In C++ Code Example

Example: void does not a name a type in cpp void does not name a type

A __construct On An Eloquent Laravel Model

Answer : You need to change your constructor to: public function __construct(array $attributes = array()) { parent::__construct($attributes); $this->directory = $this->setDirectory(); } The first line ( parent::__construct() ) will run the Eloquent Model 's own construct method before your code runs, which will set up all the attributes for you. Also the change to the constructor's method signature is to continue supporting the usage that Laravel expects: $model = new Post(['id' => 5, 'title' => 'My Post']); The rule of thumb really is to always remember, when extending a class, to check that you're not overriding an existing method so that it no longer runs (this is especially important with the magic __construct , __get , etc. methods). You can check the source of the original file to see if it includes the method you're defining.

Apply Multiple Font Colors To The Text In A Single Google Sheets Cell

Answer : As on July 2018, Apps-Script support changing individual text colors and other font related styles. Two methods are added to SpreadsheetApp . newTextStyle() and newRichTextValue() . The following apps-script changes such fontstyles in A1. For best effects, Use a lengthy string(30 characters or more). function rainbow(){ var rng = SpreadsheetApp.getActiveSheet().getRange("A1"); var val = rng.getValue().toString(); var len = val.length; // length of string in A1 var rich = SpreadsheetApp.newRichTextValue(); //new RichText rich.setText(val); //Set Text value in A1 to RichText as base for (var i=0;i<len;i++){ //Loop through each character var style = SpreadsheetApp.newTextStyle(); // Create a new text style for each character var red= ("0"+Math.round((1/len)*(i)*255).toString(16)).substr(-2,2); // var green= ("0"+Math.round((1/len)*Math.min(i*2,len-Math.abs(i*2-len))*255).toString(16)).substr(-2,2); // var blue= (&

Bad JSON: IncrementVersionTracking Query Failed: Unknown Column '0.11.7.3' In 'field List' At Terraria.ModLoader.UI.ModBrowser.UIModBrowser.PopulateFromJson(LocalMod[] InstalledMods, String Json) Code Example

Example: C# Unknown column 'FundAllocation' in 'field list /* Could be: a) Using the wrong kind of qoutes, ie. 'FieldName' instead of `FieldName` b) Your table does not have that column c) You are trying to update/access data in the incorrect table (see point b) */

How To Run C Program In Windows 10 Using Cmd Code Example

Example 1: How to run C program using command gcc < file - name . c > - o < output - file - name > Example 2: compile c file in command prompt windows cl program . c

Clearing Spotify Cache To Recover Disk Space?

Answer : Found on Lifehacker: When you play a song on Spotify, it uses some of your hard drive space to cache that file for faster playing later. Here's how to clear that cache if you need some extra disk space. By default, Spotify limits its cache to 10% of your free space, which means the default setting should be okay—but if you've changed it, you could run into disk space problems. All you need to do is delete the files in the following folder (for your platform): Windows: C:\Users\USERNAME\AppData\Local\Spotify\Storage OS X: /Users/USERNAME/Library/Caches/com.spotify.client/Storage/ Linux: ~/.cache/spotify/Storage/ You can adjust the maximum size of the cache so it doesn't grow so big, and the next time you start spotify it will shrink the cache down to the size you specify. Close spotify, then open for editing the prefs file which is at: Windows 1 : %APPDATA%\Roaming\Spotify\prefs Linux: $HOME/.config/spotify/prefs Add or modify the line starting with

Angular Material Icons List Code Example

Example: material icons angular < mat - icon class = "mat-icon-rtl-mirror" svgIcon = "thumb-up" > < / mat - icon >

Alarm After 20 Minutes Code Example

Example: 20 minute timer for good eyesight every 20 minutes look out the window at something 20 feet away for 20 seconds

Cannot Find Module 'glob'

Answer : There's already an issue reporting this error message. The workaround until the next release is to install glob for the project ( npm install --save glob ) Regarding the commands, according to their repository under Generating and serving an Angular2 project via a development server the commands are as follow ng new ponyracer : This command will create a project named ponyracer (a folder named ponyracer with all the set up in it). ng serve : This command will run the live reload server to serve the application so you can see it in your browser. PS : If you test the solution suggested in the issue it would be nice of you to report if it worked or not. PS2 : I tested now (I fixed my error) and I cannot reproduce your error. I'm using node v5.5.0 and npm v3.7.3. Can you specify which node and npm versions are you using? I had the same error on Windows 10, D:\Code\AngularJS>ng new greetings-ac Cannot find module 'glob' Error: Cannot find m