Skip to content

Instantly share code, notes, and snippets.

View Peleg's full-sized avatar

Peleg Rosenthal Peleg

View GitHub Profile
const IS_BROWSER = typeof window !== 'undefined';
if (!IS_BROWSER) {
require('isomorphic-fetch');
}
const COOKIE = 'REPLACE W YOURS';
const API_BASE = 'https://api.equinox.com';

#jquery calculator:

  1. create html file and include the dependencies (jquery, bootstrap);

  2. create html layout on page. that includes: script, buttons (numbers, clear, operators, equals);

  3. declare variables for the numbers:

    • first number,
    • second number
var word;
var allowedGuesses;
var correctGuesses;
var wrongGuesses;
var wordElement = document.getElementById('word');
var letterCountElement = document.getElementById('letterCount');
var lettersGuessedElement = document.getElementById('lettersGuessed');
function initializeGame() {
@Peleg
Peleg / es6-7.js
Last active April 13, 2016 00:07
es6/7
/**
* const
* - non-re-writable
* - use everywhere you don't need to reassign!
*/
const foo = 'bar';
/**
* Block scoped variables
*/
@Peleg
Peleg / fb_bd_liker.js
Created November 27, 2014 21:31
Facebook Birthday Liker - likes your friends' posts for your birthday
/**
*
* Facebook Birthday Liker -
* Likes your friends' posts for your birthday
*
* Usage:
* 1. Face the fact that you're an ungrateful, lazy being
* 2. Paste the following code in your console
*
*/
// load this in admin.js
Tenement.Model = Backbone.Model.extend({
url: function () {
return '/admin/api' + this.urlRoot;
}
});
// load this one in application.js
Tenement.Model = Backbone.Model.extend({
url: function () {
@Peleg
Peleg / backbone-ext.js
Created August 7, 2014 21:03
Overwriting backbone params to comply with rails conventions
// Overwrite Backbone#sync in order to allow easy form submissions
(function ($) {
// Modify params in order to follow the Rails convention:
// comments: [Obj, Obj] => comments_attributes: { 0: Obj, 1: Obj }
// video: { id: 2, title: 'foo' } => video_attributes: { id: 2, title: 'foo' }
var railifyParams = function (params) {
for (var key in params) {
if (!params.hasOwnProperty(key)) continue;
if (params[key] instanceof Object) {
@Peleg
Peleg / t9Dictionary.js
Last active August 29, 2015 14:03
T9 Dictionary for node.js
// Usage:
// var T9Dictionary = require('./t9_dictionary')
// var dict = new T9Dictionary(<path to text file>)
// dict.suggest(4663) => [ 'good', 'gone', 'home', 'hood', 'hoof' ]
module.exports = (function () {
// Modules
var fs = require('fs');