Skip to content

Instantly share code, notes, and snippets.

# credit to this person for a js implementation of the function, http://stackoverflow.com/users/3473058/user3473058
def find_local_maxima(input_array)
goAsc = false # ascending move
goDesc = false # descending move
local_maxima = []
index = 0
while (index < (input_array.length - 1)) do
@zackster
zackster / StockTwits_API_SQS_worker .rb
Last active July 19, 2016 03:03
This worker will post messages from an Amazon SQS queue via the StockTwits API. It requires you to have an access_token (obtained via the Stocktwits API) and an SQS queue with messages containing the contents of your StockTwits messages. It respects the StockTwits API rate limitations through an exponential backoff algo.
require 'aws-sdk'
require 'unirest'
require 'pp'
STOCKTWITS_QUEUE_URL = 'PATH TO YOUR QUEUE GOES HERE...' # looks like https://sqs.REGION.amazonaws.com/######/name
STOCKTWITS_API_URL = 'https://api.stocktwits.com/api/2/messages/create.json?access_token=ACCESS_TOKEN_OF_STOCKTWITS_USER_TO_POST'
Aws.config.update({
region: 'REGION',
credentials: Aws::Credentials.new('ACCESS KEY', 'SECRET')
@zackster
zackster / download_8k_indexes.rb
Created August 29, 2016 16:08
Download 8-K filings from the SEC
require 'posix/spawn'
require 'pry'
require 'active_support/all'
years = (2010..2016).to_a
quarters = (1..4).to_a
@zackster
zackster / process_8k.rb
Created August 29, 2016 16:48
Script for processing SEC 8-K filings en masse
require 'nokogiri'
require 'pg'
require 'json'
require 'parallel'
require 'timeout'
def score( array )
array.each_with_object(Hash.new(0)){|key,hash| hash[key] += 1}
end
@zackster
zackster / zidisha_growth_charts.rb
Created November 21, 2016 17:47
Zidisha growth charts
require 'open-uri'
require 'nokogiri'
require 'groupdate'
require 'gruff'
nok = Nokogiri(open("https://www.zidisha.org/reports/loans-funded"))
countries = nok.search("select[name='country']").search('option').map{|x|[x.children.text, x.attributes['value'].value.to_sym]}.reject{|x|x.first.blank?}
countries.each do |country, code|
begin
@zackster
zackster / reddit-ads.rb
Created February 7, 2017 16:32
Automatically export your reddit ads data to a csv file so you can review CTR, CPC, subreddits targeted, etc.
require 'parallel'
require 'httparty'
require 'pry'
def fetch_reddit_page(reddit_link)
cookies = [ ] # get these from EditThisCookie chrome extension: Export -> Copy to clipboard (copies as a ruby-friendly array of hashes)
["#job", 6], ["$100,000.00", 6], ["$14,100", 6], ["$155,", 6], ["$18/hr", 6], ["$20/hr", 6], ["$27.00", 6], ["$28.50", 6], ["$37.00", 6], ["$42.75", 6], ["$43.00", 6], ["$44.00", 6], ["$66.00", 6], ["$70-$85k.\\n\\nrequired", 6], ["$95,000.00", 6], ["$95k", 6], ["&gt;&gt;&gt;", 6], ["(.net,", 6], ["(18+)", 6], ["(2+", 6], ["(3)", 6], ["(40", 6], ["(50%", 6], ["(8", 6], ["(anaheim)", 6], ["(android", 6], ["(any", 6], ["(auburn)", 6], ["(backend)", 6], ["(battery", 6], ["(bay", 6], ["(berlin,", 6], ["(bonus)", 6], ["(bronx)", 6], ["(btc)", 6], ["(burlington)", 6], ["(burnaby)", 6], ["(c#,", 6], ["(c++,", 6], ["(c,", 6], ["(crypto", 6], ["(csv)", 6], ["(cupertino)", 6], ["(custom", 6], ["(customer", 6], ["(dba)", 6], ["(desktop", 6], ["(devops)", 6], ["(dlp)", 6], ["(dmv)", 6], ["(ember", 6], ["(ex.", 6], ["(excel,", 6], ["(fi/co)", 6], ["(fresno,", 6], ["(full-stack)", 6], ["(gaithersburg)", 6], ["(greenwich", 6], ["(hardware", 6], ["(harlem", 6], ["(high", 6], ["(hp", 6], ["(http://academy.hubspot.com/certific
class Authoritarianism < ActiveRecord::Base
belongs_to :potential_juror
def score
(demographic_structure_calc + occupation_calc + education_calc + marital_status_calc + focused_calc) / 5.0
end
private
@zackster
zackster / expand_keyword_list.rb
Last active October 19, 2017 03:27
For the benefit of https://codefor.cash subscribers – automatic matching of skills to online job ads
def expand_keyword_list(keyword_list)
synonym_list = {
'rails': ['ror', 'ruby on rails', 'rails'],
'html': ['html5', 'html', 'html4'],
'css': ['css3', 'css', 'cascading style sheets', 'cascading stylesheets'],
'node': ['node', 'nodejs', 'node.js', 'node js'],
'javascript': ['javascript', 'java script', 'js'],
' unity ': [' unity ', 'unity3d', 'unity 3d']
}
@zackster
zackster / process_gom.py
Created October 19, 2017 04:30
Normalize Code For Cash programming job corpus
import csv
import string
import re
programming_keywords = set([".net", ".net core", "3d", "abap", "active directory", "activecampaign", "admob", "adobe photoshop", "adtech", "adwords", "agile", "ai", "airflow", "aix", "ajax", "akka", "albanian", "alexa", "alexa skills", "alfresco", "algorithms", "amazon web services", "amazon-web-services", "ambari", "analytics", "andriod app development", "android", "androidstudio", "angular", "angular 2", "angular.js", "angular2", "angularjs", "animation", "ansible", "ant", "apache", "apache spark", "apache2", "api", "app", "app development", "app extensions", "apple", "application", "apps", "architect", "architecture", "arduino", "arm", "artificial intelligence", "asp.net", "asp.net mvc", "asp.net web api", "asp.net web forms", "assembly", "augmented reality", "aurelia", "aureliajs", "austin", "automate", "automation", "avada", "avr", "aws", "azure", "babel", "back end", "back-end", "backbone", "backbonejs", "backend", "backend developer", "bash", "beaglebone", "beautifu