Skip to content

Instantly share code, notes, and snippets.

View sitano's full-sized avatar

Ivan Prisyazhnyy sitano

View GitHub Profile
@sitano
sitano / simple-fetch.rs
Created October 18, 2016 23:50
Simple example of URL fetcher in Rust
// Ivan Prisyazhnyy <[email protected]>, 2016
// Package implements example of parallel URL fetcher counting Go entries.
// Test: echo 'https://golang.org\nhttps://golang.org\nars\nhttps://golang.org\n' | cargo run
// Test: echo 'https://golang.org\nhttps://golang.org\nars\nhttps://golang.org\n' | cargo run
// Test: echo 'https://golang.org\nhttps://golang.org\nars\nhttps://golang.org\n' | cargo run
// Test: echo 'https://golang.org\nhttps://golang.org\nars\nhttps://golang.org\n' | cargo run
// Test: echo 'https://golang.org\nhttps://golang.org\nars\nhttps://golang.org\n' | cargo run
//
// Cargo.toml
@sitano
sitano / simple-fetch.go
Last active September 25, 2016 15:59
Simple example of URL fetcher with scalable up thread pool. Fan-out channels. Async reads. Sync writes.
// Ivan Prisyazhnyy <[email protected]>, 2016
// Package implements example of parallel URL fetcher counting Go entries.
// Test: echo 'https://golang.org\nhttps://golang.org\nars\nhttps://golang.org\n' | go run main.go -debug -k 0
// Test: echo 'https://golang.org\nhttps://golang.org\nars\nhttps://golang.org\n' | go run main.go -debug -k 1
// Test: echo 'https://golang.org\nhttps://golang.org\nars\nhttps://golang.org\n' | go run main.go -debug -k 2
// Test: echo 'https://golang.org\nhttps://golang.org\nars\nhttps://golang.org\n' | go run main.go -debug -k 3
// Test: echo 'https://golang.org\nhttps://golang.org\nars\nhttps://golang.org\n' | go run main.go -debug -k 4
package main
@sitano
sitano / gist:bdf2ce7f2af949c960204689df6e77b6
Created August 29, 2016 17:07
xfreerdb: license connection sequence aborted
[19:05:22:088] [8430:8431] [INFO][com.freerdp.client.x11] - Property 419 does not exist
[19:05:22:088] [8430:8431] [DEBUG][com.freerdp.client.x11] - Searching for XInput pointer device
[19:05:22:088] [8430:8431] [DEBUG][com.freerdp.client.x11] - Pointer device: 9
[19:05:22:088] [8430:8431] [DEBUG][com.freerdp.core.nego] - Enabling security layer negotiation: TRUE
[19:05:22:088] [8430:8431] [DEBUG][com.freerdp.core.nego] - Enabling restricted admin mode: FALSE
[19:05:22:089] [8430:8431] [DEBUG][com.freerdp.core.nego] - Enabling RDP security: TRUE
[19:05:22:089] [8430:8431] [DEBUG][com.freerdp.core.nego] - Enabling TLS security: TRUE
[19:05:22:089] [8430:8431] [DEBUG][com.freerdp.core.nego] - Enabling NLA security: TRUE
[19:05:22:089] [8430:8431] [DEBUG][com.freerdp.core.nego] - Enabling NLA extended security: FALSE
[19:05:22:089] [8430:8431] [DEBUG][com.freerdp.core.nego] - state: NEGO_STATE_NLA
@sitano
sitano / slither_debug.js
Last active June 6, 2016 21:56
render slither.io body parts movement
// ==UserScript==
// @name slither debug
// @version 0.1
// @description install with Tampermonkey (https://tampermonkey.net/)
// @author john.koepi / sitano, stacs
// @match http://slither.io
// @grant none
// ==/UserScript==
/*jshint esnext: true */
// Ivan Prisyazhnyy <[email protected]>, 2016
// Package implements simple in-memory single threaded key value database
// with nested transactions support. Interactive input support based on stdin.
// Program reads command from stdin, evaluates them and prints output to stdout.
// Errors are printed to stderr. Author missed readline emacs shortcuts while
// developing this.
package main
import (
package main
import (
_ "unsafe"
"fmt"
"runtime/pprof"
"os"
"time"
)
@sitano
sitano / max_spin_test.go
Created March 27, 2016 10:58
Max active spinning ns/op in go runtime 1.6
// proc_test.s
#include "go_asm.h"
#include "go_tls.h"
#include "funcdata.h"
#include "textflag.h"
TEXT runtime·ProcYield(SB),NOSPLIT,$0-0
MOVL cycles+0(FP), AX
again:
@sitano
sitano / Run.ps1
Created December 15, 2015 15:12
This is PowerShell script execution wrapper which can dynamically setup args and read $input. v1.
<#
.SYNOPSIS
This is PowerShell script execution wrapper which can dynamically setup args and read $input.
.EXAMPLE
If you need read input. This would not work in Consul config because of "" in -Command.
echo 'ars {blah,tatata}' | PowerShell.exe -NoProfile -NonInteractive -Command "$input | ./Run.ps1 -ScriptName ... -Arg1 val1 -Arg2 val2 ..."
.EXAMPLE
@sitano
sitano / fast-sudoku.cc
Created October 27, 2015 18:58
not best, but 8ms - beats 77.99% of cpp submissions.
class Solution {
private:
int flags[3][3] = {{0}};
int rows[9] = {0};
int cols[9] = {0};
int count = 0;
deque<pair<int, int>> s;
public:
void solveSudoku(vector<vector<char>>& board) {
class Solution {
public:
void solveSudoku(vector<vector<char>>& board) {
for (int row = 0; row < 9; row ++) {
auto rowi = &board[row];
for (int col = 0; col < 9; col ++) {
if ((*rowi)[col] == '.') {
for (char a = '1'; a <= '9'; ++ a) {
if (can(board, col, row, a)) {
(*rowi)[col] = a;