Skip to content

Instantly share code, notes, and snippets.

View coderek's full-sized avatar
👽

Derek Zeng coderek

👽
View GitHub Profile
# 1B problem B 2013 Google Code Jam
# adapted answer from 'dolphinigle'
gets.to_i.times do |ca|
my, n = gets.split(" ").map(&:to_i)
motes = gets.split(" ").map(&:to_i).sort
best = motes.length # all delete
if my == 1
puts "Case ##{ca+1}: #{best}"
commit c503be473c95fc5a0f3634bf4a1557e5dd1357ed
Author: Derek Zeng <qiang.zeng@starhub.com>
Date: Fri May 10 15:45:54 2013 +0800
save
diff --git a/sass/base/_theme.scss b/sass/base/_theme.scss
index 1a43a03..9765d08 100644
--- a/sass/base/_theme.scss
+++ b/sass/base/_theme.scss
@coderek
coderek / json.rb
Last active December 24, 2015 06:39
jruby -S gem install json-jruby
## install json-jruby library
# jruby -S gem install json-jruby
## create json.rb file which contains code below
## generate json.class file
# jrubyc json.rb
## run
# java -cp .:/path/to/jruby-complete-1.7.4.jar json
## should see some output
@coderek
coderek / ap.rb
Last active December 24, 2015 06:48
# awesome print
# Awesome Print is a Ruby library that pretty prints Ruby objects in full color exposing their internal structure with proper indentation. Rails ActiveRecord objects and usage within Rails templates are supported via included mixins.
# grab zipped gem from https://github.com/michaeldv/awesome_print/archive/master.zip
# command to compile
# `jrubyc ap.rb`
# command to run
# `java -cp .:/path/to/jruby-complete-1.7.4.jar ap`
# HAML is a language that can be compiled to HTML
# it's syntax is easy to write and read, thus it's very popular among web developers
# grab zipped gem from https://github.com/haml/haml/archive/master.zip
# also the dependency https://github.com/rtomayko/tilt/archive/master.zip
# command to compile
# `jrubyc haml.rb`
# command to run
# download at https://github.com/nex3/sass/archive/stable.zip
# command to compile
# `jrubyc sass.rb`
# command to run
# `java -cp .:/path/to/jruby-complete-1.7.4.jar sass`
$:.unshift "D:\\sass-stable\\lib" # replace with your lib path
require "sass"
# active support library
# Active Support is the Ruby on Rails component responsible for providing Ruby language extensions, utilities, and other transversal stuff.
# It offers a richer bottom-line at the language level, targeted both at the development of Rails applications, and at the development of Ruby on Rails itself.
# http://guides.rubyonrails.org/active_support_core_extensions.html
# examples of functions
# blank? and present?
var doopizlist = new DoopizCollection();
doopizlist.fetch({
success: function(collection ) {
console.log (collection); // see what's here ?
},
error: function(doopizlist , error) {
console.log("error")
}
});
@coderek
coderek / article_bg.css
Created November 19, 2013 01:14
nice backgorund
background: {
url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAE8AAABPCAYAAACqNJiGAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyJpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuMC1jMDYwIDYxLjEzNDc3NywgMjAxMC8wMi8xMi0xNzozMjowMCAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RSZWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZVJlZiMiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIENTNSBNYWNpbnRvc2giIHhtcE1NOkluc3RhbmNlSUQ9InhtcC5paWQ6NUVFREE2QTFENjc3MTFFMDg0RDg4QURBN0E4NTA4NTUiIHhtcE1NOkRvY3VtZW50SUQ9InhtcC5kaWQ6NUVFREE2QTJENjc3MTFFMDg0RDg4QURBN0E4NTA4NTUiPiA8eG1wTU06RGVyaXZlZEZyb20gc3RSZWY6aW5zdGFuY2VJRD0ieG1wLmlpZDpGNTQwMEVFNkQ1OTUxMUU
@coderek
coderek / inheritance.js
Last active December 29, 2015 07:49
demostrate mixins and open class
// mixin 1
var SuperAbility = {
dance: function () {
console.log (this.name + " is dancing...");
},
talk: function () {
console.log ("talking from mixin...");
}
}
// mixin 2