Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@agners
agners / git_bash_prompt.sh
Created February 2, 2013 22:38
Git bash prompt
# Bash PS1 for Git repositories showing branch and relative path inside
# the Repository
# Reset
RESET="\[\033[0m\]"
# Regular Colors
BLACK="\[\033[0;30m\]"
RED="\[\033[0;31m\]"
GREEN="\[\033[0;32m\]"
@agners
agners / gist:5787602
Created June 15, 2013 10:00
WMA to MP3
#!/bin/bash -e
IN=$1
OUT=`echo "$IN"|sed -e 's/wma$/mp3/'`;
echo "Will convert from $IN to $OUT";
echo Extracting...
mplayer -ao pcm:waveheader:file=/tmp/audiodump.wav "$IN" 2>/dev/null > /tmp/taginfo;
echo Encoding...
lame --id3v2-only -m j -h --vbr-new -b 192 "/tmp/audiodump.wav" -o "/tmp/$OUT";
@agners
agners / bashrc
Created June 17, 2013 21:37
Arch Linux bashrc with Git shell prompt
# /etc/bash.bashrc
#
# https://wiki.archlinux.org/index.php/Color_Bash_Prompt
#
# This file is sourced by all *interactive* bash shells on startup,
# including some apparently interactive shells such as scp and rcp
# that can't tolerate any output. So make sure this doesn't display
# anything or bad things will happen !
# Test for an interactive shell. There is no need to set anything
@agners
agners / sort.c
Created November 2, 2013 23:11
quicksort/mergesort implementation in C
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ELEMENTS 100
void quicksort(int array[], int left, int right);
void mergesort(int array[], int length);
void printarray(int array[], int length)
@agners
agners / 25_windows_uefi
Created December 18, 2012 18:28
Adds Grub2 entries found on EFI system partition (/boot/efi)
#!/bin/sh
set -e
# Probe for UEFI entries in EFI system partition
prefix="/usr"
exec_prefix="${prefix}"
datarootdir="${prefix}/share"
export TEXTDOMAIN=grub
export TEXTDOMAINDIR="${datarootdir}/locale"
@agners
agners / container.go
Last active March 12, 2017 23:03 — forked from 17twenty/container.go
Containerisation in 100 Lines of Go Code
package main
import (
"fmt"
"os"
"os/exec"
"syscall"
)
func main() {
@agners
agners / main.c
Last active May 24, 2017 04:42 — forked from mlubin/newton.jl
i.MX 7 Cortex-M4 FreeRTOS C micro benchmark
#include <math.h>
#include "FreeRTOS.h"
#include "task.h"
#include "board.h"
#include "debug_console_imx.h"
double squareroot(double x)
{
double it = x;
while (fabs(it*it - x) > 1e-13) {
@agners
agners / update_bytecode_timestamps.py
Created January 28, 2019 15:12
Update Python3 bytecode timestamps
#!/usr/bin/python3
# Python scripts which reads all Python bytecode files (pyc) and clears
# the timestamp (set to 0)
# This is useful for OSTree which clears modification time of all source
# files. Processed bytecode files are then not considered stale anymore.
import sys, os
import marshal
import importlib.util
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import os
import sys
import time
import usb
ftdi_eval = {
'tty': "/dev/ttyUSB3",
@agners
agners / cp2102n-qfn20-gpio-ctrlep.py
Created May 28, 2021 17:31
Control CP2102N GPIO by using pyusb
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Author: Stefan Agner
import os
import sys
import time
import usb
CP210X_VENDOR_SPECIFIC = 0xFF