Skip to content

Instantly share code, notes, and snippets.

@AmaxJ
AmaxJ / blackjack.scala
Last active December 10, 2017 16:03
blackjack
object BlackJack {
def main(args: Array[String]) = {
val deck = new Deck()
val players = addPlayers(3)
println(deck.deal)
println(deck.cards)
}
def addPlayers(num: Int) = {
@AmaxJ
AmaxJ / practice.js
Created January 1, 2017 22:22
practice with dan
//Installed node modules: jquery underscore request express jade shelljs passport http sys lodash async mocha chai sinon sinon-chai moment connect validator restify ejs ws co when helmet wrench brain mustache should backbone forever debug
var _ = require('underscore');
var num = "the number: ";
var num2 = "10";
// console.log(num + num2)
var num3 = 42; //string //integer
function vacancies(arr) {
var vacancies = [];
for (var i=0; i < arr.length; i++) {
if (arr[i] === "vacancy") {
vacancies.push(arr[i]);
}
}
if (vacancies.length === 0) {
return "no vacancies";
}
import React from "react";
import { render } from "react-dom";
const ParentComponent = React.createClass({
getDefaultProps: function() {
console.log("ParentComponent - getDefaultProps");
},
getInitialState: function() {
console.log("ParentComponent - getInitialState");
return { text: "" };

Javascript

Javascript: The Good Parts -- Beginner/Intermediate

http://www.amazon.com/JavaScript-Good-Parts-Douglas-Crockford/dp/0596517742

Legendary book, a must-read for any Javascript programmer at least once. Goes into the basics of Javascript with the assumption that the reader is an experienced programmer already, coming from another language or already understands a fair bit about Javascript itself. Very good review of basics and more advanced concepts (like scope/closure, functions as first class objects, etc).

Javascript Design Patterns (Stoyan Stefanov) -- Intermediate

//Create a new Graph Object
FB.api(
'me/objects/video.movie',
'post', {
'object': {
'title': 'Sample Movie',
'type': 'video.movie',
'image': 'http://stuffpoint.com/cats/image/41633-cats-cute-cat.jpg',
'url': 'http://localhost:9000',
'description': 'Example Description Here',
@AmaxJ
AmaxJ / resource.py
Created June 14, 2015 23:08
user resource
from app import db
from app.models import User
from flask_restful import Resource, fields, marshal, reqparse
user_field = {
'id' : fields.Integer,
'username' : fields.String,
'email' : fields.String
}
(function(){
var inherits = function(subClass, superClass){
subClass.prototype = Object.create(superClass.prototype);
subClass.prototype.constructor = subClass;
}
var inherits2 = function (ChildClass, ParentClass) {
function Surrogate () {}
Surrogate.prototype = ParentClass.prototype;
ChildClass.prototype = new Surrogate();
// write nLengthSubstrings(string, n)
var nLengthSubstrings = Assessment.nLengthSubstrings = function(str, num){
var result = [];
if(str.length < num) { return result; }
else {
for(var i=0; i+num <= str.length; i++){
var x = i + num;
var sub= str.substring(i, x);
result.push(sub);
}