Skip to content

Instantly share code, notes, and snippets.

View rthbound's full-sized avatar

Ryan T. Hosford rthbound

View GitHub Profile
@rthbound
rthbound / updating.sh
Last active August 29, 2015 14:14
making markup changes and css additions to a bunch of projects at once
while IFS="," read -r downcased titleized; do
cd What${titleized}IsIt
git checkout .
sed -i "s/center/not-center/g" ./index.html
sed -i 's/document.getElementById("time").innerHTML = (date + "<br\/>" + time + ":" + s);/document.getElementById("time").innerHTML = ("<div class='pull-left'>" + date + "<\/div><div class='pull-right'>" + time + ":" + s + "<\/div>");/g' ./assets/script.js
cat ../style.css >> assets/style.css
git commit -am "Adds markup and css for pull-left and pull-right classes"
git push -u origin gh-pages
cd ..
@rthbound
rthbound / generation.sh
Created January 25, 2015 04:29
Generating a bunch of hiiiighly similar projects
[email protected]:rthbound/WhatMoonIsIt.git
sourcename=WhatMoonIsIt
while IFS="," read -r downcased titleized; do
rm -rf What${titleized}IsIt
newsource=$(echo $source | sed "s/$sourcename/$titleized/g")
git clone $source What${titleized}IsIt
find ./What${titleized}IsIt -type f -exec sed -i "s/Moon/$titleized/g" {} \;
find ./What${titleized}IsIt -type f -exec sed -i "s/our moon/moon/g" {} \;
find ./What${titleized}IsIt -type f -exec sed -i "s/moon/$downcased/g" {} \;
def getgst
d { 'gets fired' }
s = Building.get_gst_for_building(params[:buildinginfo])
d { s.to_s('F') }
@var = s.to_s('F')
respond_to do |format|
format.html { render :text => @var }
end
end
EMBERJS BACKBONEJS
-built in support for standard features yields a larger package size +smaller package size
+supporting many common features means library's dependencies list will grow less over time -achieves smaller package size by sacrificing built in features
-if the common features aren't needed then they are unnecessarily included -smaller package size advantage is lost if many libraries are used to compensate/extend backbone's feature set
+hailed as strong when for multipage, navigational, long-term project +hailed as strong when project is a single page or part of a page (widget)
+has a default testing stack using QUnit -no default testing library, implies a task for choosing and implementing a testing stack
+More opinionated can be good when multiple teams or developers are working in the same project -Less opinionated can be bad when multiple teams or developers are working in the same project. Can lead to incons
if request.xhr?
render partial: 'this_controller/index', layout: false
else
respond_to do |format|
format.html # index.html.erb
format.json
end
end
@rthbound
rthbound / animated_moon.rb
Last active August 29, 2015 13:57
Make a gif of the Moon as seen from Earth for one lunar year, starting now - http://gfycat.com/SilverPositiveBluet
require "usno/imagery"
require "open-uri"
require "RMagick"
include Magick
def animate(n,f)
i=0
time = Time.now
# Monkey patch hash
class Hash
# @return [Hash] a hash with underscored keys
def underscore_keys
result = {}
self.each do |k,v|
k = k.to_s.underscore
result[k] = v.kind_of?(Hash) ? v.underscore_keys : v
result[k] = v.collect { |obj| obj.underscore_keys if obj.kind_of?(Hash) } if v.kind_of?(Array)
# SQLite version 3.x
# gem install sqlite3
#
# Ensure the SQLite 3 gem is defined in your Gemfile
# gem 'mysql2'
#gem 'pg'
development:
adapter: postgresql
# Extend the Array class with a to_h method
class Array
def to_h
Hash[*self]
end
end
# Extend rexml/document to create a Ruby hash from xml
class REXML::Document