Skip to content

Instantly share code, notes, and snippets.

@Pistos
Pistos / key-bindings.zsh
Created Oct 8, 2021
Modifications to fzf keybindings (zsh) for Ctrl-R to allow Space and Ctrl-E to select but not execute selection
View key-bindings.zsh
# ____ ____
# / __/___ / __/
# / /_/_ / / /_
# / __/ / /_/ __/
# /_/ /___/_/ key-bindings.zsh
#
# - $FZF_TMUX_OPTS
# - $FZF_CTRL_T_COMMAND
# - $FZF_CTRL_T_OPTS
# - $FZF_CTRL_R_OPTS
@Pistos
Pistos / android-type.rb
Last active Oct 24, 2020
Ruby REPL for typing text on Android via adb
View android-type.rb
require "readline"
def escaped(s)
s.gsub("'", "'\\\\''")
end
while s = Readline.readline("> ", true)
e = escaped(s)
puts `./android-type.sh '#{e}'`
end
@Pistos
Pistos / account.rb
Last active Nov 13, 2021
Using Database Cleaner and FactoryBot with Hanami
View account.rb
# spec/factories/account.rb
FactoryBot.define do
factory :account, class: AccountRepository do
# ...
end
end
View gist:9adacc03c1eab533d836e0b387258219
# emerge -atv dolphin
* Last emerge --sync was 39d 12h 55m 15s ago.
These are the packages that would be merged, in reverse order:
Calculating dependencies... done!
[ebuild R ] kde-apps/dolphin-4.14.3-r1:4/4.14::gentoo USE="handbook thumbnail* (-aqua) -debug -semantic-desktop" 0 KiB
[ebuild N ] kde-apps/ffmpegthumbs-15.08.3:4/15.08::gentoo USE="(-aqua) -debug" 0 KiB
[ebuild N ] kde-apps/thumbnailers-15.08.3:4/15.08::gentoo USE="(-aqua) -debug" 0 KiB
@Pistos
Pistos / rdbi-memleak.rb
Created Feb 25, 2013
RDBI memory leak
View rdbi-memleak.rb
require 'rdbi'
require 'rdbi-driver-postgresql'
dbh = RDBI.connect(:PostgreSQL, host: 'localhost', database: 'any_database', username: 'someusername')
while 1 < 2
puts `ps aux | grep #{Process.pid} | grep -v grep`
1000.times do
dbh.execute "SELECT 1"
end
View gist:4235052
http://2.bp.blogspot.com/-mGCjGLUiVm4/T9C6fkEyBGI/AAAAAAAAAkc/Tq1k-_w4Ym8/s1600/484285_379853398743566_1989524798_n.jpg
View gist:3797840
Prove that there exists an
N = (p1 · p2 · p3 · ... · pn ) + 1
which is not prime, where p1, p2 ... pn are the prime numbers.
View 00-Riddle.txt
There are each a cup of milk and a cup of coffee (same amounts).
First you transfer one spoon of milk into the coffee.
After achieving an optimal mixture, transfer one spoon of the milky coffee into the milk.
Is there more coffee in the milk or more milk in the coffee?
View spec_helper.rb
require_relative '../app'
require_relative 'factories'
require 'capybara/rspec'
Capybara.configure do |config|
# config.default_driver = :rack_test
config.default_driver = :selenium
config.app = Ramaze.middleware
end
@Pistos
Pistos / comments-dump.sh
Created Jun 22, 2012
Dumping posts and comments out of Diaspora database
View comments-dump.sh
# Set author_id to desired people table record id
echo 'SELECT c.id, c.guid, p.guid AS post_guid, c.created_at, c.text, c.likes_count FROM comments c, posts p WHERE p.id = c.commentable_id AND c.author_id = 3 ORDER BY c.id' | psql -U diaspora -h localhost -A -F '
' -R '
--- record
' diaspora_production > diaspora-comments.dump