Skip to content

Instantly share code, notes, and snippets.

@jeankueo
jeankueo / LinkedList.js
Created October 23, 2016 09:55
Create a linked list, with method add and contain
function Node (next) {
this.next = next;
}
function LinkedList () {
this.add = function (node) {
if (!this.head) {
this.head = node;
this.tail = node;
<svg>
<path d="656,3.590086515234319L7.507422977054138,3.48480602146023L7.558771980274737,3.1812911923072864L7.693528083432315,2.7150530043982144L7.9428757690279586,2.1405771983989377L8.326445669204796,1.5249377592717224L8.85014232774543,0.9400820352413847L9.50521542237436,0.45479925270044297L10.26866142239143,0.12740320938441185L11.10492359941662,0.00003398554654032715L11.96874207965496,0.09523321534974649L12.808902609527914,0.4151115680249612L13.572552107792642,0.9430564687132881L14.209698099217515,1.647577886990394L14.677492324703223,2.487611251080419L14.943917704886266,3.418428410127233L14.990550716013795,4.397271680291563L14.814153398611367,5.38792340489455L14.426953326201767,6.3636348061688315L13.855586617911364,7.308126889580041L13.138798060140417,8.214695436613766L12.324102984772056,9.083750906578336L11.463707861075228,9.919356155978882L10.610052354102011,10.725455816324024L9.811369010869653,11.502503447364067L9.107654776715906,12.245088110548274L8.527411396744823,12.940961433619478L8.08544274310878
@jeankueo
jeankueo / gist:58a8a9152cc1a5cc083565220eafc8e9
Last active May 30, 2016 09:43
flatten an unknown depth array
function flatArray (source) {
if (Array.isArray(source)) {
return source.reduce(function (previous, current) {
return previous.concat(flatArray(current));
}, [])
}
return [source];
}
@jeankueo
jeankueo / jsfiddle-svg-path
Created December 31, 2013 06:43
Use this code to adjust svg path on JSFiddle
<svg xmlns="http://www.w3.org/2000/svg">
<path d="M0,10 h180 v30 h-80 l-10,10 l-10,-10 H0 v-30"></path>
</svg>