Skip to content

Instantly share code, notes, and snippets.

Zhuochun zhuochun

Block or report user

Report or block zhuochun

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View keyboardlistener.cs
using System;
using System.Diagnostics;
using System.Runtime.InteropServices;
using System.Runtime.CompilerServices;
using System.Windows.Input;
using System.Windows.Threading;
using System.Collections.Generic;
namespace Ownskit.Utils
{
View spec_helper.rb
# This file is copied to spec/ when you run 'rails generate rspec:install'
ENV["RAILS_ENV"] ||= 'test'
require File.expand_path("../../config/environment", __FILE__)
require 'rspec/rails'
require 'rspec/autorun'
require 'capybara/rails'
require 'capybara/rspec'
require 'database_cleaner'
# Requires supporting ruby files with custom matchers and macros, etc,
View master.vim
" copy all this into a vim buffer, save it, then...
" source the file by typing :so %
" Now the vim buffer acts like a specialized application for mastering vim
" There are two queues, Study and Known. Depending how confident you feel
" about the item you are currently learning, you can move it down several
" positions, all the way to the end of the Study queue, or to the Known
" queue.
" type ,, (that's comma comma)
View ruby-debugging.markdown

Gems

gem 'debugger', group: [:development, :test]

Debugging

  • Add debugger to anywhere in code that needs a breakpoint.
  • Refresh the page, the rails server terminal will stop, use help.
View less-loop.less
.make_spans(@index, @total) when (@index < @total) {
.span@{index} {
height: unit((30 * @index), px);
}
.make_spans((@index + 1), @total);
}
.make_spans(1, 34);
View nodewebkit.json
{
"main": "index.html",
"name": "nw-demo",
"description": "demo app of node-webkit",
"version": "0.1.0",
"keywords": [ "demo", "node-webkit" ],
"window": {
"title": "node-webkit demo",
"icon": "link.png",
"toolbar": true,
View gulpfile-sass.js
// Include gulp
var gulp = require('gulp');
// Include Our Plugins
var sass = require('gulp-sass');
var lr = require('tiny-lr'),
refresh = require('gulp-livereload'),
server = lr();
View dci_alt.rb
class User < ActiveRecord::Base
# ... lots of persistence stuff
end
class GitHubUserProvisioner < SimpleDelegator
def provision_with!(user_info, extra_user_hash)
self.github_login = extra_user_hash['login']
self.name = user_info['name']
self.email = user_info['email']
self.github_url = user_info['urls']['GitHub']
View rails_association.rb
class User < ActiveRecord::Base
#let's just make it simple and only add one column for this model called 'username'
attr_accessible :username
#use "follower_id" as the foreign key since by default it will use "user_id" which does
#not exist inside the "relationships" table
has_many :relationships, foreign_key: :follower_id
#find all user with the ID matching the "followed_user_ids" of the result. If I did not
#include "source: :followed_user", it will look for the column "following_id" which is wrong
View weibo_page_delete.js
// Zhuochun
// 2013-12-15
function eventFire(el, etype) {
if (el.fireEvent) {
(el.fireEvent('on' + etype));
} else {
var evObj = document.createEvent('Events');
evObj.initEvent(etype, true, false);
el.dispatchEvent(evObj);
You can’t perform that action at this time.