Skip to content

Instantly share code, notes, and snippets.

@shime
shime / README.md
Last active April 12, 2024 10:49
The Qlobe - by Yusuke Endoh

Qlobe

Qlobe is a fascinating example of quine in Ruby, submitted by a member of the Ruby core team - Yusuke Endoh.

Programs that output changed executable versions of themselves while managing to spin the globe and still remaining executable are cool, right?

To experience its magic, run the following

curl -fSSl https://gist.githubusercontent.com/shime/f0ebe84ca42c33b51d42/raw/5e74315dc6b6fe572f8a457536ad7eb17ad3f1e4/qlobe.rb > qlobe.rb; while true; do ruby qlobe.rb | tee temp.rb; sleep 1; mv -f temp.rb qlobe.rb; done
@shime
shime / _README.md
Last active April 2, 2024 17:00
getting tired of guessing tar flags in 2013?

Looks familiar?

Worry no more! Use extract and prosper!

Usage

@shime
shime / github_secrets.md
Last active April 29, 2023 20:04
Secret Github Features

Taken from Zach Holman's "Git and Github Secrets".

Keyboard Shortcuts

t - quickly jump through files (similar to cmd+T in VI or Text Mate)

w - quickly switch branches

s - search

@shime
shime / _readme.md
Last active April 28, 2023 18:56
github oauth in node using express

What?

Most basic example of authenticating with Github in node.

How?

Clone this gist, change keys inside config.js and then hit npm install && node app.js.

Done?

@shime
shime / _README.md
Last active March 15, 2021 19:26
comparing dates and times in RSpec

What is this?

How do you compare date/times in RSpec?

If you do this

expect(Time.now.to_i).to eq Time.new(2014, 4, 2).to_i
@shime
shime / _readme.md
Last active November 8, 2020 08:54 — forked from ryin/tmux_local_install.sh
installation script for tmux 1.9a

Having trouble installing the latest stable version of tmux?

I know, official package for your OS/distro is outdated and you just want the newest version of tmux.

Well, this script should save you some time with that.

Prerequisities

  • gcc
@shime
shime / rc.xml
Created November 6, 2014 17:10
openbox shortcuts for window management
<keyboard>
<!-- resize windows with Alt + Direction -->
<keybind key="A-Right">
<action name="GrowToEdgeEast"/>
</keybind>
<keybind key="A-Left">
<action name="GrowToEdgeWest"/>
</keybind>
<keybind key="A-Down">
<action name="GrowToEdgeSouth"/>
@shime
shime / readme.md
Last active March 13, 2020 09:39
bake your own code reloader for rails

Let's build our own code reloader for Rails, shall we?

Require dependency problems

Run this inside rails/railties:

$ grep -rn "eager_load_paths" .

You should get the results from Rails::Engine::Configuration and Rails::Engine. As you know, each Rails application is actually a Rails::Engine and Rails::Engine::Configuration is that thing wrapped inside Rails.application.config block.

@shime
shime / reseed.rake
Last active December 18, 2018 10:30
Reseed database in Rails without dropping it. Originally posted at https://shime.sh/til/faster-database-resets-in-rails
namespace :db do
desc 'Clears the database and then seeds it'
task reseed: :environment do
Rake::Task["db:truncate"].invoke
Rake::Task["db:seed"].invoke
end
desc 'Clears the database'
task truncate: :environment do
puts "Truncating database"
@shime
shime / list_files.js
Created October 9, 2014 20:31
list files in a directory with node.js
var fs = require('fs'),
path = require('path')
var listFiles = function(dir, next){
fs.readdir(dir, function(err, nodes){
if (err) next(err)
next(null, nodes.filter(function(node){
return fs.lstatSync(path.resolve(dir) + "/" + node).isFile()
}))
})