Skip to content

Instantly share code, notes, and snippets.

View wuputah's full-sized avatar
🐘

Jonathan Dance (JD) wuputah

🐘
View GitHub Profile
if Array.new(10) { Time.now.nsec % 1000 }.sum == 0
puts "nsec precision not available"
exit
end
a = 0
10_000_000.times do
t = Time.now
d = ( sprintf("%.9f", t.to_f).split('.')[1].to_i - t.nsec ).abs
# edge case around 0 nsec where .to_f results in .999999999
@wuputah
wuputah / letter.md
Last active March 30, 2017 06:09
My letter to my family about the changes in broadband privacy.

Most outlets are not getting this story right. They don't understand the technical details behind what can be tracked, sold, or how your ISP (Internet Service Provider) can advertise to you.

What is changing?

Actually, nothing. The Obama-era rule did not go into effect, but ISPs may have stopped efforts to sell this data due to the new FCC regulation. I would like to think ISPs are nervous about making their customers angry, and realize they could face backlash if they sell your data. That means that all of this is already true, yet you don't get this type of advertising right now (as far as you know).

Note that this also applies to your mobile data carrier anytime you use the Internet on your smartphone (not over wifi, though whatever wifi network you are connected to cannot be trusted either). However, mobile carriers may be subject to different (older) regulations since they are a "telephone" company. I am a computer nerd, not a telecommunications lawyer.

What can my ISP track about me?

Vision

What I want to do this year

Values

/shrug

Methods

@wuputah
wuputah / hosts
Created October 21, 2016 18:13
/etc/hosts
151.101.45.6 status.heroku.com
54.214.39.172 status-api.heroku.com
54.225.133.67 support.heroku.com
54.225.188.133 api.heroku.com
23.21.173.253 api-direct.heroku.com
192.30.253.113 github.com
192.30.253.118 gist.github.com
52.21.186.9 splunk.herokai.com
104.244.42.193 twitter.com
151.101.48.133 assets-cdn.github.com
if Rails.env.development?
lambda do
forbidden_files = ['active_support/core_ext/object/to_json']
module Kernel
def require_with_dont_load_forbidden_files(name)
if forbidden_files.include?(name)
raise LoadError, "#{name} is forbidden"
end
require_without_dont_load_forbidden_files(name)
@wuputah
wuputah / Gemfile
Last active December 19, 2015 01:59
Running a command via Rendezvous and capturing the output.
source 'https://rubygems.org/'
gem 'rendezvous'
gem 'heroku-api'
gem 'netrc'
tell application "Google Chrome"
set aWin to make new window with properties {mode:"incognito"}
tell aWin
make new tab with properties {URL:"http://www.wuputah.com"}
close tab 1
end tell
activate
end tell
>> def fact(n, r)
> if n < 2
> r
> else
> fact(n-1, n*r)
> end
> end
=> nil
>> fact(8720, 1)
=> 42190895430181916664979031806056928246303353451535636903773271316751702454531800280700498288825191072312390610447587954346720269259692495920127490654583176499074215852936506326556512651275020902681028408186164876934018066277852504002354904436539580624158841854584430580553205445678489279798415237578251015457819238211230996395174721526160166715453429700539475407302042107727975081050340508488865545782567001627527256801478522173103429539485321166200911428966344400772272969303858818597878181807615411366351182083258934467160969229226144067176912092520864697527038515938049590698544346189637434543160878992587889412988150063728225782549842240447124939040852245676989331855076443880183502308022073971744344239015274826387293786227930235969158940115582665264215146994173722360461092488599138170809222943662940806837299667841141685770580124593359987397203021073274581159074540783199754953227439324551958425260235
#!/usr/bin/env ruby
require 'rubygems'
['json', 'cloudapp_api'].each do |gem|
begin
require gem
rescue LoadError
puts "You need to install #{gem}: gem install #{gem}"
exit!(1)
end
# t1 and t2 are Time objects
>> Benchmark.realtime { 1_000_000.times { 1000*(t2-t1) }}
=> 1.562801266
>> Benchmark.realtime { 1_000_000.times { t2-t1 }}
=> 1.014025201
>> Benchmark.realtime { 1_000_000.times { Time.now; Time.now } }
=> 2.133374417
>> Benchmark.realtime { 1_000_000.times { }}
=> 0.069858542