Skip to content

Instantly share code, notes, and snippets.

@niun
niun / git-extract-file.markdown
Created November 13, 2015 14:35 — forked from ssp/git-extract-file.markdown
Extract a single file from a git repository

How to extract a single file with its history from a git repository

These steps show two less common interactions with git to extract a single file which is inside a subfolder from a git repository. These steps essentially reduce the repository to just the desired files and should performed on a copy of the original repository (1.).

First the repository is reduced to just the subfolder containing the files in question using git filter-branch --subdirectory-filter (2.) which is a useful step by itself if just a subfolder needs to be extracted. This step moves the desired files to the top level of the repository.

Finally all remaining files are listed using git ls, the files to keep are removed from that using grep -v and the resulting list is passed to git rm which is invoked by git filter-branch --index-filter (3.). A bit convoluted but it does the trick.

1. copy the repository to extract the file from and go to the desired branch

@niun
niun / time-from-internet.sh
Created July 15, 2016 17:19
show time from Internetz in shell, iso-8601
curl -G -s --data-urlencode "format=%FT%T%:z" http://www.timeapi.org/cet/now # www.timeapi.org cet is CET/CEST. Don't use cest
date --iso-8601='seconds' -d "$(curl -s http://www.timeapi.org/utc/now)" # www.timeapi.org use local timezone settings
date -d "$(curl -s http://www.timeapi.org/utc/now)" +"%FT%T (UTC%:z = %Z)" # not quite ISO with timezone illustration
date -d "$(curl -s http://www.timeapi.org/utc/now)" +"%A %d.%m.%Y, %T (UTC%:z = %Z)" # non-ISO, easy readable by a german with day of week
date --iso-8601='seconds' -d "$(curl -s --head http://google.com | grep ^Date: | sed 's/Date: //g')" # google.com
date --iso-8601='seconds' -d "$(cat </dev/tcp/time.nist.gov/13 | cut -d' ' -f2,3) UTC" # NIST
date --iso-8601='seconds' -d "$(cat </dev/tcp/de.pool.ntp.org/13)" # ntp pool project
@niun
niun / esp8266-03-result.md
Last active January 20, 2018 15:15
Test ESP8266 AT commandos

Connected to my ESP8266-ESP-03 with following baudrate settings

BAUD = 9600
BOOT_BAUD = 115200

esp8266_at_test.py prints this:

PINGING esp8266...
> AT

>