Skip to content

Instantly share code, notes, and snippets.

View d4rky-pl's full-sized avatar

Michał Matyas d4rky-pl

View GitHub Profile
@d4rky-pl
d4rky-pl / split_tab.py
Created February 7, 2012 20:18
Sublime Text Editor split view tabbing
#
# srsly Klausa...
#
# { "keys": ["super+shift+["], "command": "split_prev_view" },
# { "keys": ["super+shift+]"], "command": "split_next_view" },
# { "keys": ["super+alt+left"], "command": "split_prev_view" },
# { "keys": ["super+alt+right"], "command": "split_next_view" },
#
@d4rky-pl
d4rky-pl / gist:9f197f9dbfa7db5e5845
Created April 24, 2015 18:24
error: 'this' pointer cannot be null in well-defined C++ code; pointer may be assumed to always convert to true [-Werror,-Wundefined-bool-conversion]
[2015-04-24 20:18:40] /Users/d4rky/.rvm/wrappers/ruby-2.2.1@rubinius/rake
current path: /Users/d4rky/.rvm/src/rbx-2.5.2
PATH=/Users/d4rky/.rvm/bin:/usr/local/opt/pkg-config/bin:/usr/local/opt/libtool/bin:/usr/local/opt/automake/bin:/usr/local/opt/autoconf/bin:/Applications/Postgres.app/contents/macos/bin:/Users/d4rky/.bin:/usr/local/bin:/Users/d4rky/android-sdk-macosx/apache-ant-1.9.4/bin:/Users/d4rky/android-sdk-macosx/tools:/Users/d4rky/android-sdk-macosx/platform-tools:/Users/d4rky/android-sdk-macosx/build-tools/19.1.0:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin
command(3): /Users/d4rky/.rvm/wrappers/ruby-2.2.1@rubinius/rake install --trace
** Invoke install (first_time)
** Invoke build:build (first_time)
** Invoke vm/vm (first_time)
** Invoke vm/gen/config_variables.h (first_time)
** Invoke library/rubinius/configuration.rb (first_time, not_needed)
** Invoke config.rb (first_time, not_needed)
@d4rky-pl
d4rky-pl / gist:a34d4ec5d2b40447bcd6
Last active August 29, 2015 14:22
Benchmarking ExecJS with therubyracer and node
require 'benchmark'
require 'execjs'
require 'therubyracer'
js_code = '2+2'
STDOUT.sync = true
ExecJS.runtime = ExecJS::Runtimes::Node
Benchmark.bmbm(20) do |benchmark|
@d4rky-pl
d4rky-pl / meth_vs_proc.rb
Created July 8, 2015 11:25
meth_vs_proc.rb
Calculating -------------------------------------
method 56.995k i/100ms
proc 49.213k i/100ms
proc new 57.562k i/100ms
-------------------------------------------------
method 1.797M (±10.7%) i/s - 8.891M
proc 1.522M (± 8.3%) i/s - 7.579M
proc new 1.867M (± 7.9%) i/s - 9.267M
Comparison:
@d4rky-pl
d4rky-pl / constant_is_illusion.rb
Created March 12, 2016 07:32
Actual code found in legacy project
def self.extend_printouts_constants
const = 'PRINTOUT_PROCESS_STATES'
if ProductPrintingSupport.const_defined?(const)
old = ProductPrintingSupport.const_get(const)
ProductPrintingSupport.send(:remove_const, const)
ProductPrintingSupport.const_set(const, old + [:job_ganging_printout_in_progress])
end
end
@d4rky-pl
d4rky-pl / DESCRIPTION.md
Created July 29, 2016 09:25
nio4r / non-blocking IO problem

I'm trying to implement running ffmpeg process with timeout without resorting to Ruby's Timeout class or spawning a new Thread with counter inside (that's how streamio-ffmpeg does it and it's error-prone and it feels wrong)

Unfortunately when doing non-blocking reads with nio4r, the size of returned chunks of data is pretty much random. While doing synchronous reads result in block yielding every line, in case of nio4r the polling makes it unpredictable.

Is there a better way or should I just somehow glue together responses when I somehow detect the response is incomplete?

@d4rky-pl
d4rky-pl / bar.rb
Last active March 30, 2017 22:46
import/export in Ruby
ModuleExporter.module(__FILE__) do
_Bar = Class.new do
def bar
"Bar!"
end
end
export _Bar
end
@d4rky-pl
d4rky-pl / gist:4d10c3fd6a26c6fd112f6ce8a78627e5
Created April 4, 2017 12:25
converter from unified to separated mode in mobx-react-form
// This script is ugly and simple but it works
// Sharing in case someone else find it useful
window.fieldConverter = (obj) => {
let fields = map(obj, (values, field_name ) => field_name)
let labels = reduce(obj, (acc, values, field_name) => { acc[field_name] = values.label; return acc } ,{})
let rules = reduce(obj, (acc, values, field_name) => { acc[field_name] = values.rules; return acc } ,{})
let defaults = reduce(obj, (acc, values, field_name) => { acc[field_name] = values.default; return acc } ,{})
let types = reduce(obj, (acc, values, field_name) => { acc[field_name] = values.type; return acc } ,{})
let values = reduce(obj, (acc, values, field_name) => { acc[field_name] = values.value; return acc } ,{})
@d4rky-pl
d4rky-pl / keybase.md
Created April 14, 2017 10:54
keybase.md

Keybase proof

I hereby claim:

  • I am d4rky-pl on github.
  • I am nerdblogpl (https://keybase.io/nerdblogpl) on keybase.
  • I have a public key whose fingerprint is 4DE7 F67D 3A8D 0C5F 04EC 8AAC DF1C E039 57AB 7520

To claim this, I am signing this object:

@d4rky-pl
d4rky-pl / _demo.rb
Last active April 24, 2017 22:13
mobx-ruby
require 'mobx'
Mobx.init
class Session
extend Mobx::Extension
observable :user
observable :company
end