This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | |
| ): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #! /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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| use 5.010; | |
| use strict; | |
| use warnings; | |
| use AnyEvent; | |
| use AnyEvent::Handle; | |
| use AnyEvent::Socket; | |
| use AnyEvent::Log; | |
| use Data::Dumper; |
NewerOlder