Skip to content

Instantly share code, notes, and snippets.

View lqez's full-sized avatar
:octocat:
Doing something on net

Hyunwoo Park lqez

:octocat:
Doing something on net
View GitHub Profile
@lqez
lqez / admin.py
Last active August 29, 2015 14:00 — forked from elidickinson/admin.py
Using summernote in django flatpages.
from django.contrib import admin
from django.contrib.flatpages.models import FlatPage
# Note: we are renaming the original Admin and Form as we import them!
from django.contrib.flatpages.admin import FlatPageAdmin as FlatPageAdminOld
from django.contrib.flatpages.admin import FlatpageForm as FlatpageFormOld
from django import forms
from django_summernote.widgets import SummernoteWidget
@lqez
lqez / gist:5705167
Created June 4, 2013 11:06
Counting size of image files with grouping.
find -E . -regex '.*\.(jpg|png)' -exec identify {} \; | cut -d ' ' -f 3 | sort -nr | uniq -c
@lqez
lqez / gist:5295389
Created April 2, 2013 19:25
Example of calling function every N seconds precisely.
import threading
import time
import psutil
import os
from datetime import datetime
def precise_repeat(f, interval=1.0, run=False):
delay = interval - (time.time() % interval)
threading.Timer(delay, precise_repeat, (f, interval, True)).start()
@lqez
lqez / nicecoder.py
Last active December 13, 2015 17:58
Dict <-> String parser for NICE - KOREA INFORMATION SERVICE
#
# Dict <-> String parser for NICE - KOREA INFORMATION SERVICE (sigh)
#
# [email protected]
#
from itertools import izip
def encode(d):
res = []
@lqez
lqez / gist:3999191
Last active October 12, 2015 08:28
Sentry bot to warn SSL certificates expirations.
#!/usr/bin/python
# -*- coding:utf-8 -*-
# Park Hyunwoo <[email protected]>
#
# You can download ssl-cert-check from http://prefetch.net/articles/checkcertificate.html
#
import smtplib
import email
import os
@lqez
lqez / gist:3944436
Created October 24, 2012 06:47
An overview of new features and changes in Redis 2.6.x
An overview of new features and changes in Redis 2.6.x
======================================================
* Server side Lua scripting, see http://redis.io/commands/eval
* Virtual Memory removed (was deprecated in 2.4)
* Hardcoded limits about max number of clients removed.
* AOF low level semantics is generally more sane, and especially when used in slaves.
* Milliseconds resolution expires, also added new commands with milliseconds precision (PEXPIRE, PTTL, ...).
* Better memory usage for "small" lists, ziplists and hashes when fields or values contain small integers.
* Read only slaves.
@lqez
lqez / gist:3698667
Created September 11, 2012 13:54
Modification on iScroll
/* 1. Add preventThreshold in default options and disable preventDefault, about 65L */
that.options = {
/* ... */
preventThreshold: 3,
/* ... */
onBeforeScrollStart: function (e) { /*e.preventDefault();*/ },
/* ... */
};
@lqez
lqez / gist:3698579
Created September 11, 2012 13:44
a little bit modified version of jquery.touchToClick.js
/*
* Author: cargomedia.ch
*
* Binds 'touchstart' when binding $.on('click')
* and triggers 'click' when 'touchend' happens without 'touchmove' inbetween.
*/
(function($) {
if (!("ontouchstart" in window)) {
return;
}
@lqez
lqez / gist:3656474
Created September 6, 2012 13:52
a quick and dirty way to help dull django cache framework
from django.core.cache import cache
"""
a quick and dirty way to help dull django cache framework
Stores another copy of cache value with longer timeout value.
So, this will prevent multiple instances create a new copy of cache at same time.
Usage : Import this instead of 'django.core.cache'
and use your cache-related codes without any changes.
@lqez
lqez / gist:3368666
Created August 16, 2012 09:13
SAMPLE : webtoon admin.py
from webtoon.models import *
from django.contrib import admin
class AuthorAdmin(admin.ModelAdmin):
list_display = ('name', 'desc')
admin.site.register(Author, AuthorAdmin)
class ComicAdmin(admin.ModelAdmin):
list_display = ('title', 'author', 'desc')
admin.site.register(Comic, ComicAdmin)