Skip to content

Instantly share code, notes, and snippets.

Dragonfly and DigitalOcean

TLDR

Configuring Dragonfly to host files remotely on DigitalOcean Spaces? Pull in the dragonfly-s3_data_store gem, and this is the config for you:

# config/initializers/dragonfly.rb

require 'dragonfly'
@efatsi
efatsi / index.html
Created November 16, 2012 22:41
Angular.js twitter search
<!doctype html>
<html ng-app="Twitter">
<head>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.0.2/angular.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.0.2/angular-resource.min.js"></script>
<script type="text/javascript" src="twitter.js"></script>
<link rel="stylesheet" href="../bootstrap/css/bootstrap.min.css">
</head>
<body>
@efatsi
efatsi / .bash_profile
Created May 8, 2017 23:16
Bash function for pulling remote heroku database and loading locally
heroku_pg_pull() {
database=$1
environment=$2
if [ "$database" = "" ]; then
echo "Must pass in local database name, maybe one of these?"
cat config/database.yml | grep "database:"
return 1
fi
String json = String("{\"count\":" + String(count) + "}");
int stringLength;
if (count < 10) {
stringLength = 13;
} else if (count < 100) {
stringLength = 14;
} else if (count < 1000) {
stringLength = 15;
} else {
#include <DoubleCounter.h>
#include <Servo.h>
const int serialPin = 8;
const int registerClockPin = 9;
const int serialClockPin = 10;
const int servoPin = 5;
DoubleCounter counter(serialPin, registerClockPin, serialClockPin);
def self.alphabetized_by_label
initial_hash = all.group_by(&:product_type_name)
initial_hash.each do |key, value|
initial_hash[key] = value.sort{|x,y| x.en_name <=> y.en_name}
end
{}.tap do |final_hash|
initial_hash.keys.sort.each do |key|
final_hash[key] = initial_hash[key]
end
end
@efatsi
efatsi / configuration_types.rb
Created January 10, 2013 17:24
ConfigurationTypes
configuration_types = [
{
:en_name => "Handheld",
:es_name => "De mano",
:position => 1,
:color => "#6b8fbf"
},
{
:en_name => "Lavalier",
:es_name => "De solapa",
@efatsi
efatsi / bash_script
Created December 19, 2012 20:57
Jinglebots cronjob
#! /bin/bash
[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # Load RVM function
# this line kills the existing speak.rb if one is running
for X in `ps aux | grep speak.rb $1 | awk {'print $2'}`; do kill $X; done
# need to cd to the proper directory for relative path reasons in the ruby code
cd ~/Desktop/jinglebots/robot
ruby speak.rb
Password:
debug3: packet_send2: adding 32 (len 22 padlen 10 extra_pad 64)
debug2: input_userauth_info_req
debug2: input_userauth_info_req: num_prompts 0
debug3: packet_send2: adding 48 (len 10 padlen 6 extra_pad 64)
debug1: Authentication succeeded (keyboard-interactive).
Authenticated to 192.168.7.104 ([192.168.7.104]:22).
debug1: channel 0: new [client-session]
debug3: ssh_session2_open: channel_new: 0
debug2: channel 0: send open
require 'rubygems'
require 'twitter/json_stream'
require 'json'
TWITTER = {
:username => "letitsnow1415",
:password => "",
:search_terms =>["viget"]
}