This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
types= ["breast", "diaper", "sleep", "memory", "solids", "pumping"] | |
ages= ["2 weeks", "4 weeks", "8 weeks", "12 weeks", "16 weeks", "20 weeks", "24 weeks"] | |
types.each do |type| | |
if type == "breast" | |
print "\n => breast section \n\n\n" | |
end | |
if type == "diaper" | |
print "\n\n => diaper section \n\n\n" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# this is a perfect use case for a capistrano task | |
# capistrano includes ruby ssh libraries and is used for deployments | |
# assuming ssh access is NOT password based but key-based | |
require 'capistrano' | |
default_run_options[:pty] = true | |
# Application Name | |
set :application, "remote_script" | |
# Repository Settings |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#requiring official aws-sdk ruby gem | |
# stable and widely used : https://github.com/aws/aws-sdk-ruby | |
# last authored 8 hours from now | |
require 'aws-sdk' | |
s3 = AWS::S3.new | |
s3.config( | |
:access_key_id => ENV['ACCESS_KEY_ID'], #storing access keys on remote server as ENV Variables is a good practice |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# problem : | |
# was trying to import a 3D model in a web page in json format for use with threejs : https://github.com/mrdoob/three.js | |
# 3D model was exported from maya using this threejs plugin # https://github.com/mrdoob/three.js/tree/master/utils/exporters/maya | |
# exported json had two problems: | |
# 1. all of it was in one line, i.e no indents | |
# 2. float values inside keys were not quoted i.e stringified. | |
# here's the snippet, it converts the 'bad' json to 'good' ( quoted json ) | |
@parsed = JSON.parse(Rails.root.join("app","assets","javascripts","model.js").read) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#author : osman ehmad | |
import urllib2 | |
page = urllib2.urlopen('http://www.javascript-coder.com/files/window-popup/javascript-window-open-example1.html') | |
source = page.read() | |
# SCRIPT or script will depend upon pages you want crawled | |
# or both can easily be incorporated |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# EC = 1/2*(2**exp-1) | |
# ^equation | |
def exp_backoff(upto) | |
result = [ ] | |
# ^ stores wait periods | |
(1..upto).each do |iter| | |
result << (1.0/2.0*(2.0**iter - 1.0)).ceil |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#dependencies : | |
#gem install mechanize | |
# ^ if this doesnt work, and you are on ubuntu, you'll have to install nokogiri | |
# gem install __name__ is now by default equivalent of gem install __name__ -y (-y for including all dependencies) | |
#gem install w3c_validtors | |
# I had to write this in order to validate pages against html5 compliance for our in house product | |
# my first repo. |