Skip to content

Instantly share code, notes, and snippets.

@simplay
simplay / vim_me_tonight.md
Last active August 29, 2015 14:19
all vim steps needed to be done...

... and this is how the story started...

:s/foo/bar/gc replace every foo in a text with bar (confirm after each detected occurrence). goto beginning of a word (move cursor onto its first letter), type v1ey to copy that word and move cursor to target word (its first letter) and type v1ep to overwrite it with copied word (not taht overwritten word is now in clipboard, i.e. can be pastes again - easy word swaps).

Locations you should know: ~/.vimrc

Initially, do this:

i1 = [1,2,3,4,5]
i2 = (0...(i1.size-1)).inject([]) {|pairs,x| pairs += ((x+1)...i1.size).map {|y| [i1[x],i1[y]]}}
@simplay
simplay / screen_shortcuts.md
Last active November 21, 2015 14:06
screen keybindings

Screen Keybindings

Definitions

<c-a> := presss control a

Window Management

@simplay
simplay / install_rvm_windows.md
Last active November 24, 2015 14:55
install rvm and jruby under windows 7

1 . cygwin installiere (x86 verion (auso nid 64bit)): source: http://cygwin.com/install.html

2 . Cygwin package manager installiere (drmit uf windows in cygwin s gliche wie apt-get uf linux distros chasch mache)

lynx -source rawgit.com/transcode-open/apt-cyg/master/apt-cyg > apt-cyg
install apt-cyg /bin

How to install Boost (1.55 or greater)

On windows 7 or greater

Requirements

  • Visual Studio installed on your system
  • Admin Privileges

Sources

@simplay
simplay / refactoring_using_metaprogrammin.rb
Created May 20, 2013 14:57
Refactoring in Ruby using dynamic methods and dynamic dispatch (1) using dynamic proxy that is also a blank slate (2) source: book - metaprogramming-ruby
# given class Computer: refactor me
class Computer
def initialize(computer_id, data_source)
@id = computer_id
@data_source = data_source
end
def mouse
info = @data_source.get_mouse_info(@id)
price = @data_source.get_mouse_price(@id)
@simplay
simplay / own_dsl.rb
Created May 21, 2013 18:30
event monitoring system - example for scope, blocks, procs, lambdas in ruby source: metaprogramming-ruby
lambda {
setups = []
events = {}
Kernel.send :define_method, :event do |name, &block|
events[name] = block
end
Kernel.send :define_method, :setup do |&block|
setups << block
end
@simplay
simplay / cppfoo.cpp
Created January 22, 2016 15:01
Pointers are evil...
#include <iostream>
using namespace std;
int main() {
int i = 10;
int j = i;
int &ai = i;
int *pi = &i;
*pi = *pi + 1;
# client.rb
require 'socket'
require 'digest/sha1'
require 'json'
hostname = "localhost"
port = 2000
socket = TCPSocket.open(hostname, port)
1.times do |i|
content = "#{i.to_s}: #{ARGV[0].to_s}"
msg = {
function filtered_img = bfilt( img, sigma_s, sigma_r)
%BFILT bilateral filter applied on img using sigma_s, sigma_r.
% img image, spatial, range deviation sigma_s, sigma_r
h = waitbar(0, 'Applying Bilateral Filter...');
set(h, 'Name', 'Bilateral Filter Progress Bar');
% compute window size - depends on sigma_s
w = ceil(1.5*sigma_s);