Skip to content

Instantly share code, notes, and snippets.

View sargo's full-sized avatar

Wojciech Lichota sargo

View GitHub Profile
const { Transform } = require('readable-stream');
const stream = require('stream');
class SimpleTransform extends Transform {
_transform(chunk, enc, callback) {
this.push(chunk);
return callback();
}
}
import io
import picamera
import logging
import socketserver
import time
from threading import Condition
from http import server
import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BCM)
ssh-rsa AAAAB3NzaC1yc2EAAAABJQAAAQEAuHvYm5+ZmDPqF5vO5Sm5r0UvAPzwBiTTHUhsayWEXJD/LLau1S5GA7ot97h3JTwnGLtU8TwcbZ7sbfB2tiZzYYu6ehiIm9QuFBQN5rYIpwU7N6nANCzH4+5UFEHHRma7u4eLX7KZRvHe/xMyHKLbijvJjHpsB9kxZW6MkOy3A4ZWStcSTgkk5Fk2jTFSg4gVVH0n7i4kTQEWBEa0Xijpkj8YWhghpKRLmR8aFXCSk8c7wIe/szTvjDaoHYM5umYDz3+Dwyp2pqGo29LuLsa3bVvOJwlJwYZ/8qEgFExo+nOHbKzmdzgGV5PTLkyy/leoeJPp0sBNVASCc08gA1QsJQ== adtonos-hosting

Prepare Ubuntu 18.04 for running Cloud9 (via SSH)

sudo apt-get update
sudo apt-get upgrade
sudo apt-get autoremove

Upgrade tmux

@sargo
sargo / links-en.md
Last active January 23, 2019 11:00
@sargo
sargo / links.md
Last active February 21, 2018 23:15

There is this piece of code that is not yet covered by tests, and our product owner requested that we increase code coverage. Can you do it?

Three modes:

What do they check?

  • easy: knowledge about tests in general, ability to test different execution paths, ability to handle exceptions, very basic creativity, simple unit testing
  • normal: ability to write test cases for more than one object at the same time, more complex scenarios

#GROT interview question

Take a look at GROT game. Write algorithm that will find longest chain (return coordinates of start point). As sample input use:

sample = [
    ['u', 'd', 'u', 'u'], # ↑ ↓ ↑ ↑
    ['u', 'r', 'l', 'l'], # ↑ → ← ←
    ['u', 'u', 'l', 'u'], # ↑ ↑ ← ↑
 ['l', 'd', 'u', 'l'], # ← ↓ ↑ ←

WeirdText is a text encoding.

It is not "encryption" because humans can usually read it quite easily. But machines may find it difficult to read without the list of original words. Except of having fun, there are real-world applications for this, e.g. if encryption is forbidden by law in your country, but you still don't want your email content to get automatically processed somehow.

Encoding

For each original word in the original text, leave the first and last character of it in that position, but shuffle (permutate) all the characters in the middle of the word. If possible, the resulting "encoded" word MUST NOT be the same as the original word. Keep everything else (whitespace, punctuation, etc.) like in the original. To make decoding by a machine possible, your encoder shall also output a sorted list of original words (only include words that got shuffled, not text that did not).

The composite output of the encoder (see example below) contains encoded text (WeirdText) and also the sorted lis

@sargo
sargo / .konchrc
Created June 6, 2014 13:57
.konchrc
# -*- coding: utf-8 -*-
import datetime
import os
import pprint
import re
import sys
import time
import konch