Skip to content

Instantly share code, notes, and snippets.

View varjmes's full-sized avatar
🏳️‍🌈

James varjmes

🏳️‍🌈
View GitHub Profile
@varjmes
varjmes / theendingisalwaysdeath.rb
Last active December 18, 2015 00:09
Tiny text-based adventure game written in Ruby.
def prompt
print("> ")
end
puts("You enter a dark room with two doors. Do you go through door #1 or #2?")
prompt; door = gets.chomp
if door == "1"
puts("You walk towards door #1")
@varjmes
varjmes / gist:5694853
Created June 2, 2013 20:31
Tiny text-based adventure game I wrote in Ruby today. Spoilers: You die.
def prompt
print("> ")
end
puts("You enter a dark room with two doors. Do you go through door #1 or #2?")
prompt; door = gets.chomp
if door == "1"
puts("You walk towards door #1")
// Check if the player is ready to play!
confirm("Are you ready to begin?");
// How old is the player?
var age = prompt("How old are you?");
if (age < 18) {
console.log("Fine, you can play, but I'm not responsible for you.");
} else {
console.log("Let's go!");
@varjmes
varjmes / rockpaperscissors.js
Last active December 23, 2015 16:49
Rock, Paper, Scissors -> Is there a simpler way to do this?
var userChoice = prompt("Do you choose rock, paper or scissors?");
var computerChoice = Math.random();
if (computerChoice < 0.34) {
computerChoice = "rock";
} else if(computerChoice <= 0.67) {
computerChoice = "paper";
} else {
computerChoice = "scissors";
}
@varjmes
varjmes / returnoftheelderlywoman.js
Last active December 24, 2015 06:29
Playing with Switch & Case Statements.
var user = prompt("An elderly lady approaches you, brandishing a sharpened umbrella. Do you FIGHT, do you RUN or do you CURL up into the fetal position?").toUpperCase();
switch(user) {
case 'FIGHT':
console.log("You'd really hurt an old lady? For shame.");
var hits = prompt("How many times will you hit her?");
var sure = prompt("Are you sure?").toUpperCase();
if (hits >= 1 && sure === 'YES') {
console.log("How Heinous. She's dead. And you're a bad person.");
} else if (hits === 0 || sure === 'NO' ) {
// First we need to identify where in the DOM we're applying the list.
var parent = document.getElementById('output');
// Then we need to create the ordered list in the DOM.
var ol = document.createElement('ol');
// We have an ordered list. But we need to make sure it's within the "output" element!
parent.appendChild(ol);
// Time for some more sexy FizzBuzz.
// This is FizzBuzzing from number 1 - 100.
for (var i = 1; i <= 100; i++) {
@varjmes
varjmes / form.html
Created October 27, 2013 17:37
Basic Form
<form>
<input id="body" placeholder="Charlotte! You are Amazeballs!" />
<button id="button">Text Me, Baby!</button>
</form>
Functional programming is abstraction through the use of functions and reduce something into it's most basic components. FP involves keeping your functions as pure as possible and not mutating the state of the program at any point with them.
How does functional programming differ from OOP? What are higher order functions? How do you get started with functional JavaScript? Tim will answer all your questions and more, taking you through the core concepts and code examples of FP.
// Include gulp
var gulp = require("gulp");
// Include gulp plugins
var jshint = require("gulp-jshint");
var sass = require("gulp-sass");
// JS Lint Task
gulp.task("lint", function() {
return gulp.src("js/*.js")
Front-End London - https://www.youtube.com/playlist?list=PLOSHQ_hfikSoJ2tOfCheuiPcEcbSa7WpO
XOXO Fest - https://www.youtube.com/user/xoxofest
Generate - http://www.generateconf.com/videos
Lots of stuff from the jQuery Cons - https://www.youtube.com/channel/UCDT2QjewZ8DHsiaDXQFkxPg
Lots of stuff from JS Confs & CSS Conf EU - https://www.youtube.com/user/jsconfeu
Sass Conf 2013 - https://www.youtube.com/playlist?list=PLXrTmSPkhnXsd_MGL5Y__7IoRemarkRVi