This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # default branch to serve | |
| set $branch "master"; | |
| # Serve features on *.app.dev subdomain | |
| if ($host ~* ^([^.]+)\.app\.dev\.company\.com$) { | |
| set $branch $1; | |
| } | |
| # All branches are hosted from a subdirectory | |
| root /var/www/branches/$branch; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| gitdir="$(git rev-parse --git-dir)" | |
| hook="$gitdir/hooks/post-commit" | |
| # disable post-commit hook temporarily | |
| [ -x $hook ] && chmod -x $hook | |
| git commit -a -m "Commit all changes for testing. Will be reverted automatically" | |
| # enable it again | |
| chmod +x $hook |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function clamp(val, min, max) { | |
| return Math.min(Math.max(min, val), max) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| * This will give you the same result, and make | |
| * it easier to change the box-sizing in plugins | |
| * or other components that leverage other behavior. | |
| * @see https://css-tricks.com/inheriting-box-sizing-probably-slightly-better-best-practice/ | |
| */ | |
| html { | |
| box-sizing: border-box; | |
| } | |
| *, *:before, *:after { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Write a function that takes two strings, and returns the index of the first occurrence of one string in the other | |
| // Do not use built-in functions: indexOf, substr, substring, array.split | |
| function indexof(strToFind, str) { | |
| var len1 = str.length; | |
| var len2 = strToFind.length; | |
| var i, j, numCorrect; | |
| for (i=0; i<len1; i++) { | |
| numCorrect = 0; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function reverse(str) { | |
| if (str === '') | |
| return ''; | |
| else | |
| return reverse(str.substr(1)) + str.charAt(0); | |
| } | |
| reverse("hello, world"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Find the length of maximum number of consecutive numbers jumbled up in an array. | |
| // e.g.: 1, 94, 93, 1000, 2, 92, 1001 should return 3 for 92, 93, 94 | |
| var numbers = [1, 94, 93, 1000, 2, 92, 1001]; | |
| var sequences = []; | |
| var count = 1; | |
| var diff; | |
| var largest; | |
| // sort | |
| numbers.sort(function(a, b){ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Given two strings, print all the inter-leavings | |
| // of the Strings in which characters from two strings | |
| // should be in same order as they were in original strings. | |
| // | |
| // e.g. | |
| // for "abc", "de", print all of these: | |
| // adebc, abdec, adbce, deabc, dabce, etc, etc | |
| var s1 = 'abc' | |
| var s2 = 'de' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Launch Redis on computer starts. | |
| ln -sfv /usr/local/opt/redis/*.plist ~/Library/LaunchAgents | |
| # Start Redis server via “launchctl”. | |
| launchctl load ~/Library/LaunchAgents/homebrew.mxcl.redis.plist | |
| # Start Redis server using configuration file. | |
| redis-server /usr/local/etc/redis.conf | |
| # Stop Redis on autostart on computer start. |