This file contains 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 matplotlib | |
import numpy as np | |
import phase1 | |
from scipy import misc | |
im_raw = misc.imread('image2.png') | |
nearest = lambda array, value: array[(np.abs(array-value)).argmin()] | |
im_flat = im_raw.reshape(im_raw.shape[0]*im_raw.shape[1], im_raw.shape[2]) | |
colours_top = [x[1] for x in sorted(phase1.rle(sorted([tuple(x) for x in im_flat], reverse=True)), reverse=True)][:4] | |
colours_list = [tuple(x) for x in colours_top] | |
im_top_flat = np.array([nearest(colours_top, colour) if tuple(colour) not in colours_list else colour for colour in im_flat]) |
This file contains 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
#!/usr/bin/env python | |
# Script for automatic backup of files to a fileserver using rsync. | |
# Directories to backup and details about the remote fileserver and | |
# exclude patterns must be entered in the backup script itself. | |
# See 'User Configurable Parameters' below. | |
# | |
# Backup consists of three functions controlled by commandline arguments: | |
# | |
# /etc/backup sync |
This file contains 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 sys | |
import traceback | |
import pyroute2.netns | |
i = 0 | |
while True: | |
try: | |
pyroute2.netns.setns('/proc/1/ns/net') | |
except: | |
traceback.print_exc(file=sys.stderr) | |
print(i) |
This file contains 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 os | |
import sys | |
import traceback | |
import pyroute2.netns | |
i = 0 | |
import functools | |
@functools.lru_cache(maxsize=1024) | |
def get_fd_from_netnspath(netnspath): |
This file contains 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 os | |
import socket | |
import struct | |
import asyncio | |
import logging | |
DNS_SERVER = '8.8.8.8' | |
DNS_PORT = 53 | |
def encode_header(packet_id): |
This file contains 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 sys | |
import os | |
from urllib.request import urlopen | |
from urllib.parse import urlencode | |
from time import time | |
from copy import copy | |
from re import findall | |
PASTEBIN_URL = 'https://pastebin.com/api/api_post.php' | |
PASTEBIN_LOGIN_URL = 'https://pastebin.com/api/api_login.php' |
This file contains 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
def start_redis_server(redis_socket_path = "/tmp/redis.sock"): | |
conf = b"""port 0 | |
databases 1 | |
unixsocket %s | |
maxmemory 100mb | |
maxmemory-policy volatile-lru | |
save ''""" % redis_socket_path.encode() | |
logging.debug('launching redis with conf: %s' % conf) | |
redis_process = subprocess.Popen(['redis-server', "-"], stdin = subprocess.PIPE, start_new_session=True) | |
try: |
This file contains 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
[ 0.000000] Initializing cgroup subsys cpu | |
[ 0.000000] Linux version 3.0.21+ (benxiwang@benxiwang-Lenovo) (gcc version 4.6.3 20111117 (prerelease) (GCC) ) #1 PREEMPT Mon Oct 10 12:53:23 CST 2016 | |
[ 0.000000] CPU: ARMv7 Processor [410fc051] revision 1 (ARMv7), cr=10c5387d | |
[ 0.000000] CPU: VIPT nonaliasing data cache, VIPT aliasing instruction cache | |
[ 0.000000] Machine: QCT MSM9615 CDP | |
[ 0.000000] Partition (from atag) boot -- Offset:2fc Size:52 | |
[ 0.000000] Partition (from atag) sbl2 -- Offset:a Size:1b | |
[ 0.000000] Partition (from atag) rpm -- Offset:25 Size:1b | |
[ 0.000000] Partition (from atag) efs2 -- Offset:40 Size:53 | |
[ 0.000000] Partition (from atag) dsp1 -- Offset:93 Size:1f |
This file contains 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
- hosts: all | |
remote_user: root | |
tasks: | |
- user: name=name state=present shell=/bin/bash | |
- name: setup resolv.conf | |
lineinfile: path=/run/resolvconf/resolv.conf line='nameserver 8.8.8.8' create=yes state=present | |
- name: hardcode ports.ubuntu.com | |
lineinfile: path=/etc/hosts line='91.189.88.150 ports.ubuntu.com' state=present | |
- name: aptitude | |
apt: name=aptitude state=installed |
This file contains 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 os | |
import socket | |
import struct | |
import asyncio | |
import logging | |
DNS_SERVER = '8.8.8.8' | |
DNS_PORT = 53 | |