Skip to content

Instantly share code, notes, and snippets.

View amrnt's full-sized avatar

Amr Tamimi amrnt

View GitHub Profile
@amrnt
amrnt / ror.md
Created August 8, 2012 23:40 — forked from ticktricktrack/ror.md
RoR dependencies

RoR setup instructions: I guess you already have XCode on your machine.

In general: avoid sudo where you can, with this setup you can install and run everything without sudo

homebrew

http://mxcl.github.com/homebrew/

here is a list of the packages on my machine

# ========================================
# Testing n-gram analysis in ElasticSearch
# ========================================
curl -X DELETE localhost:9200/ngram_test
curl -X PUT localhost:9200/ngram_test -d '
{
"settings" : {
"index" : {
"analysis" : {
require 'net/http'
class ServerProxy
def self.call(env)
if env["PATH_INFO"] =~ /^\/server_proxy/
request = Rack::Request.new(env)
params = request.params
Net::HTTP.start(params["service_url"]) {|http|
req = Net::HTTP::Get.new(params["service_path"])
@amrnt
amrnt / gist:2881883
Created June 6, 2012 13:34 — forked from yoshioota/gist:2070371
ruby-debug + ruby 1.9.3 + rbenv
# Install with:
# bash < <(curl -L https://raw.github.com/gist/2070371)
#
# renv, ruby 1.9.3-p125, linecache19-0.5.13.gem, ruby-debug-base19-0.11.26.gem
#
# https://raw.github.com/gist/1333785
# http://d.hatena.ne.jp/kurizo/20111225/p1
#
echo "Installing ruby-debug with ruby-1.9.3-p125 ..."
@amrnt
amrnt / referer_control.rb
Created May 30, 2012 17:03 — forked from postmodern/referer_control.rb
A Rack middleware app to control access to paths based on the Referer header.
module Rack
#
# RefererControl is a Rack middleware app which restricts access to paths
# based on the Referer header. Using RefererControl you can make sure
# users follow the intended flow of a website. If a controlled path is
# visited with an unacceptable Referer URI, then a simple 307 Redirect
# response is returned.
#
# RefererControl should also make Cross Site Request Forgery (CSRF) a
# little more difficult to exploit; but not impossible using JavaScript.
@amrnt
amrnt / gist:2012155
Created March 10, 2012 17:13
Ember.js Helpful Resources
@amrnt
amrnt / README.md
Created March 8, 2012 13:29 — forked from fnichol/README.md
A Common .ruby-version File For Ruby Projects

A Common .ruby-version File For Ruby Projects

Background

I've been using this technique in most of my Ruby projects lately where Ruby versions are required:

  • Create .rbenv-version containing the target Ruby using a definition name defined in ruby-build (example below). These strings are a proper subset of RVM Ruby string names so far...
  • Create .rvmrc (with rvm --create --rvmrc "1.9.3@myapp") and edit the environment_id= line to fetch the Ruby version from .rbenv-version (example below).

Today I learned about another Ruby manager, rbfu, where the author is using a similar technique with .rbfu-version.

/*
* Author: Amr Numan Tamimi <amrnt0@gmail.com>
* Extracted from: Foursquare.com
* Last Modify: 1/3/2011
*/
(function() {
var Api;
/*
* Author: Amr Numan Tamimi <amrnt0@gmail.com>
* Extracted from: Foursquare.com
* Last Modify: 1/3/2011
*/
(function() {
var iframeManager;
u1 = User.first
u2 = User.last
p = Post.first
u1.cancel_like!(p)
u2.cancel_like!(p)
p.like_count == 0
p.dislike_count == 0