Skip to content

Instantly share code, notes, and snippets.

View liesislukas's full-sized avatar
🚀
Excited

Lukas Liesis liesislukas

🚀
Excited
View GitHub Profile
@liesislukas
liesislukas / gist:1473ec0876cc264c4c7d317af211dc06
Last active May 5, 2017 07:44
WooCommerce: update attributes for all products by using search to filter the products before update.
var WooCommerceAPI = require('woocommerce-api');
var WooCommerce = new WooCommerceAPI({
url: 'https://xxxx.lt',
consumerKey: 'xxxxx',
consumerSecret: 'xxxxx',
wpAPI: true,
version: 'wc/v1'
});
function helper({timeout, id, value, data}) {
@liesislukas
liesislukas / js.js
Last active April 25, 2017 14:13
Modified LiquidMetal algorithm with more weight for strings that have bigger max sequence & huge boost for sequences in front
(function (global) {
let SCORE_NO_MATCH = 0.0;
let SCORE_MATCH = 1.0;
let SCORE_TRAILING = 0.8;
let SCORE_TRAILING_BUT_STARTED = 0.9;
let SCORE_BUFFER = 0.85;
let WORD_SEPARATORS = ' \t_-';
let LiquidMetal = {
lastScore: null,
@liesislukas
liesislukas / runCron.js
Created May 5, 2017 07:43
Node.js cron runner. Interval is set using moment.js add() function. Check sample code
/*
Sample usage:
runCron({promise: screenshotsCache, intervalNumber: 5, intervalString: 'minutes'});
This will call "screenshotsCache" Promise every 5 minutes.
If promise resolves after 6 minutes, it will be called again immediately because 5 mins already passed.
*/
@liesislukas
liesislukas / encodings.js
Last active July 20, 2017 13:42
All possible encodings used on web. I need to validate if encoding string is "valid" and these are all encodings. Check comment below
const validEncodings = [
'US-ASCII', 'iso-ir-6', 'ANSI_X3.4-1968', 'ANSI_X3.4-1986', 'ISO_646.irv:1991', 'ISO646-US', 'us', 'IBM367', 'cp367',
'csASCII', 'ISO-8859-1', 'ISO_8859-1:1987', 'iso-ir-100', 'ISO_8859-1', 'latin1', 'l1', 'IBM819', 'CP819',
'csISOLatin1', 'ISO-8859-2', 'ISO_8859-2:1987', 'iso-ir-101', 'ISO_8859-2', 'latin2', 'l2', 'csISOLatin2',
'ISO-8859-3', 'ISO_8859-3:1988', 'iso-ir-109', 'ISO_8859-3', 'latin3', 'l3', 'csISOLatin3', 'ISO-8859-4',
'ISO_8859-4:1988', 'iso-ir-110', 'ISO_8859-4', 'latin4', 'l4', 'csISOLatin4', 'ISO-8859-5', 'ISO_8859-5:1988',
'iso-ir-144', 'ISO_8859-5', 'cyrillic', 'csISOLatinCyrillic', 'ISO-8859-6', 'ISO_8859-6:1987', 'iso-ir-127',
'ISO_8859-6', 'ECMA-114', 'ASMO-708', 'arabic', 'csISOLatinArabic', 'ISO-8859-7', 'ISO_8859-7:1987', 'iso-ir-126',
'ISO_8859-7', 'ELOT_928', 'ECMA-118', 'greek', 'greek8', 'csISOLatinGreek', 'ISO-8859-8', 'ISO_8859-8:1988',
const _ = require('lodash');
function orderObjectFields(input) {
if (!input) {
return input;
}
if (_.isString(input)) {
return input;
} else if (_.isArray(input)) {
@liesislukas
liesislukas / Fix ssl.ca.location issue on OSX
Created December 14, 2017 19:06
Fix ssl issue while installing node-rdkafka on OS X
before npm i:
install openssl: `brew install openssl`
export CPPFLAGS=-I/usr/local/opt/openssl/include
export LDFLAGS=-L/usr/local/opt/openssl/lib
export default function openInTab({url}) {
let instance = window.open('about:blank');
if (url.indexOf('http') !== 0) {
url = `http://${url}`;
}
let meta = `<meta http-equiv="refresh" content="0;url=${url}">`;
instance.document.write(meta);
instance.document.close();
return false;
}
@liesislukas
liesislukas / Docker shell commands.sh
Created August 11, 2018 00:21 — forked from bahmutov/Docker shell commands.sh
A personal cheat sheet for running local Node project in a Docker container
# See list of docker virtual machines on the local box
$ docker-machine ls
NAME ACTIVE URL STATE URL SWARM DOCKER ERRORS
default * virtualbox Running tcp://192.168.99.100:2376 v1.9.1
# Note the host URL 192.168.99.100 - it will be used later!
# Build an image from current folder under given image name
$ docker build -t gleb/demo-app .
@liesislukas
liesislukas / Immutable JS Examples
Created October 24, 2018 07:09 — forked from singhshivam/Immutable JS Examples
Immutable JS Examples
List()
var list = Immutable.List([1,2,3])
// [1, 2, 3]
List.isList()
Immutable.List.isList(list)
// true
List.of()
var list = Immutable.List.of(1,2,3);
@liesislukas
liesislukas / generate_load.sh
Created October 26, 2018 07:40
generate load on server
sha1sum /dev/zero | sha1sum /dev/zero