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 / 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"
View Gemfile
source 'https://rubygems.org'
gem "minitest"
@shime
shime / eighth.rb
Last active Jun 6, 2016
my codility solutions
View eighth.rb
def solution(a)
counter = [0] * a.length
a.each do |element|
if ! (1 <= element && element <= a.length)
return 0
else
if counter[element-1] != 0
return 0
else
counter[element-1] = 1
@shime
shime / .gitignore
Last active Nov 8, 2015
Hello world over bittorrent DHT
View .gitignore
node_modules
*.log
View keybase.md

Keybase proof

I hereby claim:

  • I am shime on github.
  • I am shime (https://keybase.io/shime) on keybase.
  • I have a public key whose fingerprint is 3436 35B8 B1DE 69EC DB61 97F5 936B 516B 5B9C 52BB

To claim this, I am signing this object:

@shime
shime / console.js
Last active Oct 1, 2015
pick a random meetup attendee
View console.js
// Paste this into your browser console to pick a random attendee
// from the list of users in the "Going" section of your
// event at meetup.com
//
// Skips the organizer (first in the list).
$('#rsvp-list li').eq(Math.floor(Math.random()*($('#rsvp-list li').length - 1)) + 1).find('a').text()
@shime
shime / readme.md
Last active Aug 29, 2015
debugging Ember components and views in the newer Ember versions
View readme.md
@shime
shime / Dockerfile
Last active Aug 29, 2015
confiig files
View Dockerfile
FROM base/archlinux:latest
# install dependencies
RUN pacman -Syu --noconfirm
RUN pacman --noconfirm -S base-devel yajl nodejs git openssh imagemagick python2
RUN ln -s /usr/bin/python2 /usr/bin/python
# install yaourt
WORKDIR /tmp/scratch
RUN curl https://aur.archlinux.org/packages/pa/package-query/package-query.tar.gz | tar zx
View keybase.md

Keybase proof

I hereby claim:

  • I am shime on github.
  • I am shime (https://keybase.io/shime) on keybase.
  • I have a public key whose fingerprint is 3032 0F07 65F2 3ABC 8BCB 3AF6 D409 B2B4 1F90 597C

To claim this, I am signing this object:

@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
You can’t perform that action at this time.