Skip to content

Instantly share code, notes, and snippets.

🤠
It's great in Phoenix 🚲

Dave Tapley dukedave

🤠
It's great in Phoenix 🚲
Block or report user

Report or block dukedave

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@dukedave
dukedave / substring_replacement.sh
Last active Aug 29, 2015
Substring Replacement in Bash
View substring_replacement.sh
# Works okay:
FILE=something.txt; echo ${FILE/txt/log}
# Works okay:
find . -name \*.txt -exec sh -c 'FILE={}; echo ${FILE}' \;
# Fails with 'sh: 1: Bad substitution':
find . -name \*.txt -exec sh -c 'FILE={}; echo ${FILE/txt/log}' \;
# Works
View hash.rb
> event.context
=> {"meridien"=>"pm", "contact"=>"jennifer", "contact_id"=>954}
> event.context.class
=> Hash
> event.context['works'] = 'normally'
=> "normally"
> event.context
=> {"meridien"=>"pm", "contact"=>"jennifer", "contact_id"=>954, "works"=>"normally"}
>
> # Now trying HashWithIndifferentAccess
@dukedave
dukedave / 85004_fm_free.txt
Created Jun 26, 2015
Free FM channels at 85004
View 85004_fm_free.txt
# http://radio-locator.com/cgi-bin/vacant?select=city&city=54004&state=&x=0&y=0
89.1 FM BEST!
89.5 FM BEST!
89.9 FM BEST!
90.1 FM BEST!
90.5 FM BEST!
91.5 FM BEST!
91.7 FM BEST!
93.3 FM BEST!
@dukedave
dukedave / pending_fail.rb
Created Jan 23, 2015
Pending failing rspec tests
View pending_fail.rb
#!/usr/bin/ruby
require 'pty'
cmd = ARGV.first
begin
PTY.spawn( cmd ) do |stdin, stdout, pid|
begin
stdin.each do |line|
View rvm_get_stable_fail.log
$ rvm get stable
Downloading https://get.rvm.io
Downloading https://github.com/wayneeseguin/rvm/archive/1.26.9.tar.gz
Downloading https://github.com/wayneeseguin/rvm/releases/download/1.26.9/1.26.9.tar.gz.asc
gpg: Signature made Wed 07 Jan 2015 04:55:10 AM MST using RSA key ID BF04FF17
gpg: Can't check signature: public key not found
Warning, RVM 1.26.0 introduces signed releases and automated check of signatures when GPG software found.
Assuming you trust Michal Papis import the mpapis public key (downloading the signatures).
GPG signature verification failed for '/home/dave/.rvm/archives/rvm-1.26.9.tgz' - 'https://github.com/wayneeseguin/rvm/releases/download/1.26.9/1.26.9.tar.gz.asc'!
View token.hbs
Token {{id}}
{{debugger}}
{{view 'translation-list' contentBinding='translations'}}
View magento_1045
I, [2014-09-16T13:53:52.616946 #17989] INFO -- : SOAP request: http://127.0.0.1:8080/index.php/api/v2_soap/index/
I, [2014-09-16T13:53:52.617093 #17989] INFO -- : SOAPAction: "urn:Mage_Api_Model_Server_V2_HandlerAction", Content-Type: text/xml;charset=UTF-8, Content-Length: 583
D, [2014-09-16T13:53:52.617162 #17989] DEBUG -- : <?xml version="1.0" encoding="UTF-8"?><env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:typens="urn:Magento" xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"><env:Body><typens:shoppingCartCustomerSet><sessionId>f64157706ed396c47e3ed0c461498c30</sessionId><quoteId>2</quoteId><customerData><firstname>testFirstname</firstname><lastname>testLastName</lastname><email>testEmail@mail.com</email><mode>guest</mode><website_id>0</website_id></customerData></typens:shoppingCartCustomerSet></env:Body></env:Envelope>
D, [2014-09-16T13:53:52.617332 #17989] DEBUG -- : HTTPI POST request to 127.0.0.1 (net_http)
I, [2014-09-16
@dukedave
dukedave / regex.rb
Created Aug 18, 2014
\a \A \z \Z in Ruby regexes
View regex.rb
irb(main):001:0> 'derp' =~ /derp\Z/
=> 0
irb(main):002:0> 'derp' =~ /derp\z/
=> 0
irb(main):003:0> 'derp' =~ /\Aderp\z/
=> 0
irb(main):004:0> 'derp' =~ /\aderp\z/
=> nil
@dukedave
dukedave / sequel_pk_in_module.rb
Created Jul 22, 2014
Explicitly declaring Sequel PK in module
View sequel_pk_in_module.rb
def self.included(o)
o.extend ClassMethods
o.set_primary_key [:user_id, :period]
o.unrestrict_primary_key
end
@dukedave
dukedave / indexes.sql
Created Jul 22, 2014
Implicit primary key index is redundant
View indexes.sql
"events_pkey" PRIMARY KEY, btree (user_id, period)
"events_user_id_period_excl" EXCLUDE USING gist (user_id WITH =, period WITH &&)
You can’t perform that action at this time.