Skip to content

Instantly share code, notes, and snippets.

@DVG
DVG / ppa-behind-proxy.bash
Created April 3, 2014 14:38
ppa-behind-proxy.bash
# The ppa will have the sources listed on it's site: https://launchpad.net/~gwendal-lebihan-dev/+archive/cinnamon-stable
# edit /etc/apt/sources.list
deb http://ppa.launchpad.net/nilarimogard/webupd8/ubuntu quantal main
deb-src http://ppa.launchpad.net/nilarimogard/webupd8/ubuntu quantal main
# Add signing key
wget "http://keyserver.ubuntu.com:11371/pks/lookup?op=get&search=0xA777609328949509" -O out && sudo apt-key add out && rm out
@DVG
DVG / Rakefile
Created September 29, 2014 19:33
Update background Image to National Geographic Photo of the day
TODAY = Time.now.strftime("%Y-%m-%d")
USER = "MY_USER"
PICTURES_DIR = "/home/#{USER}/Pictures/national-geographic/"
TODAYS_PICTURE = "#{PICTURES_DIR}#{TODAY}-ngeo.jpg"
PROXY_HOST = 'proxy.example.net'
PROXY_PORT = 8443
desc "Fetch National Geographic Photo of the Day"
task :get_photo_of_the_day do
# http://photography.nationalgeographic.com/photography/photo-of-the-day/
@DVG
DVG / env
Created February 26, 2015 14:37
Environment Variables
COLORTERM=gnome-terminal
DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-6qbTLpVXel,guid=65fcd2c788d00cd94308487600000093
DEFAULTS_PATH=/usr/share/gconf/gnome-fallback.default.path
DEFAULT_USER=me
DESKTOP_SESSION=gnome-fallback
DISPLAY=:0.0
EDITOR=vim
FTP_PROXY=http://ftp://proxy.mycompany.net:8000/
GDMSESSION=gnome-fallback
GDM_LANG=en_US
@DVG
DVG / unciorn.rb
Last active August 29, 2015 14:17
Unicorn configuraiton
# set path to app that will be used to configure unicorn,
# note the trailing slash in this example
@dir = "/path/to/app/"
worker_processes 2
working_directory @dir
timeout 30
# Specify path to socket unicorn listens to,
@DVG
DVG / nginx.conf
Created March 18, 2015 14:18
nginx for sinatra
# this sets the user nginx will run as,
#and the number of worker processes
user nobody nogroup;
worker_processes 1;
# setup where nginx will log errors to
# and where the nginx process id resides
error_log /var/log/nginx/error.log;
pid /var/run/nginx.pid;
@DVG
DVG / Dockerfile
Created April 11, 2015 19:14
Docker
FROM ruby:2.2.1
RUN apt-get update -qq && apt-get install -y build-essential
RUN apt-get install -y libxml2-dev libxslt1-dev
RUN apt-get install -y libqt4-webkit libqt4-dev xvfb
RUN apt-get install -y nodejs
ENV APP_HOME /code
RUN mkdir $APP_HOME
WORKDIR $APP_HOME
ADD Gemfile* $APP_HOME/
@DVG
DVG / patch-chrome.sh
Created May 26, 2015 13:22
Patch Chrome
#!/bin/bash
cp /usr/share/applications/google-chrome.desktop ~/google-chrome.desktop.bak~
sudo sed -i 's/\/usr\/bin\/google\-chrome\-stable/\/usr\/bin\/google\-chrome\-stable \-\-touch\-devices=123/g' /usr/share/applications/google-chrome.desktop
@DVG
DVG / env.rb
Created May 21, 2009 17:07
env.rb file for using Cucumber, Webrat, Mechanize and RSpec to test non-ruby applicaitons.
require 'webrat'
require 'webrat/core/matchers'
include Webrat::Methods
include Webrat::Matchers
Webrat.configure do |config|
config.mode = :mechanize
end
class MechanizeWorld < Webrat::MechanizeSession
@DVG
DVG / Obj-C Detailed Error Save.m
Created June 25, 2010 14:56
Bruce's Detailed Error Code
NSError* error;
if(![managedObjectContext save:&error]) {
NSLog(@"Failed to save to data store: %@", [error localizedDescription]);
NSArray* detailedErrors = [[error userInfo] objectForKey:NSDetailedErrorsKey];
if(detailedErrors != nil && [detailedErrors count] > 0) {
for(NSError* detailedError in detailedErrors) {
NSLog(@" DetailedError: %@", [detailedError userInfo]);
}
}
else {
cellForRowAtIndexPath:(NSIndexPath *)indexPath {
for (int y=0; y<[selectedMonsters count];y++) {
if [[selectedMonsters objectAtIndex:y] isKindOfTemplate:[monsters objectAtIndexPath:indexPath]] {
cell.detailLabel.text = [monster quantity];
}
else {
cell.detailLabel.text = "";
}
}
}