Skip to content

Instantly share code, notes, and snippets.

View slawosz's full-sized avatar

Sławosz Sławiński slawosz

View GitHub Profile
package main
import "fmt"
type Vertex struct {
X, Y float64
}
func main() {
var vertexp *Vertex;
@mislav
mislav / _readme.md
Last active July 22, 2025 23:54
tmux-vim integration to transparently switch between tmux panes and vim split windows

I use tmux splits (panes). Inside one of these panes there's a Vim process, and it has its own splits (windows).

In Vim I have key bindings C-h/j/k/l set to switch windows in the given direction. (Vim default mappings for windows switching are the same, but prefixed with C-W.) I'd like to use the same keystrokes for switching tmux panes.

An extra goal that I've solved with a dirty hack is to toggle between last active panes with C-\.

Here's how it should work:

anonymous
anonymous / concerning.rb
Created December 18, 2012 18:00
class Module
# We often find ourselves with a medium-sized chunk of behavior that we'd
# like to extract, but only mix in to a single class.
#
# We typically choose to leave the implementation directly in the class,
# perhaps with a comment, because the mental and visual overhead of defining
# a module, making it a Concern, and including it is just too great.
#
#
# Using comments as lightweight modularity:
@slawosz
slawosz / 0-readme.md
Created November 26, 2012 16:49 — forked from sxua/0-readme.md
ruby-1.9.3-p286 cumulative performance patch.

Patch for ruby 1.9.3-p327 is here: https://gist.github.com/4063779

Patched ruby 1.9.3-p286 for 30% faster rails boot

Overview

This script installs a patched version of ruby 1.9.3-p286 with boot-time performance improvements (#66 and #68), and runtime performance improvements (#83 and #84). It also includes the new backported GC from ruby-trunk.

Many thanks to funny-falcon for the performance patches.

@davelnewton
davelnewton / 01_error.txt
Created August 23, 2012 23:48
A JRuby, Rails, RSpec, Spork, and an error walk into a bar...
$ rspec --drb spec/models/foo_spec.rb .../rubies/jruby-1.6.7/lib/ruby/1.9/drb/drb.rb:375 warning:
ObjectSpace is disabled; _id2ref only supports immediates, pass -X+O to enable
NoMethodError: undefined method `flush' for nil:NilClass
method_missing at .../rubies/jruby-1.6.7/lib/ruby/1.9/drb/drb.rb:1099
run at .../gems/jruby-1.6.7@cowbania/gems/rspec-core-2.11.1/lib/rspec/core/drb_command_line.rb:22
run at .../gems/jruby-1.6.7@cowbania/gems/rspec-core-2.11.1/lib/rspec/core/runner.rb:63
autorun at .../gems/jruby-1.6.7@cowbania/gems/rspec-core-2.11.1/lib/rspec/core/runner.rb:8
class AttributeAccessor < Module
def initialize(name)
@name = name
@name_ivar = "@#{@name}"
end
def included(model)
super
define_accessors
@andkerosine
andkerosine / raskell.rb
Created August 15, 2012 05:56
Haskell-like list comprehensions in Ruby
$stack, $draws = [], {}
def method_missing *args
return if args[0][/^to_/]
$stack << args.map { |a| a or $stack.pop }
$draws[$stack.pop(2)[0][0]] = args[1] if args[0] == :<
end
class Array
def +@
@romannurik
romannurik / SwipeDismissListViewTouchListener.java
Last active May 1, 2021 10:16
**BETA** Android 4.0-style "Swipe to Dismiss" sample code
Moved to
https://github.com/romannurik/android-swipetodismiss
class ActionDispatch::Routing::Mapper
def draw(routes_name)
instance_eval(File.read(Rails.root.join("config/routes/#{routes_name}.rb")))
end
end
BCX::Application.routes.draw do
draw :api
draw :account
draw :session
@tddium
tddium / campfire.rb
Last active October 2, 2015 13:58
Campfire Post-Build Notifier
#!/usr/local/bin/ruby
# Copyright (c) 2012 Solano Labs All Rights Reserved
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice, this
# list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright notice,