Skip to content

Instantly share code, notes, and snippets.

View hsuh's full-sized avatar
🦕

Hsu Hlaing hsuh

🦕
  • Edinburgh
  • 22:36 (UTC -12:00)
View GitHub Profile
@hsuh
hsuh / gitlog
Created June 17, 2014 13:26
A better git log
Just type in:
git log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit
Or create an alias -
git config --global alias.lg "log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit"
And every time you need to see your log, just type in
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="http://mbostock.github.com/d3/d3.js?1.27.1"></script>
<style type="text/css">
div.tooltip {
position: absolute;
text-align: center;
width: 60px;
@hsuh
hsuh / index.html
Last active August 29, 2015 14:02 — forked from mbostock/.block
Force layout with tooltips
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="http://mbostock.github.com/d3/d3.js?2.1.3"></script>
<script type="text/javascript" src="http://mbostock.github.com/d3/d3.geom.js?2.1.3"></script>
<script type="text/javascript" src="http://mbostock.github.com/d3/d3.layout.js?2.1.3"></script>
<style type="text/css">
.link {
stroke: #ccc;
@hsuh
hsuh / script
Last active August 29, 2015 14:02
Drawing HTML in canvas
<!DOCTYPE html>
<html >
<head>
</head>
<body>
<script type="text/javascript">
var canvas = document.getElementById('canvas');
var ctx = canvas.getContext('2d');
var data = '<svg xmlns="http://www.w3.org/2000/svg" width="200" height="200">' +
@hsuh
hsuh / index.html
Last active August 29, 2015 14:02 — forked from biovisualize/index.html
A simple tooltip
<!DOCTYPE html>
<html >
<head>
<script type="text/javascript" src="http://mbostock.github.com/d3/d3.js"></script>
</head>
<body>
<div class="example_div"></div>
<script type="text/javascript">
var tooltip = d3.select("body")
.append("div")
@hsuh
hsuh / gist:f8a8128ad81ec50fa5d9
Created May 30, 2014 09:34
Angularjs Service vs Factory vs Provider
Services
Syntax: module.service( 'serviceName', function ); Result: When declaring serviceName as an injectable argument you will be provided with an instance of the function. In other words new FunctionYouPassedToService().
Factories
Syntax: module.factory( 'factoryName', function ); Result: When declaring factoryName as an injectable argument you will be provided with the value that is returned by invoking the function reference passed to module.factory.
Providers
@hsuh
hsuh / gist:2aa923424907bb46a31c
Created May 28, 2014 00:38
git change config
git config --global alias.st status
For convenience and because dependencies may use node command instead of nodejs, a symbolic link is necessary to avoid having this error:/usr/bin/env: node: No such file or directory
Add Node symbolic link
sudo ln -s /usr/bin/nodejs /usr/bin/node
@hsuh
hsuh / d3cola.js
Last active August 29, 2015 14:01
SVG paths
We couldn’t find that file to show.
@hsuh
hsuh / d3cola.js
Last active August 29, 2015 14:01
Force layout constrained
var width= 960; var height = 500;
var color = d3.scale.category20();
var cola = cola.d3adaptor()
.linkDistance(120)
.avoidOverlaps(true)
.size([width,height])
var svg = d3.select("body").append("svg")
.attr("width", width)