Skip to content

Instantly share code, notes, and snippets.

Sebastián Gurin cancerberoSgx

View GitHub Profile
View git rebase a PR.md
  • 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
a css-like syntax parser using peg.js
View css-like-pegjs-parser.txt
/*
* CSS like attribute parsing.
*
* Parses strings like
`comp[name=myComp] > layer[name=myLayer light=true selected]` to objects.
`.cl #id>[name=123]`
*/
View hwo to record terminal to svg
asciinema rec -t "typescript-ast-explorer cast 1" ../Documents/test4.cast
svg-term --in ../Documents/test4.cast --out demo3.sv
View ts-simple-ast-browser-example.ts
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 Jun 29, 2018
tgz excluding folders
View backup-excluding.sh
tar --exclude='./.git' --exclude='./node_modules' -zcvf ../project-foo.tgz .
@cancerberoSgx
cancerberoSgx / arrayUnion.js
Created May 29, 2018
array union in chained method call with standards and non new func decls
View arrayUnion.js
arr1.concat(arr2).filter((value, pos, arr)=>arr.indexOf(value)===pos)
@cancerberoSgx
cancerberoSgx / tsChildren.md
Created May 25, 2018
getChildren vs forEachChildren in TypeScript API
View tsChildren.md

For a SourceFile with the following code :

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

Transverse it using getChildren()

View exec-global-regex-and-get-each-group-index.markdown

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
update fork's master with original repo
View update-fork-master.sh
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
async/await doubt unexpected
View async-doubt.js
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);
You can’t perform that action at this time.