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
| parse_git_branch() { | |
| slashes=${PWD//[^\/]/} | |
| directory="$PWD" | |
| path=false | |
| if [ -d ".git" ]; then | |
| path="." | |
| else | |
| for (( n=${#slashes}; n>0; --n )) do | |
| test -e "$directory/.git" && path="$directory" |
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
| // example: | |
| // | |
| // var promises = new PromiseStack(); | |
| // | |
| // for (var i = 0; i < 10; i++) promises.push(/* a promise */, /* args... */); | |
| // | |
| // promises.limit( | |
| // 4, | |
| // function () { | |
| // console.log('success'); |
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
| <html> | |
| <head> | |
| <meta property="og:video" content="http://www.youtube.com/v/rRoy6I4gKWU?version=3&autohide=1"> | |
| <meta property="og:video:type" content="application/x-shockwave-flash"> | |
| <meta property="og:video:width" content="1280"> | |
| <meta property="og:video:height" content="720"> | |
| </head> | |
| </html> |
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
| var spawn = require('child_process').spawn; | |
| function doesCommandExist (command, callback) { | |
| var child = spawn('type', [command]); | |
| child.on('close', function (code) { | |
| callback(!code); | |
| }); | |
| } | |
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
| Array.prototype.slice.call(document.styleSheets).forEach(function (stylesheet, index, array) { | |
| if (!stylesheet.rules) return; | |
| console.groupCollapsed("Stylesheet #%s", index); | |
| Array.prototype.slice.call(stylesheet.rules).forEach(function (rule, index, array) { | |
| var properties = rule.cssText.match(/\{\s+?(.+)\s+?\}/); | |
| if (rule.type === 1) { | |
| console.log('%s%c %s', rule.selectorText, 'font-weight: normal; color: #999', properties ? properties[1] : ''); |
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
| var script = document.createElement('script'); script.src = 'http://code.jquery.com/jquery-2.0.3.min.js'; document.head.appendChild(script); | |
| var order = { | |
| 960015155: 1, // Lucerne Cheese Natural Pepper Jack - 32 Oz | |
| 960035197: 1, // Coke Soda Diet - 20-12 Fl. Oz. | |
| 188560047: 1, // Smithfield Bacon Naturally Hickory Smoked Thick Sliced - 16 Oz | |
| 960030810: 1, // Claim Pie Lattice Apple Jumper - 46 Oz | |
| 184490015: 3, // Green Jalapeno Peppers | |
| 184060007: 5, // Bananas | |
| // 960073834: 1, // Safeway Farms White Whole Mushrooms - 16 Oz |
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
| DELIMITER ;; | |
| CREATE PROCEDURE insert_data() | |
| BEGIN | |
| DECLARE i INT DEFAULT 0; | |
| WHILE i < 1000000 DO | |
| /* QUERY */ | |
| SET i = i + 1; | |
| END WHILE; | |
| END;; |
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
| /** | |
| * The first commented line is your dabblet’s title | |
| */ | |
| background: #f06; | |
| background: linear-gradient(45deg, #f06, yellow); | |
| min-height: 100%; |
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 getBlocksFromRect(width, height, blockCount) { | |
| var blocks = [], cols, rows; | |
| if (Math.sqrt(blockCount) === Math.floor(Math.sqrt(blockCount))) { | |
| cols = rows = Math.sqrt(blockCount); | |
| } else { | |
| cols = blockCount / 2 === Math.floor(blockCount / 2) ? 2 : 1; | |
| rows = blockCount / cols; | |
| } |
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 AsyncTaskThrottle () { | |
| this._queued = null; | |
| this._busy = false; | |
| } | |
| AsyncTaskThrottle.prototype = { | |
| do: function (task) { | |
| if (!this._busy) { | |
| this._queued = task; | |
| return this._call(); |