Skip to content

Instantly share code, notes, and snippets.

View bittorf's full-sized avatar

Bastian Bittorf bittorf

View GitHub Profile
@bittorf
bittorf / ls.c
Created May 8, 2021 15:36 — forked from svdamani/ls.c
Simple ls command implementation in C
#include <stdio.h>
#include <dirent.h>
#include <string.h>
#define GREEN "\x1b[32m"
#define BLUE "\x1b[34m"
#define WHITE "\x1b[37m"
void Usage() {
fprintf(stderr, "\nUsage: exec [OPTION]... [DIR]...\n");
@bittorf
bittorf / base64.sh
Created January 26, 2019 20:04 — forked from markusfisch/base64.sh
base64 fallback implementation in bash
#!/bin/bash
# Fallback base64 en-/decoder for systems that lack a native implementation
#
# @param ... - flags
which base64 &>/dev/null || {
# if even od is missing
which od &>/dev/null || od()
{
local C O=0 W=16
@bittorf
bittorf / GPL.md
Created October 23, 2015 15:45 — forked from jnrbsn/GPL.md
A Markdown-formatted GPL for your GitHub projects.

GNU GENERAL PUBLIC LICENSE

Version 3, 29 June 2007

Copyright © 2007 Free Software Foundation, Inc. <http://fsf.org/>

Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed.

#!/bin/sh
# detect, of we have already added an alias,
# if not, do it:
. /lib/functions.sh
config_load network
alread_added()
{
@bittorf
bittorf / bst.sh
Last active July 26, 2016 08:40 — forked from iestynpryce/bst.sh
#!/bin/bash
#
# Binary search tree is of the form:
# 10
# / \
# / \
# 4 16
# / \ /
# 1 7 12
#
find_mtd_index()
{
local partition_name="$1" # e.g. u-boot
local line mtd_dev number
line="$( grep "\"$partition_name\""$ /proc/mtd )"
mtd_dev="${line%%:*}"
number="${mtd_dev##mtd}"
echo "$number"
@bittorf
bittorf / .profile fragment
Created June 25, 2012 16:11 — forked from jcamenisch/.profile fragment
Lightning-fast project-wide find/replace with git grep and sed
gg_replace() {
if [[ "$#" == "0" ]]; then
echo 'Usage:'
echo ' gg_replace term replacement file_mask'
echo
echo 'Example:'
echo ' gg_replace cappuchino cappuccino *.html'
echo
else
find=$1; shift
root@box:~ cat /etc/config/wireless
config wifi-device radio0
option type mac80211
option country US
option txpower 10
option channel 1
option macaddr 68:7f:74:0a:21:54
option frag off
option hwmode 11g