Skip to content

Instantly share code, notes, and snippets.

View bithive's full-sized avatar

bithive bithive

  • Reed College
  • Portland, OR
View GitHub Profile
@chrisk
chrisk / crontab.erb
Created August 17, 2011 20:34
Example crontab generation in Capistrano
# This crontab is automatically generated on deploy
SHELL=/bin/bash
[email protected]
RAILS_ENV=<%= stage %>
RAKE_CMD="<%= "#{bundle_path} rake --rakefile #{current_path}/Rakefile --trace" %>"
LOG_FILE="<%= "#{current_path}/log/cron.log" %>"
# Note: times are in the user's local time
<% if stage == :production && primary_server -%>
@joxxoxo
joxxoxo / scope_operators_initializer.rb
Last active December 14, 2015 08:19
Add 'or' and 'and_not' methods to AR::Relation
module ScopeOperators
def or(other).
left = arel.constraints.reduce(:and)
right = other.arel.constraints.reduce(:and)
scope = merge(other)
left ||= Arel::Nodes::Grouping.new(0) # take none if no conditions
right ||= Arel::Nodes::Grouping.new(0) # take none if no conditions
scope.where_values = [ Arel::Nodes::Grouping.new(left).or(Arel::Nodes::Grouping.new(right)) ]
scope
end
<html>
<!-- You may need to download them from https://github.com/brix/crypto-js/tree/release-3.1.2/build -->
<script src="rollups/sha1.js"></script>
<script src='components/lib-typedarrays-min.js'></script>
<body>
<script>
function sha1sum() {
var oFile = document.getElementById('uploadFile').files[0];
var sha1 = CryptoJS.algo.SHA1.create();
var read = 0;