This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
finalRed= (red * 0.393) + (green * 0.769) + (blue * 0.189); | |
finalGreen = (red * 0.349) + (green * 0.686) + (blue * 0.168); | |
finalBlue= (red * 0.272) + (green * 0.534) + (blue * 0.131); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var win = window.open('foo.html', 'windowName',"width=200,height=200,scrollbars=no"); | |
var timer = setInterval(function() { | |
if(win.closed) { | |
clearInterval(timer); | |
alert('closed'); | |
} | |
}, 1000); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'spec_helper' | |
describe Users::OauthCallbacksController, "handle facebook authentication callback" do | |
describe "#annonymous user" do | |
context "when facebook email doesn't exist in the system" do | |
before(:each) do | |
stub_env_for_omniauth | |
get :facebook |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class PdfMerger | |
def merge(pdf_paths, destination) | |
first_pdf_path = pdf_paths.delete_at(0) | |
Prawn::Document.generate(destination, :template => first_pdf_path) do |pdf| | |
pdf_paths.each do |pdf_path| | |
pdf.go_to_page(pdf.page_count) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Make it use C-a, similar to screen.. | |
unbind C-b | |
unbind l | |
set -g prefix C-a | |
bind-key C-a last-window | |
# Reload key | |
bind r source-file ~/.tmux.conf | |
set -g default-terminal "screen-256color" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ApplicationController < ActionController:Base | |
before_action :update_online_status | |
def update_online_status | |
now = DateTime.now | |
expire_time = now + 5.minutes | |
current_time_key = "online_users:#{now.minute}" | |
$redis.sadd(current_time_key, current_user.id) | |
$redis.expireat(current_time_key, expire_time) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'faye' | |
class ServerAuth | |
def incoming(message, callback) | |
do_something if message =~ /^\/meta\/subscribe/ | |
do_other_something if message =~ /^\/meta\/unsubscribe/ | |
callback.call(message) | |
end | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[2013-11-26 23:45:07] __rvm_make | |
__rvm_make () | |
{ | |
\make "$@" || return $? | |
} | |
current path: /Users/doxuanhuy/.rvm/src/ruby-1.9.2-p320 | |
command(3): __rvm_make -j 1 | |
/usr/local/opt/gcc46/bin/gcc-4.6 -O3 -I/usr/local/opt/readline/include -I/usr/local/opt/libksba/include -I/usr/local/opt/openssl/include -fno-common -pipe -I. -I.ext/include/x86_64-darwin13.0.0 -I./include -I. -DRUBY_EXPORT -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -o main.o -c main.c | |
/usr/local/opt/gcc46/bin/gcc-4.6 -O3 -I/usr/local/opt/readline/include -I/usr/local/opt/libksba/include -I/usr/local/opt/openssl/include -fno-common -pipe -I. -I.ext/include/x86_64-darwin13.0.0 -I./include -I. -DRUBY_EXPORT -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -o dln.o -c dln.c | |
/usr/local/opt/gcc46/bin/gcc-4.6 -O3 -I/usr/local/opt/readline/include -I/usr/local/opt/libksba/include -I/usr/local/opt/openssl/include -fno-common -pipe -I. -I.ext/include/x86_64-darwin13.0.0 -I./include -I. -DRUBY_EXPORT -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -o dmydln.o -c dmydln.c |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'date' | |
require 'rugged' | |
data = File.read('./source.txt').split("\n") | |
dist = data[0].size.times.map {|i| data.map {|n| n[i] } }.flatten | |
date = Date.today - 366 | |
date += 1 until date.wday.zero? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# A quick and dirty implementation of an HTTP proxy server in Ruby | |
# because I did not want to install anything. | |
# | |
# Copyright (C) 2009 Torsten Becker <[email protected]> | |
require 'socket' | |
require 'uri' |