Skip to content

Instantly share code, notes, and snippets.

View panw's full-sized avatar

Pan W panw

  • New York, New York
View GitHub Profile
@panw
panw / [ruby]ruby-to-javascript-overview.rb
Last active February 21, 2017 16:07
Ruby to JavaScript Overview
numbers = [1,2,3]
numbers.each do |num|
puts "I am #{num}"
end
double_numbers = numbers.map do |num|
num * 2
end
@panw
panw / [javascript]ruby-to-javascript-overview.js
Last active February 21, 2017 16:07
Ruby to JavaScript Overview
var numbers = [1, 2, 3];
numbers.forEach(function(num, index, array) {
console.log('I am ' + num)
})
var doubledNumbers = numbers.map(function(num) {
return num * 2
});
require 'pry'
class GumballMachineTerminalView
def initialize
end
def welcome_message
puts "Welcome to the Squirrel's Gumball Machine"
end
@panw
panw / moneyz_wasted_on_violations_instead_of_chipotle.rb
Created December 23, 2016 17:34
Calculate how much Chipotle you could have had. Instead you wasted the moneyz on parking violations.
require 'open-uri'
require 'json'
require 'pry'
# THE ADDRESS ON THE INTERNET YOU WANT TO FETCH DATA FROM
BASE_URL = "https://data.cityofnewyork.us/resource/uvbq-3m68.json"
# GET USER INPUT TO MAKE IT DYNAMIC
puts 'What is the license plate number you want to search for?'
user_input = gets.chomp
@panw
panw / react_timeline_component_in.rb
Created September 15, 2016 22:34
If a React Component was Written in Ruby
class Timeline << React::Component {
def initialize(props) {
super(props)
@state = { tweets: [] }
}
def component_did_mount() {
self.fetchTweets();
}
@panw
panw / react_es6_timeline.jsx
Created September 15, 2016 18:55
React ES6 Timeline Component
class Timeline extends React.Component {
constructor(props) {
super(props);
this.state = {
tweets: []
};
this.fetchTweets = this.fetchTweets.bind(this);
}
componentDidMount() {
@panw
panw / react_es5_timeline.jsx
Last active September 15, 2016 18:54
React ES5 Timeline Component
const Timeline = React.createClass({
getInitialState: function() {
return { tweets: [] };
},
componentDidMount: function() {
this.fetchTweets();
},
fetchTweets: function() {
@panw
panw / rails_setup.md
Last active July 25, 2020 02:07
Rails Setup Notes

Creating a Rails app called my_great_app

  1. Generate a new Rails app
rails new [APP-NAME] -T -d postgresql --skip-turbolinks
  1. Make an initial commit
cd [APP-NAME]
@panw
panw / rails_setup_notes.txt
Created August 21, 2016 12:12 — forked from stevecass/rails_setup_notes.txt
Starting a new rails app
#Creating an app called my_great_app
rails new my_great_app -T -d postgresql --skip-turbolinks
cd my_great_app
git init
git add .
git commit -m "Initial commit. Rails boilerplate."
# Edit gemfile
# #Remove the reference to coffee-rails.
class Gumball
attr_reader :color, :flavor
DEFAULT_COLORS = ['red', 'green', 'blue']
DEFAULT_FLAVORS = ['sour apple', 'bacon', 'gravy']
def initialize(options={})
@color = options.fetch(:color) { DEFAULT_COLORS.sample }
@flavor = options.fetch(:flavor) { DEFAULT_FLAVORS.sample }
end
end