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
  • change "base" branch of this PR: master => 3.4 (use "Edit" button near PR title)
  • rebase your commits from master onto 3.4 branch. For example:
  • git rebase -i --onto upstream/3.4 upstream/master
  • push rebased commits into source branch of your fork (with --force option)
@cancerberoSgx
cancerberoSgx / css-like-pegjs-parser.txt
Created May 23, 2019 02:57
a css-like syntax parser using peg.js
/*
* CSS like attribute parsing.
*
* Parses strings like
`comp[name=myComp] > layer[name=myLayer light=true selected]` to objects.
`.cl #id>[name=123]`
*/
asciinema rec -t "typescript-ast-explorer cast 1" ../Documents/test4.cast
svg-term --in ../Documents/test4.cast --out demo3.sv
import Project from "ts-simple-ast";
const project = new Project({ useVirtualFileSystem: true });
const file = project.createSourceFile("src/a.ts", `
export class A {
method1(msg: string): string {
return "hello " + name;
}
}`);
file.getClassOrThrow("A").getMembers().forEach(m => console.log(m.getKindName()));
@cancerberoSgx
cancerberoSgx / backup-excluding.sh
Last active June 29, 2018 23:41
tgz excluding folders
tar --exclude='./.git' --exclude='./node_modules' -zcvf ../project-foo.tgz .
@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)
@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 / 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 / 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 / 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);