Skip to content

Instantly share code, notes, and snippets.

View kyrylo's full-sized avatar

Kyrylo Silin kyrylo

View GitHub Profile
# True for Python 2 and Python 3.
def foo(bar = []):
bar.append(1)
print(bar)
foo() #=> [1]
foo() #=> [1, 1]
@kyrylo
kyrylo / pry_ls_headings.diff
Last active December 11, 2015 01:59
Adds headings for methods in the output of `ls` command of Pry. It was rejected, because for most people it looks unpleasant.
commit e2503bc03d983f2e095bd04c7c3de7ca9b6a2e71
Author: Kyrylo Silin <kyrylosilin@gmail.com>
Date: Sun Jan 13 17:37:36 2013 +0200
Ls: slightly change the styling of heading methods
diff --git a/lib/pry/commands/ls.rb b/lib/pry/commands/ls.rb
index 5349e9e..5bf35f7 100644
--- a/lib/pry/commands/ls.rb
+++ b/lib/pry/commands/ls.rb
@kyrylo
kyrylo / custom.css.css
Last active December 12, 2015 08:48 — forked from banister/custom.css.css
#button-babies {
position: relative;
margin: 0 -80px 1.5em 80px;
display: block;
float: left;
width: 700px;
text-align: center;
word-spacing: 8px;
font-size: 30px;
letter-spacing: -2px;
@kyrylo
kyrylo / crap_that_i_constantly_forget.md
Created March 13, 2013 11:41
Crap that I constantly forget

Switching Rubinius modes:

  • 1.9 mode: RBXOPT=-X19 ruby foo.rb
  • 1.8 mode: RBXOPT=-X18 ruby foo.rb

Switching JRuby modes:

  • 1.9 mode: JRUBY_OPTS=--1.9 ruby foo.rb
  • 1.8 mode: JRUBY_OPTS=--1.8 ruby foo.rb
(require 'auto-complete-config)
(add-to-list 'ac-dictionary-directories "~/.emacs.d/dict")
(ac-config-default)
@kyrylo
kyrylo / rfe-1.1.rb.txt
Last active December 19, 2015 06:39
Ruby for entertainment #1
[1] pry(main)> HELLO!!!
| def answer
| :HI!
| end
NoMethodError: undefined method `HELLO!' for main:Object
from (pry):4:in `__pry__'
[2] pry(main)> answer
=> :"HI!"
@kyrylo
kyrylo / rfe-2.1.rb
Created July 3, 2013 13:30
Ruby for entertainment #2
puts "#{ RUBY_VERSION } #{ RUBY_PATCHLEVEL }" #=> "1.8.7 370"
nil.frozen? #=> false
nil.freeze
nil.frozen? #=> false
69.frozen? #=> false
69.freeze
69.frozen? #=> false
@kyrylo
kyrylo / a.md
Created July 30, 2013 22:33
Running a Cinch IRC bot on Heroku (by zobar)
  1. Add Heroku to your Gemfile and bundle install.
  2. Create your Heroku app. This will only work with their (currently-beta) 'cedar' stack, so you have to heroku create --stack=cedar.
  3. Create a Procfile for your bot. This tells Heroku how to run your worker. In our case, the bot is bot.rb, so the only line in the Procfile is cinch: bundle exec ./bot.rb
  4. Commit and push to Heroku.
  5. You do not want a Web worker running, so heroku scale web=0 cinch=1. This also sets up your deployments to restart the bot.
@kyrylo
kyrylo / terminal-for-entertainment.md
Last active December 20, 2015 14:08
How to enter plain text passwords in your terminal.

Zsh

# ~/.zshrc
setopt HIST_IGNORE_SPACE

Bash

void print_library(const struct book *library, int count);
void sort(struct book *library, int count, void (*sorting_method)(struct book *, struct book, int, int));
void alphabetically(struct book *library, struct book temp, int i, int j);
void by_value(struct book *library, struct book temp, int i, int j);
void print_delim(void);
int fltcmp(float a, float b);