TypeScript: Define a union type from an array of strings

TypeScript 3.4 added const assertions which allow for writing this as: const fruits = [“Apple”, “Orange”, “Pear”] as const; type Fruits = typeof fruits[number]; // “Apple” | “Orange” | “Pear” With as const TypeScript infers the type of fruits above as readonly[“Apple”, “Orange”, “Pear”]. Previously, it would infer it as string[], preventing typeof fruits[number] from … Read more

Android activity over default lock screen

getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON| WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD| WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED| WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON); try using this flags to disable lock screen when the activity is started. After API level 17 you can use <activity android:name=”.yourActivityName” android:showOnLockScreen=”true” android:screenOrientation=”sensorPortrait” > showOnLockScreen like in the example…

Are there pointers in javascript?

No, JS doesn’t have pointers. Objects are passed around by passing a copy of a reference. The programmer cannot access any C-like “value” representing the address of an object. Within a function, one may change the contents of a passed object via that reference, but you cannot modify the reference that the caller had because … Read more

Why Bundle Install is installing gems in vendor/bundle?

In your project folder you will have .bundle directory that holds configuration for bundler. try deleting that folder. it should reset the install path for your gems back to system-wide settings. In the case you just want to edit the install path, opening .bundle/config with your favorite editor should show you the path to vendor/bundle. … Read more

How to set editor theme in IntelliJ Idea

OK I found the problem, I was checking in the wrong place which is for the whole IDE’s look and feel at File->Settings->Appearance The correct place to change the editor appearance is through File->Settings->Editor->Colors &Fonts and then choose the scheme there. The imported settings appear there 🙂 Note: The theme site seems to have moved.

Move item in array to last position

to move an element (of which you know the index) to the end of an array, do this: array.push(array.splice(index, 1)[0]); If you don’t have the index, and only the element, then do this: array.push(array.splice(array.indexOf(element), 1)[0]); Example: var arr = [1, 2, 6, 3, 4, 5]; arr.push(arr.splice(arr.indexOf(6), 1)[0]); console.log(arr); // [1, 2, 3, 4, 5, 6] … Read more

Working with SQL views in Entity Framework Core

In Entity Framework Core 2.1 we can use Query Types as Yuriy N suggested. A more detailed article on how to use them can be found here The most straight forward approach according to the article’s examples would be: 1.We have for example the following entity Models to manage publications public class Magazine { public … Read more

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