Skip to content

Instantly share code, notes, and snippets.

@simkimsia
simkimsia / encoders.py
Created November 3, 2019 10:51
For the long story read the tweet thread on pt 34 here https://twitter.com/KimStacks/status/1190943466492051457
"""
Helper classes for parsers.
"""
import datetime
import decimal
import json # noqa
class FromValuesToDRFJSONEncoder(json.JSONEncoder):
"""
@simkimsia
simkimsia / conflicts.md
Last active July 11, 2018 09:42
text diagram for git conflicts
              master
                |
                |
   +-------<----+----->------+
   |            |            |
   |            |            |
   |            |            |
branch1         |         branch2
   |            |            |
@simkimsia
simkimsia / another_expected_config.js
Created May 1, 2018 05:09
Possible config for tableup
// inspired by datatables.net
// see https://datatables.net/examples/basic_init/filter_only.html for example
$(document).ready(function() {
$('#example').TableUp( {
"paging": true,
"rowsPerPageOptions": [2, 5, 10],
"rowsPerPage": 5,
"checkbox": true,
"search": true
@simkimsia
simkimsia / kafka-commands.md
Last active April 16, 2018 11:26
Kafka commands

Commands

How to get started

  1. start docker

  2. run this command in 1 terminal

docker run --rm -it \
           -p 2181:2181 -p 3030:3030 -p 8081:8081 \
           -p 8082:8082 -p 8083:8083 -p 9092:9092 \
@simkimsia
simkimsia / steps.md
Created April 5, 2018 04:08
how to run postgresql data replication
  1. install postgres (on both servers)

  2. omnipitr (on both servers)

  • download and extract omnipitr archive
  • cd /var/lib/postgresql
  • as postgres, wget https://codeload.github.com/omniti-labs/omnipitr/zip/v1.3.3
  • as ubuntu, sudo apt-get install unzip
  • as postgres, go to ~ and unzip v1.3.3
  • as postgres, mkdir ~/.omnipitr
  • as postgres, run sanity check (see evernote for details)
@simkimsia
simkimsia / currencies.sql
Created November 29, 2016 02:41
currencies mysql
CREATE TABLE IF NOT EXISTS `currencies` (
`id` int(11) NOT NULL auto_increment,
`name` varchar(64) default NULL,
`code` char(3) default NULL,
PRIMARY KEY (`id`),
KEY `idx_currency_name` (`currency_name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ;
--
-- Dumping data for table `currency`
@simkimsia
simkimsia / countries.sql
Created November 29, 2016 02:36
countries in mysql
CREATE TABLE IF NOT EXISTS `countries` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`iso` char(2) NOT NULL,
`name` varchar(80) NOT NULL,
`nicename` varchar(80) NOT NULL,
`iso3` char(3) DEFAULT NULL,
`numcode` smallint(6) DEFAULT NULL,
`phonecode` int(5) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
@simkimsia
simkimsia / TasksController.php
Created December 16, 2015 06:40
How to use queuesadilla in a Cake 3.x controller action
<?php
class TasksController extends AppController {
//.. code
public function execute_it($id) {
$task = $this->Tasks->get($id);
$_worker = envDefault('WORKER_CLASS', 'Sequential');
<?php
namespace App\Exception;
use Cake\Core\Exception\Exception;
class InvalidAuthenticationException extends Exception
{};
<?php
...
/**
* HTTP POST handler
*
* @return void|\Cake\Network\Response
*/
protected function _post()