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
" Vim Cheat sheet | |
" http://vim.rtorr.com/ | |
" If ctrl + s freezes your vim, use this config in .bashrc to disable sending xoff | |
" stty -ixon | |
" This command will remove trailing whitespace on save | |
autocmd BufWritePre *.* :%s/\s\+$//e | |
" Set line numbers |
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 r = 0, | |
len = 1000000, | |
a = 0, b = 0; | |
while (len--) { | |
r = Math.floor(Math.random() * 2) + 1; | |
if (r === 1) { | |
a++; | |
} else { |
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
<?php | |
/** | |
* Clear cache CLI style | |
* | |
* | |
* @category Mage | |
* @package Mage_Shell | |
* @copyright Copyright (c) 2015 Bjarne Oeverli (http://bjarneo.codes) | |
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.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
sudo chown -R $(whoami) ~/.npm |
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
Model + View | |
http://stackoverflow.com/a/5864000 | |
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 stop = new Date().getTime(); | |
while(new Date().getTime() < stop + 10000); |
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(){ | |
function getRandomColor() { | |
var letters = '0123456789ABCDEF'.split(''); | |
var color = '#'; | |
for (var i = 0; i < 6; i++ ) { | |
color += letters[Math.floor(Math.random() * 16)]; | |
} | |
return color; |
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
import React from 'react'; | |
import ReactDOM from 'react-dom'; | |
import FeedList from './feed-list'; | |
class Feed extends React.Component { | |
render() { | |
return ( | |
<div className="feed-wrapper"> | |
<FeedList /> | |
</div> |
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
// Remove N documents from collection | |
var idsToRemove = db.collection.find({ "query": "to perform" }).limit(10000).sort({ "_id": -1 }).toArray().map(function(doc) { return doc._id; }); | |
db.collection.remove({ "_id": { $in: idsToRemove }}) | |
// Update | |
db.collection.update({ "_id": { $set: { "test": "update" } } }); | |
// Get current operations | |
db.currentOp(); |
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
const events = {}; | |
function on(event, callback) { | |
if (!events[event]) { | |
events[event] = []; | |
} | |
events[event].push(callback); | |
} |