Skip to content

Instantly share code, notes, and snippets.

View lukasbach's full-sized avatar
🦕

Lukas Bach lukasbach

🦕
View GitHub Profile
@lukasbach
lukasbach / getUrlParams.js
Created May 14, 2018 14:41
Get url parameters in JavaScript
const getUrlParams = locationSearch => locationSearch.substring(1).split('&')
.reduce((map, obj) => {let [a, b] = obj.split('='); map[a] = b; return map; }, {});
/*
Example:
const params = getUrlParams(window.location.search);
Assuming window.location.search = ?a=b&c=d
Then: params = {a: 'b', c: 'd'}
*/
let funRun = (w1, w2, b) => {
let obj = {};
obj.ga1 = w1 * -0.4 + w2 * 0.5 + b;
obj.ga2 = w1 * -0.8 + w2 * (-0.2) + b;
obj.gb1 = w1 * 0.5 + w2 * 1.2 + b;
obj.gb2 = w1 * -0.4 + w2 * 2.5 + b;
return obj;
}
nextIter = (w1, w2, b) => {
@lukasbach
lukasbach / deepReplace.js
Created July 5, 2018 17:55
Replace object members by member name in a deeply nested object
const deepReplace = (obj: object, keyName: string, replacer: (from: any) => string) => {
for (const key in obj) {
if (key === keyName) {
obj[key] = replacer(obj[key]);
} else if (Array.isArray(obj[key])) {
(obj[key] as any[]).forEach(member => deepReplace(member, keyName, replacer));
} else if (typeof obj[key] === "object") {
deepReplace(obj[key], keyName, replacer);
}
}
{
standalone:true,
src_folders:[
'__nightwatch__/testOrchestration'
],
output_folder:'reports',
custom_assertions_path:'',
page_objects_path:'__nightwatch__/pageObjects',
globals_path:'',
selenium:{
const removeDuplicates<T> = (arr: T[], equal: (a: T, b: T) => boolean) =>
arr.filter((item, pos) => arr.indexOf(arr.find(inner => equal(inner, item)) === pos));
@lukasbach
lukasbach / formatTimeZoneOffset.ts
Created April 14, 2020 13:46
Format Timezone Offset
const formatTimeZoneOffset = (offset: number) => {
return (
(offset >= 0 ? '+' : '-') +
('0' + Math.floor(Math.abs(offset))).slice(-2) +
':' +
('0' + Math.round((Math.abs(offset) % 1) * 60)).slice(-2)
);
};
@lukasbach
lukasbach / reference.bib
Created April 1, 2021 15:05
t-Distribution Table LaTeX Code
@article{howell,
author = {Howell, D},
title = {{Fundamental Statistics For the Behavioral Sciences}},
year = {2008}
}
@lukasbach
lukasbach / book
Created February 12, 2022 23:38
Factorio Modular Traingrid Blueprint Library
This file has been truncated, but you can view the full file.
0eNrMvVtvXcmSnftXCnoWjZn3zA34we6DAxiwAcMNAzYawgarxKpNbJYoU1R192ns/34WKV7mEjNXji9yabcfGt2t4hozMy55iYiM8W/vfr75evX57vrT/Z9/vr3967s//dvrv3x596d/+jfwBw//7fqX20/f/vnL9W+fLm8e/u3+Xz9fvfvTu+v7q9/fvX/36fL3h//v7vL65t3f3r+7/vTx6l/e/cn97f30J1/uL3/568Wv1zf3V3cX15++XN0d/o8dhv/bh/fvrj7dX99fX30bw+P/869//vT1958Pf/kn9wJ19S+f766+fLn4evjl3W93t4f/ffHz1c394WOfb78cAG4/PQzjABr+Q3r/7l/f/amU/5AOn/p4fXf1y7f/nN8/D/P26/3nr/fvHqbw3Rf9my/e311++vL59u5+8D0//l4HP6zMKFtmFO0zysqM0hv8L59vru8fNP0GOT4j1zluxuNOSBMF42eEX+34b+QeO/gN4xekV7cBxdZXwfSgLH7cBKu//jQweufB4J17UawgFosHu01YlMaTiUufNK0aLmHzcmwldHnhC5oFcxd3gX2hEjPLp52EO7SLaLR+419I7AsWR3dlxdM98vQKPN0HLq6GXMDHhS9oCuFu7Df2Be7G3rEvFKDhB6WdcDLPd2XPFh3fyGgTOBAF7r6+sMOp419gh6JAvPVhwid0Gbh/+spGGxe+IB3igsE/2QoQsmFJfjH5ajk7BL7vhuEHu1Kr9g80SWjNfmmSPhC5L8fhB3zvA85+fWp9f4veDlkloQT7laYOxhzttzBNzsk+5pGc+Y5aZ2LgHtmY6qp9zJqcm30GAzknw3HYoUEn03HYLS2+yS9dFqvhCJ7Cwk1uYLEpLmCOFJ4W7oOawvPCHW406rJwa9NGXRdGXaUvtIU5DCwkG9w3zzDdAuZAf9kv3YktDplXbq6jaazcVUfiNjgk2zay5fTr6tIKnMvCjXgk/bpwj9ck1RZGLS0CxXB/DRMLKm4BcyDr4hdiBJKsS1j
@lukasbach
lukasbach / recipes.ts
Last active March 23, 2022 21:49
TypeScript Advanced typing recipes
type Wrapper<T> = { wrapped: T };
type MapObject<T extends Record<keyof Object, any>> = {
[K in keyof T]: Wrapper<T[K]>;
};
type MapTuple<T extends [...any[]]> = {
[I in keyof T]: Wrapper<T[I]>;
} & { length: T["length"] };
@lukasbach
lukasbach / content.md
Created August 9, 2022 09:06
markdown example

Advertisement :)

  • pica - high quality and fast image resize in browser.
  • babelfish - developer friendly i18n with plurals support and easy syntax.

You will like those projects!