Skip to content

Instantly share code, notes, and snippets.

Avatar

Devon Estes devonestes

View GitHub Profile
@devonestes
devonestes / twitter_pruner.rb
Created Mar 20, 2018
Delete your old tweets
View twitter_pruner.rb
require 'twitter'
client = Twitter::REST::Client.new do |config|
config.consumer_key = ""
config.consumer_secret = ""
config.access_token = ""
config.access_token_secret = ""
end
def collect_with_max_id(collection=[], max_id=nil, &block)
View struct_change.ex
iex(1)> defmodule Tester do
...(1)> defstruct [:first, :second]
...(1)> def foo_to_bar(struct = %{__struct__: struct_module}) do
...(1)> updated_list = struct
...(1)> |> Map.from_struct
...(1)> |> Enum.map(fn({key, value}) ->
...(1)> if value == :foo do
...(1)> {key, :bar}
...(1)> else
...(1)> {key, value}
View count_bug_script.rb
begin
require 'bundler/inline'
rescue LoadError => e
$stderr.puts 'Bundler version 1.10 or later is required. Please update your Bundler'
raise e
end
gemfile(true) do
source 'https://rubygems.org'
gem 'rails', '~> 4.2.3'
View gist:e49eb33d95aa746db412
View gist:6a7c0059106946bf743c
$(document).ready(function() {
navigator.geolocation.getCurrentPosition(successCallback,errorCallback,options);
});
var weekdays = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"];
var dayOfWeekIndex = (new Date()).getDay();
View gist:f1f342152a6b6bca19f4
# When we're working with validations in AR, remember that most of them are accepting hashes as arguments.
# For example, we could re-write
validates :email, { :uniqueness => true }
# as
validates(:email, { :uniqueness => true })
# which pretty clearly shows that we have two arguments for the validates method, a symbol and a hash