Skip to content

Instantly share code, notes, and snippets.

View nibb13's full-sized avatar

Arthur Makhonko nibb13

View GitHub Profile
@nibb13
nibb13 / http-sh-tricks.txt
Created February 25, 2017 13:11
Some HTTP handling tricks in shell
# Получение параметра lang из GET query string:
LANG=$(echo "$QUERY_STRING" | sed -n 's/^.*lang=\([^&]*\).*$/\1/p' | sed "s/%20/ /g")
# Установка cookie (Внимание! Опции -en могут отсутствовать в вашем echo):
COOKIE="Set-cookie: lang=$LANG; expires=Thursday, 01-Jan-9999 12:00:00 GMT\n"
echo -en "Content-Type: text/html; charset=UTF-8\r\n"
echo -en "$COOKIE\r\n"
echo -en "\r\n"
# Установка cookie (printf-версия, portable):
@nibb13
nibb13 / router_temp.txt
Last active July 13, 2017 15:33
Get temperature on router
echo T=$((`wl -i eth1 phy_tempsense|awk {' print $1 '}`/2+20))
@nibb13
nibb13 / runonce.sh.txt
Created August 26, 2017 18:37
Here's an approach that combines atomic directory locking with a check for stale lock via PID and restart if stale. Also, this does not rely on any bashisms.
#!/bin/sh
#ref: http://stackoverflow.com/a/25243837
SCRIPTNAME=$(basename $0)
LOCKDIR="/var/lock/${SCRIPTNAME}"
PIDFILE="${LOCKDIR}/pid"
if ! mkdir $LOCKDIR 2>/dev/null
then

If you have a low # of commits and you don't care if these are combined into one mega-commit, this works well:

unstage the files (replace 1 with # of commits)

git reset --soft HEAD~1

create a new branch

git checkout -b NewBranchName

//
//"Часы с кукушкой" на GenTee (http://www.gentee.ru)
//Идея с http://bash.org.ru
//Made by nibb13 (nibble@list.ru)
//Распространяются по GNU GPL =)
//
//!!!Работает скрыто, закрывается ручным убийством процесса!!!
//
import "kernel32.dll"{