Skip to content

Instantly share code, notes, and snippets.

@y-yagi
y-yagi / boot.rb
Created September 25, 2016 06:24
trace = TracePoint.new(:c_call) do |tp|
if tp.method_id == :extend && tp.self.to_s == "ActiveRecord::Base"
puts "#{tp.path}:#{tp.lineno}\n"
end
end
trace.enable
require 'bundler/setup' # Set up gems listed in the Gemfile.
record = Post.new(:title => 'Yay', :body => 'This is some insert SQL')
# easiest way to achieve this is by calling protected #arel_attributes_values (tested in
# rails 3.2.13). the alternative is to build the entire insert statement using arel >_>
record.class.arel_table.create_insert \
.tap { |im| im.insert(record.send(:arel_attributes_values, false)) } \
.to_sql
package main
import (
"fmt"
"os"
"os/exec"
"strings"
)
func run() {
CREATE TABLE Accounts (
account_id SERIAL PRIMARY KEY,
account_name VARCHAR(20),
first_name VARCHAR(20),
last_name VARCHAR(20),
email VARCHAR(100),
password_hash CHAR(64),
portrait_image BYTEA,
hourly_rate NUMERIC(9,2)
);
package main
import (
"bufio"
"fmt"
"os"
"regexp"
)
func parseAndCreateSql(line string) {
-- Control frame information -----------------------------------------------
c:0129 p:---- s:0701 e:000700 CFUNC :deflate
c:0128 p:0020 s:0697 e:000696 METHOD /home/yaginuma/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/pdf-core-0.4.0/lib/pdf/core/filters.rb:16
c:0127 p:0044 s:0692 e:000691 BLOCK /home/yaginuma/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/pdf-core-0.4.0/lib/pdf/core/stream.rb:48 [FINISH]
c:0126 p:---- s:0686 e:000685 CFUNC :call
c:0125 p:0010 s:0682 e:000681 BLOCK /home/yaginuma/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/pdf-core-0.4.0/lib/pdf/core/filter_list.rb:46 [FINISH]
c:0124 p:---- s:0679 e:000678 CFUNC :each
c:0123 p:0009 s:0676 e:000675 METHOD /home/yaginuma/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/pdf-core-0.4.0/lib/pdf/core/filter_list.rb:45
c:0122 p:0035 s:0672 E:000e50 METHOD /home/yaginuma/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/pdf-core-0.4.0/lib/pdf/core/stream.rb:46
c:0121 p:0034 s:0669 e:000667 METHOD /home/yaginuma/.rbenv/versions/2.2.2/lib/ruby/gem
require 'openssl'
require 'socket'
KEY = OpenSSL::PKey::RSA.new <<-_end_of_pem_
-----BEGIN RSA PRIVATE KEY-----
MIICXgIBAAKBgQDLwsSw1ECnPtT+PkOgHhcGA71nwC2/nL85VBGnRqDxOqjVh7Cx
aKPERYHsk4BPCkE3brtThPWc9kjHEQQ7uf9Y1rbCz0layNqHyywQEVLFmp1cpIt/
Q3geLv8ZD9pihowKJDyMDiN6ArYUmZczvW4976MU3+l54E6lF/JfFEU5hwIDAQAB
AoGBAKSl/MQarye1yOysqX6P8fDFQt68VvtXkNmlSiKOGuzyho0M+UVSFcs6k1L0
maDE25AMZUiGzuWHyaU55d7RXDgeskDMakD1v6ZejYtxJkSXbETOTLDwUWTn618T
#!/usr/bin/env ruby
# Tab completion for minitest tests.
#
# INSTALLATION:
#
# 1. Put this file in a directory in your $PATH. Make sure it's executable
# 2. Run this:
#
# $ complete -o bashdefault -f -C /path/to/this/file.rb ruby
@y-yagi
y-yagi / pr.md
Last active August 29, 2015 14:13 — forked from piscisaureus/pr.md

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = git@github.com:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:

#!/usr/bin/env ruby
BIT_OR = '\|'
BIT_AND = '\&'
ADD = '\+'
MULTIPLATION = '\*'
input = ARGV[0]
[BIT_OR, BIT_AND, ADD, MULTIPLATION].each do |operator|