Skip to content

Instantly share code, notes, and snippets.

Avatar

Christopher Piekarski chris-piekarski

View GitHub Profile
@chris-piekarski
chris-piekarski / tag_aosp_repo
Created Jun 27, 2013
How to tag AOSP using repo
View tag_aosp_repo
repo forall -c 'git tag spectralink_sprint_8'
repo forall -c 'git push ssh://cpiekarski@tinfoil:29418/$REPO_PROJECT --tags'
View gerrit_git_push_config
$ cat .git/config
...
[remote "for-a-exp"]
url = tr:kernel/common
receivepack = git receive-pack --reviewer=a@a.com --cc=b@o.com
push = HEAD:refs/for/experimental
$ git push for-a-exp
@chris-piekarski
chris-piekarski / go_html_page_serve
Created Jul 16, 2013
Serve up html page from Go
View go_html_page_serve
func goHandler(w http.ResponseWriter, r *http.Request) {
if r.Method == "POST" {
fmt.Print("Got a POST")
}
body, _ := ioutil.ReadFile("mag.html")
w.Write(body)
}
@chris-piekarski
chris-piekarski / kill_all_by_name
Last active Dec 20, 2015
Kill all procs by name
View kill_all_by_name
kill `ps ax | grep chrome | grep -v 'grep' | cut -f1 -d' ' -s`
#test -> check if -f 1 or -f 2
ps ax | grep rake | grep -v 'grep' | cut -d ' ' -f 2
View android_config.xml
Add res/values/config.xml
<resources>
<bool name="config_hardwareAccelerated">true</bool>
<bool name="config_largeHeap">false</bool>
<bool name="is_large_screen">false</bool>
<bool name="allow_rotation">false</bool>
</resources>
Get values with:
@chris-piekarski
chris-piekarski / android_io
Created Aug 31, 2013
Android Read/Write External Storage
View android_io
//From AOSP Doc
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
/* Checks if external storage is available for read and write */
public boolean isExternalStorageWritable() {
String state = Environment.getExternalStorageState();
if (Environment.MEDIA_MOUNTED.equals(state)) {
return true;
}
@chris-piekarski
chris-piekarski / confusion
Created Sep 5, 2013
Nebulous Definitions
View confusion
"The point here is that a lot of terms are thrown around in this industry, and not everyone
uses them properly. Additionally, as in this case, the definitions may be nebulous; this,
of course, leads to confusion." - Network Warrior page 2
View gist:6617285
The exec command is not implemend by default for init.rc despite what the readme.txt says. Add the following to get it working.
file: android/system/core/init/builtins.c
int do_exec(int nargs, char **args)
{
const int cmd_line_max = 256;
char cmd_line[cmd_line_max];
int cmd_length, i;
@chris-piekarski
chris-piekarski / java_sha1_string
Last active Dec 24, 2015
Hash a String using SHA-1 and return hash as String
View java_sha1_string
private static String getSha1Hash(String value) {
MessageDigest digester = null;
String sha1Value = null;
try {
digester = MessageDigest.getInstance("SHA-1");
digester.update(value.getBytes("UTF-8"), 0, value.length());
byte[] sha1hash = digester.digest();
StringBuilder sb = new StringBuilder();
for( byte b : sha1hash )
{
View no_nsa
Blowfish in CFB
---- exchange password with bob ------>
export PASSWORD=no_nsa
echo "hello, bob!" > plaintext.doc
openssl bf-cfb -salt -in plaintext.doc -out ciphertext.bin -pass env:PASSWORD
openssl base64 -in ciphertext.bin -out base64.txt
---- send to bob ----->