Skip to content

Instantly share code, notes, and snippets.

Avatar
🥑
avocado

Charlie Egan charlieegan3

🥑
avocado
View GitHub Profile
@charlieegan3
charlieegan3 / twitter.rb
Created Oct 8, 2014
Data on Twitter Subscriptions
View twitter.rb
require 'twitter'
TWITTER_CONSUMER_KEY = 'xxxx'
TWITTER_CONSUMER_SECRET = 'xxxx'
USERNAME = 'username'
FRIEND_COUNT = 200 #Max 200, I think.
TWEET_COUNT = 50
START_INDEX = 68 #if you hit the rate limit start where you left off
twitter_client = Twitter::REST::Client.new do |config|
View gist:8c6faa8804ca5b1a1fc8
def sorted_dup_hash(array)
Hash[*array.inject(Hash.new(0)) { |h,e| h[e] += 1; h }.
select { |k,v| v > 1 }.inject({}) { |r, e| r[e.first] = e.last; r }.
sort_by {|_,v| v}.reverse.flatten]
end
@charlieegan3
charlieegan3 / global_cast.rb
Created Dec 1, 2013
A simple script to process a list of films to find the most common cast members.
View global_cast.rb
require 'badfruit'
require 'guess'
require 'sexmachine'
d = SexMachine::Detector.new
bf = BadFruit.new("YOUR_RT_API_KEY")
movies = ["Hunger Games: Catching Fire","Gravity", "..." ]
total = movies.size.to_s
@charlieegan3
charlieegan3 / question1.elm
Last active Apr 22, 2016
Elm: 99 questions
View question1.elm
-- q1: myLast
import Html exposing (text)
myLast : List a -> Result String a
myLast list =
Result.fromMaybe ("Can't get head of empty.")
<| List.head
<| List.reverse list
main =
View question01.fs
// question 1
// Last element of a list
exception ListEmptyError of string
let last xs =
match xs with
|[] -> raise (ListEmptyError("List is empty"))
|x -> x |> List.rev |> List.head
[<EntryPoint>]
View slack_export_image_downloader.rb
require 'json'
require 'open-uri'
require 'pry'
urls = []
Dir.glob("general/*.json") do |f|
list = JSON.parse(File.open(f).read)
urls += list.select do |e|
e["file"] && e["file"]["filetype"].match(/jpg/)
end.map { |e| e["file"]["url_private_download"] }
View result_monad.swift
//: Playground - noun: a place where people can play
import Darwin
import Foundation
enum Result<T> {
case Ok(T)
case Err(String)
}
View install_clamav.md

Installing clamAV on OSX 10.11 using homebrew

brew install clamav
freshclam -v
vi /usr/local/etc/clamav/clamd.conf
# add line LocalSocket /tmp/clamd.socket
./usr/local/Cellar/clamav/0.99.2_1/sbin/clamd --config-file=/usr/local/etc/clamav/clamd.conf
ps aux | grep clam
View gist:dc03849a45dab182b3851699f9761ab0
### Keybase proof
I hereby claim:
* I am charlieegan3 on github.
* I am charlieegan3 (https://keybase.io/charlieegan3) on keybase.
* I have a public key whose fingerprint is 3DA9 3090 84D0 D854 FE09 8588 DB86 FF2D 25A9 6313
To claim this, I am signing this object:
View data.json
[{"from":{"lat":"51.502500","lon":"-0.278126","name":"Acton Town"},"to":{"lat":"51.517675","lon":"-0.0824580","name":"Liverpool Street"},"time":46.05,"legs":5},{"from":{"lat":"51.50856013","lon":"-0.262879534","name":"Acton Central"},"to":{"lat":"51.517675","lon":"-0.0824580","name":"Liverpool Street"},"time":52.65,"legs":3},{"from":{"lat":"51.51394","lon":"-0.07537","name":"Aldgate"},"to":{"lat":"51.517675","lon":"-0.0824580","name":"Liverpool Street"},"time":7.483333333333333,"legs":3},{"from":{"lat":"51.51514","lon":"-0.07178","name":"Aldgate East"},"to":{"lat":"51.517675","lon":"-0.0824580","name":"Liverpool Street"},"time":10.8,"legs":3},{"from":{"lat":"51.54097","lon":"-0.30061","name":"Alperton"},"to":{"lat":"51.517675","lon":"-0.0824580","name":"Liverpool Street"},"time":56.25,"legs":3},{"from":{"lat":"51.67435","lon":"-0.60732","name":"Amersham"},"to":{"lat":"51.517675","lon":"-0.0824580","name":"Liverpool Street"},"time":75.75,"legs":5},{"from":{"lat":"51.53253","lon":"-0.10579","name":"Angel"},"to"