Skip to content

Instantly share code, notes, and snippets.

@coreyhaines
coreyhaines / slack_delete.rb
Created August 21, 2016 02:08 — forked from jamescmartinez/slack_delete.rb
This Ruby script will bulk remove all Slack files older than 30 days. Just add your API token from https://api.slack.com/web#authentication into the token quotes at the top of the file.
require 'net/http'
require 'json'
require 'uri'
@token = ''
def list_files
ts_to = (Time.now - 30 * 24 * 60 * 60).to_i # 30 days ago
params = {
token: @token,
@coreyhaines
coreyhaines / Cleanedup_Item.elm
Created July 16, 2016 18:18
Some elm cleanup
updateItemBasedOnEditItemState : EditItemType -> Item -> Item
updateItemBasedOnEditItemState editItemType item =
let
stopEditing : { item | typeData : ItemTypeData } -> (Maybe.Maybe newEditState -> ItemTypeData) -> { item | typeData : ItemTypeData }
stopEditing item itemTypeDataWithoutEditState =
{ item | typeData = itemTypeDataWithoutEditState Nothing }
updateEditingState : { item | typeData : ItemTypeData } -> (Maybe.Maybe newEditState -> ItemTypeData) -> newEditState -> { item | typeData : ItemTypeData }
updateEditingState item itemTypeDataWithoutEditState editItem =
{ item | typeData = itemTypeDataWithoutEditState (Just editItem) }
@coreyhaines
coreyhaines / outline
Created May 4, 2016 13:45
Fun with Lambdas
# Welcome
## Start with a Lambda
## Get to Hello, world
# What is a lambda
## Ruby Syntax
## Identity
## K
## GetFirst
## GetSecond
@coreyhaines
coreyhaines / abstract
Created April 6, 2016 13:09
Prolog Talk Abstration
Title: I don't know Prolog, and so can you
Abstract: Prolog is a wildly popular declarative logic programming language that all the hot startups and whiz kids are using these days. So, being neither a hot startup nor a whiz kid, I figured I'd learn it. In this talk, I'll share some of the early learnings I've had that can only be considered "mind-bending."
We'll look at a bit of the syntax, the solver model and then dive into some wild and crazy list operations. Finding all the combinatorial variations of a list using the function isMember? Yup! We'll do that.
If you are anything like me, and I know you are, you'll come away from this talk saying "I'm sold! PROLOG FOREVER!"
ary = [
1,
1,
1
]
class Array
def remove_vals(*vals)
out = self.dup
__remove_vals(out, *vals)
ary = [
1,
1,
1
]
class Array
def remove_vals(*vals)
return out if vals.empty?
@coreyhaines
coreyhaines / Get raw json from EventBoard
Last active January 2, 2016 14:29
EventBoard Stuff Thanks to Pete Hodgson @ph1 for figuring this out.
# List of conferences
curl -d {} -H "Content-Type:application/json" https://eventboard.falafel.com/ConferenceService2/ConferenceListEx
# The 59 specifies the version according to the latest version that is present in the DataVersion attribute of the conference list above
curl http://cdn.eventboard.falafel.com/conferencecatalogs/codemash2014.59.data.json
@coreyhaines
coreyhaines / blow_it.rb
Created November 7, 2013 21:01
Does this blow method cache? Global? Just for class?
def method_missing(method, *args, &block)
if helper.respond_to?(method)
self.class_eval "def #{method}(*args, &block); helper.send('#{method}', *args, &block); end"
self.send(method, *args, &block)
else
super
end
end
Design Patterns often are discussed with a negative tone. We laugh at Java developers and their heavy classes with the patterns encoded in the name. After all, who wants to try to understand the AbstractBaseClassFactoryManager? But don't most Ruby developers spend their time in a framework that glorifies a select few patterns to the point where the idea of writing code outside these patterns is considered heretical? On the other hand, Evolutionary Design says we are supposed to let the design come out over time, listening to the feedback we get from the combination of tests and refactoring, planning as little ahead as possible. What's a developer to do?
Ideally, Design Patterns are used as communication, not construction, as description, not prescription. In this talk, we'll discuss using patterns as a goal, as guides when iterating and evolving our system's design. Rather than thinking "I'll solve this with a strategy pattern," we can say that our design is heading "towards a strategy pattern" or we ended u
🐈 $ baseline up ruby
/Users/coreyhaines/Documents/codes/test/.baseline/Vagrantfile:14:in `<top (required)>': undefined method `configure' for Vagrant:Module (NoMethodError)
from /Users/coreyhaines/.rvm/gems/ruby-2.0.0-p247/gems/vagrant-1.0.7/lib/vagrant/config/loader.rb:115:in `load'
from /Users/coreyhaines/.rvm/gems/ruby-2.0.0-p247/gems/vagrant-1.0.7/lib/vagrant/config/loader.rb:115:in `block in procs_for_source'
from /Users/coreyhaines/.rvm/gems/ruby-2.0.0-p247/gems/vagrant-1.0.7/lib/vagrant/config.rb:41:in `block in capture_configures'
from /Users/coreyhaines/.rvm/gems/ruby-2.0.0-p247/gems/vagrant-1.0.7/lib/vagrant/config.rb:36:in `synchronize'
from /Users/coreyhaines/.rvm/gems/ruby-2.0.0-p247/gems/vagrant-1.0.7/lib/vagrant/config.rb:36:in `capture_configures'
from /Users/coreyhaines/.rvm/gems/ruby-2.0.0-p247/gems/vagrant-1.0.7/lib/vagrant/config/loader.rb:114:in `procs_for_source'
from /Users/coreyhaines/.rvm/gems/ruby-2.0.0-p247/gems/vagrant-1.0.7/lib/vagrant/config/loader.rb:51:in `block in set'