Skip to content

Instantly share code, notes, and snippets.

Avatar

Bastian Bittorf bittorf

View GitHub Profile
View alias_already_added?
#!/bin/sh
# detect, of we have already added an alias,
# if not, do it:
. /lib/functions.sh
config_load network
alread_added()
{
View gist:1824950
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
@bittorf
bittorf / .profile fragment
Created Jun 25, 2012 — forked from jcamenisch/.profile fragment
Lightning-fast project-wide find/replace with git grep and sed
View .profile fragment
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
View gist:4274979
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 / GPL.md
Created Oct 23, 2015 — forked from jnrbsn/GPL.md
A Markdown-formatted GPL for your GitHub projects.
View GPL.md

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.

View bst.sh
#!/bin/bash
#
# Binary search tree is of the form:
# 10
# / \
# / \
# 4 16
# / \ /
# 1 7 12
#
@bittorf
bittorf / base64.sh
Created Jan 26, 2019 — forked from markusfisch/base64.sh
base64 fallback implementation in bash
View base64.sh
#!/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 / ls.c
Created May 8, 2021 — forked from svdamani/ls.c
Simple ls command implementation in C
View ls.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");