Skip to content

Instantly share code, notes, and snippets.

@dortzur
dortzur / 0_reuse_code.js
Created Oct 5, 2016
Here are some things you can do with Gists in GistBox.
View 0_reuse_code.js
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@dortzur
dortzur / reddit-scripts.js
Last active Sep 15, 2016
Reddit "Hot Story" and "Best Comments" algorithms in JavaScript
View reddit-scripts.js
//Based off of https://medium.com/hacking-and-gonzo/how-reddit-ranking-algorithms-work-ef111e33d0d9
function hotStory(ups, downs,date){
const score = ups - downs;
const order = Math.log(Math.max(Math.abs(score), 1), 10);
const sign = score > 0 ? 1 : ((score < 0) ? -1 : 0);
const seconds = (date.getTime()/1000) - 1134028003;
return Math.round(sign * order + seconds / 45000, 7);
}
@dortzur
dortzur / example.html
Created Sep 28, 2011 — forked from joelnet/example.html
Unobtrusive Knockout support library for jQuery
View example.html
Choose a ticket class: <select id="tickets"></select>
<p id="ticketOutput"></p>
<script id="ticketTemplate" type="text/x-jquery-tmpl">
{{if chosenTicket}}
You have chosen <b>${ chosenTicket().name }</b>
($${ chosenTicket().price })
<button data-bind="click: resetTicket">Clear</button>
{{/if}}
You can’t perform that action at this time.