Skip to content

Instantly share code, notes, and snippets.

View utkarshkukreti's full-sized avatar

Utkarsh Kukreti utkarshkukreti

View GitHub Profile
@remy
remy / trim-canvas.js
Last active May 3, 2024 13:39
Trims the surrounding transparent pixels from a canvas
// MIT http://rem.mit-license.org
function trim(c) {
var ctx = c.getContext('2d'),
copy = document.createElement('canvas').getContext('2d'),
pixels = ctx.getImageData(0, 0, c.width, c.height),
l = pixels.data.length,
i,
bound = {
top: null,
require "benchmark"
N = (ARGV.shift || 40).to_i
def fib(n)
return n if n < 2
fib(n-2) + fib(n-1)
end
Benchmark.bmbm do |x|
@medecau
medecau / opcp.md
Last active March 7, 2024 18:11
Online Programming Contests and Puzzles
@fnichol
fnichol / database.yml
Created March 24, 2011 02:12
An example using ActiveRecord to connect to a WordPress database
development:
adapter: mysql2
encoding: utf8
reconnect: false
database: rails_proj_development
pool: 5
username: rp_dev
password: wootwoot
host: localhost
@digal
digal / Dimensions.scala
Created April 3, 2011 19:47
Scala DSL for simple imagemagick-styles geometry strings
/**
* DSL for imagemagick-style geometry strings
* See http://www.imagemagick.org/Magick++/Geometry.html for description
* Note: offesets are not supported
*
* Implements following constructs
*
* <width> x <height> - Rect
* <Rect> <Qualifier> (where qualifier is !/%/>/<) - Geometry
*
$ wget "http://createyourproglang.com/download.php?cbreceipt=WPXCNE6F&time=1302748966&item=1&cbpop=D8F9D688"
--2011-04-13 23:11:24-- http://createyourproglang.com/download.php?cbreceipt=WPXCNE6F&time=1302748966&item=1&cbpop=D8F9D688
Resolving createyourproglang.com... 173.236.190.249
Connecting to createyourproglang.com|173.236.190.249|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 41189241 (39M) [application/zip]
Saving to: `download.php?cbreceipt=WPXCNE6F&time=1302748966&item=1&cbpop=D8F9D688'
51% [=======================================> ] 21,100,649 65.8K/s in 5m 30s
@ryanb
ryanb / rails_3_1_rc4_changes.md
Created May 6, 2011 01:10
The Changelogs for Rails 3.1 Beta 1

Railties 3.1 RC4

  • The new rake task assets:clean removes precompiled assets. [fxn]

  • Application and plugin generation run bundle install unless --skip-gemfile or --skip-bundle. [fxn]

  • Fixed database tasks for jdbc* adapters #jruby [Rashmi Yadav]

  • Template generation for jdbcpostgresql #jruby [Vishnu Atrai]

@beoran
beoran / c_parser.rb
Created May 12, 2011 12:11 — forked from postmodern/c_parser.rb
An ANSI C Parser using the Ruby Parslet library.
#
# A C Parser using the Parslet library.
#
# ANSI C Grammar:
#
# * http://www.lysator.liu.se/c/ANSI-C-grammar-l.html
# * http://www.lysator.liu.se/c/ANSI-C-grammar-y.html
#
require 'parslet'
<?php
function doubleclick_adplanner() {
$data = file_get_contents('http://www.google.com/adplanner/static/top1000/');
preg_match_all('/href=["\']([^"\']+)?["\']target=["\']_blank/im',$data,$matches);
return implode("\n",$matches[1]);
}
function alexa_global($num = 500) {
static $topsites;
@jamierumbelow
jamierumbelow / original.php
Created May 16, 2011 22:52
A potential, CoffeeScript-esque nicer PHP
// ----------------------
// NO <?php TAG!
// ----------------------
// ----------------------
// SIGNIFICANT WHITESPACE ELIMINATES THE NEED
// FOR CURLY BRACES (YAY)
// ----------------------
class Sessions extends MY_Controller