Skip to content

Instantly share code, notes, and snippets.

Avatar
🦍
Generating legacy code

Hector Zarco zzarcon

🦍
Generating legacy code
View GitHub Profile
@zzarcon
zzarcon / fibonacci_memoization.js
Created Feb 17, 2016
Javascript Fibonacci memoization
View fibonacci_memoization.js
function fibonacci(num, memo) {
memo = memo || {};
if (memo[num]) return memo[num];
if (num <= 1) return 1;
return memo[num] = fibonacci(num - 1, memo) + fibonacci(num - 2, memo);
}
@zzarcon
zzarcon / .bash_profile
Created Mar 3, 2015
Git terminal helper
View .bash_profile
### GIT
source ~/.bash/gitprompt.sh
if [ -f ~/.git-completion.bash ]; then
. ~/.git-completion.bash
fi
alias gss="git status --short"
alias gl="git log --pretty=format:'%Cred%h%Creset - %C(green) %an %C(reset) - %C(yellow)%d%Creset %s %Cgreen(%cr) %Creset'"
View fibo_loop.js
function fibonacci(num){
var a = 1, b = 0, temp;
while (num >= 0){
temp = a;
a = a + b;
b = temp;
num--;
}
@zzarcon
zzarcon / fibonacci.js
Created Feb 17, 2016
Javascript Fibonacci
View fibonacci.js
function fibonacci(num) {
if (num <= 1) return 1;
return fibonacci(num - 1) + fibonacci(num - 2);
}
View changedFiles.js
runWhen([{
changedFiles: () => Promise.resolve(['app/index.js', 'app/components/header.jsx']),
glob: ['app/components/**'],
task(paths) {}
}])
View force_colors.js
const subprocess = exec(command, {
env: {...process.env, FORCE_COLOR: true}
});
View stdout-pipe.js
const subprocess = exec(command);
subprocess.stdout.pipe(process.stdout);
subprocess.stderr.pipe(process.stdout);
subprocess.on('exit', code => process.exit(code));
View run-when-await.js
// Inline await to get the the user changed files
const filesToMatch = changedFiles ? await changedFiles() : files;
// Example of a test
test('should run command if glob files matches', async () => {
await modifyFixtures();
const {stdout} = await run(`'["__fixtures__/**"]' 'echo fixtures changed'`);
expect(stdout.trim()).toEqual('fixtures changed');
await restoreFixtures();
View custom_install.yml
install:
- git clone https://github.com/$TRAVIS_REPO_SLUG.git $TRAVIS_REPO_SLUG
- cd $TRAVIS_REPO_SLUG
- git checkout -qf $TRAVIS_COMMIT