Skip to content

Instantly share code, notes, and snippets.

View veganstraightedge's full-sized avatar
🐢
Computers were a mistake.

Shane Becker veganstraightedge

🐢
Computers were a mistake.
View GitHub Profile
@veganstraightedge
veganstraightedge / infura.rb
Last active February 26, 2018 11:37
The very start of what will likely become an Infura API wrapper gem. Lots TODO still.
### Infura helper class
require "http"
require "json"
class Infura
NETWORK = :mainnet
API_BASE_URL = "https://api.infura.io/v1/jsonrpc/#{Infura::NETWORK}/"
class << self
vendor/ruby-2.5.0/lib/ruby/2.5.0/monitor.rb:185:in `lock': deadlock; recursive locking (ThreadError)
from vendor/ruby-2.5.0/lib/ruby/2.5.0/monitor.rb:185:in `mon_enter'
from vendor/ruby-2.5.0/lib/ruby/2.5.0/monitor.rb:224:in `mon_synchronize'
from vendor/bundle/ruby/2.5.0/gems/dalli-2.7.6/lib/dalli/options.rb:23:in `alive?'
from vendor/bundle/ruby/2.5.0/gems/dalli-2.7.6/lib/dalli/ring.rb:42:in `server_for_key'
from vendor/bundle/ruby/2.5.0/gems/dalli-2.7.6/lib/dalli/client.rb:361:in `perform'
from vendor/bundle/ruby/2.5.0/gems/dalli-2.7.6/lib/dalli/client.rb:181:in `incr'
from vendor/bundle/ruby/2.5.0/gems/dalli-2.7.6/lib/active_support/cache/dalli_store.rb:234:in `block (2 levels) in increment'
from vendor/bundle/ruby/2.5.0/gems/dalli-2.7.6/lib/dalli/client.rb:262:in `with'
from vendor/bundle/ruby/2.5.0/gems/dalli-2.7.6/lib/active_support/cache/dalli_store.rb:82:in `with'
@veganstraightedge
veganstraightedge / fizz_buzz_1.ex
Created May 22, 2017 17:08
Spent an hour or so with @zzak getting my first look at Elixir. We Fizz Buzzed. ¯\_(ツ)_/¯
defmodule FizzBuzz do
def run do
range = 1..10
Enum.each range, fn i -> print_eye(i) end
end
def print_eye i do
cond do
rem(i, 3) == 0 ->
IO.puts "Fizz"
{
"items": [{
"type": ["h-event"],
"properties": {
"author": [{
"value": "gRegor Morrill",
"type": ["h-card"],
"properties": {
"photo": ["/assets/img/profile.jpg"],
"name": ["gRegor Morrill"],
"Calling all. This is our last cry before our eternal silence."
- The 2.X version.
Coming VERY SOON: The 3.0 Version!
3.0 is a nearly complete re-write of the Microformats Ruby parser.
3.0 will fix almost all outstanding issues on the GitHub repo,
add classical Microformats support and more! But unfortunately,
the cost of doing this is that there will be some breaking changes
and changing API.
@veganstraightedge
veganstraightedge / each-vs-map.rb
Last active May 2, 2017 22:41
For when you can't remember the difference between .each and .map, here's a reminder! It's written in Ruby, but the principle is the same in Javascript.
# In Ruby
# Array.each
# Iterate through each a collection unchanged
User.all.each do |user|
puts user.email
puts user.name
puts
end
@veganstraightedge
veganstraightedge / exercise.rb
Last active April 26, 2017 03:22
As a fun exercise, Morgan and I are implement shift, unshift, push and pop in ruby and js. The return is nbd. The changing the array in place stumped me. Bc I didn’t realize you change self.
class Array
def shift
output = self.first
self = self[1..-1]
output
end
def unshift(item)
[item] + self

Keybase proof

I hereby claim:

  • I am veganstraightedge on github.
  • I am veganstraightedg (https://keybase.io/veganstraightedg) on keybase.
  • I have a public key ASBB7IIfEcbDfy9QB_pyTYjdo8j67iyG-C0kB6u7faqhjwo

To claim this, I am signing this object:

@veganstraightedge
veganstraightedge / regex-help.md
Last active February 12, 2017 11:01
I need help writing this regex. Maybe it's obvious to someone else, but I keep failing one while matching the other or vice versa.

I need help writing this regex. Maybe it's obvious to someone else, but I keep failing one while matching the other or vice versa.

In Ruby.

Here are the the three test cases that I need to meet.

[[https://example.com/photo.png]]
[[https://example.com/video.mp4 With a text caption that's always separated from the URL by at least one space.]]
[[https://example.com/photo.png]] [[https://example.com/photo.png]]

This is all based on the [alpha release][1].

Properties

From the built-in help system:

For many settings TextMate will look for a .tm_properties file in the current folder and in any parent folders (up to the user’s home folder).

These are simple setting = value listings where the value is a format string in which other variables can be referenced.