This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var userChoice = prompt("Do you choose rock, paper or scissors?"); | |
var computerChoice = Math.random(); | |
console.log(computerChoice); | |
if(computerChoice <= 1/3){ | |
computerChoice = "rock"; | |
} else if(computerChoice <= 2/3){ | |
computerChoice = "paper"; | |
} else if(computerChoice <= 1){ | |
computerChoice = "scissors"; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Function.prototype.bind = function(thisObj) { | |
var that = this, args = Array.prototype.slice.call(arguments, 1); | |
return function() { | |
var xArgs = Array.prototype.slice.call(arguments); | |
return that.apply(thisObj, args.concat(xArgs)); | |
}; | |
}; | |
function fn() { | |
return this; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function disable_submit_button(obj) { | |
var selector = 'input[type="submit"]'; | |
var in_sub; | |
if (!obj) { | |
in_sub = document.querySelectorAll(selector); | |
} else { | |
var in_sub = obj.querySelectorAll(selector); | |
} | |
setTimeout(function(){ | |
if (in_sub) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Q = require('q'), | |
fs = require('fs'); | |
Q.longStackSupport = true; | |
var filterLargeFilename = function (array) { | |
var length = 10; | |
return array.filter(function (name) { | |
return (name.length <= length); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
app.factory('Gapi', ['$q', function($q) { | |
var loaded = false, loading = false; | |
function makeRequest() { | |
// do it later if we're not loaded yet | |
if (!loaded) { | |
return load().then(makeRequest); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var x = require("./fnord"); | |
module.exports = function foo() { | |
console.log(x(1, 2)); | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var mysql = require('../lib/db'); | |
var pub = { | |
authorize:function(uid,origin, cb){ | |
mysql.getConnection(function(err, connection) { | |
if (err){ return cb(err); } | |
// Use the connection | |
connection.query('SELECT secret_key,domain_name FROM rs_eshop_auth WHERE secret_key = ?',uid, function(err, rows) { | |
if (err){ return cb(err); } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require! { | |
React | |
RRouter | |
request: superagent | |
Header: "../components/Header.ls" | |
Loading: "../components/Loading.ls" | |
} | |
Link = RRouter.Link |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Promise = require('bluebird'); // or load bluebird some other way | |
var getSoundCloudUser = function(artist, params){ | |
var get = Promise.promisify(Soundcloud.get, Soundcloud) | |
return get('/e1/users/' + artist + '/stream', params); | |
}; | |
var stream = { | |
tracks: [], | |
playlists: [] | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var mysql = require('mysql'), | |
http = require('http'); | |
var connections = [null, null, null].map(function(){ | |
var connection = mysql.createConnection({ | |
host : 'localhost', | |
database : 'benchmark', | |
user : 'root', | |
password : '1234' | |
}); |
OlderNewer