Skip to content

Instantly share code, notes, and snippets.

View nikoheikkila's full-sized avatar
:electron:
Nice to meet you!

Niko Heikkilä nikoheikkila

:electron:
Nice to meet you!
View GitHub Profile
@nikoheikkila
nikoheikkila / utils.js
Created September 1, 2011 08:48
Javascript: Utility library
/**
* utils.js
*
* @author Niko Heikkilä (@ytserman) <http://scr.im/ytserman>
*
* Contains several utility functions for cross-browser compatibility.
* Drop this into your javascript folder and call before other scripts.
*
*/
function createRequest() {
@nikoheikkila
nikoheikkila / hwmodule.py
Created February 18, 2012 18:04
Python: hwmodule-0.1
import os, sys, hashlib
# -*- coding: utf-8 -*-
def encryptMAC(address):
''' Generate MD5 checksum from unicode physical address '''
try:
# Calculate checksum
print("Calculating, please wait...", end="\n")
checksum = hashlib.md5(address.encode('utf-8'))
@nikoheikkila
nikoheikkila / index.html
Created March 6, 2012 21:56
HTML5: Basic Template
<!doctype html>
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7" lang="en"> <![endif]-->
<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8" lang="en"> <![endif]-->
<!--[if IE 8]> <html class="no-js lt-ie9" lang="en"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en"> <!--<![endif]-->
<head>
<!-- Headers and title text -->
<meta charset="utf-8">
<title>
@nikoheikkila
nikoheikkila / printr.py
Created March 7, 2012 13:56
Python: Recursive printer for lists
#################################################################
# #
# PRINTR.PY #
# #
# Advanced printing for python terminal or file handling #
# Homepage: http://pypi.python.org/pypi/printr #
# #
#################################################################
import sys
@nikoheikkila
nikoheikkila / curl.wrapper.php
Created March 7, 2012 14:26
PHP: cURL Wrapper with traits
<?php
/**
* cURL Wrapper trait for PHP => 5.4
*
* Contains several API classes which uses this trait
*/
trait curl
{
@nikoheikkila
nikoheikkila / pdo_mysql.php
Created April 9, 2012 20:25
PHP: Using PDO_MYSQL driver
<?php
/**
* Example script for using PDO and MySQL
* Requires PHP >= 5.1
*
* @author Niko Heikkilä
* @version 1.0
*/
@nikoheikkila
nikoheikkila / cdb_example.py
Created April 24, 2012 19:59
Python: CouchDB example
"""
cdb_example.py
CouchDB example script
API documentation: http://packages.python.org/CouchDB/getting-started.html
"""
import sys
import couchdb
@nikoheikkila
nikoheikkila / sendmail.sh
Created June 28, 2012 09:52
Bash: Send mail from command-line
#!/bin/bash
# Send a simple mail from shell with this script
# Niko Heikkila 2012
TO=$1
SUBJECT=$2
MSG=$3
BODY=$HOME/message.tmp
@nikoheikkila
nikoheikkila / PasswordHash.class.php
Created June 29, 2012 22:04
PHP: Utility class for hashing password securely
<?php
/**
* Utility class for hashing password securely
* (source material from Net Tuts+)
*
* @author Niko Heikkilä
* @version 1.0
*/
@nikoheikkila
nikoheikkila / bzcomp.sh
Created July 12, 2012 18:05
Bash: Bzip2 compress given files in directory
#!/bin/bash
#
# bzcomp
# Bzip2 compress given files in directory
#
# Example usage: bzcomp logs/ '*.log' 4
#
# Author: Niko Heikkilä
# Version: 1.0.1
#