Skip to content

Instantly share code, notes, and snippets.

View kangfend's full-sized avatar
🏠

Sutrisno Efendi kangfend

🏠
View GitHub Profile
@kangfend
kangfend / decrypt.py
Created June 22, 2022 23:43
Decrypt Codeigniter Encryption
from binascii import unhexlify
from hkdf import Hkdf
import hashlib
from base64 import b64decode
from Crypto.Cipher import AES
from Crypto.Util.Padding import unpad
@kangfend
kangfend / remove_duplicates.py
Created January 7, 2020 05:32 — forked from victorono/remove_duplicates.py
Django - remove duplicate objects where there is more than one field to compare
from django.db.models import Count, Max
unique_fields = ['field_1', 'field_2']
duplicates = (
MyModel.objects.values(*unique_fields)
.order_by()
.annotate(max_id=Max('id'), count_id=Count('id'))
.filter(count_id__gt=1)
)
@kangfend
kangfend / thai-id-card.py
Created October 19, 2018 08:12 — forked from bouroo/thai-id-card.py
Thai National ID Card reader in python
#!/usr/bin/env python3
# bouroo
# 27.09.2018
# sudo apt-get -y install pcscd python-pyscard python-pil
import binascii
import io
import os
import sys
from PIL import Image
import time
import re
import md5
import requests
INSTAGRAM_URL = "https://www.instagram.com"
USER_AGENT = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36"
def get_first_page(hashtag):
return requests.get(INSTAGRAM_URL + "/explore/tags/{}/".format(hashtag), headers={ "user-agent": USER_AGENT })
@kangfend
kangfend / gist:1e90caffb642cfa869266032860e1983
Created March 6, 2018 09:57 — forked from grandmanitou/gist:8863248
Place multiple markers with infowindow on Google Maps API v3, use external links to trigger click and center map on desired location.
<script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?language=fra&amp;sensor=false"></script>
<script type="text/javascript">
var map;
var Markers = {};
var infowindow;
var locations = [
[
'Samsung Store Madeleine',
'<strong>Samsung Store Madeleine</strong><p>5 Boulevard Malesherbes, 75008 Paris<br>10h – 20h</p>',
48.8701925,
@kangfend
kangfend / nginx-tuning.md
Created December 14, 2017 07:08 — forked from denji/nginx-tuning.md
NGINX tuning for best performance

Moved to git repository: https://github.com/denji/nginx-tuning

NGINX Tuning For Best Performance

For this configuration you can use web server you like, i decided, because i work mostly with it to use nginx.

Generally, properly configured nginx can handle up to 400K to 500K requests per second (clustered), most what i saw is 50K to 80K (non-clustered) requests per second and 30% CPU load, course, this was 2 x Intel Xeon with HyperThreading enabled, but it can work without problem on slower machines.

You must understand that this config is used in testing environment and not in production so you will need to find a way to implement most of those features best possible for your servers.

<table class="MsoNormalTable"
style="background:white;border-collapse:collapse"
cellspacing="0" cellpadding="0" border="0">
<tbody>
<tr>
<td style="border:none;border-left:solid #F8941C
2.25pt;padding:0in 0in 0in 6.0pt" valign="top">
<p class="MsoNormal"><span
style="font-size:11.5pt;font-family:&quot;Arial&quot;,sans-serif;color:#222222">Natasia Liu<o:p></o:p></span></p>
<p class="MsoNormal"><b><span
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright © 2016 Sutrisno Efendi <[email protected]>
# Auto download video from akhyar.tv
import argparse
import os
import re
import requests

Multiple MySQL Versions with Homebrew

For homebrew version 0.9.5.

brew -v # => Homebrew 0.9.5

Install the current version of mysql.

# Install current mysql version

brew install mysql

@kangfend
kangfend / beautiful_idiomatic_python.md
Created July 1, 2016 12:45 — forked from JeffPaine/beautiful_idiomatic_python.md
Transforming Code into Beautiful, Idiomatic Python: notes from Raymond Hettinger's talk at pycon US 2013. The code examples and direct quotes are all from Raymond's talk. I've reproduced them here for my own edification and the hopes that others will find them as handy as I have!

Transforming Code into Beautiful, Idiomatic Python

Notes from Raymond Hettinger's talk at pycon US 2013 video, slides.

The code examples and direct quotes are all from Raymond's talk. I've reproduced them here for my own edification and the hopes that others will find them as handy as I have!

Looping over a range of numbers

for i in [0, 1, 2, 3, 4, 5]: