Skip to content

Instantly share code, notes, and snippets.

View cancerberoSgx's full-sized avatar

Sebastián Gurin cancerberoSgx

  • home
  • Montevideo, Uruguay
View GitHub Profile
@cancerberoSgx
cancerberoSgx / watch and exec.md
Last active April 25, 2018 06:32
watch and exec

Using unix command watch for detecting a change in file and executing command:

while true ; do  watch -g -d "cat src/index.ts" && yarn run doc-docco ; done

More refined, this time executes the command first:

CMD="yarn run doc-docco"; eval $CMD ; while true ; do watch -g -d "cat src/index.ts" && eval $CMD ; done
# Usage examle:
# $ time sh testing/repeatUntilFails.sh "npm run test-nobuild"
counter=0
while true; do
eval $1
if [[ "$?" -ne 0 ]]; then
echo
echo "*******"
echo " * FAILURE at loop #"$counter

echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p

@cancerberoSgx
cancerberoSgx / rmnodemodules.sh
Last active June 5, 2025 18:38
remove node_modules and package-lock.json recursively
find . -name "node_modules" -exec rm -rf '{}' +; find . -name "package-lock.json" -exec rm -rf '{}' +;
@cancerberoSgx
cancerberoSgx / promisified-hyperquest.js
Created May 10, 2018 05:44 — forked from nikcorg/promisified-hyperquest.js
Promisified Hyperquest -- A quick exercise wrapping Hyperquest in a Promise for an easy thenable API.
var concat = require("concat-stream");
var hyperquest = require("hyperquest");
var stream = require("stream");
// Wait for the request to finish or fail
function promisify(req) {
return new Promise(function (resolve, reject) {
req.on("error", reject).pipe(concat({ encoding: "string" }, resolve));
});
@cancerberoSgx
cancerberoSgx / async-doubt.js
Last active May 14, 2018 03:56
async/await doubt unexpected
function main(arr) {
arr.map(async (o) => {
const result = await g(o); // I expect it to await here but it doesn't
});
}
function g(o) {
return new Promise((resolve) => {
setTimeout(() => {
resolve(o);
@cancerberoSgx
cancerberoSgx / update-fork-master.sh
Created May 17, 2018 03:25
update fork's master with original repo
git remote add upstream $ORIGINALGITURL
git fetch upstream
git checkout master
git merge upstream/master
git push
@cancerberoSgx
cancerberoSgx / exec-global-regex-and-get-each-group-index.markdown
Created May 23, 2018 04:39
exec global regex and get each group index

exec global regex and get each group index

is not direct way in js to iterate a global regex and obtain the location of each group match in the input. This is kind of straight forward solution using indexOf and sum

A Pen by Sebastián Gurin on CodePen.

License.

@cancerberoSgx
cancerberoSgx / tsChildren.md
Created May 25, 2018 00:21
getChildren vs forEachChildren in TypeScript API

For a SourceFile with the following code :

/** Test1 description */ 
export class Test1 {
  dance(){ ; return}
}

Transverse it using getChildren()

@cancerberoSgx
cancerberoSgx / arrayUnion.js
Created May 29, 2018 05:29
array union in chained method call with standards and non new func decls
arr1.concat(arr2).filter((value, pos, arr)=>arr.indexOf(value)===pos)