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 'zlib' | |
require 'stringio' | |
require 'json' | |
def gunzip(data) | |
io = StringIO.new(data, "rb") | |
gz = Zlib::GzipReader.new(io) | |
decompressed = gz.read | |
end | |
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 currentTimezoneOffset() { | |
var dstPeriod = { | |
2012: [new Date(2012, 2, 11), new Date(2012, 10, 4)], | |
2013: [new Date(2013, 2, 10), new Date(2013, 10, 3)], | |
2014: [new Date(2014, 2, 9), new Date(2014, 10, 2)], | |
2015: [new Date(2015, 2, 8), new Date(2015, 10, 1)], | |
2016: [new Date(2016, 2, 13), new Date(2016, 10, 6)], | |
2017: [new Date(2017, 2, 12), new Date(2017, 10, 5)], | |
2018: [new Date(2018, 2, 11), new Date(2018, 10, 4)], | |
2019: [new Date(2019, 2, 10), new Date(2019, 10, 3)], |
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/bash | |
# Update our package manager... | |
sudo apt-get update | |
# Install dependencies for RVM and Ruby... | |
sudo apt-get install -y build-essential libxslt1-dev libxml2-dev libreadline-dev zlib1g-dev libssl-dev curl git-core | |
# Get and install RVM | |
curl -L https://get.rvm.io | sudo bash -s stable |
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 "rvm/capistrano" | |
... | |
namespace :bootstrap do | |
task :default do | |
# Specific RVM string for managing Puppet; may or may not match the RVM string for the application | |
set :user, "ubuntu" | |
# Set the default_shell to "bash" so that we don't use the RVM shell which isn't installed yet... | |
set :default_shell, "bash" |
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 | |
# Credentials for a MySQL user with PROCESS, SUPER permissions | |
USERNAME= | |
PASSWORD= | |
# MySQL Server location | |
HOST=127.0.0.1 | |
PORT=3306 |
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 sh | |
## | |
# This is script with usefull tips taken from: | |
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx | |
# | |
# install it: | |
# curl -sL https://raw.github.com/gist/2108403/hack.sh | sh | |
# |
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 | |
CHARACTERS = (('A'..'Z').to_a + ('a'..'z').to_a + (0..9).to_a) | |
GROUP = 53 | |
MY_MACHINE_DYNDNS_ADDRESS = "Put your DynDns DNS name here" | |
MY_SSH_PORT = "Your router's external port that will forward to SSH" # as a Fixnum | |
def ridiculous_password | |
(1..20).map do |
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 "openssl" | |
require "digest" | |
def aes128_cbc_encrypt(key, data, iv) | |
key = Digest::MD5.digest(key) if(key.kind_of?(String) && 16 != key.bytesize) | |
iv = Digest::MD5.digest(iv) if(iv.kind_of?(String) && 16 != iv.bytesize) | |
aes = OpenSSL::Cipher.new('AES-128-CBC') | |
aes.encrypt | |
aes.key = key | |
aes.iv = iv |
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
# minimal rails3 app | |
require 'action_controller' | |
Router = ActionDispatch::Routing::RouteSet.new | |
Router.draw do | |
root :to => 'site#index' | |
end | |
class SiteController < ActionController::Metal |
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 is a brief description of how to get VestalVersions and Paperclip to play nicely. | |
The paperclip_initializer.rb extends paperclip for a new option :keep_old_files which means that paperclip won't remove the file when a new file is uploaded. In order for this to work, the model also needs to have to have specific settings: | |
#1. The version needs to be included in the file path | |
#2. A method to get the actual path to the file. (The file may not be at the current version) | |
You can view both these settings in the model_files.rb file below. | |
Note: If you dealing with public files then you will need to include the :id_and_version option in the :url and :path. Then in the view you need to reference the model_file.versioned_file_path. |