Skip to content

Instantly share code, notes, and snippets.

=> .net, .net core, .net, sql server, javascript, typescript, .net-core, .netcore, 3d, 3d modeling, 3d modelling, a, abap, access, accessibility, actionscript, active directory, activecampaign, activiti, add-ins, admob, adobe photoshop, adtech, advertising, adwords, agile, ai, airflow, aix, ajax, ajax/json, akka, albanian, alexa, alexa skill kit, alexa skills, alexaskills, alfresco, algorithm, algorithms, algoritms, amazon web services, amazon-mws, amazon-web-services, ambari, amber, amzone, analyist, analytics, andriod app development, android, android development, android studio, android-sdk, androidsdk, androidstudio, angular, angular 2, angular.js, angular2, angular4, angularjs, ansible, ant, apache, apache spark, apache-impala, apache-wicket, apache2, apex, api, api development, api integration, api-development, apis, apl, app, app development, app extensions, apple, apple search ads, application, applications, applied, apps, apps., ar, arcgis, architect, architecture, arduino, arkit, arm, artificial int
class Array
def sum
inject(0.0) { |result, el| result + el }
end
def mean
sum / size
end
end
trials = 1000000
events = 0
trials.times do
coords = 8.times.map { [rand, rand] }
squares = coords.map { |x,y| [(x/0.25).ceil, (y/0.25).ceil] }
unless squares.inject(Hash.new(0)) { |total, e| total[e] += 1 ;total}.select{|k,v| v>=3}.count.zero?
events += 1
end
end
puts events.to_f / trials.to_f
@zackster
zackster / main.py
Created October 19, 2017 04:43
Serverless fasttext implementation. I have a blog post on the Code For Cash blog (blog.codefor.cash) that discusses what else is needed to run fasttext in a serverless AWS lambda environment: compiling fasttext on ec2 for linux, including nltk in the root directory of the zip, etc.
import string
import re
import nltk
def normalize(text):
# remove punctuation
text = re.sub('[%s]' % re.escape(string.punctuation), '', text)
# split into words
# nltk.data.path.append("/nltk_data")
from nltk.tokenize import word_tokenize
@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
@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']
}
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
["#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
@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)
@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