Skip to content

Instantly share code, notes, and snippets.

function hak_image_id() {
global $hak_thisimage;
if($hak_thisimage) {
return $hak_thisimage['id'];
}
}
function hak_thumbnail_url() {
global $hak_thisimage, $img_dir;
if (!empty($hak_thisimage["thumbnail"])) {
$out= hu.$img_dir.'/'.$id.'t'.$ext;
return $out;
}
}
@hakjoon
hakjoon / smarttabs.el
Last active September 26, 2015 12:17 — forked from jacius/smarttabs.el
Emacs smart tabs - indent with tabs, align with spaces!
;;
;; Emacs smart tabs functionality
;; Intelligently indent with tabs, align with spaces!
;;
;; Note: Indenting only uses tabs when indent-tabs-mode is non-nil,
;; otherwise it uses spaces as usual.
;;
;; To use: save as smarttabs.el in your .emacs.d directory, and add
;; "(require 'smarttabs)" to your .emacs file.
;;
@hakjoon
hakjoon / gist:1236686
Created September 23, 2011 03:30
Conditional CSV
<?PHP
$read = fopen("in.csv", "r");
$write = fopen("out.csv", "w");
while (!feof($read) ) {
$line = fgetcsv($read, 1024);
if ($line[2] == "what I want") {
@hakjoon
hakjoon / gist:1336655
Last active September 27, 2015 21:48
Upgrade VBox guest additions
# On Vagrant Box
wget -c \
http://download.virtualbox.org/virtualbox/4.1.12/VBoxGuestAdditions_4.1.12.iso \
-O VBoxGuestAdditions_4.1.12.iso
sudo mount VBoxGuestAdditions_4.1.12.iso -o loop /mnt
sudo sh /mnt/VBoxLinuxAdditions.run --nox11
rm *.iso
@hakjoon
hakjoon / flymake.el
Created November 9, 2011 03:47
Flymake with Info Support
;;; flymake.el -- a universal on-the-fly syntax checker
;; Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009
;; Free Software Foundation, Inc.
;; Author: Pavel Kobyakov <pk_at_work@yahoo.com>
;; Maintainer: Pavel Kobyakov <pk_at_work@yahoo.com>
;; Version: 0.3
;; Keywords: c languages tools
# Source: https://gist.github.com/4702275
#
# All-purpose gist tool for Pythonista.
#
# When run directly, this script sets up four other scripts that call various
# functions within this file. Each of these sub-scripts are meant for use as
# action menu items. They are:
#
# Set Gist ID.py - Set the gist id that the current file should be
# associated with.
@hakjoon
hakjoon / pg_perms.txt
Last active August 29, 2015 14:02
PostgreSQL Django permissions for dev
CREATE USER username WITH PASSWORD 'myPassword';
CREATE DATABASE dbname;
GRANT ALL PRIVILEGES ON DATABASE dbname TO username;
ALTER USER username CREATEDB;
@hakjoon
hakjoon / pyclean.sh
Last active August 29, 2015 14:03
Remove .pyc
#!/bin/bash
pyclean() {
find . -name "*.pyc" -delete
find . -type d -empty -delete
}
@hakjoon
hakjoon / filtered_dict.py
Created October 20, 2015 14:04
Filtered Dictionary without None values
def filtered_dict(d, keys):
return {key: d[key] for key in keys if d.get(key) is not None}