Skip to content

Instantly share code, notes, and snippets.

@scaint
scaint / web.sh
Created March 18, 2015 19:37
A simplest "web server" shell script
#!/bin/sh
while :; do nc -l 9292 <<< $'HTTP/1.1 200 OK\r\nHello, world!'; done
@scaint
scaint / 0_reuse_code.js
Last active August 29, 2015 14:16
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@scaint
scaint / gist:56170113fab974b978b7
Created February 25, 2015 11:08
Rename some_file.js => some_file.js.coffee in Vim
:sav %.coffee | bd# | !rm #
convert source.png -resize 128x128 -normalize -equalize -posterize 4 -colors 8 -unique-colors -scale 1000% colors.png
(ls ~ & echo $! > /tmp/pid) | grep 'text'; cat /tmp/pid
while true; do git pull && notify-send 'It works again!' && break; sleep 5s; done
@scaint
scaint / crontab
Created July 7, 2014 05:22
~/bin/crontab
#!/bin/bash
if [ "$1" = '-r' ]
then
dialog --clear --yesno 'Do you realy want to remove crontab?' 5 45 || exit
fi
/usr/bin/crontab $@
_ex_.backtrace[0].tap { |v| s = v.split(':'); `gvim --remote-tab +#{s[1]} #{s[0]}` }
#!/bin/bash
# Updates rbenv and it's plugins to latest versions
rbenv_path="$HOME/.rbenv"
plugins_path="$rbenv_path/plugins"
echo -e "\033[1;32mUpdating rbenv\033[0m"
cd "$rbenv_path"
git pull
for plugin in $(ls "$plugins_path"); do
class Product < ActiveRecord::Base
attr_accessor :publisher
# ...
before_save { publisher.try(:broadcast, :before_save self) }
end