Skip to content

Instantly share code, notes, and snippets.

View relaxedtomato's full-sized avatar

Ram relaxedtomato

View GitHub Profile
@relaxedtomato
relaxedtomato / montyhall.js
Created February 27, 2015 00:30
Solving the Monty Hall Problem 1000 Times.
var doors = [];
var temp;
//NO SWITCH
var firstGuess;
var doorOpen;
var noSwtichcorrect=0;
var noSwitchwrong=0;
function placeCar(){
//if begins with a vowel, add 'ay' to the end
//consonant sounds, move it to the end and add 'ay'
function translate(str){
var strArr = str.split(" ");
var result = [];
strArr.forEach(function(word){
var wordArr = word.split("");
console.log(wordArr);
var shiftToEnd = '';
var traverseDomAndCollectElements = function(matchFunc, startEl) {
var resultSet = [];
if (typeof startEl === "undefined") {
startEl = document.body;
}
// your code here
// traverse the DOM tree and collect matching elements in resultSet
// use matchFunc to identify matching elements
@relaxedtomato
relaxedtomato / word_count.js
Created March 24, 2015 13:28
exercism.io wordcount
//store each word as object key, and property count
//this allows for quick lookup and counting
var words = function(str){
var strArr = str.split(" ");
var objCount = {};
strArr.forEach(function(word){
if(objCount[word]){
objCount[word] += 1;
@relaxedtomato
relaxedtomato / gist:0e9daeeb7af4c4e65fbb
Last active August 29, 2015 14:18
Basic MEAN Stack Scaffold
#Place file named as 'dir.sh' on main directory and run bash dir.sh
#ensure to include 'dir.sh' with .gitignore
# Create Folders
mkdir -p app/{models,routes}
mkdir -p config
mkdir -p config/api
mkdir -p public/{css,js/{controllers,directives,services,templates,factories},img,views}
mkdir -p server
mkdir -p server/models
dir.sh
node_modules
bower_components
config
@relaxedtomato
relaxedtomato / gist:aad3168abe5a2e092b17
Created May 1, 2015 16:31
Using Cheerio with BlueBird
var request = require('request');
var cheerio = require('cheerio');
var bluebird = require('bluebird');
bluebird.promisifyAll(request);
var promise = request.getAsync('http://www.reddit.com');
promise.get(1).then(function (htmlbody) {
var $ = cheerio.load(htmlbody);
@relaxedtomato
relaxedtomato / gist:b2cfc3d1ed12969d1a77
Created May 26, 2015 13:46
React + Browserify Gulp Task
/**
* Created by ram on 15-05-03.
*/
var gulp = require('gulp');
var babelify = require('babelify');
var source = require('vinyl-source-stream');
var reactify = require('reactify');
var browserify = require('browserify')();
var gutil = require('gulp-util');
var filter = require('gulp-filter');
/**
* Created by ram on 15-05-03.
*/
var gulp = require('gulp');
var babelify = require('babelify');
var source = require('vinyl-source-stream');
var reactify = require('reactify');
var browserify = require('browserify');
var gutil = require('gulp-util');
var filter = require('gulp-filter');