Skip to content

Instantly share code, notes, and snippets.

@miku
miku / py2.py
Created August 18, 2020 19:27
Metaclass syntax Python 2 and 3
class A:
pass
class B(metaclass=A):
pass
@miku
miku / gist:9d32607dc394949e5f56bf2066562c79
Created August 15, 2020 16:41 — forked from fnielsen/gist:3904327
Python shelve concurrency
import shelve
import multiprocessing
import os
filename = "tmp.shelve"
N = 4
end = 10000
def insert((offset, jump, end, filename)):
@miku
miku / http_proxy.go
Created July 2, 2020 15:52 — forked from jim3ma/http_proxy.go
Register Dialer Type for HTTP&HTTPS Proxy in golang
package main
import (
"bufio"
"fmt"
"net"
"net/http"
"net/url"
"crypto/tls"
@miku
miku / .gitignore
Last active June 30, 2020 11:06
Check tar files status
/tarcheck
/elsevier_tarcheck.ndj
@miku
miku / main.go
Last active May 15, 2020 22:03
On the fly content type detection.
// Tee plus LimitWriter.
// LimitWriter taken from: https://github.com/kubernetes/kubernetes/blob/579e0c74c150085b3fac01f6a33b66db96922f93/pkg/kubelet/util/ioutils/ioutils.go#L39-L70
//
package main
import (
"bytes"
"flag"
"io"
"io/ioutil"
@miku
miku / 23689767.py
Last active October 23, 2021 21:16
https://stackoverflow.com/a/23689767/89391 / How to use a dot “.” to access members of dictionary?
class dotdict(dict):
"""
A dictionary supporting dot notation.
"""
__getattr__ = dict.get
__setattr__ = dict.__setitem__
__delattr__ = dict.__delitem__
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
@miku
miku / TkinterPong.py
Created May 10, 2020 19:43 — forked from calebrob6/TkinterPong.py
Python Tkinter Poing
import Tkinter
from Tkinter import Frame, BOTH, Canvas
#By Caleb Robinson
class Pong(Frame):
player1 = 0
player2 = 0
ballX=50
ballY=50
I was drawn to programming, science, technology and science fiction
ever since I was a little kid. I can't say it's because I wanted to
make the world a better place. Not really. I was simply drawn to it
because I was drawn to it. Writing programs was fun. Figuring out how
nature works was fascinating. Science fiction felt like a grand
adventure.
Then I started a software company and poured every ounce of energy
into it. It failed. That hurt, but that part is ok. I made a lot of
mistakes and learned from them. This experience made me much, much
prefix publisher journals dois
10.12679 0 0
10.7579 123Doc Education 0 0
10.3731 21st Century COE Program (Toplogical Science and Technology) 1 40
10.5775 A. I. Rosu Cultural Scientific Foundation Fundatia cultural-stiintifica A. I. Rosu 1 80
10.4037 AACN Publishing 2 766
10.1306 AAPG/Datapages 4 21817
10.3183 AB Svensk Papperstidning 1 1550
10.5769 ABEAT - Associacao Brasileira de Especialistas em Alta Tecnologia 1 57
10.7597 ACOPIOS - Revista Iberica de Mineralogia 1 9
@miku
miku / insert_paginator.py
Created April 15, 2020 22:02 — forked from evan-burke/insert_paginator.py
psycopg2 execute_values wrapper for accurate row counts
# One of the fastest ways to insert bulk data into Postgres (at least, aside from COPY) is using the psycopg2 extras function execute_values.
# However, this doesn't return an accurate row count value - instead, it just returns the row count for the last page inserted.
# This wraps the execute_values function with its own pagination to return an accurate count of rows inserted.
# Performance is approximately equivalent to underlying execute_values function - within 5-10% or so in my brief tests.
import psycopg2
import psycopg2.extras
import math
db_connection_string = "dbname=EDITME host=EDITME"