Skip to content

Instantly share code, notes, and snippets.

@kp666
kp666 / introrx.md
Last active August 29, 2015 14:18 — forked from staltz/introrx.md

The introduction to Reactive Programming you've been missing

(by @andrestaltz)

So you're curious in learning this new thing called Reactive Programming, particularly its variant comprising of Rx, Bacon.js, RAC, and others.

Learning it is hard, even harder by the lack of good material. When I started, I tried looking for tutorials. I found only a handful of practical guides, but they just scratched the surface and never tackled the challenge of building the whole architecture around it. Library documentations often don't help when you're trying to understand some function. I mean, honestly, look at this:

Rx.Observable.prototype.flatMapLatest(selector, [thisArg])

Projects each element of an observable sequence into a new sequence of observable sequences by incorporating the element's index and then transforms an observable sequence of observable sequences into an observable sequence producing values only from the most recent observable sequence.

@kp666
kp666 / list.txt
Created May 28, 2015 14:46
dpkg-l
/usr/include/ImageMagick-6/magick
/usr/include/ImageMagick-6/magick/quantum.h
/usr/include/ImageMagick-6/magick/resize.h
/usr/include/ImageMagick-6/magick/log.h
/usr/include/ImageMagick-6/magick/animate.h
/usr/include/ImageMagick-6/magick/histogram.h
/usr/include/ImageMagick-6/magick/property.h
/usr/include/ImageMagick-6/magick/compress.h
/usr/include/ImageMagick-6/magick/geometry.h
/usr/include/ImageMagick-6/magick/type.h
@kp666
kp666 / default.rb
Created March 4, 2016 01:23
Cookbook Name:: memcached
require 'pp'
#
# Cookbook Name:: memcached
# Recipe:: default
#
node[:applications].each do |app_name,data|
user = node[:users].first
case node[:instance_role]
#!/bin/bash
if [ ! -f /usr/share/ssu/features.d/customer-jolla.ini ]; then
cat >/usr/share/ssu/features.d/customer-jolla.ini <<EOL
[customer-jolla]
repos = customer-jolla
packages = feature-jolla
description = Jolla specific content
version = 0.0.6-10.4.10.jolla
name = Jolla
@kp666
kp666 / query_planner.markdown
Created January 23, 2017 20:35 — forked from hgmnz/query_planner.markdown
PostgreSQL query plan and SQL performance notes

Types of index scans

Indexes

Sequential Scan:

  • Read every row in the table
  • No reading of index. Reading from indexes is also expensive.
@kp666
kp666 / db.rake
Created March 19, 2017 05:49 — forked from hopsoft/db.rake
Rails rake tasks for dump & restore of PostgreSQL databases
# lib/tasks/db.rake
namespace :db do
desc "Dumps the database to db/APP_NAME.dump"
task :dump => :environment do
cmd = nil
with_config do |app, host, db, user|
cmd = "pg_dump --host #{host} --username #{user} --verbose --clean --no-owner --no-acl --format=c #{db} > #{Rails.root}/db/#{app}.dump"
end
puts cmd
@kp666
kp666 / translate.js
Created May 26, 2017 05:40 — forked from mgechev/translate.js
Translate.js
var translate = (function () {
var symbols = {
a: '([]+![])[+!+[]]',
b: '([]+{})[+!+[]+!+[]]',
c: '([]+{})[+!+[]+!+[]+!+[]+!+[]+!+[]]',
d: '([]+[][+[]])[+!+[]+!+[]]',
e: '([]+[][+[]])[+!+[]+!+[]+!+[]]',
f: '([]+[][+[]])[+!+[]+!+[]+!+[]+!+[]]',
g: '([]+([]+[])[([]+{})[+!+[]+!+[]+!+[]+!+[]+!+[]]+([]+{})[+!+[]]+([]+[][+!+[]])[+!+[]]+([]+![])[+!+[]+!+[]+!+[]]+([]+{})[+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]]+([]+!![])[+!+[]]+([]+!![])[+!+[]+!+[]]+([]+{})[+!+[]+!+[]+!+[]+!+[]+!+[]]+([]+{})[+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]]+([]+{})[+!+[]]+([]+!![])[+!+[]]])[+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]]',
h: '(+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[])[([]+{})[+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]]+([]+{})[+!+[]]+([]+([]+[])[([]+{})[+!+[]+!+[]+!+[]+!+[]+!+[]]+([]+{})[+!+[]]+([]+[][+!+[]])[+!+[]]+([]+![])[+!+[]+!+[]+!+[]]+([]+{})[+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]]+([]+!![])[+!+[]]+([]+!![])[+!+[]+!+[]]
...............[libsecp256k1] illegal argument: Invalid flags
Aborted (core dumped)
rake aborted!
def all_alphabets
[[*'A'..'Z'], [*'a'..'z']]
end
def rotated_by_key(key)
all_alphabets.flat_map{|x|x.rotate(key)}
end
def ceaser(string,key)
string.tr(all_alphabets.join,rotated_by_key(key).join)
@kp666
kp666 / n2s.rb
Created September 22, 2017 13:58
def process(file)
text = File.read(file)
string = text.lines.first
string.split(', ')
.map {|c| c.split("=")}
.inject({}) {|c, v| c[v[0]]=v[1].to_s.split(" ").map(&:to_i); c}
.inject([]) {|k, v| v[1].each {|i| k[i] = v[0]}; k}
.join
end