Skip to content

Instantly share code, notes, and snippets.

View kalmanolah's full-sized avatar

Kalman Olah kalmanolah

View GitHub Profile
@kalmanolah
kalmanolah / nowplaying.py
Last active August 29, 2015 14:09
Python3 script for showing what's currently playing. Currently supports mpd (with ncmpcpp) and spotify.
#!/usr/bin/env python3
"""
This script prints some info about the currently playing song, in a pretty way.
@author Kalman Olah
"""
import cgi
import dbus
import shlex
@kalmanolah
kalmanolah / pdoc.py
Last active August 29, 2015 14:06
pdoc - a puppet documentation generator thingy
#!/usr/bin/env python3
# @python3
# @author Kalman Olah <[email protected]>
"""pdoc - a puppet documentation generator thingy."""
import os
import re
import fnmatch
import click
from datetime import datetime

Keybase proof

I hereby claim:

  • I am kalmanolah on github.
  • I am kalman (https://keybase.io/kalman) on keybase.
  • I have a public key whose fingerprint is 70E8 BDAD B2D5 3F2C 1B05 CF52 546B 0CF0 E442 45DD

To claim this, I am signing this object:

@kalmanolah
kalmanolah / ftp_helper.php
Created April 16, 2014 07:41
Real ugly PHP function for uploading file contents via FTP or SFTP
<?php
function uploadFileContentsViaFtp(
$sftp = false,
$host,
$port,
$user,
$password,
$folder,
$file_name,
$file_contents
@kalmanolah
kalmanolah / generate_color.js
Created March 17, 2014 12:49
A color generator which allows mixing with white to produce colors that are pleasing to the eye.
function generateColor(mix, mixColor) {
if (!mixColor) {
mixColor = {
red: 255,
green: 255,
blue: 255
};
}
var red = Math.floor((Math.random()*256)),
@kalmanolah
kalmanolah / puppet-prep.sh
Created January 17, 2014 23:44
Bash script for installing and running the latest version of puppet on a machine running debian wheezy.
#!/bin/bash
# Bash script for installing and running the latest version
# of puppet on a machine running debian wheezy
# Set some variables
puppet_server="puppet.example.com"
sleep_time="120"
# Add PuppetLabs repo
cat > /etc/apt/sources.list.d/puppetlabs.list << EOL
@kalmanolah
kalmanolah / time_format.js
Last active January 2, 2016 17:18
A little javascript snippet for formatting times in seconds.
function formatTime(secs, format) {
if (!format) {
format = '%hh %mm %ss';
}
var hours = ("0" + Math.floor(secs / 3600)).slice(-2),
minutes = ("0" + Math.floor((secs % 3600) / 60)).slice(-2),
seconds = ("0" + (secs % 60)).slice(-2);
return format
@kalmanolah
kalmanolah / postgrayskull.bash
Created December 20, 2013 22:18
The alias He-Man would use to work with PostgreSQL. Comes with autocompletion.
#!/bin/bash
# What if He-Man used Postgres?
_he_man_autocomplete() {
COMPREPLY=("the Power of postGRESQL...")
return 0
}
By() {
if [[ $EUID -ne 0 ]]; then
@kalmanolah
kalmanolah / foreman-prep.sh
Created November 30, 2013 06:51
Script for installing the Foreman installer with the latest version of puppet from the puppetlabs repo.
#!/bin/bash
# Foreman repo
echo "deb http://deb.theforeman.org/ wheezy 1.3" > /etc/apt/sources.list.d/foreman.list
wget -q http://deb.theforeman.org/foreman.asc -O- | apt-key add -
# PuppetLabs repo
cat > /etc/apt/sources.list.d/puppetlabs.list << EOL
deb http://apt.puppetlabs.com wheezy main devel dependencies
deb-src http://apt.puppetlabs.com wheezy main devel dependencies
@kalmanolah
kalmanolah / TranslationExtension.php
Created November 25, 2013 10:43
Twig extension for translating arrays in Symfony2. Works just like the regular 'trans' filter, but takes an array as input instead.
<?php
namespace Your\ExampleBundle\Twig;
use Symfony\Component\Translation\TranslatorInterface;
/**
* Twig extension for translating arrays in Symfony2
* Works just like the regular 'trans' filter, but takes an array as input instead
*
* your.examplebundle.translation_extension: