Skip to content

Instantly share code, notes, and snippets.

@wiyoe
wiyoe / disable-cors.txt
Created January 26, 2018 11:39
Mozilla disable cors.
about:config -> security.fileuri.strict_origin_policy -> false
@wiyoe
wiyoe / lodash-pick.js
Last active January 29, 2018 15:04
Lodash Pick Key(Property)
var itemList = [
{id: 5, name: "sample 5", color: "red"},
{id: 6, name: "sample 6", color: "blue"},
];
itemList = _.map(itemList, function (item) { // Pick
return _.pick(item, ['id', 'name']);
});
@wiyoe
wiyoe / jquery-table-data.js
Created February 1, 2018 13:08
Jquery get table data to array.
var list = [];
$('table.resource-summary > tbody > tr').each(function(i, el) {
var $tds = $(this).find('td');
var obj = {
field_name: $tds.eq(0).text(),
description: $tds.eq(1).text(),
}
list.push(obj);
});
@wiyoe
wiyoe / windows-build-tools.txt
Last active February 2, 2018 06:50
NPM install windows-build-tools and node-gyp
npm install --global --production windows-build-tools
npm install --global node-gyp
//npm --add-python-to-path='true' --debug install --global windows-build-tools
##https://github.com/felixrieseberg/windows-build-tools/issues/33
##https://github.com/felixrieseberg/windows-build-tools/issues/47
@wiyoe
wiyoe / moment-utc-unix.js
Last active February 5, 2018 12:43
Momemt.js UTC Unix timestamp
moment.unix(); // Current UTC timestamp
moment.utc().unix(); // Current UTC timestamp
moment.utc("28-01-1992", "DD-MM-YYYY").unix(); // Convert to unix
moment.unix(696556800).utc().format("DD-MM-YYYY"); // Convert to date
@wiyoe
wiyoe / timezone-conversation.php
Last active February 5, 2018 13:27
PHP UTC Date to Locale Date
date_default_timezone_set("Europe/Istanbul");
$dateInUTC = "2018-02-05 13:22:56";
$time = strtotime($dateInUTC.' UTC');
echo $dateInLocal = date("Y-m-d H:i:s T", $time); // 2018-02-05 16:22:56 +03
@wiyoe
wiyoe / package-versions.txt
Created February 7, 2018 08:10
Viewing All Versions of an NPM Package
npm show quipu-tools@* version
@wiyoe
wiyoe / template-literal.js
Created February 15, 2018 08:24
Javascript ES6 iterate with template literal.
const dogs = [
{ name: 'Snickers', age: 2 },
{ name: 'Hugo', age: 8 },
{ name: 'Sunny', age: 1 }
];
const markup = `
<ul class="dogs">
${dogs.map(dog => `<li>${dog.name} is ${dog.age * 7}</li>`)}
</ul>
@wiyoe
wiyoe / decorator-example.js
Created February 15, 2018 12:03
Javascript decorator example.
function meta(object) {
return function(target) {
Object.keys(object).forEach(
key => target.prototype[key] = object[key]
)
}
}
@meta({
manufacturer: 'evolas'
@wiyoe
wiyoe / gettime.js
Last active February 19, 2018 11:00
Javascript unix timestamp.
const dateTime = new Date().getTime();
const unix = Math.round(dateTime / 1000);