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
@zhuochun
zhuochun / jQuery Plugin.js
Created Oct 28, 2012
jQuery Plugin Boilerplate
View jQuery Plugin.js
/* ========================================
* <Project> - <Description>
*
* Author:
* Last Edit:
* ========================================
* <License>
* ======================================== */
// the semi-colon before function invocation is a safety net against concatenated
@zhuochun
zhuochun / fixnavbar.js
Created Dec 6, 2012
Scroll Fix on Top Navbar
View fixnavbar.js
// fix navbar on scroll
var $win = $(window)
, $nav = $('.navbar')
, navTop = $('.navbar').length && $('.navbar').offset().top - 10
, isFixed = 0
processScroll()
$win.on('scroll', processScroll)
@zhuochun
zhuochun / run_async.js
Created Apr 21, 2013
Run a large batch of async tasks separated
View run_async.js
var complete = {}, completed = 0;
var i, thread = 23, total = 179, max = (total / thread | 0) + 1;
function startCount(idx, max) {
if (completed >= total) {
console.log("completed = " + completed);
console.log(complete);
return ;
} else if (idx === max || idx >= total) {
View loadCss.js
function loadCss(css) {
var link;
if ($.isArray(css)) {
$.each(css, function (idx, lk) {
loadCss(lk);
});
} else {
link = document.createElement("link");
link.type = "text/css";
View eigenclass.rb
#Person
class Person
end
#class method
class Person
def self.address
puts "hangzhou"
end
end
View 20130426184456_devise_create_users.rb
class DeviseCreateUsers < ActiveRecord::Migration
def change
create_table :users do |t|
t.timestamps
## Database authenticatable
t.string :email, :null => false, :default => ""
t.string :encrypted_password, :null => false, :default => ""
## Recoverable
t.string :reset_password_token
@zhuochun
zhuochun / Macbook Air 2013 Webcam.md
Last active Dec 23, 2015
Solve New Mountain Lion Update Webcams not accessible from applications
View Macbook Air 2013 Webcam.md

After the latest OS X system update, Macbook Air 2013 Webcam no longer working on Chrome/Skype.

Solution

  1. Download the attached file.

  2. Go to Finder>Go>Go to Folder

  3. Copy and paste this into the search bar: /Library/CoreMediaIO/Plug-Ins/DAL/

View capybara cheat sheet
=Navigating=
visit('/projects')
visit(post_comments_path(post))
=Clicking links and buttons=
click_link('id-of-link')
click_link('Link Text')
click_button('Save')
click('Link Text') # Click either a link or a button
click('Button Value')
View jquery.onclose.coffee
$ = jQuery
TRANSFORM_TYPES = ['PUT', 'POST', 'DELETE']
$.activeTransforms = 0
$(document).ajaxSend (e, xhr, settings) ->
return unless settings.type in TRANSFORM_TYPES
$.activeTransforms += 1
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.