C# 4: Dynamic and Nullable

Great question. Two facts that you probably don’t know: Dynamic behind the scenes is just object. That is, a “dynamic” variable is an “object” variable with a hint to the compiler that says “generate dynamic operations on this variable when it is used.” There is no such thing as a boxed nullable. When you box … Read more

Using JFreeChart to display recent changes in a time series

The JFreeChart class DynamicTimeSeriesCollection is a good choice. Addendum: As noted by @Bahadır, the last point of the series was persistently zero. @Don helpfully suggests advancing the time and then appending the data. dataset.advanceTime(); dataset.appendData(newData); import java.awt.BorderLayout; import java.awt.EventQueue; import java.awt.FlowLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.util.Random; import javax.swing.JButton; import javax.swing.JComboBox; import javax.swing.JPanel; import javax.swing.Timer; … Read more

Dynamic nested Material menu from json object in Angular 5

The following structure should work for you: <button mat-button [matMenuTriggerFor]=”main_menu”>My menu</button> <mat-menu #main_menu=”matMenu”> <ng-container *ngFor=”let mainItem of objectKeys(my_menu)”> <button mat-menu-item [matMenuTriggerFor]=”sub_menu”>{{ mainItem }}</button> <mat-menu #sub_menu=”matMenu”> <button *ngFor=”let subItem of my_menu[mainItem]” mat-menu-item>{{ subItem }}</button> </mat-menu> </ng-container> </mat-menu> Since I placed sub_menu inside the embedded template (*ngFor) we can use the same name for template reference variable(#sub_menu). … Read more

Displaying emoticons in Android

I think it would be more useful to build Spannable. private static final Factory spannableFactory = Spannable.Factory .getInstance(); private static final Map<Pattern, Integer> emoticons = new HashMap<Pattern, Integer>(); static { addPattern(emoticons, “:)”, R.drawable.emo_im_happy); addPattern(emoticons, “:-)”, R.drawable.emo_im_happy); // … } private static void addPattern(Map<Pattern, Integer> map, String smile, int resource) { map.put(Pattern.compile(Pattern.quote(smile)), resource); } public static … Read more

Dynamic favicon using image manipulation similar to Gmail adding a count

You can make an image with the canvas element, and then just replace the current favicon. Check out the following link for a good explanation on it. Reference Code is from the above reference. Markup <link id=”favicon” rel=”icon” type=”image/png” href=”image.png” /> JS (function () { var canvas = document.createElement(‘canvas’), ctx, img = document.createElement(‘img’), link = … Read more

Strange behaviour when using dynamic types as method parameters

What you need to remember is that dynamic resolution basically does the same process as static resolution, but at runtime. Anything that couldn’t be resolved by the CLR won’t be resolved by the DLR. Let’s take this small program, inspired by yours, and that doesn’t use dynamic at all: namespace ConsoleApplication38 { public interface IActualInterface … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)