Skip to content

Instantly share code, notes, and snippets.

View adamloving's full-sized avatar
💭
10x Ninja Rockstar

Adam Loving adamloving

💭
10x Ninja Rockstar
View GitHub Profile
@adamloving
adamloving / sample.vcf
Created February 20, 2013 17:13
Sample vcard for "add us to your address book" links.
BEGIN:VCARD
VERSION;TYPE=WORK:3.0
FN:Steeve Levy
N:Steeve Levy;;;;
PROFILE:VCARD
ADR:;;21 Forest Court,Snaresbrook;London;;E11 1PL;United Kingdom
EMAIL:[email protected]
ORG:Nifty Drives
URL:http://www.theniftyminidrive.com
END:VCARD
@adamloving
adamloving / spam-check.rb
Last active December 13, 2015 23:09
Some ruby code to do a spam check of an email via http://spamcheck.postmarkapp.com/doc
#!/usr/bin/env ruby
require 'json'
f = open('test/fixtures/raw_email.txt')
s = f.read
h = { email: s, options: 'long' } # the postmarkapp format
File.open('spam-check.json', 'w') { |f| f.write(h.to_json) }
results = `curl -X POST "http://spamcheck.postmarkapp.com/filter" -H "Accept: application/json" -H "Content-Type: application/json" -v -d @spam-check.json`
results = JSON.parse(results)
puts results['report']
@adamloving
adamloving / rails-flash-partial.slim
Created February 19, 2013 19:32
Applies Twitter bootstrap styles to rails flash messages. Add this to your application layout with = render 'layouts/flash', :locals => { :flash => flash } To quote http://stackoverflow.com/questions/5798791/what-is-the-difference-when-using-flash-error-alert-and-notice "The semantics of what or when to use :alert/:error/:notice are really up to…
- if locals[:flash]
- flash = locals[:flash]
- if flash[:warn] || flash[:alert]
.alert #{flash[:warn]} #{flash[:alert]}
- if flash[:notice] || flash[:success]
.alert.alert-success #{flash[:notice]} #{flash[:success]}
- if flash[:info]
.alert.alert-info #{flash[:info]}
- if flash[:error]
.alert.alert-error #{flash[:error]}
@adamloving
adamloving / excel-web-query.vb
Created February 18, 2013 19:09
Icky code to retrieve data into excel from an external web page.
Sub URL_Get_Query()
With ActiveSheet.QueryTables.Add(Connection:= _
"URL;http://webservices.pcquote.com/cgi-" & _
"bin/excelget.exe?TICKER=msft", _
Destination:=Range("a1"))
.BackgroundQuery = True
.TablesOnlyFromHTML = True
.Refresh BackgroundQuery:=False
.SaveData = True
@adamloving
adamloving / post-commit
Created February 14, 2013 06:24
git hook for creating a featbeat entry for each commit
#!/bin/sh
#
# An example hook script that is called after a successful
# commit is made.
#
# To enable this hook, rename this file to "post-commit".
curl -d "[email protected]&subject=1 commit featbeat-code committed" http://featbeat.adamloving.com/api/inbound_email
@adamloving
adamloving / common-email-providers.txt
Last active April 1, 2022 13:53
Sampling of popular email service providers. These were the most frequent from my list that I was able to eyeball. From an experiment to figure out what percentage of email addresses on an email list use an ISP for email as opposed to a corporate, educational, or military email address.
gmail.com
yahoo.com
hotmail.com
aol.com
columbus.rr.com
sbcglobal.net
comcast.net
msn.com
insight.rr.com
earthlink.net
@adamloving
adamloving / host_lookup.rb
Last active December 11, 2015 17:58
Use host command to see if domain has MX records. This ruby code is used for validating a list of email addresses by checking if their domain has a valid MX record.
#!/usr/bin/env ruby
emails = open('test/fixtures/temp-emails-2.txt').read
emails = emails.split("\n")
cache = {}
found_domains = 0
no_mail_domains = []
found_emails = 0
total_emails = 0
@adamloving
adamloving / email_from_csv.rb
Created January 17, 2013 01:10
Kind of a silly way to get the emails out of a google contacts csv file. Tried greping with a regex to no avail.
require 'csv'
require 'iconv'
contents = open('adams_google_contacts.csv').read
contents = Iconv.iconv('UTF-8', 'UTF-16LE', contents).first
contents = contents[1..-1]
csv = CSV.parse(contents, :headers => true)
y = csv.map { |row| row['E-mail 1 - Value'] }.compact.uniq
@adamloving
adamloving / footer_position.coffee
Last active December 11, 2015 04:58
Prevent whitespace below a footer element. Keep the footer attached to the bottom of the window by resizing the container above it. I used this with a Twitter Bootstrap layout. There is a special case if the width changes, due to bootstrap resizing the page content. I didn't want to position the footer fixed to the bottom, because then the conte…
@adamloving
adamloving / facebook-scrape-usernames.js
Created January 3, 2013 01:23
Grab names and profile URLs from the comments on a Facebook page. Paste this into the Chrome developer console while the tab is open to your Facebook page.
// inject jQuery
(function(){var a=document.createElement("script");a.src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.js";a.type="text/javascript";document.getElementsByTagName("head")[0].appendChild(a)})()
// output names and profile URLs
$('.UFICommentContent a').each(function(i, el) { console.log($(el).text(), $(el).attr('href')) })