Skip to content

Instantly share code, notes, and snippets.

View nicholalexander's full-sized avatar

nichol alexander nicholalexander

View GitHub Profile
#the fiddle class in ruby
#http://ruby-doc.org/stdlib-2.0.0/libdoc/fiddle/rdoc/Fiddle/Pointer.html#method-c-new
require 'fiddle'
require 'pry'
#this is a regular variable holding a string, aka a string object with the
#value "hello strange person"
my_string = "hello strange person!"
#this gets an integer pointing to location of your object in memmory.
@nicholalexander
nicholalexander / custom_array.rb
Created November 22, 2013 18:52
creating a custom array by inheriting and redefining...
class LifeBoardArray < Array
def [](index)
if index<=3
super(index)
elsif index > 3
super(index%4)
else
raise IndexError
end
@nicholalexander
nicholalexander / gist:7413525
Created November 11, 2013 13:55
a script to build the sinatra skeleton and minimal config of files. missing sinatra reloader and ability to set path. chmod 755 to make executable - and also i think it has to be in the path where you're building, i don't know how it would work to make it part of your bin folder.
#!/bin/sh
mkdir app
cd app
mkdir public
mkdir views
touch server.rb
echo "require 'pry' \n require 'sinatra' \n \n get '/' do \n erb :index \n end \n" >> server.rb
cd public
@nicholalexander
nicholalexander / javascript-recipie.md
Last active December 27, 2015 13:49
an attempt to break down the javascript work in class into some logical steps.

My Javascript Logic Recipie

I have found that the Javascript work we have done so far lends itself to encapsulate in logical steps. When starting new javascript work, here is the little cookbook/recipie I follow. Here are my thoughts using TicTacToe and PixArt as examples.

1) Datamodeling

I am going to define the object as the game. So that I can say myGame = new TicTacToe();

My game needs a board. It needs players, but X always goes first. And the game is either won or unwon but when it starts, there is no winner. I think my game should have how many moves have been played (but this could also be figured out by inspecting the board).

The actions I will have are only two: make a move, and see if someone has won.

installing gmaps4rails

##controller

@hash = Gmaps4rails.build_markers(@posts) do |post, marker|
    marker.lat post.latitude.to_f
    marker.lng post.longitude.to_f
    marker.picture({

:url => post.image.url(:thumb),

Checklist for Heroku/Sinatra/Active Record App Deployment

1. Write your app - YAY!

2. Prepare Your App

  • Set up your environments.rb file

    • mkdir config
    • touch config/environments.rb
  • Set it up thusly: