Skip to content

Instantly share code, notes, and snippets.

jhjguxin / rails_time_zone_and_db_time.markdown
Last active August 29, 2015 13:56
rails time zone outside of Rails eg db time
View rails_time_zone_and_db_time.markdown
# simple ruby code example for running python script
path_to_script = File.dirname(__FILE__)
puts "It's a ruby script"
puts "Run python script with backticks"
puts "Result is available in"
puts `python #{path_to_script}/ UserName 37`
View maze.rb
#!/usr/bin/env ruby
# Author : Emad Elsaid (
require 'gosu'
include Gosu
# credits to:
class GameWindow < Window
def initialize
super DIMENSION, DIMENSION, false, 1000
self.caption = "Maze"
View mobile-uploader.rb
#!/usr/bin/env ruby
# Author : Emad Elsaid (
require 'sinatra'
set :port, 3000
set :environment, :production
get '/' do
View coderwall.rb
#!/usr/bin/env ruby
# Author : Emad Elsaid (
require "selenium-webdriver" # gem install selenium-webdriver
require "highline/import" # gem install highline
def coderwall github_email, github_password, title, content, tags
driver = Selenium::WebDriver.for :firefox ""
jhjguxin / rails_ar_join_sort_demo.rb
Created April 1, 2014 11:58
how rails organization join query and sort them
View rails_ar_join_sort_demo.rb
class WxUser < ActiveRecord::Base
has_many :orders, -> { order('id DESC') }
has_many :shop_wx_user_maps
belongs_to :shop
def orders_in_shop(shop_id)
orders.where(shop_id: shop_id)
jhjguxin / bootstrap-wysihtml5.js
Last active August 29, 2015 13:58
integrate wysihtml5 with qiniu cloud and jquery file upload
View bootstrap-wysihtml5.js
!function($, wysi) {
"use strict";
var tpl = {
"font-styles": function(locale, options) {
var size = (options && options.size) ? ' btn-'+options.size : '';
return "<li class='dropdown'>" +
"<a class='btn dropdown-toggle" + size + "' data-toggle='dropdown' href='#'>" +
"<i class='icon-font'></i>&nbsp;<span class='current-font'>" + locale.font_styles.normal + "</span>&nbsp;<b class='caret'></b>" +
"</a>" +
echo 'export PATH=$HOME/local/bin:$PATH' >> ~/.bashrc
. ~/.bashrc
mkdir ~/local
mkdir ~/node-latest-install
cd ~/node-latest-install
curl | tar xz --strip-components=1
./configure --prefix=~/local
make install # ok, fine, this step probably takes more than 30 seconds...
curl | sh

PhoneCat Tutorial App

A great way to get introduced to AngularJS is to work through this tutorial, which walks you through the construction of an AngularJS web app. The app you will build is a catalog that displays a list of Android devices, lets you filter the list to see only devices that interest you, and then view details for any device.

Follow the tutorial to see how Angular makes browsers smarter — without the use of native extensions or plug-ins:

jhjguxin / wshop_api.markdown
Created April 9, 2014 05:50
vcooline wshop api
View wshop_api.markdown
# app/grape/api.rb
class API < Grape::API
  # prefix "api"
 # version 'v1'