Skip to content

Instantly share code, notes, and snippets.

@re5et
re5et / no-final.js
Created February 22, 2016 04:00
huh
const crypto = require('crypto');
const algorithm = 'aes-256-ctr';
const password = 'DERRRRP'
function encrypt(text){
const cipher = crypto.createCipher(algorithm, password)
const crypted = cipher.update(text,'utf8','hex')
return crypted;
}
# -*- mode: ruby -*-
# vi: set ft=ruby :
# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
Vagrant.configure(2) do |config|
# The most common configuration options are documented and commented below.
# For a complete reference, please see the online documentation at
@re5et
re5et / gist:bc9d8e5847b5fd697d15
Created February 5, 2015 19:30
The reasons we set START_CTX in our unicorn config
atom
so @keefe, the deal with the unicorn restart problem is this:
1) When restarting, unicorn takes the binary for the rails unicorn bin from $0
2) capistrano releases are changing this location
3) unicorn expects the binary it is using to stay in the same spot ($0)
so after: https://github.com/Bluescape/thoughtstream-chef/pull/278 and https://github.com/substantial/cookbook-rails_nginx_unicorn/pull/12
@re5et
re5et / edit.sh
Last active August 29, 2015 14:05
EDITOR=edit
#! /bin/bash
emacsclient -e "(external-edit \"$1\")" > /dev/null

1: Generate CSR

openssl req -new -newkey rsa:2048 -nodes -keyout server-cert.key -out server-cert-sign-req.csr

# Country Name (2 letter code) [AU]:US
# State or Province Name (full name) [Some-State]:California
# Locality Name (eg, city) []:
# Organization Name (eg, company) [Internet Widgits Pty Ltd]:Flutterby Labs, Inc.
# Organizational Unit Name (eg, section) []:
# Common Name (eg, YOUR name) []:www.dogo.co
(defun async-command-and-highlight (command highlights &optional output-buffer)
(kill-buffer output-buffer)
(async-shell-command command output-buffer)
(with-current-buffer output-buffer
(mapcar
(lambda (highlight)
(highlight-phrase (car highlight) (cdr highlight)))
highlights)))
(async-command-and-highlight
class ActiveRecord::Base
def self.boolean_returning_transaction
begin
result = false
result = ActiveRecord::Base.transaction do
yield
return true
end
rescue
@re5et
re5et / force-save.el
Created August 27, 2013 21:59
Save a buffer, even if it hasn't been modified. I use this to touch / save a buffer when I want a test to run, etc.
(global-set-key (kbd "C-x C-s") 'force-save)
(defun force-save ()
(interactive)
(not-modified 1)
(save-buffer))
# RSpec matcher for validates_with.
# https://gist.github.com/2032846
# Usage:
#
# describe User do
# it { should validate_with CustomValidator }
# end
RSpec::Matchers.define :validate_with do |validator, options = {}|
match do |subject|
@re5et
re5et / node_https.js
Created July 1, 2013 19:34
node https server
const crypto = require('crypto'),
fs = require("fs"),
http = require("http");
var privateKey = fs.readFileSync('privatekey.pem').toString();
var certificate = fs.readFileSync('certificate.pem').toString();
var credentials = crypto.createCredentials({key: privateKey, cert: certificate});
var handler = function (req, res) {