Skip to content

Instantly share code, notes, and snippets.

@dodeja
dodeja / hack.sh
Last active December 11, 2015 00:19 — forked from caycefischer/hack.sh
#!/usr/bin/env sh
##
# This is script with usefull tips taken from:
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
#
# install it:
# curl -sL https://raw.github.com/gist/2279031/hack.sh | sh
#
function addr(arr, v, n) {
var steps = n === 0 ? arr.length-1 : Math.abs(n);
var step = n < 0 ? -1 : 1;
var i = n < 0 ? arr.length-1 : 0;
var count = arr.length-1;
while(count > 0 && steps > 0) {
console.log(arr[i])
if(arr[i] === v) {
arr[i]++;
[{
"id": "OBxNkQ6BCHqFUQ",
"print_on": "2012-03-18",
"batch_state": "current",
"current": true,
"last_status": null,
"last_status_on": null,
"photos": [{
"id": "jBPaF_rCuvHxBQ",
"ratio": 1.33,
@dodeja
dodeja / gist:1691624
Created January 27, 2012 23:44
Warden HTTP Basic Auth Strategy for Padrino
# I am using this for an API. So auth key is passed as user name.
Warden::Strategies.add(:basic) do
def auth
@auth ||= Rack::Auth::Basic::Request.new(env)
end
def store?
false
@dodeja
dodeja / gist:1299572
Created October 19, 2011 20:31
PPMetrics
// User
var PPM = {
user_id: 0,
init: function(uid){
var self = this;
this.user_id = uid;
Plankton.sync('http://draw.test.envolve.com/ppmetrics/', function(data){ self.after_sync(self, data) });
},
after_sync: function(self, data){
@dodeja
dodeja / Gemfile
Created July 25, 2011 02:28
Rails 3.1 stable branch ASSET helpers bug reproducing steps.
source 'http://rubygems.org'
# Rails Gems
gem 'rails', :git => 'git://github.com/rails/rails.git', :branch => '3-1-stable'
gem 'sprockets', :git => 'git://github.com/sstephenson/sprockets.git'
gem 'sqlite3'
group :assets do
gem 'sass-rails', :git => 'git://github.com/rails/sass-rails.git', :branch => '3-1-stable'
# gem 'sass-rails', "~> 3.1.0.rc"
@dodeja
dodeja / forcessl.rb
Created July 22, 2011 18:03
Root Domain to WWW redirection in Rails 3.1 before forcing SSL on Heroku
# in config/environments/production.rb
# config.force_ssl = true
# config.middleware.use "Forcessl"
# Make sure redirection happens before forcing ssl
# config.middleware.insert_before 'Rack::SSL', 'Forcessl'
# in lib/forcessl.rb
# change *. to your domain
class Forcessl
source :gemcutter
gem 'rails', '3.1.0.rc4'
group :assets do
gem 'sass-rails', "~> 3.1.0.rc"
gem 'coffee-script'
gem 'uglifier'
end
@dodeja
dodeja / gist:1095687
Created July 20, 2011 19:16
SSL Error on heroku
/usr/local/lib/ruby/1.9.1/net/http.rb:678:in `connect'
/usr/local/lib/ruby/1.9.1/net/http.rb:678:in `block in connect'
/usr/local/lib/ruby/1.9.1/timeout.rb:57:in `timeout'
/usr/local/lib/ruby/1.9.1/timeout.rb:87:in `timeout'
/usr/local/lib/ruby/1.9.1/net/http.rb:678:in `connect'
/usr/local/lib/ruby/1.9.1/net/http.rb:637:in `do_start'
/usr/local/lib/ruby/1.9.1/net/http.rb:626:in `start'
vendor/bundle/ruby/1.9.1/gems/rest-client-1.6.3/lib/restclient/request.rb:170:in `transmit'
vendor/bundle/ruby/1.9.1/gems/rest-client-1.6.3/lib/restclient/request.rb:64:in `execute'
vendor/bundle/ruby/1.9.1/gems/rest-client-1.6.3/lib/restclient/request.rb:33:in `execute'
@dodeja
dodeja / page_curl_mixin.sass
Created June 23, 2011 21:33
Page Curl Ballerness
// USAGE
// @include page-curl(rgba(0,0,0,0.2), 6deg, 2deg, 0.85deg, 0px, 10px, 20px)
@mixin transform($scale, $rotate, $trans-x, $trans-y, $skew-x, $skew-y)
-moz-transform: scale($scale) rotate($rotate) translate($trans-x, $trans-y) skew($skew-x, $skew-y)
-webkit-transform: scale($scale) rotate($rotate) translate($trans-x, $trans-y) skew($skew-x, $skew-y)
-o-transform: scale($scale) rotate($rotate) translate($trans-x, $trans-y) skew($skew-x, $skew-y)
-ms-transform: scale($scale) rotate($rotate) translate($trans-x, $trans-y) skew($skew-x, $skew-y)
transform: scale($scale) rotate($rotate) translate($trans-x, $trans-y) skew($skew-x, $skew-y)