Skip to content

Instantly share code, notes, and snippets.

View fraserxu's full-sized avatar
🐢
No idea

Fraser Xu fraserxu

🐢
No idea
View GitHub Profile
Running 'compile' for libxml2 2.9.2... ERROR, review '/Library/Ruby/Gems/2.0.0/gems/nokogiri-1.6.6.2/ext/nokogiri/tmp/x86_64-apple-darwin14/ports/libxml2/2.9.2/compile.log' to see what happened.
*** extconf.rb failed ***
sudo gem install nokogiri -- --with-xml2-include=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/usr/include/libxml2 --use-system-libraries
// http://tex.stackexchange.com/questions/175598/how-to-compile-on-a-mac-after-upgrade-to-maverick-os-10-9-2
It seems that the upgrade wiped the link from your Library (where MacTeX puts your actual TeX distribution) into your /usr/texbin. You can reinstate this link with the following:
ln -s /Library/TeX/Distributions/.DefaultTeX/Contents/Programs/texbin \
/usr/texbin
This will essentially create a shortcut at /usr/texbin that points to your texbin in MacTeX's internal directory. You still should make sure that /usr/texbin is in your PATH environment variable, though.
NB. If you use LateX -> PS -> PDF, you may also need to repair the link to ghostscript:
sudo ln -s /usr/local/bin/gs-noX11 gs
@fraserxu
fraserxu / gist:98a2a30601752526864f
Created March 20, 2015 04:53
make a grouped array
var data = {"16":1,"17":5,"18":324,"19":396,"20":456,"21":441,"22":454,"23":525,"24":488,"25":499,"26":498,"27":551,"28":556,"29":556,"30":555,"31":558,"32":590,"33":543,"34":552,"35":621,"36":569,"37":593,"38":532,"39":565,"40":590,"41":625,"42":587,"43":624,"44":647,"45":718,"46":656,"47":724,"48":725,"49":690,"50":649,"51":650,"52":675,"53":666,"54":563,"55":663,"56":537,"57":619,"58":529,"59":535,"60":479,"61":484,"62":415,"63":457,"64":381,"65":332,"66":294,"67":333,"68":329,"69":262,"70":232,"71":245,"72":198,"73":198,"74":185,"75":193,"76":162,"77":221,"78":151,"79":155,"80":150,"81":122,"82":125,"83":99,"84":84,"85":115,"86":89,"87":105,"88":70,"89":65,"90":65,"91":59,"92":63,"93":55,"94":35,"95":38,"96":37,"97":27,"98":35,"99":30,"100":19,"101":19,"102":12,"103":12,"104":11,"105":8,"106":9,"107":5,"108":13,"109":5,"110":7,"111":2,"112":6,"113":3,"114":1};
var ages = [], years = [];
var groupIndex = 1;
var maxGroupIndex = 16;
// make years
for (var i = 18; i < 98; i++ ) {
years.push(i)
}
@fraserxu
fraserxu / addDate.js
Created February 28, 2015 10:19
date add
function dateAdd(date, interval, units) {
var ret = new Date(date); //don't change original date
switch(interval.toLowerCase()) {
case 'year' : ret.setFullYear(ret.getFullYear() + units); break;
case 'quarter': ret.setMonth(ret.getMonth() + 3*units); break;
case 'month' : ret.setMonth(ret.getMonth() + units); break;
case 'week' : ret.setDate(ret.getDate() + 7*units); break;
case 'day' : ret.setDate(ret.getDate() + units); break;
case 'hour' : ret.setTime(ret.getTime() + units*3600000); break;
case 'minute' : ret.setTime(ret.getTime() + units*60000); break;
### Keybase proof
I hereby claim:
* I am fraserxu on github.
* I am fraserxu (https://keybase.io/fraserxu) on keybase.
* I have a public key whose fingerprint is FAB4 7AE3 198F D595 1D44 D34C 311B 021F 9AFF 7F3F
To claim this, I am signing this object:
@fraserxu
fraserxu / pattern.js
Created February 5, 2015 03:22
svg pattern generator
var btoa = require('btoa')
var fs = require('fs')
var pattern = fs.readFileSync('test.svg', { encoding: 'utf-8'})
var b64 = btoa(pattern)
var b64 = "data:image/svg+xml;base64," + b64
console.log(b64)
@fraserxu
fraserxu / layout.scss
Created December 23, 2014 03:06
sass responsive layout mixins
$tablet-width: 768px;
$desktop-width: 1024px;
@mixin tablet {
@media (max-width: #{$tablet-width - 1px}) {
@content;
}
}
@mixin desktop {
@fraserxu
fraserxu / china_provinces.json
Created December 18, 2014 06:38
china population stack barchart
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@fraserxu
fraserxu / china_provinces.json
Created December 18, 2014 06:35
china population choropleth
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@fraserxu
fraserxu / README.md
Last active August 29, 2015 14:11 — forked from mbostock/.block

This variation of a line chart demonstrates how to use a linear gradient to change the color of a line based on a y-threshold. This technique is similar to the gradient encoding, but with two stops at the same offset. An alternative method is to draw multiple lines with different colors and different clipping regions.