Skip to content

Instantly share code, notes, and snippets.

View pbcquoc's full-sized avatar

Pham Ba Cuong Quoc pbcquoc

View GitHub Profile
@pbcquoc
pbcquoc / multiprocess_write_file.py
Created July 6, 2018 03:02
multiprocess write to single file python
import multiprocessing as mp,os
from datetime import timedelta, date
import os
def daterange(date1, date2):
for n in range(int ((date2 - date1).days)+1):
yield date1 + timedelta(n)
def unwrap_self(cls, kw1, kw2):
cls.process_wrapper(kw1, kw2)
@pbcquoc
pbcquoc / str2ip.py
Created May 30, 2018 06:42
python convert string to ipv4 in the correct way.
import socket, struct
def str2ip(ip):
"Convert dotted IPv4 address to integer."
packedIP = socket.inet_aton(ip)
return struct.unpack("!i", packedIP)[0]
@pbcquoc
pbcquoc / is_emoji.py
Created October 12, 2017 09:14 — forked from jezdez/is_emoji.py
A Python script to check if a character is or a text contains emoji
# -*- encoding: utf-8 -*-
# pip install emoji
import emoji
def char_is_emoji(character):
return character in emoji.UNICODE_EMOJI