Skip to content

Instantly share code, notes, and snippets.

@mcansky
mcansky / script.js
Created September 24, 2013 08:45
testing dom manipulation with Jasmine
(function(window){
add_pic = function (options) {
$('#pic').append("<img href='http://google.com/logo.jpg'/>");
};
@mcansky
mcansky / gist:6346465
Created August 26, 2013 20:46
sublime config
{
"auto_complete_commit_on_tab": true,
"bold_folder_labels": true,
"caret_style": "solid",
"color_scheme": "Packages/Color Scheme - Default/Solarized (Dark).tmTheme",
"create_window_at_startup": false,
"dictionary": "Packages/Language - English/en_GB.dic",
"ensure_newline_at_eof_on_save": true,
"file_exclude_patterns":
[
install-bunder-gem:
cmd.run:
- name: gem install bundler
- shell: /bin/bash
- user: corn
- onlyif: which ruby | grep rbenv
- require:
- pkg: rbenv-deps
@mcansky
mcansky / gist:5430383
Created April 21, 2013 17:35
I need to use another attribute (a hash, which is the id from a cloudant db) rather than id. Being new to ember, I am wondering how the route and controller need to be. Is there anything special to do for the linkTo too ? finally, is there a part of the doc treating of such cases ?
App.Router.map(function() {
this.resource('post', { path: '/posts/:post_id' });
});
App.PostRoute = Ember.Route.extend({
model: function(params) {
return App.Post.find({hash: params.post_some_attr});
}
});
# Reset
Color_Off='\e[0m' # Text Reset
# Regular Colors
Black='\e[0;30m' # Black
Red='\e[0;31m' # Red
Green='\e[0;32m' # Green
Yellow='\e[0;33m' # Yellow
Blue='\e[0;34m' # Blue
Purple='\e[0;35m' # Purple
/* global */
@import "5grid/core.css"
@import "style"
/* Large desktop */
@media (min-width: 1200px)
@import "5grid/core-1200px.css"
@import "style-1000px.css"
/* Portrait tablet to landscape and desktop */
require 'benchmark'
n = 500
archs = ["i486", "ia64"]
archs.each do |arch|
Benchmark.bm(7) do |x|
x.report("case : #{arch}") { n.times { case arch when /i\d86/ then "i386" else arch end }}
x.report("if (match): #{arch}") { n.times { if (arch.match(/i\d86/)) then "i386" else arch end }}
def spook(_a, &block)
if _a == 1
puts "BOUYAH"
else
yield
end
end
[1,2].each do |i|
spook i do
- "N'hesitez pas à venir discuter" ('do not hesitate to come and talk with us')
- "N'hesitez pas à venir nous saluer" ("do not hesitate to come and say hi to us") might be better
more imperative :
- "Venez nous dire bonjour" ("Come say hi")
- "Venez discuter avec nous" ("Come talk to us !")
@mcansky
mcansky / gist:3434417
Created August 23, 2012 08:59
signing an aws s3 url
# encoding : utf-8
require 'openssl'
require 'digest/sha1'
require 'base64'
module Aws
extend self
def signed_url(path, expire_date)
digest = OpenSSL::Digest::Digest.new('sha1')
can_string = "GET\n\n\n#{expire_date}\n/#{S3_BUCKET}/#{path}"