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
// Straight DOM / Javascript | |
// Images are blocked through a data attribute client-side | |
var targetImages = document.querySelectorAll('img[data-blocked-src]') | |
// Go through all the blocked images and replace the node with an img element | |
// using the proper link as its source | |
for(var i = 0, l = targetImages.length; i < l; i++) { | |
visibleImage = document.createElement('img'); | |
visibleImage.src = targetImages[i].getAttribute('data-blocked-src'); | |
targetImages[i].parentNode.replaceChild(visibleImage, targetImages[i]); |
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
package main | |
import ( | |
"fmt" | |
"time" | |
) | |
func boring(msg string) <-chan string { // Returns receive-only channel of strings. | |
c := make(chan string) | |
go func() { // We launch the goroutine from inside the function. |
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
package main | |
import ( | |
"fmt" | |
"net/http" | |
"strings" | |
"log" | |
"io/ioutil" | |
"path/filepath" | |
"os" | |
) |
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
package main | |
import "fmt" | |
import "os" | |
func main() { | |
m := make(map[string]int) | |
m["foo"] = 1 | |
m["blah"] = 2 |
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
_.detect(collection, function(item) { | |
// conditions here | |
}, | |
{ | |
one: function(item) { | |
// function to execute when one item is found | |
}, | |
none:function(){ | |
// function to execute when no item is found | |
} |
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
staffplan/ $ bundle exec rails console [11:21:10 (v2!!!) ] | |
/Users/bertrand/.rbenv/versions/1.9.3-p286/lib/ruby/gems/1.9.1/gems/actionpack-3.2.8/lib/action_dispatch/http/mime_type.rb:102: warning: already initialized constant MOBILE | |
Loading development environment (Rails 3.2.8) | |
irb(main):001:0> exit | |
/Users/bertrand/.rbenv/versions/1.9.3-p286/lib/ruby/1.9.1/irb.rb:83: [BUG] Segmentation fault | |
ruby 1.9.3p286 (2012-10-12 revision 37165) [x86_64-darwin12.2.0] | |
-- Control frame information ----------------------------------------------- | |
c:0032 p:---- s:0118 b:0118 l:000117 d:000117 CFUNC :throw | |
c:0031 p:0015 s:0113 b:0113 l:000112 d:000112 METHOD /Users/bertrand/.rbenv/versions/1.9.3-p286/lib/ruby/1.9.1/irb.rb:83 |
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
def permissions_information_for_company(company) | |
init_haml_helpers | |
m = user.memberships.where(company_id: company.id).first | |
capture_haml do | |
haml_tag :div, {:class => "permissions_info"} do | |
haml_tag :h2 do | |
haml_concat "Permissions" | |
end | |
if m.permissions.present? | |
haml_concat "#{user.full_name} has the following permissions for company #{company.name}:" |
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
irb(main):009:0> d = Date.new(2012, 12, 31) | |
=> #<Date: 2012-12-31 ((2456293j,0s,0n),+0s,2299161j)> | |
irb(main):010:0> d.cweek | |
=> 1 | |
irb(main):011:0> d.year | |
=> 2012 |
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
irb(main):022:0> Date.parse("2012/12/31").cweek | |
=> 1 | |
irb(main):023:0> Date.parse("2012/12/31").year | |
=> 2012 |
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
static linked_list** | |
find_key(linked_list *list, char *key) | |
{ | |
linked_list *current = list; | |
while(!(current && (strcmp(current->kv.key, key)))){ | |
current = current->next; | |
} | |
return &(current); | |
} |