Skip to content

Instantly share code, notes, and snippets.

View moonmaster9000's full-sized avatar

moonmaster9000 moonmaster9000

View GitHub Profile
@moonmaster9000
moonmaster9000 / javascriptClasses_es6_versus_es5.js
Last active August 13, 2019 17:13
Javascript Classes: es5 versus es6
//old school es5 syntax for creating a class
//advantage: lets you create private functions and state through closure
//disadvantage: looks weird if you learned OO through language like c++/java/ruby, etc. Doesn't support prototypical inheritance.
//constructor function
function MyES5Class(aPrivateVar){
var aontherPrivateVar = "I'm a private variable! You can't access me from the outside."
this.publicVar = "I'm a public variable! You can access me from the outside!"
this.myPublicFunction = function(){

React Cheat Sheet

Getting started with React is simple. There's only three things you need to know to get started: Components, props, and state.

Components

Components are the basic building blocks of a react app. They have a render method:

const React = require("react")
@moonmaster9000
moonmaster9000 / test_double_cheat_sheet.md
Created April 19, 2017 20:37
Test Double Cheat Sheet

Test Doubles

There are five types:

  • Dummy
  • Stub
  • Spy
  • Mock
  • Fake
function RPS(){
this.play = function(p1, p2, ui){
new PlayUseCase(p1, p2, ui).execute()
}
}
function PlayUseCase(p1, p2, ui){
this.execute = function(){
if (inputInvalid()){
ui.invalid()
@moonmaster9000
moonmaster9000 / imperative.feature
Created November 24, 2012 20:10
Imperative Tweet Feature
Scenario: Valid tweet
Given there is a user "bob" with password "password"
And there is a user "alice" with password "password"
And I visit "/"
And I fill in "username" with "bob"
And I fill in "password" with "password"
And I click "Log in"
When I fill in "Tweet" with "this is a test tweet noise noise noise noise noise noise noise noise noise noise noise noise noise noise noise noise haha I'm less than 140 characters."
And I click "Submit"
Then I should see "Your tweet was submitted"
#
# Feature: Test How Spinach Works
#
# Scenario: Test triple equals
# Given I have an empty array:
# """
# @array = []
# """
#
# Then it should be empty:
@moonmaster9000
moonmaster9000 / gist:1242032
Created September 26, 2011 11:17
parsing .travis.yml
ruby-1.8.7-p334 :001 > require 'yaml'
=> true
ruby-1.8.7-p334 :002 > YAML.load File.read(".travis.yml")
=> {"before_script"=>"echo 'before start' && sed -i '' -e 's/admin:password\\@//' features/support/env.rb && echo 'before end'", "rvm"=>["1.8.7", "1.9.2", "1.9.3", "rbx-2.0", "ree"]}
@moonmaster9000
moonmaster9000 / rack-test-port.rb
Created June 9, 2011 20:57
rack-test port settings
get "/", {}, "HTTP_HOST" => "example.org:9000"
last_request.port.should == 9000
get "/", {}, "SERVER_PORT" => "9000"
last_request.port.should == 9000
header "Host", "example.org:9000"
get "/"
last_request.port.should == 9000
@moonmaster9000
moonmaster9000 / bash_errors
Created April 20, 2011 18:31
errors when opening a new terminal after installing the latest rvm from github
-bash: /Users/mparker/.rvm/scripts/selector: line 202: syntax error near unexpected token `('
-bash: /Users/mparker/.rvm/scripts/selector: line 202: ` if [[ -z "${rvm_ruby_version:-""}" ]] (( rvm_head_flag == 0 ))'
-bash: /Users/mparker/.rvm/scripts/selector: line 202: syntax error near unexpected token `('
-bash: /Users/mparker/.rvm/scripts/selector: line 202: ` if [[ -z "${rvm_ruby_version:-""}" ]] (( rvm_head_flag == 0 ))'
def my_reverse( a )
reversed = []
length_a = a.length
for counter in Array.new( length_a )
last = a.pop
reversed.push( last )
end
reversed
end