This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This is a shell archive. Remove anything before this line, then | |
# unpack it by saving it in a file and typing "sh file". (Files | |
# unpacked will be owned by you and have default permissions.) | |
# | |
# This archive contains: | |
# Makefile ping.1 ping.c ping.shar newping.1 newping.c | |
echo x - Makefile | |
cat > "Makefile" << '//E*O*F Makefile//' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Ok, so I'm trying to replace a ' character with \' in a ruby string. I have working code, but it was | |
*way* too painful getting there for my taste. | |
Take a look: | |
ree-1.8.7-2010.02 :001 > single_quote = "\'" | |
=> "'" | |
ree-1.8.7-2010.02 :003 > single_quote.gsub(/'/, "\\\'") | |
=> "" | |
ree-1.8.7-2010.02 :004 > single_quote.gsub(/'/) {|c| "\\'"} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
user=> (ns my-ns) | |
nil | |
my-ns=> (defrecord Outfit [shirt pants]) | |
my_ns.Outfit | |
my-ns=> (ns clothes.outfit | |
#_=> (:require [my-ns]) | |
#_=> (:import [my_ns Outfit])); note that we defined it in my-ns, but we have to use an underscore to import it | |
nil | |
clothes.outfit=> (Outfit. "t-shirt" "jeans") | |
#my_ns.Outfit{:shirt "t-shirt", :pants "jeans"} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns pdf-text-extractor.core | |
(:import [com.snowtide.pdf OutputTarget PDFTextStream])) | |
(defn pdf-to-text [file] | |
(let [pdfts (new PDFTextStream file) | |
output (new StringBuilder 1024)] | |
(.pipe pdfts (new OutputTarget output)) | |
(.close pdfts) | |
output)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function fix-file-endings () { | |
for f in `git ls-files` | |
do | |
newline=' | |
' | |
lastline=$(tail -n 1 $f; echo x); lastline=${lastline%x} | |
[ "${lastline#"${lastline%?}"}" != "$newline" ] && echo >> $f | |
done | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var cycleTimeFunctionThatNeedsABetterName = function(acceptedDate, inProgressDate) { | |
var cycleTime = Math.round(Ext.Date.getElapsed(acceptedDate,inProgressDate) / 1000 / 60 / 60 / 24); | |
if (cycleTime === 0) cycleTime = 1; | |
return cycleTime; | |
}; | |
Ext.define('CustomApp', { | |
extend: 'Rally.app.App', | |
componentCls: 'app', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Do you prefer this? | |
merchant["thing"] = important_stuff.map { |important_thing| important_thing["units"] }.inject(&:+) | |
#Or this? | |
important_stuff.each { |important_thing| merchant["thing"] += important_thing["units"] } | |
#Why? Is it completely objective? Or are ruby's idioms/social mores/conventions the deciding factor? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
window.CountCalculator=window.PriceCalculator=window.TaxCalculator=window.ShippingCaclulator = { | |
calculate: (num) -> (num == undefined ? 0 : num + 1) } | |
ChainsCalls = | |
chain: (dependencies, method) -> | |
_(dependencies).inject((memo, dependency) -> | |
dependency[method](memo) | |
, undefined) | |
Invoice = |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#see http://jjinux.blogspot.com/2012/02/ruby-working-around-ssl-errors-on-os-x.html | |
require 'open-uri' | |
require 'net/https' | |
module Net | |
class HTTP | |
alias_method :original_use_ssl=, :use_ssl= | |
def use_ssl=(flag) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var o = this.options, scroll = this.cssPosition == 'absolute' && !(this.scrollParent[0] != document && $.ui.contains(this.scrollParent[0], this.offsetParent[0])) ? this.offsetParent : this.scrollParent, scrollIsRootNode = (/(html|body)/i).test(scroll[0].tagName); |
NewerOlder