Skip to content

Instantly share code, notes, and snippets.

/**
This groovy script will take a CSV file that represents the data
in a database. The first row should be the name of the columns and
all other rows should represent the data you wish to insert.
*/
// Setup basic information
numColumns = 6
tableName = "TABLE_NAME"
CAS, CAS, CAS!
@atonse
atonse / edt_until_1972.rb
Created February 12, 2011 22:30
Returns the GMT offset for US Eastern Time based on timestamp for the last 30 years
module DSTCalculations
@@dst_years = [
["4/3/1966", "10/30/1966"],
["4/2/1972", "10/29/1972"],
["4/1/1973", "10/28/1973"],
["4/7/1974", "10/27/1974"],
["4/6/1975", "10/26/1975"],
["4/4/1976", "10/31/1976"],
["4/3/1977", "10/30/1977"],
@atonse
atonse / resque.rake
Created June 16, 2011 14:13
Rake Tasks for Resque Management
desc "retry all failed jobs and remove retried jobs"
task :retry_all => :environment do
# retry all jobs
Resque::Failure.all(0, Resque::Failure.count).each_with_index { |j, i| Resque::Failure.requeue(i) unless j['retried_at'] }
# remove all retried jobs
Resque::Failure.count.times { |i| Resque::Failure.remove(0) if Resque::Failure.all(0)['retried_at'] }
end
@atonse
atonse / gist:1165820
Created August 23, 2011 16:47
Gmail Poll IMAP
def self.perform
imap = Net::IMAP.new('imap.gmail.com', 993, true)
imap.login('MAILBOX', 'PASSWORD')
loop do
imap.select('INBOX')
imap.search(['UNSEEN']).each do |message_id|
messages = imap.fetch(message_id, ['RFC822'])
messages.each do |message|
@atonse
atonse / gist:1217868
Created September 14, 2011 21:37
Undefine certain task so there is no chance of running this by mistake in a more important environment
def undefine_task(*names)
app = Rake.application
tasks = app.instance_variable_get('@tasks')
names.flatten.each { |name| tasks.delete(name) }
end
if %W{production staging integration}.include?(Rails.env)
undefine_task %w(
db:bootstrap
db:bootstrap:reset
@atonse
atonse / chef_solo_bootstrap.sh
Last active December 11, 2015 09:58 — forked from ryanb/chef_solo_bootstrap.sh
Ubuntu 12.04 LTS, Ruby 1.9.3p374
#!/usr/bin/env bash
apt-get -y update
apt-get -y install build-essential zlib1g-dev libssl-dev lib64readline-gplv2-dev libyaml-dev
cd /tmp
wget ftp://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p374.tar.gz
tar -xvzf ruby-1.9.3-p374.tar.gz
cd ruby-1.9.3-p374/
./configure --prefix=/usr/local
make
make install

Keybase proof

I hereby claim:

  • I am atonse on github.
  • I am atonse (https://keybase.io/atonse) on keybase.
  • I have a public key ASBaxav8FQZqBLvSlplcle_YNeQz2hK7ZkNgRMXDqNOBbgo

To claim this, I am signing this object:

@atonse
atonse / controllers.application.js
Last active April 14, 2016 15:28
Datepicker UTC Issues
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle'
});
import Ember from 'ember';
export default Ember.Component.extend({
didRender() {
this._super(...arguments);
let svg = d3.select(this.$('.pipeline-view-container')[0]).append('svg');
let xScale = d3.time.scale()
.domain([new Date(), new Date()])
.range([0, 500])