This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Simulation for question #27 from https://www.inc.com/business-insider/google-hardest-interview-questions.html | |
class Simulation | |
def initialize(drop_rate, sidewalk_size) | |
@drop_rate = drop_rate # drops per second | |
@sidewalk_size = sidewalk_size # size of the sidewalk in drops(100 for 1m sidewalk with 1cm drop size) | |
@sidewalk = Hash.new # use a hash for much quicker lookup compared to a 2-dimentional array | |
end | |
def run |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if [[ $RETVAL -ne 0 ]] | |
then | |
symbols+="%{%F{red}%}✘" | |
else | |
symbols+="%{%F{green}%}✓" | |
fi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#original from http://stackoverflow.com/a/5452950/1305200 | |
def inplace_edit(filename) | |
File.open(filename, 'r+') do |file| | |
write_pos = 0 | |
file.each_with_index do |line, index| | |
eof = file.eof? | |
read_pos = file.pos | |
file.pos = write_pos | |
new_line = yield(line.chomp, index) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'inline' | |
class SigHandler | |
inline do |builder| | |
builder.include '<signal.h>' | |
builder.c ' | |
long address(){ | |
struct sigaction oldact; | |
sigaction(SIGINT, NULL, &oldact); | |
sigaction(SIGINT, &oldact, NULL); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Сенат | |
1 : уран - 55, титанит - 75, кредиты - 18, время - 0 с., кристаллы: 0 | |
2 : уран - 70, титанит - 95, кредиты - 23, время - 1170 с., кристаллы: 0 | |
3 : уран - 91, титанит - 124, кредиты - 30, время - 1494 с., кристаллы: 0 | |
4 : уран - 117, титанит - 159, кредиты - 38, время - 1865 с., кристаллы: 0 | |
5 : уран - 148, титанит - 202, кредиты - 48, время - 2333 с., кристаллы: 0 | |
6 : уран - 188, титанит - 256, кредиты - 62, время - 2808 с., кристаллы: 0 | |
7 : уран - 241, титанит - 328, кредиты - 79, время - 3384 с., кристаллы: 0 | |
8 : уран - 309, титанит - 422, кредиты - 101, время - 4068 с., кристаллы: 0 | |
9 : уран - 395, титанит - 539, кредиты - 129, время - 4853 с., кристаллы: 0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
root@ec26e4b4d070:/# rm -rf --no-preserve-root / | |
rm: cannot remove `/etc/hosts': Device or resource busy | |
rm: cannot remove `/etc/hostname': Device or resource busy | |
rm: cannot remove `/etc/resolv.conf': Device or resource busy | |
rm: cannot remove `/dev/console': Device or resource busy | |
rm: cannot remove `/dev/pts/ptmx': Operation not permitted | |
rm: cannot remove `/dev/mqueue': Device or resource busy | |
rm: cannot remove `/dev/shm': Device or resource busy | |
rm: cannot remove `/sys/fs/aufs/si_2c358a327a25dbd4/br0': Read-only file system | |
rm: cannot remove `/sys/fs/aufs/si_2c358a327a25dbd4/br1': Read-only file system |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
rake neo4j:install[community-2.1.6] | |
rake neo4j:start | |
rake neo4j:stop | |
rake neo4j:reset_yes_i_am_sure | |
rake neo4j:reset_yes_i_am_sure[test] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if Gem.available?('rspec') | |
require 'rspec/core/rake_task' | |
desc "Run all specs with rcov" | |
RSpec::Core::RakeTask.new("spec:coverage") do |t| | |
t.rcov = true | |
t.rcov_opts = '-o rspec_coverage --rails --include views -Ispec --exclude gems\/,spec\/,features\/,seeds\/' | |
t.spec_opts = "-c -f h -o rspec.html" | |
end |