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 | |
from functools import wraps | |
from multiprocessing import Process, Queue | |
def processify(func): | |
'''Decorator to run a function as a process. | |
Be sure that every argument and the return value |
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
use std::fs; | |
use std::time::Instant; | |
use rand::Rng; | |
use rusqlite::{Connection, Result}; | |
fn insert_data(conn: &mut Connection) -> Result<()> { | |
let mut rng = rand::thread_rng(); | |
let mut t: u64 = 1600000000; | |
let num_entries = 1000 * 1000; |
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 json | |
import requests | |
def transform_data(data: dict) -> dict: | |
return { | |
"url": data["url"], | |
"tag_names": data["tags"], | |
"unread": bool(data["is_archived"]), |
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 json | |
import subprocess | |
def main(): | |
with open("wallabag-all.json") as fobj: | |
data = json.load(fobj) | |
for entry in reversed(data): | |
cmd = ["docker", "compose", "exec", "shiori", "shiori", "add", "-a", | |
entry["url"], "-i", entry["title"]] | |
if entry["tags"]: |
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
from __future__ import print_function | |
import ctypes | |
from ctypes import wintypes | |
GetCurrentProcess = ctypes.windll.kernel32.GetCurrentProcess | |
GetCurrentProcess.restype = wintypes.HANDLE | |
OpenProcessToken = ctypes.windll.advapi32.OpenProcessToken | |
OpenProcessToken.argtypes = (wintypes.HANDLE, wintypes.DWORD, ctypes.POINTER(wintypes.HANDLE)) | |
OpenProcessToken.restype = wintypes.BOOL |
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 logging | |
import multiprocessing | |
import time | |
import mplog | |
FORMAT = '%(asctime)s - %(processName)s - %(levelname)s - %(message)s' | |
logging.basicConfig(level=logging.DEBUG, format=FORMAT) | |
existing_logger = logging.getLogger('x') |
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 ctypes | |
from ctypes import POINTER | |
from ctypes.wintypes import HANDLE, LPVOID, WORD, DWORD, BOOL | |
LPSTR = ctypes.c_char_p | |
LPBYTE = LPSTR | |
LPHANDLE = POINTER(HANDLE) | |
LPDWORD = POINTER(DWORD) |
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 cPickle | |
import json | |
import ujson | |
import msgpack | |
d = { | |
'words': """ | |
Lorem ipsum dolor sit amet, consectetur adipiscing | |
elit. Mauris adipiscing adipiscing placerat. | |
Vestibulum augue augue, |
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/python | |
import sys | |
import time | |
import math | |
import gtk | |
import gobject | |
import pyglet | |
import pyglet.gl as gl |
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 socket | |
import struct | |
import sys | |
from httplib import HTTPResponse | |
from BaseHTTPServer import BaseHTTPRequestHandler | |
from StringIO import StringIO | |
import gtk | |
import gobject |
NewerOlder