Skip to content

Instantly share code, notes, and snippets.

Hrvoje Šimić shime

Block or report user

Report or block shime

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@shime
shime / rc.xml
Created Nov 6, 2014
openbox shortcuts for window management
View rc.xml
<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 May 18, 2019
The Qlobe - by Yusuke Endoh
View README.md

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 / github_secrets.md
Last active May 3, 2019
Secret Github Features
View github_secrets.md

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 Apr 22, 2019
comparing dates and times in RSpec
View _README.md

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 Mar 7, 2019
getting tired of guessing tar flags in 2013?
View _README.md

Looks familiar?

Worry no more! Use extract and prosper!

Usage

@shime
shime / _readme.md
Last active Feb 25, 2019
github oauth in node using express
View _readme.md

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 / reseed.rake
Last active Dec 18, 2018
Reseed database in Rails without dropping it. Originally posted at https://shime.sh/til/faster-database-resets-in-rails
View reseed.rake
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 / _readme.md
Last active Sep 29, 2018 — forked from ryin/tmux_local_install.sh
installation script for tmux 1.9a
View _readme.md

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 / list_files.js
Created Oct 9, 2014
list files in a directory with node.js
View list_files.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()
}))
})
@shime
shime / tracking.rb
Created Dec 21, 2012
Tracking request durations in Rails. Courtesy of @stathat
View tracking.rb
if Rails.env.production?
slow_logfile = File.open(Rails.root.join("log", "slow.log"), 'a')
slow_log = Logger.new(slow_logfile)
slow_log.level = Logger::INFO
ActiveSupport::Notifications.subscribe "process_action.action_controller" do |name, start, finish, id, payload|
duration = (finish - start) * 1000
StatHat::API.ez_post_value("rails request duration", "info@stathat.com", duration)
view_time = 0
db_time = 0
You can’t perform that action at this time.