Skip to content

Instantly share code, notes, and snippets.

Bertrand Chardon Veejay

Block or report user

Report or block Veejay

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
Veejay / workaround.js
Last active Dec 12, 2015
Workaround for Flickr images "click-to-display"
View workaround.js
// 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]);
Veejay / channels_select.go
Created Jan 18, 2013
Example of channel communication with a simple select statement. Taken from Rob Pike's slides about concurrency in Go.
View channels_select.go
package main
import (
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.
View test.go
package main
import (
Veejay / firstprog.go
Created Jan 11, 2013
First Go program. Iterates over a map and reads the content of a given directory.
View firstprog.go
package main
import "fmt"
import "os"
func main() {
m := make(map[string]int)
m["foo"] = 1
m["blah"] = 2
View detect.js
_.detect(collection, function(item) {
// conditions here
one: function(item) {
// function to execute when one item is found
// function to execute when no item is found
Veejay / bug
Created Nov 12, 2012
Ruby Interpreter Bug
View bug
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
Veejay / permissions.rb
Created Oct 31, 2012
Decorator method
View permissions.rb
def permissions_information_for_company(company)
m = user.memberships.where(company_id:
capture_haml do
haml_tag :div, {:class => "permissions_info"} do
haml_tag :h2 do
haml_concat "Permissions"
if m.permissions.present?
haml_concat "#{user.full_name} has the following permissions for company #{}:"
Veejay / date.rb
Created Oct 30, 2012
Date handling
View date.rb
irb(main):009:0> d =, 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
Veejay / date.rb
Created Oct 30, 2012
Funky Date handling
View date.rb
irb(main):022:0> Date.parse("2012/12/31").cweek
=> 1
irb(main):023:0> Date.parse("2012/12/31").year
=> 2012
View test.c
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);
You can’t perform that action at this time.