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
## multi screens | |
:split/:vsplit - splits screens | |
crtl+w & arrows - navigate through windows | |
ctrl+w & < > ** resize horizontal screen | |
ctrl+w & + - ** resize vertical screen | |
Exit and go back to editor: | |
ctrl+z --> fg |
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
console.log('first'); | |
function go(){ | |
console.log('third'); | |
}; | |
//next tick starts with this cb | |
process.nextTick(go); | |
//async | |
setTimeout(function(){ | |
console.log('fourth'); |
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
/* Server */ | |
var fs = require('fs'); | |
var net = require('net'); | |
var Readable = require('stream').Readable; | |
var Writable = require('stream').Writable; | |
var server = net.createServer(function(socket){ | |
socket.setKeepAlive(true); | |
var stream = fs.createReadStream(__dirname+'/out.txt'); |
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
var listenMethods = {listenTo: 'on', listenToOnce: 'once'}; | |
// Inversion-of-control versions of `on` and `once`. Tell *this* object to | |
// listen to an event in another object ... keeping track of what it's | |
// listening to. | |
_.each(listenMethods, function(implementation, method) { | |
Events[method] = function(obj, name, callback) { | |
var listeningTo = this._listeningTo || (this._listeningTo = {}); | |
var id = obj._listenId || (obj._listenId = _.uniqueId('l')); | |
listeningTo[id] = obj; |
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
//check if the position about to be added threatens anyone | |
function isValid(board, x, y){ | |
for (var i=0; i<board.length; i++){ | |
if (board[i]!=-1){ | |
if (i == x) | |
return false; | |
if (board[i] == y) | |
return false; | |
if ((i-x == board[i]-y) || (i-x)/(board[i]-y) == 1 || (i-x)/(board[i]-y) == -1) | |
return false; |
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" /> | |
<title>Backbone.js example</title> | |
<link rel="stylesheet" type="text/css" href="css/sunny/jqueryui.min.css"/> | |
</head> | |
<body> | |
<!-- "slider" is a jquery slider --> | |
<div id="slider"></div> |
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.$palettes.on('hidden.bs.collapse', function (e) { | |
var $this = $(this), | |
targetPage = $target.attr('id').slice(0, -6), | |
$target = $(e.target); | |
var $i = $("span[itemprop=expandCollapseIcons] i", $("#" + targetPage + "-panel"); | |
if ($i.hasClass('icon-chevron-down')) { | |
$i.removeClass('icon-chevron-down').addClass('icon-chevron-up'); | |
} else { | |
$i.removeClass('icon-chevron-up').addClass('icon-chevron-down'); |
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.$palettes.on('hidden.bs.collapse', function (e) { | |
var $this = $(this), | |
$target = $(e.target); | |
var $i = $("span[itemprop=expandCollapseIcons] i", $target.closest(".panel")); | |
if ($i.hasClass('icon-chevron-down')) { | |
$i.removeClass('icon-chevron-down').addClass('icon-chevron-up'); | |
} else { | |
$i.removeClass('icon-chevron-up').addClass('icon-chevron-down'); | |
} |
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 consolify(el){ | |
var oLog = console.log; | |
var oWarn = console.warn; | |
var oErr = console.error; | |
console.log = console.info = function(message){ | |
if (oLog) | |
oLog.call(console, message); | |
write(message, el, "info"); | |
}; |
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
<?php | |
function base64url_encode($data) { | |
return rtrim(strtr(base64_encode($data), '+/', '-_'), '='); | |
} | |
function aes_encrypt($data, $aes_key, $sha_key) { | |
// apply PKCS#7 padding | |
$pad = 16-strlen($data)%16; | |
$data .= str_repeat(chr($pad),$pad); | |
// generate random IV |
OlderNewer