Skip to content

Instantly share code, notes, and snippets.

View igorcoding's full-sized avatar
🍹
Having fun

Igor Latkin igorcoding

🍹
Having fun
View GitHub Profile
@igorcoding
igorcoding / rps.py
Last active October 11, 2017 13:10
import asyncio
import collections
import time
import uvloop; asyncio.set_event_loop_policy(uvloop.EventLoopPolicy())
def chunkify(lst, n):
s = len(lst) // n
o = 0
import multiprocessing
def map_parallel(func, iterable, chunksize=1, *,
pool=None,
n_processes=None,
progress_bar_func=None,
pool_kwargs=None,
progress_bar_func_kwargs=None,
total=None
):
apt-key adv --keyserver ha.pool.sks-keyservers.net --recv-keys B97B0AFCAA1A47F044F244A07FCC7D46ACCC4CF8
echo "deb http://apt.postgresql.org/pub/repos/apt/ `lsb_release -c -s`-pgdg main 9.6" > /etc/apt/sources.list.d/pgdg.list
local function alter_package_path(paths, base)local isroot=function(s)return string.sub(s,1,1)=='/'end;local slashends=function(s)return string.sub(s,-1,-1)=='/'end;local fio=require('fio');local bf=debug.getinfo(2,"S").source:sub(2);local lb=fio.readlink(bf);if lb~=nil then bf=lb end;local b=bf:match("(.*/)");if not isroot(b) then b=fio.abspath(b);if not slashends(b)then b=b..'/'end;end;if base~=nil and base~="" then if isroot(base) then b=base;else b=b..base..'/';end;end;local pkg='';for _,p in ipairs(paths)do if isroot(p) then pkg=pkg..";"..p;else pkg = pkg..";"..b..p;end;end;package.path=package.path..pkg;return b;end
local base = alter_package_path({
'?.lua',
'?/init.lua',
'libs/tnt-luas16/?.lua',
})
-- Full function here:
local function alter_package_path(paths, base)
local isroot=function(s)return string.sub(s,1,1)=='/'end;
class CustomJsonEncoder(json.JSONEncoder):
def default(self, obj):
if isinstance(obj, JsonSerializable):
return obj.__to_json__()
if isinstance(obj, datetime.datetime) or isinstance(obj, datetime.date):
return int(time.mktime(obj.timetuple()))
return super(CustomJsonEncoder, self).default(obj)
class JsonSerializable:
class ObjectId(JsonSerializable, str):
def __init__(self, object_id):
super().__init__()
self.object_id = int(object_id)
def __str__(self):
return str(self.object_id)
def __int__(self):
return self.object_id
import tensorflow as tf
import tensorflow.examples.tutorials.mnist.input_data
import numpy as np
mnist = tensorflow.examples.tutorials.mnist.input_data.read_data_sets("MNIST_data/", one_hot=True)
image_size = 28
n_labels = 10
def create_w_b(n_prev_layer, n_next_layer):
import tensorflow as tf
import tensorflow.examples.tutorials.mnist.input_data
import numpy as np
mnist = tensorflow.examples.tutorials.mnist.input_data.read_data_sets("MNIST_data/", one_hot=True)
image_size = 28
n_labels = 10
def create_w_b(n_prev_layer, n_next_layer):
@igorcoding
igorcoding / screenshot.sh
Created June 7, 2015 17:50
Make screenshot and upload it to Dropbox
#! /bin/sh
TIMESTAMP=`date +%Y-%m-%d-%H-%M-%S`
IMAGEPATH=$HOME/Dropbox/Public/Screenshots/Screenshot_$TIMESTAMP.png
gnome-screenshot $1 -f $IMAGEPATH
dropbox puburl $IMAGEPATH | xclip -selection clipboard
use 5.010;
use strict;
use warnings;
use AnyEvent;
use AnyEvent::Handle;
use AnyEvent::Socket;
use AnyEvent::Log;
use Data::Dumper;