Skip to content

Instantly share code, notes, and snippets.

View jli168's full-sized avatar

jli168 jli168

  • New York
View GitHub Profile
@jli168
jli168 / 0_reuse_code.js
Last active August 29, 2015 14:08
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@jli168
jli168 / another_way
Last active June 22, 2019 09:03
download file to client using cURL
<?php
$ch = curl_init($url);
$fp = @fopen("../Files/System/TEST/temp.xml", "w");
curl_setopt($ch, CURLOPT_FILE, $fp);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_exec($ch);
curl_close($ch);
fclose($fp);
$file = "../Files/System/TEST/temp.xml";
@jli168
jli168 / debounce.js
Last active February 29, 2016 14:52
javascript debounce function
// call func after a defined interval of time
var debounce = function( func, wait ) {
var timeoutId = null;
// set default interval time
wait = wait || 200;
return function() {
var args = arguments,
context = this;
@jli168
jli168 / unit_test_backbone_endpoint.js
Created April 14, 2016 10:55
unit test: favorite way to mock backbone endpoint and test callbacks, using `$ajax` and promise
//////////////////////////
// backbone fetch method
//////////////////////////
// set up fetch & callbacks
myCollection.fetch( options )
.done( this.successHandler.call( this ) )
.fail( this.errorHandler.call( this ) );
//////////////////////////
@jli168
jli168 / loop_youtube.js
Created March 19, 2017 01:04
add loop button on youtube video
/**
* Note: this code is copied from Casey Chu( bitsofpancake )'s repo: https://github.com/bitsofpancake/youtube-loop-video
* and minorly changed ( remove the style block, set looping default to true ).
*
* How to use the code: when you are on a youtube video page and want to loop this video,
* just create a snippet in chrome dev tool ( developer tools > source > snippets )
* copy this code into the snippet, and run it!
*
* The code will create a "loop" button in the UI, and by default it will set to loop the video,
* you can toggle the button to enable/disable looping.