Skip to content

Instantly share code, notes, and snippets.

View nikoheikkila's full-sized avatar
🇺🇦
Stand with Ukraine

Niko Heikkilä nikoheikkila

🇺🇦
Stand with Ukraine
View GitHub Profile
@nikoheikkila
nikoheikkila / pseudo.h
Created August 6, 2012 11:00
C: Pseudo-code example
/* Pseudo code */
function buzz
{
print_number = false
loop i from 1 to 100
{
print_number = true
@nikoheikkila
nikoheikkila / formuploader.js
Created August 20, 2012 08:06
NodeJS: Asynchronous programming in modules
/**
* formuploader.js via callbackhell.com
*/
function formSubmit(submitEvent) {
/* Get value from input field */
var name = document.querySelector('input').value;
/* Send a request with postResponse() as a callback */
@nikoheikkila
nikoheikkila / vpn.txt
Created January 1, 2013 14:43
HMA VPN Servers
##############################################################################
#### ####
#### HMA VPN Servers ####
#### Location, IP address and response time (ms) ####
#### ####
##############################################################################
--- USA ---
New York, Manhattan (LOC1 S3) 173.234.233.226 125 ms
New York, Manhattan (LOC1 S4) 173.208.45.130 125 ms
@nikoheikkila
nikoheikkila / screen_guard.py
Created January 22, 2013 16:19
Check if GNU screen is running, else send a message via Pushover API and store time in a log file.
import httplib, sys, urllib
from datetime import date, datetime, strftime
from screenutils import list_screens, Screen
def push_message(token, key, msg=""):
"""
Send a notification via Pushover API
This function uses Python 2. For Python 3 replace
httplib with http.client and urlencode with urllib.parse
"""
@nikoheikkila
nikoheikkila / telemarketer.py
Created January 29, 2013 21:02
Python: Lookup telemarketers from the blacklist
#!/usr/bin/python
# -*- coding: utf-8 -*-
##############################################################################
# #
# Lookup telemarketers from the blacklist #
# By: Niko Heikkilä, 2013 under GNU GPLv3 #
# http://www.gnu.org/licenses/gpl.html #
# #
# Blacklist provided by Amigazone.fi and may change without prior notice. #
@nikoheikkila
nikoheikkila / main.py
Created May 25, 2013 09:26
Python: general main() function
"""Module docstring
This is a placeholder for a long usage message.
"""
import sys
import getopt
def process(arg):
@nikoheikkila
nikoheikkila / fizzbuzz.sh
Created June 4, 2013 13:54
Bash: typical program
#!/usr/bin/env bash
# FizzBuzz
#
# Take and print numbers between 1 and 100.
# When a number is divisible by 3, print "Fizz".
# When it is divisible by 5, print "Buzz".
# When it is divisible both by 5 and 3, print "FizzBuzz".
function isDivisibleBy
@nikoheikkila
nikoheikkila / dosbox-0.74.conf
Created August 30, 2013 17:18
DOSBox 0.74 configuration
# This is the configurationfile for DOSBox 0.74. (Please use the latest version of DOSBox)
# Lines starting with a # are commentlines and are ignored by DOSBox.
# They are used to (briefly) document the effect of each option.
[sdl]
# fullscreen: Start dosbox directly in fullscreen. (Press ALT-Enter to go back)
# fulldouble: Use double buffering in fullscreen. It can reduce screen flickering, but it can also result in a slow DOSBox.
# fullresolution: What resolution to use for fullscreen: original or fixed size (e.g. 1024x768).
# Using your monitor's native resolution with aspect=true might give the best results.
# If you end up with small window on a large screen, try an output different from surface.
@nikoheikkila
nikoheikkila / pyfibot.yml
Last active December 27, 2015 20:39
YAML: Example config for PyFiBot IRC bot
# Bot nickname on IRC channels
nick: 'pyfibot'
# Host identifiers for admin privileges
# Format: nick!user@example.com
admins:
- 'nick!user@example.com'
- '*!user@*.example.com'
# List of IRC networks for bot to join
@nikoheikkila
nikoheikkila / build.sh
Last active March 19, 2016 12:42
Bash: Upgrade WeeChat
#!/bin/bash -eu
#
# build.sh
#
# Builds the development version WeeChat with CMake
# Place this script in the build directory of WeeChat
# @author Niko Heikkilä <yo@nikoheikkila.com>
# Paths
ROOTDIR=$HOME/weechat