Skip to content

Instantly share code, notes, and snippets.

print_trace = fn(print_trace, fd) ->
receive do
msg ->
:io.format(fd, "call: (tracer pid: ~p)~n ~p~n", [self(), msg])
print_trace.(print_trace, fd)
end
end
{ok, fd} = :file.open("/tmp/trace.out", [:write])
custom_tracer = :proc_lib.spawn(fn -> print_trace.(print_trace, fd) end)
@ivalentinee
ivalentinee / convert-subs.sh
Created November 11, 2017 15:47
Convert subtitles coding system
#!/bin/bash
FILES=*.srt
for f in $FILES
do
echo "Processing $f file..."
iconv -c -f WINDOWS-1251 -t UTF-8 "$f" -o "$f"
done
@ivalentinee
ivalentinee / MoneyRails user input workaround.rb
Last active September 10, 2015 06:50
MoneyRails user input workaround
class PaymentInput < SimpleForm::Inputs::Base
def input(wrapper_options)
custom_input_options = { value: value, maxlength: 16 }
merged_input_options = merge_wrapper_options(input_html_options, wrapper_options)
merged_input_options = merge_wrapper_options(custom_input_options, merged_input_options)
@builder.text_field(attribute_name, merged_input_options)
end
def value
before_type_cast_value = object.send("#{attribute_name}_money_before_type_cast")
@ivalentinee
ivalentinee / shell-I-play.sh
Last active September 2, 2015 08:52
playing with grep/sed/tail/etc...
# most hungry processes (no, htop is too mainstream)
ps aux --sort -rss | head -n 10 | sed 's/[^ ]* *[0-9]* *\([0-9\.]*\) *\([0-9\.]*\) *[0-9]* *[0-9]* *? *[SsLl]* *[^ ]* *[^ ]* *\([^ ]*\).*/processor: \1%, memory: \2%, process: \3/'
# fix unzipped files with russian names in current directory
find . -type f -exec sh -c 'np=`echo {}|iconv -f cp1252 -t cp850| iconv -f cp866`; mv "{}" "$np"' \;
@ivalentinee
ivalentinee / fig.yml
Last active August 29, 2015 14:11
fig.yml for Rails application
db:
image: postgres
ports:
- "5432"
mailcatcher:
image: simpledrupalcloud/mailcatcher:latest
hostname: mailcatcher
ports:
- "1080:1080"