Skip to content

Instantly share code, notes, and snippets.

View kakoni's full-sized avatar

Karri Niemelä kakoni

View GitHub Profile
require 'rbnacl'
require 'base64'
class Example
attr_reader :secret_box, :index_key
def initialize
key = RbNaCl::Random.random_bytes(RbNaCl::SecretBox.key_bytes)
@index_key = RbNaCl::Random.random_bytes(RbNaCl::SecretBox.key_bytes)
@secret_box = RbNaCl::SecretBox.new(key)
@kakoni
kakoni / gist:fbd8d9a986981f2b43c19d02cfc4771a
Created March 4, 2017 21:09
Getting start with rails 5.1 beta, webpacker and vue
1) Make sure YARN is installed (https://yarnpkg.com/en/docs/install)
2) Install rails 5.1 beta
gem install rails --pre
3) Create new app
rails new myapp --webpack=vue
4) Create home controller
rails g controller home index --no-assets
CREATE EXTENSION file_fdw;
CREATE SERVER import FOREIGN DATA WRAPPER file_fdw;
CREATE FOREIGN TABLE table1_import (
col1 text,
col2 text,
...
) SERVER import OPTIONS ( filename '/path/to/file.csv', format 'csv' );
@kakoni
kakoni / gist:29b210c2b5754dba719c6e3c0edd441f
Last active February 23, 2018 02:01
Redash under centos 6.x
Dependencies:
1. Python 2.7
2. Redis
3. PostgreSQL
4. Node.js
1. Install Python 2.7
Get python 2.7 from IUS
rpm -i https://rhel6.iuscommunity.org/ius-release.rpm
yum install python27 python27-virtualenv
@kakoni
kakoni / gist:63249215f15344933ae2ddaf3fa4c2be
Last active December 14, 2016 11:16
Simple ruby skeleton.
Rakefile
========
require 'rake/testtask'
Rake::TestTask.new do |t|
t.libs << 'test'
t.libs << 'lib'
t.test_files = FileList['test/**/*_test*.rb']
t.verbose = true
end
@kakoni
kakoni / my_csv.rb
Last active December 13, 2016 19:36
Monkey-patched ruby 2.3 CSV parser for those who need force quoting on certain fields only. Usage via options like; MyCSV.generate(forced_quote_fields: [1]) do |_csv|...
require 'csv'
class MyCSV < CSV
def <<(row)
# make sure headers have been assigned
if header_row? and [Array, String].include? @use_headers.class
parse_headers # won't read data for Array or String
self << @headers if @write_headers
end
Perhaps the most important
- max_connections: the number of concurrent sessions. rule-of-thumb formula is "number of spindles+number of processors+X"
- work_mem : the maximal amount of memory to be used for intermediate results such as hash tables.
- shared_buffers the amount of memory dedicated to 'pinned' buffer space.Normally it is advised to set it to about 1/4...1/2 of all available "free" memory
- effective_cache_size the amount of memory assumed to be used by the OS's LRU buffers. Set too all available "free" memory. 3/4 aggressive, reasonable amount
- random_page_cost : an estimate for the relative cost of disk seeks.
@kakoni
kakoni / config.yml
Created September 17, 2016 19:04
Embulk error
in:
type: file
path_prefix: fail.csv
parser:
type: csv
charset: utf-8
delimiter: ','
stop_on_invalid_record: true
columns:
- {name: a, type: string}
@kakoni
kakoni / chats
Last active September 8, 2016 06:39
XMPP
----
- Extensions
- XEP-0364 OTR
- XEP-0357 Push Notifications
- XEP-XXXX OMEMO(multiclient end-to-end) (Adaption of Axolotl now known as signal protocol)
- Chatsecure for android and ios.
Conversations.io to become the new ChatSecure Android.
- Zom is fork of chatsecure
require 'fluent/plugin/parser'
require 'csv'
module Fluent
module Plugin
class CSV2Parser < ValuesParser
Plugin.register_parser('csv2', self)