Skip to content

Instantly share code, notes, and snippets.

View azolotko's full-sized avatar
🛠️

Alex Zolotko azolotko

🛠️
  • Zaandam, The Netherlands
View GitHub Profile
@marcgg
marcgg / gist:733592
Created December 8, 2010 17:26
Regex to get the Facebook Page ID from a given URL
# Matches patterns such as:
# https://www.facebook.com/my_page_id => my_page_id
# http://www.facebook.com/my_page_id => my_page_id
# http://www.facebook.com/#!/my_page_id => my_page_id
# http://www.facebook.com/pages/Paris-France/Vanity-Url/123456?v=app_555 => 123456
# http://www.facebook.com/pages/Vanity-Url/45678 => 45678
# http://www.facebook.com/#!/page_with_1_number => page_with_1_number
# http://www.facebook.com/bounce_page#!/pages/Vanity-Url/45678 => 45678
# http://www.facebook.com/bounce_page#!/my_page_id?v=app_166292090072334 => my_page_id
# http://www.facebook.com/my.page.is.great => my.page.is.great
@mjohnsullivan
mjohnsullivan / named_struct.rb
Created May 2, 2011 14:25
Ruby Struct utilities: use named parameters to create Struct-based objects and return JSON from Structs
# Struct utilities
# Author:: Matt Sullivan (mailto:matt.j.sullivan@gmail.com)
# Attempt to require Ruby Gems; 1.8.X gem support only
begin
require 'rubygems'
rescue LoadError
# Ruby Gems not installed
end
@mbleigh
mbleigh / Gemfile
Created March 21, 2012 03:14
Non-Rails Rackup with Sprockets, Compass, Handlebars, Coffeescript, and Twitter Bootstrap
source "https://rubygems.org"
gem 'sprockets'
gem 'sprockets-sass'
gem 'sass'
gem 'compass'
gem 'bootstrap-sass'
gem 'handlebars_assets'
gem 'coffee-script'
@MohamedAlaa
MohamedAlaa / tmux-cheatsheet.markdown
Last active June 21, 2024 01:45
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@headius
headius / gist:3491618
Created August 27, 2012 19:34
JVM + Invokedynamic versus CLR + DLR

Too much for teh twitterz :)

JVM + invokedynamic is in a completely different class than CLR + DLR, for the same reasons that JVM is in a different class than CLR to begin with.

CLR can only do its optimization up-front, before executing code. This is a large part of the reason why C# is designed the way it is: methods are non-virtual by default so they can be statically inlined, types can be specified as value-based so their allocation can be elided, and so on. But even with those language features CLR simply cannot optimize code to the level of a good, warmed-up JVM.

The JVM, on the other hand, optimizes and reoptimizes code while it runs. Regardless of whether methods are virtual/interface-dispatched, whether objects are transient, whether exception-handling is used heavily...the JVM sees through the surface and optimizes code appropriate for how it actually runs. This gives it optimization opportunities that CLR will never have without adding a comparable profiling JIT.

So how does this affect dynamic

@evandrix
evandrix / README.md
Created September 11, 2012 00:06
Headless web browsers

Here are a list of headless browsers that I know about:

  • [HtmlUnit][1] - Java. Custom browser engine. JavaScript support/DOM emulated. Open source.
  • [Ghost][2] - Python only. WebKit-based. Full JavaScript support. Open source.
  • [Twill][3] - Python/command line. Custom browser engine. No JavaScript. Open source.
  • [PhantomJS][4] - Command line/all platforms. WebKit-based. Full JavaScript support. Open source.
  • [Awesomium][5] - C++/.Net/all platforms. Chromium-based. Full JavaScript support. Commercial/free.
  • [SimpleBrowser][6] - .Net 4/C#. Custom browser engine. No JavaScript support. Open source.
  • [ZombieJS][7] - Node.js. Custom browser engine. JavaScript support/emulated DOM. Open source.
  • [EnvJS][8] - JavaScript via Java/Rhino. Custom browser engine. JavaScript support/emulated DOM. Open source.
@gre
gre / Application.scala
Created November 12, 2012 11:10
Generate Zip on-the-fly with Play!> Framework (2.1+)
package controllers
import play.api._
import play.api.mvc._
object Application extends Controller {
def zip = Action {
import play.api.libs.iteratee._
import java.util.zip._
(ns demo.client
(:require [enfocus.core :as ef]
[enfocus.events :as events]
[vertx.client.eventbus :as eb])
(:require-macros [enfocus.macros :as em]))
(defn open-eventbus
"Opens a connection to the remote EventBus endpoint."
[& on-open]
(let [eb (eb/eventbus "http://localhost:8081/eventbus")]
class SocialNotifier
include Celluloid
attr_reader :status
def intialize(&block)
@block = block
end
def run
@gavinking
gavinking / memoize.ceylon
Last active September 7, 2017 15:21
A useful generic function to memoize a function or method, or canonicalize a class. (Tested on Ceylon 1.1 - may not work in 1.0.)
"A generic function that produces a memoized version
of the given [[function|fun]]. Works for any function
arity."
Callable<Return,Args> memoize<Return,Args>(Callable<Return,Args> fun)
given Args satisfies Anything[] {
value cache = HashMap<Args,Return&Object|Finished>();
function callFun(Args args) {
//we'll use finished as a convenient
//unit value to represent the case
//that the function returned null