Skip to content

Instantly share code, notes, and snippets.

@hurie
hurie / setlocal.php
Last active March 13, 2024 05:52
Set locale for Indonesian on all platform (Windows, Linux and others Nix server)credit for buana95 at yahoo dot com
<?php
setlocale(LC_ALL,
'id_ID.UTF8', 'id_ID.UTF-8', 'id_ID.8859-1', 'id_ID',
'IND.UTF8', 'IND.UTF-8', 'IND.8859-1', 'IND',
'Indonesian.UTF8', 'Indonesian.UTF-8', 'Indonesian.8859-1', 'Indonesian', 'Indonesia',
'id', 'ID',
// Add english as default (if all Indonesian not available)
'en_US.UTF8', 'en_US.UTF-8', 'en_US.8859-1', 'en_US', 'American', 'ENG', 'English',
);
# Code borrowed from http://stackoverflow.com/questions/6809590/merging-a-python-scripts-subprocess-stdout-and-stderr-while-keeping-them-disti/6810231#6810231
import subprocess
import select
from logging import DEBUG, ERROR
def call(popenargs, logger, stdout_log_level=DEBUG, stderr_log_level=ERROR, **kwargs):
"""
Variant of subprocess.call that accepts a logger instead of stdout/stderr,
and logs stdout messages via logger.debug and stderr messages via
@hurie
hurie / static-binding.php
Created July 16, 2014 06:40
Trace static binding and method binding call
<?php
/**
* Created by PhpStorm.
* User: Azhar
* Date: 7/15/14
* Time: 10:59 AM
*/
$indent = 0;
@hurie
hurie / update-cache.py
Last active August 29, 2015 14:04
Organize PIP download cache
#!/python3.4
"""
Created on Aug 01, 2014
@author: Azhar
"""
from configparser import ConfigParser
import hashlib
import os
from pathlib import Path
'# Perform dir /a c:\users > c:\dir.txt
'# place this script file in c:\ too
'# double click to run it
'# run resulting script.bat from recovery mode
repprefix = " Directory of " ' Modify to your language
sourcepath = "C:\Users.bak"
targetpath = "C:\Users"
altsourcepath = "D:\Users.bak"
alttargetpath = "D:\Users"
#!/usr/bin/env python
"""
SNMP helper for HAproxy implementing EXCELIANCE-MIB with
`pass_persist` protocol. Data are retrieved from multiple instances of
haproxy using HTTP.
"""
def toOid(oid):
"""Convert a string to tuple OID"""
@hurie
hurie / inarray_flipisset_arraysearch.php
Last active May 16, 2019 17:51 — forked from ksimka/inarray_flipisset_arraysearch.php
in_array vs array_flip+isset vs array_search
<?php
ini_set('memory_limit', '2G');
$numGen = function () {
return rand(1, 9999999);
};
$rs = str_repeat("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ", 10);
$strGen = function () {