Skip to content

Instantly share code, notes, and snippets.

View sunkencity's full-sized avatar

Joel Westerberg sunkencity

  • Stockholm, Sweden
View GitHub Profile
mrxvt*font:-mixc-fixed-medium-r-normal-20-200-75-75-c-50-iso8859-1
mrxvt*foreground: #eeeeee
mrxvt*background: #1a1a1a
mrxvt*geometry: 100x30
mrxvt*visualBell: True
mrxvt*saveLines: 1000
mrxvt*termName: terminal
mrxvt*loginShell: True
#mrxvt*fullscreen: True
mrxvt*scrollbarStyle: next
(filter #(re-find #"\?$" (name (first %))) (ns-publics 'clojure.core))
namespace :delayed_job do
task :ensure, :roles => :app do
pid_from_file = capture("cat #{current_path}/tmp/pids/delayed_job.pid").strip
running_pids = capture("ps -ef | grep [d]elayed_job").split("\n").map { |x| x.split[1] }
if pid_from_file != running_pids.first || running_pids.size != 1
puts ("-"*80).console_purple
puts "Something is terribly wrong with delayed job!".console_red
puts "Running_pid: #{pid_from_file}"
puts "Running delayed job processes: #{capture("ps -ef | grep [d]elayed_job")}"
puts ("-"*80).console_purple
#!/usr/bin/env ruby
# backup script for postgresql databases
# connects via ssh and copies the file to a local path
@ssh_host = ""
@ssh_user = ""
@ssh_pass = ""
@db_name = ""
@sunkencity
sunkencity / gist:704976
Created November 18, 2010 13:38
weird id behaviour
diff --git a/js/jquery.mobile.js b/js/jquery.mobile.js
index 86f8472..c9c7e3c 100644
--- a/js/jquery.mobile.js
+++ b/js/jquery.mobile.js
@@ -478,7 +478,7 @@
}
to
- .attr( "id", fileUrl )
+ .attr( "id", fileUrl.replace(".", "") )
/** C grade styles for jquery mobile **/
body,html { font-family: Helvetica,Arial,sans-serif; padding: 0; margin: 0; background: #F0F0F0; }
h1 { margin: 0; width: 100%; background: #111111; color: #ffffff; font-size: 16px; line-height: 39px; text-align: center; margin-bottom: 30px; }
p { margin: 20px 15px 20px 15px; color: #333333; font-size: 16px; }
a { color: #2489CE; font-weight: bold; }
h2,h3,h4,h5,h6,img,pre,form,table,ul { margin: 0 15px 0 15px; }
dt { margin: 20px 15px 0 15px; }
dd { margin: 0 30px 0 30px; }
ul { list-style-type: none; border-bottom: 1px solid #cccccc; padding: 0; font-size: 14px; }
#
# Short words in Rails locale files with åäö become binary!
# But the _why oneliner seems to work. The problem is probably elsewhere. Logging this for reference.
#
# http://stdlib.rubyonrails.org/libdoc/yaml/rdoc/classes/String.html
# File yaml/rubytypes.rb, line 145
# def is_binary_data?
# ( self.count( "^ -~", "^\r\n" ) / self.size > 0.3 || self.count( "\x00" ) > 0 ) unless empty?
@sunkencity
sunkencity / gist:851560
Created March 2, 2011 19:36
start a irb console from rake
desc "Start a console"
task :console do
require 'irb'
ARGV.clear
IRB.start
end
require 'rubygems'
require 'nokogiri'
require 'pp'
class XMLToArr < Nokogiri::XML::SAX::Document
def XMLToArr.parse str, hsh
[].tap do |returning|
Nokogiri::XML::SAX::Parser.new(self.new(returning, hsh)).parse(str)
end
@sunkencity
sunkencity / do ... end block ruby
Created March 16, 2011 15:17
in 1.9.2 do ... end blocks return an enumerator, in 1.8.7 nil, but return the same as {} if assigned to a var. why?
puts [1,2,3].map {|x|x+1}.inspect
#[2, 3, 4]
puts [1,2,3].map do |x|x+1 end.inspect
#<Enumerator:0x00000100868110>