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
class Crypto | |
# encrypts data with the given key. returns a binary data with the | |
# unhashed random iv in the first 16 bytes | |
def self.encrypt(data, key) | |
cipher = OpenSSL::Cipher::Cipher.new("aes-256-cbc") | |
cipher.encrypt | |
cipher.key = key = Digest::SHA256.digest(key) | |
random_iv = cipher.random_iv | |
cipher.iv = Digest::SHA256.digest(random_iv + key)[0..15] | |
encrypted = cipher.update(data) |
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
// Usage: | |
// var express = require('express') | |
// require('enableMultipleViewRoots')(express) | |
module.exports = function(express) { | |
var old = express.view.lookup; | |
function lookup(view, options) { | |
// If root is an array of paths, let's try each path until we find the view | |
if (options.root instanceof Array) { |
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
# Formatted for readability | |
SELECT src, src_height, src_width, src_small, src_small_height, src_small_width | |
FROM photo | |
WHERE pid IN (SELECT pid | |
FROM photo_tag | |
WHERE subject='243117879034102' ) | |
OR | |
pid IN (SELECT pid | |
FROM photo | |
WHERE aid IN (SELECT aid |
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
# inspired by https://github.com/biilmann/mongo_sessions | |
require 'rack/session/abstract/id' | |
class Session | |
include Mongoid::Document | |
field :sid | |
field :data | |
field :ts, type: Integer | |
index :sid, unique: true #dont forget Session.create_indexes | |
def Session.find_by_sid(sid) | |
Session.first(conditions: {sid: sid}) |
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 express = require('express') | |
, http = require('http') | |
, connect = require('connect') | |
, io = require('socket.io'); | |
var app = express(); | |
/* NOTE: We'll need to refer to the sessionStore container later. To | |
* accomplish this, we'll create our own and pass it to Express | |
* rather than letting it create its own. */ | |
var sessionStore = new connect.session.MemoryStore(); |
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
// Require.js allows us to configure shortcut alias | |
require.config({ | |
// The shim config allows us to configure dependencies for | |
// scripts that do not call define() to register a module | |
shim: { | |
'socketio': { | |
exports: 'io' | |
}, | |
'underscore': { | |
exports: '_' |
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
module.exports = function(grunt) { | |
'use strict'; | |
// Project configuration. | |
grunt.initConfig({ | |
meta : { | |
// Specify where our test files are. Once we get all the tests switched over we can use 'test/js/**/*.spec.js' to automatically load all tests. | |
specs : ['test/js/src/**/*.spec.js'], | |
bin : { | |
coverage: 'js/bin/coverage' |
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
#!/bin/sh | |
# download | |
wget http://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-0.20.4.zip | |
# unzip and start | |
unzip elasticsearch-0.20.4.zip | |
cd elasticsearch-0.20.4 | |
# remove data in case you have defined some analyzers in the past (e.g. stop/start) | |
rm -rf data/ |
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
#!/usr/bin/env runhaskell | |
-- Haskell traceroute over icmp | |
-- now with ByteString to avoid new errors produced | |
-- by the deprecated recvFrom from Network.Socket | |
import Control.Monad | |
import Data.Bits(complement) | |
import Data.ByteString(unpack,pack) | |
import Data.List |
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
#! /usr/bin/env ruby | |
require 'rubygems' | |
require 'fog' | |
require 'fileutils' | |
require 'yaml' | |
module Apollo | |
class AwsConsole |
OlderNewer