Skip to content

Instantly share code, notes, and snippets.

View d6u's full-sized avatar

Daiwei Lu d6u

View GitHub Profile
Sol'n 1: Reset the PRAM. Do this by holding command + option + P + R on boot. After the PRAM is reset, the computer will restart again, and you can let go of those keys and start it normally.
Sol'n 2: The problem is purely software. Backup your stuff (Time Machine comes in handy here), Reinstall the OS. DO NOT immediately restore your data via Time Machine as prompted during first startup. Check to see if your Camera works. If it does, use the Migration Utility to restore data from your Time Machine backup. If it doesn't see
Sol'n 3: Worst Case Scenario, the Camera Board is going on your Mac. The quoted out-of-warranty cost of fixing this at the Genius Bar here in Canada was approx $188.00, taxes and labour included. This repair would be covered by manufactuer warranty and AppleCare.
@d6u
d6u / iTerm2 alt + arrow
Created September 5, 2013 00:37
iTerm2 alt + arrow key quick jump
alt + left: send ESC + b
alt + right: send ESC + f
alt + backspace: send HEX "0x17"
@d6u
d6u / main.css
Last active December 26, 2015 03:48
useful css snippet
p {
white-space: nowrap;
overflow: hidden;
// prevent text take more then one line
text-overflow: clip | ellipsis;
// can only be used when above two are set
}
@d6u
d6u / gist:7900833
Created December 10, 2013 21:47
JS Get Function Arguments' Name
var STRIP_COMMENTS = /((\/\/.*$)|(\/\*[\s\S]*?\*\/))/mg;
function getParamNames(func) {
var fnStr = func.toString().replace(STRIP_COMMENTS, '');
var result = fnStr.slice(fnStr.indexOf('(')+1, fnStr.indexOf(')')).match(/([^\s,]+)/g);
if (result === null) result = [];
return result;
}
<!DOCTYPE html>
<head>
<title>Stay Standalone</title>
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
<script src="stay_standalone.js" type="text/javascript"></script>
</head>
<body>
<ul>
<li><a href="http://google.com/">Remote Link (Google)</a></li>
@d6u
d6u / index.html
Created December 24, 2013 20:14
cancel in flight $http transition
<!DOCTYPE html>
<html>
<head>
<script data-require="angular.js@1.2.0-rc2" data-semver="1.2.0-rc2" src="http://code.angularjs.org/1.2.0-rc.2/angular.js"></script>
<script src="script.js"></script>
</head>
<body>
<div ng-app="queryApp" ng-controller="QueryCtrl">
var fs = require('fs');
var walk = function(dir, done) {
var results = [];
fs.readdir(dir, function(err, list) {
if (err) return done(err);
var pending = list.length;
if (!pending) return done(null, results);
list.forEach(function(file) {
file = dir + '/' + file;
fs.stat(file, function(err, stat) {
@d6u
d6u / Tmux Cheat Sheet.md
Last active August 29, 2015 14:01
Tmux Cheat Sheet

tmux cheatsheet

As configured in my dotfiles.

start new:

tmux

start new with session name:

@d6u
d6u / Ubuntu 14.04 package.sh
Last active August 29, 2015 14:01
Ubuntu 14.04 Packages
sudo apt-get update
sudo apt-get install software-properties-common # install add-apt-repository utility
sudo add-apt-repository ppa:docker-maint/testing # docker.io repository
sudo apt-get update
sudo apt-get install docker.io
[
{
"created_at": "Mon Aug 11 18:45:29 +0000 2014",
"id": 498903044189601800,
"id_str": "498903044189601792",
"text": "Infinite Ping Pong https://t.co/rT897n5Ctm",
"source": "<a href=\"http://www.hootsuite.com\" rel=\"nofollow\">Hootsuite</a>",
"truncated": false,
"in_reply_to_status_id": null,
"in_reply_to_status_id_str": null,