This file contains 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 validVideoId(id) { | |
var img = new Image(); | |
img.src = "http://img.youtube.com/vi/" + id + "/mqdefault.jpg"; | |
img.onload = function () { | |
checkThumbnail(this.width); | |
} | |
} | |
function checkThumbnail(width) { | |
//HACK a mq thumbnail has width of 320. |
This file contains 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
// unit test of redux middleware w/ jest | |
import configureStore from './configure-store'; | |
const middleware = store => next => (action) => { | |
if (action.type === 'FOO') { | |
Promise.resolve({ type: 'FOO_SUCCESS', payload: {} }).then(act => store.dispatch(act); | |
} | |
return next(action); |
This file contains 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
/** | |
* Depth-first and Breadth-first graph traversals. | |
* | |
* In this diff we implement non-recursive algorithms for DFS, | |
* and BFS maintaining an explicit stack and a queue. | |
* | |
* by Dmitry Soshnikov <[email protected]> | |
* MIT Style license | |
*/ |
This file contains 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
//To fetch a branch, you simply need to: | |
git fetch origin | |
//This will fetch all of the remote branches for you. With the remote branches | |
//in hand, you now need to check out the branch you are interested in, giving | |
//you a local working copy: | |
git checkout -b test origin/test |
This file contains 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 program is an example of how to run a command such as | |
// ps aux | grep root | grep sbin | |
// using C and Unix. | |
#include <stdlib.h> | |
#include <unistd.h> | |
int pid; | |
int pipe1[2]; | |
int pipe2[2]; |