Skip to content

Instantly share code, notes, and snippets.

View chris-piekarski's full-sized avatar
🎯
Focusing

Christopher Piekarski chris-piekarski

🎯
Focusing
  • Boulder, CO
  • 00:52 (UTC)
View GitHub Profile
@chris-piekarski
chris-piekarski / basic_file_nano_template
Last active November 26, 2018 22:57
Using NanoHTTPD in Android
Add your index.html file to res/raw
Add dep to app gradle file:
dependencies {
implementation 'org.nanohttpd:nanohttpd-webserver:2.3.1'
}
Java class file:
import fi.iki.elonen.NanoHTTPD;
@chris-piekarski
chris-piekarski / gist:78284318cbad31d7fb92f8200213cec9
Created August 24, 2018 20:49
GPLv2 Git Patch Sharing Stripper
#create patches from author(s) into one without comments
#good for GPLv2 sharing
for c in `git log --format=format:%H --author=chris`;do git format-patch --stdout --format=format:%H --no-stat -1 $c;done | tee stuff.patch
@chris-piekarski
chris-piekarski / bash_pic_convert
Created April 22, 2018 03:30
Convert images to 720p
for f in ./*.*;do convert -resize 1280x720 $f ./720p/$f; done
@chris-piekarski
chris-piekarski / repo_grep_logs_by_author
Last active February 27, 2018 19:08
Grep all AOSP repos commit messages by author
repo forall -c git log --grep="partition" --author=Chris
repo forall -c 'echo $REPO_PATH; git log --grep "partition" --author=Chris'
@chris-piekarski
chris-piekarski / git_pull_sub_repos
Last active May 28, 2019 16:24
Git Pull Multiple Subdirectory Repos
find . -maxdepth 1 -type d \( ! -name . \) -exec bash -c "cd '{}' && git pull" \;
@chris-piekarski
chris-piekarski / cli_vs_filereader
Created February 1, 2017 23:13
Android read file types
//1ms but uses file cache so not updated quickly
try {
String inputLine;
FileReader file = new FileReader("/sys/class/power_supply/battery/current_now");
BufferedReader bufferedReader = new BufferedReader(file);
inputLine = bufferedReader.readLine();
text = inputLine;
bufferedReader.close();
file.close();
} catch (Exception e) {
@chris-piekarski
chris-piekarski / aosp_app_start_profiler
Last active January 31, 2022 10:25
Android app startup profiler
From AOSP page:
"Analyzing app startup time
Use $ adb shell am start with the -P or --start-profiler option to run the profiler when your app starts.
This will start the profiler almost immediately after your process is forked from zygote, before any of your code is loaded into it."
@chris-piekarski
chris-piekarski / aosp_context_from_any_class
Created May 15, 2015 19:16
Static Application Context Method
In Android Manifest file declare following
<application android:name="com.xyz.MyApplication">
</application>
then write the class
public class MyApplication extends Application{
private static Context context;
@chris-piekarski
chris-piekarski / multi_thread_web_server
Last active May 1, 2017 01:59
Twisted - Python Multi Threaded Web Server
from twisted.web import server, resource
from twisted.internet import reactor, endpoints
class Counter(resource.Resource):
isLeaf = True
numberRequests = 0
def render_GET(self, request):
self.numberRequests += 1
request.setHeader("content-type", "text/plain")
@chris-piekarski
chris-piekarski / nmap_scripts_unspecific
Last active August 29, 2015 14:17
Nmap Pearl Scripts
http://www.unspecific.com/nmap/
vi nmap-wrapper.pl --> add $opt_d=3
$ sudo ./bin/nmap-wrapper.pl -v -l 10.0.0.0/24
$ nmap-search.pl -f ./20150320.10.0.0.gnmap port 80
$ nmap-report.pl -p80 -v
#html output
#nmap has a built in xslt stylsheet in xml output, convert to html