Skip to content

Instantly share code, notes, and snippets.

@Pistos
Pistos / key-bindings.zsh
Created October 8, 2021 14:31
Modifications to fzf keybindings (zsh) for Ctrl-R to allow Space and Ctrl-E to select but not execute selection
# ____ ____
# / __/___ / __/
# / /_/_ / / /_
# / __/ / /_/ __/
# /_/ /___/_/ 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 October 24, 2020 03:47
Ruby REPL for typing text on Android via adb
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 November 13, 2021 03:07
Using Database Cleaner and FactoryBot with Hanami
# spec/factories/account.rb
FactoryBot.define do
factory :account, class: AccountRepository do
# ...
end
end
# 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 February 25, 2013 05:23
RDBI memory leak
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
http://2.bp.blogspot.com/-mGCjGLUiVm4/T9C6fkEyBGI/AAAAAAAAAkc/Tq1k-_w4Ym8/s1600/484285_379853398743566_1989524798_n.jpg
Prove that there exists an
N = (p1 · p2 · p3 · ... · pn ) + 1
which is not prime, where p1, p2 ... pn are the prime numbers.
@Pistos
Pistos / 00-Riddle.txt
Created September 12, 2012 03:21
Math Riddle
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?
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 June 22, 2012 21:31
Dumping posts and comments out of Diaspora database
# 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