Skip to content

Instantly share code, notes, and snippets.

View melekes's full-sized avatar

Anton Kaliaev melekes

View GitHub Profile
@Heimdell
Heimdell / flash_helper.rb
Created December 25, 2012 10:40
Flash helper library
module FlashHelper
[:success, :info].each do |kind|
define_method "flash_#{kind}" do |options = {}|
msg = options[:message] || kind
flash_notice message: msg, kind: kind, now: options[:now]
end
end
def flash_error(options = {})
@mlen
mlen / flac2alac
Last active April 23, 2024 07:02
FLAC to ALAC converter. Requires Mac OS X and `flac` binary installed (ie. via Homebrew: `brew install flac`).
#!/usr/bin/env bash
set -e
convert_to_alac() {
flac="$1"
aiff="${flac%.*}.aiff"
alac="${flac%.*}.m4a"
flac -s -d --force-aiff-format -o "$aiff" "$flac"
afconvert -f m4af -d alac "$aiff" "$alac"
#!/usr/bin/env bash
#
# Wraps curl with a custom-drawn progress bar. Use it just like curl:
#
# $ curl-progress -O http://example.com/file.tar.gz
# $ curl-progress http://example.com/file.tar.gz > file.tar.gz
#
# All arguments to the program are passed directly to curl. Define your
# custom progress bar in the `print_progress` function.
#
@martinos
martinos / local_io.rb
Created January 28, 2013 22:56
For testing io stdin and stdout interaction.
module SpecHelper
def local_io(in_str)
old_stdin, old_stdout = $stdin, $stdout
$stdin = StringIO.new(in_str)
$stdout = StringIO.new
yield
$stdout.string
ensure
$stdin, $stdout = old_stdin, old_stdout
end
@somebody32
somebody32 / gist:5232120
Last active October 4, 2022 08:19
Список литературы для ознакомления с concurrent programming и реализацией этих принципов и подходов на ruby. Огромное спасибо @brainopia за составление.

Введение

Начать стоит отсюда. Не пугайтесь то, что это книга по незнакомой OS, эти термины практически везде одинаковые и здесь они изложены в понятной для начинающих форме.

http://www.qnx.com/developers/docs/6.4.1/neutrino/getting_started/s1_procs.html

Прочесть нужно треть главы до подраздела "Starting a process", если С не пугает, читайте полностью. После прочтения вы будете понимать, что такое process, thread, mutex, priorites, semaphores, scheduler, contex-switch, kernel states.

Ruby

@jedi4ever
jedi4ever / dns tuning ssh login speedup vagrant
Created May 27, 2013 13:37
speeding up DNS/SSH connections in vagrant
- Tune /etc/ssh/sshd_config
UseDNS no # Disable DNS lookups
GSSAPIAuthentication no # Disable negotation of slow GSSAPI
don't forget to restart it, use a script provider to set it , or create it with veewee or snapshot it
- Tune Vagrantfile
vb.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]
@willurd
willurd / web-servers.md
Last active April 28, 2024 21:38
Big list of http static server one-liners

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000
@owainlewis
owainlewis / java7.yml
Created July 24, 2013 10:45
Install Java 7 with Ansible on Ubuntu Linux
---
- name: ensure required packages are installed for Java 7
apt: name=$item state=latest update_cache=yes
with_items:
- python-software-properties
- name: Add Java repository to sources
action: apt_repository repo='ppa:webupd8team/java'
@willjohnson
willjohnson / README.md
Last active April 26, 2022 19:32
Server Status Widget for Dashing

Description

A Dashing widget that checks whether a server is responding to either an http or ping request. It displays either a check or alert depending on the response.

Usage