How to start any new Node.js project:
$ npx license mit > LICENSE
$ npx gitignore node
$ npx covgen YOUR_EMAIL_ADDRESS
$ npm init -y
| { | |
| "countries": [ | |
| { | |
| "country": "Afghanistan", | |
| "states": ["Badakhshan", "Badghis", "Baghlan", "Balkh", "Bamian", "Daykondi", "Farah", "Faryab", "Ghazni", "Ghowr", "Helmand", "Herat", "Jowzjan", "Kabul", "Kandahar", "Kapisa", "Khost", "Konar", "Kondoz", "Laghman", "Lowgar", "Nangarhar", "Nimruz", "Nurestan", "Oruzgan", "Paktia", "Paktika", "Panjshir", "Parvan", "Samangan", "Sar-e Pol", "Takhar", "Vardak", "Zabol"] | |
| }, | |
| { | |
| "country": "Albania", | |
| "states": ["Berat", "Dibres", "Durres", "Elbasan", "Fier", "Gjirokastre", "Korce", "Kukes", "Lezhe", "Shkoder", "Tirane", "Vlore"] | |
| }, |
| [ | |
| {name: 'Afghanistan', code: 'AF'}, | |
| {name: 'Åland Islands', code: 'AX'}, | |
| {name: 'Albania', code: 'AL'}, | |
| {name: 'Algeria', code: 'DZ'}, | |
| {name: 'American Samoa', code: 'AS'}, | |
| {name: 'AndorrA', code: 'AD'}, | |
| {name: 'Angola', code: 'AO'}, | |
| {name: 'Anguilla', code: 'AI'}, | |
| {name: 'Antarctica', code: 'AQ'}, |
| { | |
| "AL": "Alabama", | |
| "AK": "Alaska", | |
| "AS": "American Samoa", | |
| "AZ": "Arizona", | |
| "AR": "Arkansas", | |
| "CA": "California", | |
| "CO": "Colorado", | |
| "CT": "Connecticut", | |
| "DE": "Delaware", |
| import * as Knex from 'knex'; | |
| export async function up(knex: Knex): Promise<any> { | |
| return knex.schema.createTable('test_setup', (table: Knex.TableBuilder) => { | |
| table.integer('foobar'); | |
| }); | |
| } | |
| export async function down(knex: Knex): Promise<any> { | |
| return knex.schema.dropTable('test_setup'); |
| // from: https://repl.it/@dericgw/ReduxRecreated | |
| // There area lot more checks in the Redux lib but this gets the point across. | |
| function createStore(reducer, initialState) { | |
| let currentState = initialState; | |
| const listeners = []; | |
| const getState = () => currentState; | |
| function subscribe(listener) { | |
| listeners.push(listener); |
| // ng-enter="myFunction()" | |
| app.directive('ngEnter', function () { | |
| return function (scope, element, attrs) { | |
| element.bind("keydown keypress", function (event) { | |
| if(event.which === 13) { | |
| scope.$apply(function (){ | |
| scope.$eval(attrs.ngEnter); | |
| }); | |
| event.preventDefault(); |
How to start any new Node.js project:
$ npx license mit > LICENSE
$ npx gitignore node
$ npx covgen YOUR_EMAIL_ADDRESS
$ npm init -y
| /** | |
| * Return a timestamp with the format "m/d/yy h:MM:ss TT" | |
| * @type {Date} | |
| */ | |
| function timeStamp() { | |
| // Create a date object with the current time | |
| var now = new Date(); | |
| // Create an array with the current month, day and time |
All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.
elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParentelem.clientLeft, elem.clientTop, elem.clientWidth, elem.clientHeightelem.getClientRects(), elem.getBoundingClientRect()| <?php | |
| // with print | |
| $object = new MyObject(); | |
| // second param true make return value instead of print | |
| error_log( print_r( $object, true ) ); | |
| // with var_dump | |
| function write_error_log( $object = null ){ |