Skip to content

Instantly share code, notes, and snippets.

View miry's full-sized avatar

Michael Nikitochkin miry

View GitHub Profile
def max_overshoot(task_table)
@cache_result ||= {}
result = @cache_result[task_table]
return result if result
prev = 0
prev = max_overshoot(task_table[0..-2]) if task_table.size > 1
total_duration = task_table.reduce(0) {|i, s| i+s[:duration]}
require 'benchmark'
n = 50000000
Benchmark.bm(15) do |x|
x.report("regexp1") { 1.upto(n) do ; "XMLHttpReQUEst" =~ /XMLHttpRequest/i; end }
x.report("regexp2") { 1.upto(n) do ; "XMLHttpReQUEst" =~ /xmlhttprequest/i; end }
x.report("downcase") { 1.upto(n) do ; 'XMLHttpReQUEst'.downcase == 'xmlhttprequest'; end }
x.report("strip+downcase") { 1.upto(n) do ; ' XMLHttpReQUEst '.strip!.downcase! == 'xmlhttprequest'; end }
end
[color]
diff = auto
status = auto
branch = auto
ui = true
[color "branch"]
current = yellow reverse
local = yellow
remote = green
@miry
miry / index.html
Created April 23, 2013 20:42
This is a simple Sinatra application with sample of cross domain sharing resource.
<html>
<head>
<title>
Demo Cross Domain
</title>
<!-- Le styles -->
<link href="//netdna.bootstrapcdn.com/twitter-bootstrap/2.3.1/css/bootstrap-combined.min.css" rel="stylesheet">
<style>
body {
@miry
miry / md_to_html.html
Created May 1, 2013 19:47
Tested RDiscount parser to convert code blocks without indents.
....
<h2>Installation</h2>
<p>OK. First, you need a running <em>Elasticsearch</em> server. Thankfully, it's easy. Let's define easy:</p>
<pre><code>$ curl -k -L -o elasticsearch-0.20.2.tar.gz http://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-0.20.2.tar.gz
$ tar -zxvf elasticsearch-0.20.2.tar.gz
$ ./elasticsearch-0.20.2/bin/elasticsearch -f
</code></pre>
@miry
miry / .zshrc
Last active October 21, 2018 09:47
My zsh config
# Path to your oh-my-zsh configuration.
export ZSH=$HOME/.oh-my-zsh
# Set name of the theme to load.
# Look in ~/.oh-my-zsh/themes/
# Optionally, if you set this to "random", it'll load a random theme each
# time that oh-my-zsh is loaded.
ZSH_THEME="aussiegeek"
# Example aliases
gem: --no-rdoc --no-ri
@miry
miry / info_kill.sh
Last active December 20, 2015 12:28
#!/bin/bash
function info_kill() {
local frame=0
while caller $frame; do
((frame++));
done
echo "kill $*"
@miry
miry / Rakefile
Created August 27, 2013 11:05
Rubymotion tricks to generate the build version.
Motion::Project::App.setup do |app|
#Simple example to generate a pretty build version
app.version = `git log -n 1 --pretty=format:'%h'`.upcase
app.short_version = '1.0'
#...
end
@miry
miry / Rakefile
Last active December 21, 2015 20:00
Rubymotion: A nice trick to find a right profile instead to put a full path to the file
Motion::Project::App.setup do |app|
# Find Provising profile depends on Profile name
# https://github.com/HipByte/RubyMotion/blob/master/lib/motion/project/template/ios/config.rb#L88
app.provisioning_profile('IOS Wildcard Team Profile')
#or use same as app name
app.provisioning_profile(app.name)
# ...
end