Skip to content

Instantly share code, notes, and snippets.

View tobiassjosten's full-sized avatar

Tobias Sjösten tobiassjosten

View GitHub Profile
@henrikbjorn
henrikbjorn / RelDate.php
Created December 5, 2011 08:01 — forked from arnaud-lb/RelDate.php
4 lines relative date formatter with DateInterval and Symfony2 Translator
<?php
use Symfony\Component\Translation\TranslatorInterface;
function format(\DateTime $date, TranslatorInterface $translator)
{
$diff = date_create()->diff($date);
$seconds = $diff->days * 86400 + $diff->h * 3600 + $diff->i * 60 + $diff->s;
$format = $translator->transChoice('reldate', $seconds);
@dickolsson
dickolsson / puppet-provisioner
Last active October 10, 2015 19:58
Puppet bootstrap script for Ubuntu servers.
#!/bin/bash
# Puppet bootstrapping. Currently only supports Ubuntu 12.04.
#
# TODO:
# - Make idempotent
# - Support Ubuntu 10.04 and Debian 6
version_os=`expr match "$(lsb_release -c)" '.*\<\(.*\)$'`
version_stdlib=03ec16e291a70ac5ac412be36ae3b86a771b98af
@azizur
azizur / Creating a static copy of a dynamic website.md
Last active February 19, 2025 16:22
Creating a static copy of a dynamic website

The command line, in short…

wget -k -K -E -r -l 10 -p -N -F --restrict-file-names=windows -nH http://website.com/

…and the options explained

  • -k : convert links to relative
  • -K : keep an original versions of files without the conversions made by wget
  • -E : rename html files to .html (if they don’t already have an htm(l) extension)
  • -r : recursive… of course we want to make a recursive copy
  • -l 10 : the maximum level of recursion. if you have a really big website you may need to put a higher number, but 10 levels should be enough.
pipeline {
agent any
options {
disableConcurrentBuilds()
timeout(time: 30, unit: 'MINUTES')
}
environment {
PATH = "vendor/bin:/var/lib/jenkins/.composer/vendor/bin:$PATH"
@premek
premek / mv.sh
Last active March 5, 2024 17:43
Rename files in linux / bash using mv command without typing the full name two times
# Put this function to your .bashrc file.
# Usage: mv oldfilename
# If you call mv without the second parameter it will prompt you to edit the filename on command line.
# Original mv is called when it's called with more than one argument.
# It's useful when you want to change just a few letters in a long name.
#
# Also see:
# - imv from renameutils
# - Ctrl-W Ctrl-Y Ctrl-Y (cut last word, paste, paste)
%matplotlib qt
import pyaudio
import numpy as np
import matplotlib.pyplot as plt
from queue import Queue
import threading
import time
from IPython.display import display, clear_output