Skip to content

Instantly share code, notes, and snippets.

View thisismydesign's full-sized avatar

Csaba Apagyi thisismydesign

View GitHub Profile
@thisismydesign
thisismydesign / unset-http-proxy.sh
Created April 19, 2017 11:15
Unset all http proxy environment variables
unset $(env | awk -F= '{print $1}' | grep -E -i 'http.*proxy' | xargs)
@thisismydesign
thisismydesign / add-execution-rights.sh
Created April 19, 2017 11:17
Add execution rights to all .sh files
find . -name "*.sh" -exec chmod +x {} \;
@thisismydesign
thisismydesign / check-existing-ssh-tunnels.sh
Created April 19, 2017 14:50
Check for existing SSH tunnels
netstat -lpnt | grep ssh
@thisismydesign
thisismydesign / spec_helper.rb
Last active April 26, 2017 13:01
Relative file path with RSpec
# ...
RSPEC_ROOT = File.dirname __FILE__
@thisismydesign
thisismydesign / Rakefile
Created April 27, 2017 07:38
Ruby Rake task: check if source can be required locally
relative_entry_point = 'lib/...'
desc "Check if source can be required locally"
task :require do
sh "ruby -e \"require '#{File.dirname __FILE__}/#{relative_entry_point}'\""
end
@thisismydesign
thisismydesign / dos2unix.sh
Last active May 19, 2017 15:52
Convert DOS line endings to UNIX in all .sh files
find . -name "*.sh" -exec sed -i -e 's/\r$//' {} \;
@thisismydesign
thisismydesign / nesting_level_use_case.rb
Created May 19, 2017 15:55
How to write a JSON srteamer
@aggregator # what to yield
@current_nesting_level # when to yield
@parser.start_object do
@current_nesting_level += 1
end
@parser.end_object do
if yield_object?(yield_nesting_level)
yield @aggregator[@current_nesting_level].clone
@thisismydesign
thisismydesign / ssh_tunnels.sh
Last active June 12, 2017 08:56
SSH commands to create tunnels
$TARGET_PORT=
$TARGET_IP=
$TARGET_USER=
# SSH tunnel to target machine
ssh -f -N -L $TARGET_PORT:localhost:22 $TARGET_USER@$TARGET_IP
# SSH tunnel from target machine (reverse tunnel)
ssh -f -N -R $TARGET_PORT:localhost:22 $TARGET_USER@$TARGET_IP
@thisismydesign
thisismydesign / require_rails_all.rb
Last active October 30, 2017 20:08
Using rspec-rails in non-rails projects
ActiveRecord::ConnectionNotEstablished: No connection pool with 'primary' found.
-e:1:in `load'
-e:1:in `<main>'
@thisismydesign
thisismydesign / README.md
Last active March 21, 2018 18:10
Losing main thread with rake on Interrupt

Rakefile:

code = <<EOF
  begin
    sleep
  rescue Exception => e
    gets
  end
EOF