Skip to content

Instantly share code, notes, and snippets.

@kishiamy
kishiamy / gc_tips.md
Last active October 18, 2020 09:37
Tips for Gran Canaria

To eat

@twksos
twksos / CiscoVPNConnection.scpt
Last active July 31, 2023 20:50
Cisco VPN connection auto connect AppleScript
-- Please set your vpn connection name and password here
set VPNName to "VPN name"
set VPNpassword to "VPN password"
tell application "System Events"
tell current location of network preferences
set VPNService to service VPNName
end tell
set isConnected to connected of current configuration of VPNService
@jeremy2
jeremy2 / database.yml.erb
Created March 6, 2012 23:17
Engine Yard custom Chef Recipe for generating database.yml configuration file
#
# This file should be in .../cookbooks/database/templates/default/database.yml.erb
#
<%= @environment %>:
adapter: <%= @adapter %>
database: <%= @database %>
username: <%= @username %>
password: <%= @password %>
host: <%= @host %>
@PatrickTulskie
PatrickTulskie / resque_retry.rb
Created July 25, 2011 19:15 — forked from clemens/resque_retry.rb
Retry failed Resque jobs in Ruby
# inspired by http://ariejan.net/2010/08/23/resque-how-to-requeue-failed-jobs
# retry all failed Resque jobs except the ones that have already been retried
# This is, for instance, useful if you have already retried some jobs via the web interface.
Resque::Failure.count.times do |i|
Resque::Failure.requeue(i) unless Resque::Failure.all(i, 1)['retried_at'].present?
end
# retry all :)
Resque::Failure.count.times do |i|
@mheffner
mheffner / readtsc.c
Created May 13, 2011 19:21
Report gettimeofday, TSC and getrusage(self) periodically while performing I/O workload.
/*
* Dumps the value of gettimeofday(), the TSC, and
* getrusage(RUSAGE_SELF) every two seconds while performing some fake
* I/O workload on a /tmp file.
*
* Build: gcc -o readtsc readtsc.c -lrt
*/
#include <stdio.h>
# Opens the github page for the current git repository and branch in your browser
#
# based on this: http://jasonneylon.wordpress.com/2011/04/22/opening-github-in-your-browser-from-the-terminal/
# + works with current branch
# + pass file: gh foo/bar.txt #=> https://github.com/o/o/tree/master/foo/bar.txt
# + pass commit sh: gh 5116fba #=> https://github.com/o/o/commits/5116fba
#
function gh() {
giturl=$(git config --get remote.origin.url)
if [ "$giturl" == "" ]
# In your test_helper.rb
class ActiveRecord::Base
mattr_accessor :shared_connection
@@shared_connection = nil
def self.connection
@@shared_connection || retrieve_connection
end
end