Skip to content

Instantly share code, notes, and snippets.

View zhuochun's full-sized avatar

Zhuochun zhuochun

View GitHub Profile
.make_spans(@index, @total) when (@index < @total) {
.span@{index} {
height: unit((30 * @index), px);
}
.make_spans((@index + 1), @total);
}
.make_spans(1, 34);
{
"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,
// 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();
@zhuochun
zhuochun / dci_alt.rb
Created December 23, 2013 21:17 — forked from elight/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']
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
// 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);
=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')
@zhuochun
zhuochun / Macbook Air 2013 Webcam.md
Last active December 23, 2015 05:49
Solve New Mountain Lion Update Webcams not accessible from applications

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/

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
function loadCss(css) {
var link;
if ($.isArray(css)) {
$.each(css, function (idx, lk) {
loadCss(lk);
});
} else {
link = document.createElement("link");
link.type = "text/css";