Skip to content

Instantly share code, notes, and snippets.

@awatson1978
awatson1978 / .travis.yml
Last active July 21, 2023 13:45 — forked from zeroasterisk/.travis.yml
Nightwatch Runner for Travis (and Phantom)
language: node_js
node_js:
- "0.10"
services:
- mongodb
sudo: required
@mpede
mpede / AESnode.js
Last active August 29, 2015 14:08
simple AES encryption class for node - you can pass key and iv or it will create them - you can change them after object creation as well
var AES=function(key,iv){
this.rc=function(l){ l=l||16;
var text = "", possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
for(var i=0;i<l;i++) text += possible.charAt(Math.floor(Math.random() * possible.length));
return text;
}
this.iv =iv ||this.rc();
this.key=key||this.rc(128);
this.decrypt = function(encryptdata) {
var decipher = crypto.createDecipheriv('aes-256-cbc', crypto.createHash('sha256').update(this.key).digest(), this.iv);
@chris-rock
chris-rock / crypto-buffer.js
Last active November 24, 2023 09:48
Encrypt and decrypt buffers in nodejs
// Part of https://github.com/chris-rock/node-crypto-examples
var crypto = require('crypto'),
algorithm = 'aes-256-ctr',
password = 'd6F3Efeq';
function encrypt(buffer){
var cipher = crypto.createCipher(algorithm,password)
var crypted = Buffer.concat([cipher.update(buffer),cipher.final()]);
return crypted;
@ziad-saab
ziad-saab / get-roles.js
Last active October 4, 2021 15:52
Get a list of a user's roles from Parse, including child roles, up to a certain depth
// Maximum depth is 3, after that we get a "" error from Parse
function getUserRoles(user) {
var queries = [
new Parse.Query('_Role').equalTo('users', user)
];
for (var i = 0; i < 2; i++) {
queries.push(new Parse.Query('_Role').matchesQuery('roles', queries[i]));
}
return user.rolesPromise = Parse.Query.or.apply(Parse.Query, queries).find().then(
@SFantasy
SFantasy / vertical-mid.sass
Created July 30, 2014 02:29
垂直居中 (use flex box)
.out-box
display: -webkit-flex
display: flex
height: 100px
& > p
margin: auto 0
@joecliff
joecliff / cryptojs_base64_encrypt_decrypt.js
Last active March 11, 2024 08:00
An example of base64 usage in cryptojs
var CryptoJS = require("crypto-js");//replace thie with script tag in browser env
//encrypt
var rawStr = "hello world!";
var wordArray = CryptoJS.enc.Utf8.parse(rawStr);
var base64 = CryptoJS.enc.Base64.stringify(wordArray);
console.log('encrypted:', base64);
//decrypt
var parsedWordArray = CryptoJS.enc.Base64.parse(base64);
@vojtajina
vojtajina / e2e-tests.js
Created February 15, 2012 23:41
Angular: Scenario runner explanation
// simple dsl just wrapping angular's dsl, just providing higher abstraction
angular.scenario.dsl('submitMessage', function() {
return function(message) {
// these dsl already register futures (add fn into the queue),
// so you don't wrap them into addFutureAction
input('modelValue').enter(message);
element('button.submit').click();
};
});
@unixcharles
unixcharles / Ohhh noes.txt
Created September 19, 2011 14:20
OSX libxml2 error fix
Look like brew libxml2 and the one bundled with osx are fighting
/Users/unixcharles/.rvm/gems/ruby-1.8.7-p352/gems/libxml-ruby-1.1.4/lib/libxml_ruby.bundle: dlsym(0x7ffb44ee7880, Init_libxml_ruby): symbol not found - /Users/unixcharles/.rvm/gems/ruby-1.8.7-p352/gems/libxml-ruby-1.1.4/lib/libxml_ruby.bundle (LoadError)
from /Users/unixcharles/.rvm/gems/ruby-1.8.7-p352/gems/libxml-ruby-1.1.4/lib/libxml.rb:9
from /Users/unixcharles/.rvm/gems/ruby-1.8.7-p352/gems/bundler-1.0.15/lib/bundler/runtime.rb:68:in `require'
from /Users/unixcharles/.rvm/gems/ruby-1.8.7-p352/gems/bundler-1.0.15/lib/bundler/runtime.rb:68:in `require'
from /Users/unixcharles/.rvm/gems/ruby-1.8.7-p352/gems/bundler-1.0.15/lib/bundler/runtime.rb:66:in `each'
from /Users/unixcharles/.rvm/gems/ruby-1.8.7-p352/gems/bundler-1.0.15/lib/bundler/runtime.rb:66:in `require'
from /Users/unixcharles/.rvm/gems/ruby-1.8.7-p352/gems/bundler-1.0.15/lib/bundler/runtime.rb:55:in `each'
from /Users/unixcharles/.rvm/gems/ruby-1.8.7-p352/gems/bundler-1.0.1
@dariusk
dariusk / gist:1154923
Created August 18, 2011 19:22
Game Maker Script: Find Movement Range
/*
This code is modified from Mnementh's code at http://gmc.yoyogames.com/index.php?showtopic=368996
I did some bug fixes, and I modified it to allow you to pass in a hash of terrain modifier overrides.
So for example, if swamp usually has a cost of 3, but you're a hovercraft, you can pass in {swamp: 1}.
NOTE THAT THIS IS A FUNCTION THAT IS CALLED FROM INSIDE A UNIT WHEN CALCULATING MOVEMENT RANGE
It's important to keep in mind that what this is doing is updating values on each tile.
Every tile has this kind of data in it:
@isaacs
isaacs / node-and-npm-in-30-seconds.sh
Last active March 8, 2024 02:11
Use one of these techniques to install node and npm without having to sudo. Discussed in more detail at http://joyeur.com/2010/12/10/installing-node-and-npm/ Note: npm >=0.3 is *safer* when using sudo.
echo 'export PATH=$HOME/local/bin:$PATH' >> ~/.bashrc
. ~/.bashrc
mkdir ~/local
mkdir ~/node-latest-install
cd ~/node-latest-install
curl http://nodejs.org/dist/node-latest.tar.gz | tar xz --strip-components=1
./configure --prefix=~/local
make install # ok, fine, this step probably takes more than 30 seconds...
curl https://www.npmjs.org/install.sh | sh