Skip to content

Instantly share code, notes, and snippets.

View treble37's full-sized avatar
🏠
Working from home

Bruce Park treble37

🏠
Working from home
View GitHub Profile
@treble37
treble37 / accidentally_renames_instance_variables.rb
Created March 24, 2018 18:51 — forked from JoshCheek/accidentally_renames_instance_variables.rb
Example of the kinds of issues you can hit when you directly mess with memory
require 'fiddle'
public def class=(new_class)
obj_ptr = Fiddle::Pointer.new 2*self.object_id
klass_ptr = Fiddle::Pointer.new 2*new_class.object_id
obj_ptr[8, 8] = klass_ptr.ref[0, 8]
end
class A
attr_accessor :a, :b, :c
end
@treble37
treble37 / git_submodules.md
Created July 25, 2017 23:51 — forked from gitaarik/git_submodules.md
Git Submodules basic explanation

Git Submodules basic explanation

Why submodules?

In Git you can add a submodule to a repository. This is basically a repository embedded in your main repository. This can be very useful. A couple of advantages of using submodules:

  • You can separate the code into different repositories.
@treble37
treble37 / README.md
Created July 5, 2017 16:58 — forked from hofmannsven/README.md
My simply Git Cheatsheet
@treble37
treble37 / gist:55459f5f0f218ab9b5ebe74b325f4a41
Created May 16, 2017 18:19
Ruby AES Encryption using OpenSSL
#!/usr/bin/env ruby
require "openssl"
require 'digest/sha2'
require 'base64'
# We use the AES 256 bit cipher-block chaining symetric encryption
alg = "AES-256-CBC"
# We want a 256 bit key symetric key based on some passphrase
digest = Digest::SHA256.new
@treble37
treble37 / migrate_postgresql_database.md
Created February 22, 2017 00:44 — forked from olivierlacan/migrate_postgresql_database.md
How to migrate a Homebrew-installed PostgreSQL database to a new major version (9.3 to 9.4) on OS X

This guide assumes that you recently run brew upgrade postgresql and discovered to your dismay that you accidentally bumped from one major version to another: say 9.3.x to 9.4.x. Yes, that is a major version bump in PG land.

First let's check something.

brew info postgresql

The top of what gets printed as a result is the most important:

# Video: http://rubyhoedown2008.confreaks.com/08-chris-wanstrath-keynote.html
Hi everyone, I'm Chris Wanstrath.
When Jeremy asked me to come talk, I said yes. Hell yes. Immediately. But
then I took a few moments and thought, Wait, why? Why me? What am I supposed
to say that's interesting? Something about Ruby, perhaps. Maybe the
future of it. The future of something, at least. That sounds
keynote-y.
@treble37
treble37 / presenters.md
Last active November 15, 2021 12:21 — forked from somebox/presenters.md
Thoughts About Rails Presenters
@treble37
treble37 / Algorithms: Design and Analysis, Part 2.md
Created September 13, 2016 05:06 — forked from misho-kr/Algorithms: Design and Analysis, Part 2.md
Summary of "Algorithms: Design and Analysis, Part 2" course at Coursera.Org

The course will have six weeks of lectures and assignments, followed by a final exam.

Week 1

I. TWO MOTIVATING APPLICATIONS

  • Distributed shortest-path routing -- sending email messages
@treble37
treble37 / post.md
Created September 13, 2016 00:31 — forked from fxn/post.md
GeoPlanet data with ancestor chain cache imported in 10 minutes

GeoPlanet data with ancestor chain cache imported in 10 minutes

Yahoo! provides its GeoPlanet data as three separate TSV files, available for download here.

That's a database with some 17 million records:

  • 5.7 million records: locations (aka places).
  • 2.2 million records: alternative names for each place (aka aliases).
  • 9.6 million records: matrix of neighbourhoods per place (aka adjacencies).
@treble37
treble37 / gist:2faf39df359b608765560e85032d9fab
Created June 28, 2016 17:37 — forked from alex-zige/gist:5795358
Rails Rspec API Testing Notes

Rails Rspec APIs Testing Notes

Folders Structure

  spec
  |--- apis #do not put into controllers folder. 
        |--- your_api_test_spec.rb  
  |--- controllers
  |--- models
  |--- factories
 |--- views