Skip to content

Instantly share code, notes, and snippets.

View oelmekki's full-sized avatar

kik oelmekki

View GitHub Profile
# This file makes Haml work with Rails
# using the > 2.0.1 template handler API.
module Haml
# In Rails 3.1+, template handlers don't inherit from anything. In <= 3.0, they do.
# To avoid messy logic figuring this out, we just inherit from whatever the ERB handler does.
class Plugin < Haml::Util.av_template_class(:Handlers)::ERB.superclass
if ((defined?(ActionView::TemplateHandlers) &&
defined?(ActionView::TemplateHandlers::Compilable)) ||
(defined?(ActionView::Template) &&
central kik # gem install libv8 therubyracer
Successfully installed libv8-3.3.10.2-x86_64-linux
Building native extensions. This could take a while...
ERROR: Error installing therubyracer:
ERROR: Failed to build gem native extension.
/usr/bin/ruby19 extconf.rb
Compiling The Ruby Racer...
checking for v8.h in /usr/lib64/ruby/gems/1.9.1/gems/libv8-3.3.10.2-x86_64-linux/lib/libv8/v8/include... yes
checking for main() in -lpthread... yes
# ld.so.conf autogenerated by env-update; make all changes to
# contents of /etc/env.d directory
/usr/local/lib
include ld.so.conf.d/*.conf
//usr/lib32/opengl/nvidia/lib
//usr/lib64/opengl/nvidia/lib
/lib64
/usr/lib64
/usr/local/lib64
/lib32
class ApplicationController < ActionController::Base
protect_from_forgery
include ActionView::Helpers::TagHelper
def template_include_tag(*sources)
if sources.empty?
templates = ''
Dir.glob( Rails.root.join('app/templates', controller_name, "*.html.mustache").to_s ) do |template_path|
template = File.open(template_path, "rb")
templates << "\n" + content_tag( :script, template.read.html_safe, :type => "text/mustache" )
# encoding : utf-8
require 'find'
class NoRollback
def initialize( path )
Find.find( path ) do |file|
check file
end
end
" File: sudo_save.vim
" Author: Olivier El Mekki
" Email: [email protected]
" Description: save the file with sudo
" Usage:
" :SudoSave - save the file with sudo
if exists('sudo_save_plugin')
finish
endif
Function.prototype.until = function( cond, bind, time ){
bind = bind || this;
if ( ! cond.call( bind ) ){
var timer = function(){
if ( ! cond.call( bind ) ){
this.call( bind );
}
else {
public function is($exp1, $exp2, $message = '')
{
if (is_object($exp1) || is_object($exp2))
{
$value = $exp1 === $exp2;
}
else if (is_float($exp1) && is_float($exp2))
{
$value = abs($exp1 - $exp2) < self::EPSILON;
}
#!/usr/bin/env ruby
require 'net/http'
url = URI.parse('http://google.com/')
req = Net::HTTP::Get.new(url.path)
res = Net::HTTP.start(url.host, url.port) {|http|
http.request(req)
}
p res[ 'location' ]
#!/usr/bin/env ruby
require 'net/http'
url = URI.parse('http://google.com/')
req = Net::HTTP::Get.new(url.path)
res = Net::HTTP.start(url.host, url.port) {|http|
http.request(req)
}
res[ 'url' ] = 'pouet'
p res[ 'url' ]