Skip to content

Instantly share code, notes, and snippets.

@tpitale
tpitale / db-backup.sh
Last active March 7, 2022 02:19 — forked from bkenny/db-backup.sh
Simple shell script to backup each postgresql database to s3.
#!/bin/bash
BACKUP="/tmp/s3/db"
DATE=`date +"%Y-%m-%d"`
DIR="${BACKUP}/${DATE}/"
if [ ! -d $DIR ];
then
mkdir -p $DIR
fi
@tpitale
tpitale / ember-flush.js
Last active December 17, 2015 02:39
The bit of code in ember.js that is pausing for a good second or so.
RunLoop.prototype = {
/**
@method end
*/
end: function() {
this.flush();
},
// …
@tpitale
tpitale / gist:5500002
Created May 2, 2013 03:34
Building a .deb for chruby
curl https://codeload.github.com/postmodern/chruby/tar.gz/v0.3.4 -o chruby-0.3.4.tar.gz
tar -xzvf chruby-0.3.4.tar.gz
cd chruby-0.3.4
mkdir /tmp/chruby-install
PREFIX=/tmp/chruby-install make install
fpm --prefix /usr/local -a all -s dir -t deb -p chruby-VERSION_ARCH.deb -n chruby -v 0.3.4 -C /tmp/chruby-install bin share
rm -rf /tmp/chruby-install
@tpitale
tpitale / serializer.rb
Created March 10, 2013 19:32
Initializer to include support for ActiveModel::Serializers within DataMapper
require 'dm-core'
DataMapper::Model.append_inclusions(ActiveModel::SerializerSupport)
DataMapper::Collection.send(:include, ActiveModel::ArraySerializerSupport)
@tpitale
tpitale / svg-to-vector-pdf.sh
Last active January 6, 2018 13:48
Loop to rsvg-convert all SVG files to Vector PDF
for i in `ls *.svg`
rsvg-convert -f pdf -o PDF/${i}.pdf $i
@tpitale
tpitale / not_working_imap_idle.rb
Created November 28, 2012 19:35
IMAP fail example snippet
require 'net/imap'
# snippet
@imap = Net::IMAP.new('imap.gmail.com', :port => 993, :ssl => true)
@imap.login('username@gmail.com', 'password')
@imap.select('INBOX')
idler = Thread.start {
@imap.idle {|response| puts response}
@tpitale
tpitale / thumbnail_io.rb
Created November 26, 2012 03:08
Wrap a string up as a file.
class ThumbnailIO < StringIO
def initialize(*args)
super(*args[1..-1])
@name = args[0]
end
def original_filename
@name
end
end
@tpitale
tpitale / problem.rb
Created November 26, 2012 02:05
Searchable Block
searchable do
text :id
text :content
text :caller
text(:username) {(assigned_user || user).name}
text(:customer_number) {customer.customer_number}
text(:customer_name) {customer.name}
text(:customer_address) {[customer.address, customer.city, customer.state, customer.zip]}
time :created_at
end
@tpitale
tpitale / schema.xml
Created November 26, 2012 01:49
Minor additions for text fields.
<fieldType name="text" class="solr.TextField" omitNorms="false">
<analyzer type="query">
<tokenizer class="solr.StandardTokenizerFactory"/>
<filter class="solr.StandardFilterFactory"/>
<filter class="solr.LowerCaseFilterFactory"/>
<filter class="solr.PorterStemFilterFactory"/>
</analyzer>
<analyzer type="index">
<tokenizer class="solr.StandardTokenizerFactory"/>
<filter class="solr.StandardFilterFactory"/>
@tpitale
tpitale / index.html.erb
Created November 3, 2012 20:41
Make it all one handlebar inside a rails html.erb template.
<script type="text/x-handlebars" data-template-name="application">
<div class="column column-1">
{{view Docket.ProblemsStatsView}}
<%# render 'sidebar' %>
</div>
<div class="column column-2" id="problems-container">
{{view Docket.ProblemsIndexView}}
<%# render 'problems', :problems => @problems %>
</div>