Skip to content

Instantly share code, notes, and snippets.

View german's full-sized avatar

Dmytro Samoilov german

View GitHub Profile
@german
german / task1.py
Created January 29, 2015 18:58
prometheus course
import math, sys
def formula(x, mu, sigma):
exp = math.exp(- ((x - mu)**2) / (2*sigma**2))
return 1.0 / (sigma * math.sqrt(2*math.pi)) * exp
x_cli = float(sys.argv[1])
mu_cli = float(sys.argv[2])
sigma_cli = float(sys.argv[3])
print(formula(x_cli, mu_cli, sigma_cli))
german@german-HP-ProBook-4540s ➜ mmc-filter-client git:(MMC-556-Pagination) gco stable
Branch stable set up to track remote branch stable from origin.
Switched to a new branch 'stable'
german@german-HP-ProBook-4540s ➜ mmc-filter-client git:(stable) git pull origin stable
From github.com:aupeo/mmc-filter-client
* branch stable -> FETCH_HEAD
Already up-to-date.
german@german-HP-ProBook-4540s ➜ mmc-filter-client git:(stable) gco master
Switched to branch 'master'
Your branch is up-to-date with 'origin/master'.
#!/bin/sh
set -u
set -e
# Example init script, this can be used with nginx, too,
# since nginx and unicorn accept the same signals
# Feel free to change any of the following variables for your app:
APP_ROOT=/home/deploy/public_html/rm/current
PID=$APP_ROOT/tmp/pids/unicorn.pid
ENV=production
@german
german / ruby187_192_bug
Created December 8, 2010 10:53
bug in ruby 1.8.7 / ruby 1.9.2 preview 1 (wrong rounding)
$ ruby -v
ruby 1.8.7 (2010-06-23 patchlevel 299) [i686-linux]
$irb
ruby-1.8.7-p299 > a = (125.33 - (125.33/100.0*50.0))
=> 62.665
ruby-1.8.7-p299 > b = 62.665
=> 62.665
ruby-1.8.7-p299 > (a*100).round
=> 6266
@german
german / 1.9.x bug in calculation
Created December 8, 2010 11:46
error in multiplication in ruby 1.9.2 && 1.9.3dev
1.9.3dev
$ ruby -v
ruby 1.9.3dev (2010-12-08 trunk 30125) [i686-linux]
$ irb
ruby-head > 125.33 - (125.33/100.0*50.0)
=> 62.66499999999999
ruby-head > 125.33 / 100.0 * 50.0
=> 62.665000000000006
@german
german / redis-benchmark
Created July 7, 2011 16:35
redis-benchmark on my old notebook (512 RAM)
$ redis-benchmark
====== PING (inline) ======
10000 requests completed in 0.43 seconds
50 parallel clients
3 bytes payload
keep alive: 1
19.85% <= 1 milliseconds
97.70% <= 2 milliseconds
@german
german / gist:1737767
Created February 4, 2012 13:07
пелевин, ампир в
- Неужели и здесь то же самое? - задал я горький и не вполне понятный вопрос.
- И здесь, и везде, - сказал Иегова. - И всегда. Проследи за тем, что происходит во время человеческого общения.
Зачем человек открывает рот?
Я пожал плечами.
- Главная мысль, которую человек пытается донести до других, заключается в том, что он имеет доступ к гораздо более
престижному потреблению, чем про него могли подумать. Одновременно с этим он старается объяснить окружающим, что
их тип потребления гораздо менее престижен, чем они имели наивность думать. Этому подчинены все социальные маневры.
Больше того, только эти вопросы вызывают у людей стойкие эмоции.
- Вообще-то мне в жизни попадались и другие люди, - сказал я с легкой иронией.
Иегова кротко посмотрел на меня.
@german
german / active_record_introspection.rb
Created May 29, 2012 13:37
adding introspection to all ActiveRecord methods (putting method's name when it's invoked)
module ActiveRecord
Base.singleton_methods.each do |m|
Base.class_eval <<-EOS
class << self
puts "redefining #{m}"
define_method "#{m}_with_introspection" do |*args|
puts "#{m}"
send(:"#{m}_without_introspection", *args)
end
@german
german / gist:2828602
Created May 29, 2012 14:03
example of active_record methods introspection
Loading development environment (Rails 2.3.5)
>> module ActiveRecord
>> Base.singleton_methods.each do |m|
?> Base.class_eval <<-EOS
class << self
puts "redefining #{m}"
define_method "#{m}_with_introspection" do |*args|
puts "#{m}"
send(:"#{m}_without_introspection", *args)
@german
german / test_compile.c
Created July 4, 2012 14:42
minimal mruby program
#include “mruby.h”
#include “mruby/proc.h”
#include <stdio.h>
void _error(const char* s){
printf("ERROR: %s\n", s);
exit(1);
}
int main() {