This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### Keybase proof | |
I hereby claim: | |
* I am AlexanderPavlenko on github. | |
* I am alerticus (https://keybase.io/alerticus) on keybase. | |
* I have a public key whose fingerprint is 21A4 17B8 8937 82DE A577 052F BABE D11F BE87 3DB9 | |
To claim this, I am signing this object: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ adb shell | |
$ cd data/data/com.android.providers.settings/databases | |
$ sqlite3 settings.db | |
sqlite> .tables | |
sqlite> select * from secure; | |
sqlite> INSERT INTO secure (name, value) VALUES ('device_provisioned', 1); | |
sqlite> .exit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
filename = ARGV[0] | |
str = File.read filename | |
blocks = str.split('<%').map{|s| s.empty? ? s : s.split('%>') }.flatten | |
inside = false | |
blocks.map do |block| | |
if inside | |
block.gsub! '\\', '\\\\\\\\' | |
block.gsub! '"', '\"' | |
block.gsub! '#{', '#" %><%= "{" + "' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Base64ImageWrapper < StringIO | |
def initialize(data, name=nil) | |
@name = name || 'image' | |
@blob = Base64.decode64(data) | |
super @blob | |
end | |
def original_filename | |
"#@name.#{content_type.split('/').last}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Arel::Visitors | |
class ToSql | |
alias :visit_Fixnum :quoted | |
alias :visit_Bignum :quoted | |
end | |
end | |
module ActiveRecord::ConnectionAdapters | |
class PostgreSQLAdapter | |
module FixNumberToStringComparison |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
f = File.open('/tmp/tr', 'w') | |
set_trace_func proc { | |
|event, file, line, id, binding, classname| | |
if event == "call" or event == "return" | |
f.printf "%8s %s:%-2d %10s %8s\n", event, file, line, id, classname | |
end | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'timeout' | |
Timeout.timeout(0.5) do | |
begin | |
sleep 1 | |
rescue Exception => ex | |
puts ex.inspect | |
puts 'ಠ_ಠ' | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class BuggyEnumerator < Enumerator | |
def initialize(that) | |
@ivar = that | |
end | |
def each | |
return to_enum(:each) unless block_given? | |
@ivar.each{|item| yield item } | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'benchmark' | |
n = 1000 | |
Benchmark.bm do |bm| | |
keys = (1..10000).to_a | |
hash = Hash[keys.zip(keys)] | |
bm.report do | |
n.times do | |
keys.map{|key| hash[key] } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
([^-])url\(.*?/img/([^'")]+).*?\) | |
$1image-url('$2') |
OlderNewer