Skip to content

Instantly share code, notes, and snippets.

Chris Le chrisle

Block or report user

Report or block chrisle

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View answer.js
/**
* To answer @AnnieCushing's question on Twitter:
* https://twitter.com/AnnieCushing/status/806518054368739329
*
* Author: Chris Le - @iamchrisle
*
* There's a few ways to do this.
* - Like @SimoAhava suggested, server redirects that strips parameters if you
* have the ability to control the server.
@chrisle
chrisle / scraper.js
Last active Jul 2, 2016
Scrape Billboard Hot 100 and create an array of objects
View scraper.js
/**
* Install x-ray with: 'npm install x-ray'
* (Also see: https://github.com/lapwinglabs/x-ray)
*
* Run with: node scraper.js
*
* Result:
*
* [ { rankCurrent: '1',
* rankLast: 'Last Week: 1',
View designer.html
<link rel="import" href="../chart-js/chart-js.html">
<polymer-element name="my-element">
<template>
<style>
:host {
position: absolute;
width: 100%;
height: 100%;
@chrisle
chrisle / scrollwaypoints.html
Last active Aug 29, 2015
Scrolling + jQuery Waypoints
View scrollwaypoints.html
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8/jquery.min.js"></script>
<!-- Download from here: http://imakewebthings.com/jquery-waypoints/ -->
<script src="https://raw.githubusercontent.com/imakewebthings/jquery-waypoints/master/waypoints.js"></script>
<style type="text/css">
/* A box that is 500px tall */
.content {
height: 500px;
@chrisle
chrisle / gist:9478860
Last active Aug 29, 2015
Is this what you mean?
View gist:9478860
You have ...
[1,2,3,4,5,6,7,8,9]
[1,2,3,4,5,6,7]
[1,2,3]
You want in chunks of N (say 3)
[
[1,2,3],
[4,5,6],
[7,8,9],
@chrisle
chrisle / gist:8588282
Created Jan 23, 2014
TLDR - Google Analytics
View gist:8588282
/**
* The very simplest explanation of how GA works in JavaScript is that it's simply an array.
* The GA tag (not the new Universal tag) looks similar to this:
*/
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-xxxxxxxx-y']);
_gaq.push(['_trackPageview']);
(function () {
@chrisle
chrisle / gist:7055839
Last active Dec 25, 2015
Should an API allow for polling or instead push results? What do you prefer?
View gist:7055839

Question

If http://localhost/api/do_job kicks off a job on the backend that will take 45-120 seconds to complete, what should the API return?

POLL) Return 202 Accepted + a URL polling end point.

Eg:

202 Accepted
{ "job_id": 103859195, "poll": "http://localhost/poll/103859195", "complete": "0%" }
@chrisle
chrisle / gist:6368604
Created Aug 28, 2013
Humanize an underscored or camel cased string in JavaScript
View gist:6368604
/**
* Humanize a string. Turns underscored or camel cased string into human readable strings
*
* @example
* TextUtils.humanize( 'keyword_category' ); // => "Keyword Category"
* TextUtils.humanize( 'keywordCategory' ); // => "Keyword Category"
*
* @return {String}
*/
humanize: function(str) {
View gist:5774203
class Puzzle
attr_accessor :field
def initialize
self.field = true
end
def run
puts field.inspect # => true
View gist:5129460
/**
* Adds empty elements to an array
*
* @example
* A1: hello
* A2: world
*
* =splitArrayBy(A1:A2, 3)
*/
function splitArrayBy(array, n) {
You can’t perform that action at this time.