Skip to content

Instantly share code, notes, and snippets.

View ddd1600's full-sized avatar

David Douglas ddd1600

  • Murrells Inlet, SC
View GitHub Profile
require 'highline/import'
require 'open-uri'
def where_any_sql(tags, col)
tags.map {|tag| "#{col} = '#{tag}'" }.join(" OR ")
end
GOOGLE_MAPS_API_KEY = "AIzaSyD95HvG257zlJ-hy_pq3mxcTew6pSEZVdk"
#$g = GetGeographic.new
@ddd1600
ddd1600 / list_my_bitbucket_repos.rb
Created October 8, 2013 15:34
simply lists your bitbucket repos to the command line for use when cloning existing repos, etc
require 'bitbucket_rest_api'
YOUR_USERNAME="username"
YOUR_PASSWORD="password"
b = BitBucket.new login: YOUR_USERNAME, password: YOUR_PASSWORD
b.repos.list.sort_by(&:utc_last_updated).each do |r|
puts r.name
puts "https://#{b.login}@bitbucket.org//#{r.name}.git"
puts "---------"
@ddd1600
ddd1600 / add_mate_command_on_os_x
Created September 12, 2013 02:20
add this to ~/.bash_profile anywhere to link up the mate command to open up files *and* folders with textmate
ln -s /Applications/TextMate.app/Contents/SharedSupport/Support/bin/mate /usr/local/bin/mate
@ddd1600
ddd1600 / gist:6532411
Created September 12, 2013 02:14
install postgis on postgresql on rails on mac -- working
To get PostGIS running on mac with postgres.app on rails----
- update XCode
- brew install postgis
- gem install rgeo -- --with-geos-dir=/usr/lib
- database.yml should look like:
development:
adapter: postgis
encoding: unicode
postgis_extension: true
@ddd1600
ddd1600 / gist:6532406
Created September 12, 2013 02:13
install qgis on mac
gem install pyqt
add the below to ~/.bash_profile
export PYTHONPATH=/usr/local/lib/python2.7/site-packages:$PYTHONPATH
brew tap homebrew/science
brew install qgis --with-grass --with-postgis
@ddd1600
ddd1600 / postgres_app_on_mac_with_rails_working
Last active December 22, 2015 21:19
Postgres on Mac with Rails, working!
FOR MAC
- download and install Postgres.app, version 9.2.2.0 only!
(get here: http://postgres-app.s3.amazonaws.com/PostgresApp-9-2-2-0.zip <= link
from this: https://github.com/PostgresApp/PostgresApp/issues/109)
- add to ~/.bash_profile:
export PGHOST=localhost
- run:
gem uninstall pg (if already there)
gem install pg -- --with-pg-config=/Applications/Postgres.app/Contents/MacOS/bin/pg_config
@ddd1600
ddd1600 / gist:6516560
Created September 10, 2013 22:18 — forked from djq/gist:2846196
#!/bin/bash
#
# Install Postgres 9.1, PostGIS 2.0 and pgRouting on a clean Ubuntu 12.04 install (64 bit)
# updated to PostGIS 2.0.1
# basics
apt-get install python-software-properties
apt-add-repository ppa:sharpie/for-science # To get GEOS 3.3.3
# install the following pacakages
@ddd1600
ddd1600 / get_single_historical_price.rb
Created February 13, 2013 17:33
get_single_historical_price
require 'open-uri'
class GetSingleHistoricalPrice
def initialize
@month_thing = { "1" => "00", "2" => "01", "3" => "02", "4" => "03", "5" => "04", "6" => "05", "7" => "06", "8" => "07", "9" => "08", "10" => "09", "11" => "10", "12" => "11" }
end
def get_all_day_prices
Day.where(:already => false).each do |d|
begin
@ddd1600
ddd1600 / CIKgetter.R
Created October 22, 2012 20:39
get SEC CIK number from ticker symbol
getCIK = function(ticker) {
stopifnot(is.character(ticker))
uri = "http://www.sec.gov/cgi-bin/browse-edgar"
response = getForm(uri,CIK=ticker,action="getcompany")
html = htmlParse(response)
CIKNode = getNodeSet(html, "//acronym[@title=\"Central Index Key\"][text() = \"CIK\"]")
CIKNodeText = sapply(CIKNode, function(x) xmlValue(getSibling(getSibling(x))))
CIK = sub(" .*","",CIKNodeText)
CIK = sub("^0*","",CIK)
@ddd1600
ddd1600 / yahoo_finance.rb
Created September 26, 2012 02:17
My repurposed yahoo-finance gem -- dumped it straight in my rails lib folder
require 'open-uri'
require 'csv'
class YahooFinance
# VERSION = '0.1.0'
COLUMNS = {
:ask => "a",
:average_daily_volume => "a2",