Skip to content

Instantly share code, notes, and snippets.

View eyecatchup's full-sized avatar

Stephan Schmitz eyecatchup

View GitHub Profile
server {
server_name $domain_name;
root /var/www;
index index.html index.php;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
# Cache static files for as long as possible
location ~* \.(?:xml|ogg|mp3|mp4|ogv|svg|svgz|eot|otf|woff|ttf|css|js|jpg|jpeg|gif|png|ico)$ {
try_files $uri =404;
html, body {
height:100%;
}
#container {
height:100%;
overflow: hidden;
display: table;
}
@eyecatchup
eyecatchup / meta-viewport-ios7.js
Created March 11, 2014 14:24
JavaScript snippet to customize the meta viewport tag for iOS 7 (as referenced here http://j.mp/NWszwz and here http://j.mp/1h9BjYE)
// assumes your viewport meta tag has an id set to "viewport" - e.g.:
// <meta name="viewport" id="viewport" content="initial-scale=1,maximum-scale=1,minimum-scale=1,user-scalable=no,width=device-width">
(function(doc, nav) {
var ua = nav.userAgent.toLowerCase();
!ua || ua.match(/iphone|ipod/) && ((ua = ua.match(/cpu (?:\w+ )?os (\d+)_?(\d+)?/)) && ((7 < ua[1] || 7 == ua[1] && (ua[2] && 0 < ua[2])) && (doc.getElementById("viewport").content += ",minimal-ui")));
})(document, window.navigator);

Stale ODEX dependencies cause unbootable Android

This document is based on the code of Android 4.1.1_r6.1 (Jelly Bean).

Suppose that you want to customiz your android system, you may want to modify /system/framework/framework.jar (source files are in the directory frameworks/base). During development, let's assume that you just did a full build, and you decide to make some changes to some source files. After that, you want to build again. Ideally, the building system can correctly re-build everything that is dependent on the changes you just made. However, seems that the android building system does not do it properly. You will get an unbootable image caused by mismatched dex signature. If you check the log when system boots, you will see an error message like the following:

07-30 06:50:56.042: I/dalvikvm(393): DexOpt: mismatch dep signature for '/system/framework/framework.odex'
07-30 06:50:56.042: E/dalvikvm(393): /system/framework/apache-xml.jar odex has stale dependencies

The reason is

/* ---------------------------------------------------------- */
/* */
/* A media query that captures: */
/* */
/* - Retina iOS devices */
/* - Retina Macs running Safari */
/* - High DPI Windows PCs running IE 8 and above */
/* - Low DPI Windows PCs running IE, zoomed in */
/* - Low DPI Windows PCs and Macs running Firefox, zoomed in */
/* - Android hdpi devices and above */
@eyecatchup
eyecatchup / gist:9749358
Created March 24, 2014 21:17
ASCII art as found in the compiled aapt.exe (as part of the Android-SDK for Windows).
B4CUNG
_.
=?V#(..____aa, .|*!S>
:.:;=;=QQQQB`==:...:
.=;;;:jQQQQf;=;;===:.
=;;;:mQQQQ=;;;;;:;;.
.=;;;<QQQQW:;;;;;;=w,
./=;;:dQQQQ#:;;;;;:yQ[
.m:;;=QQQQQm:;;;;=mQQL.
)W;=;)QQQQQQ;=;;:mQQW'.
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"></uses-permission>
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
@eyecatchup
eyecatchup / email-info-gmx.de.txt
Created April 2, 2014 15:26
New Phishing-Email trying to steal Postbank (http://postbank.de) customer credentials and personal details via HTML form.
Return-Path: direkt@postbank.de
Received: from server.softd.com.br ([66.7.201.136]) by mx-ha.gmx.net (mxgmx103) with ESMTPS (Nemesis) id 0MXWmo-1WaVj7059q-00WTq8 for <OriginalRecipient@gmx.de>; Mon, 31 Mar 2014 01:40:15 +0200
Received: from pro1487.startdedicated.de ([188.138.92.19]:52525) by server.softd.com.br with esmtpa (Exim 4.80.1) (envelope-from <direkt@postbank.de>) id 1WUPKp-002HF4-3R for OriginalRecipient@gmx.de; Sun, 30 Mar 2014 20:40:15 -0300
From: "Postbank" <direkt@postbank.de>
Subject: Liebe Postbank Kunden, Ihr Handeln ist gefragt!
To: "OriginalRecipient@gmx.de" <OriginalRecipient@gmx.de>
Content-Type: multipart/mixed; boundary="RO1RIFdd=_IR6cdhEUIQQBKeUlmA7KXvOP"
MIME-Version: 1.0
Date: Sun, 30 Mar 2014 16:40:14 -0700
X-AntiAbuse: This header was added to track abuse, please include it with any abuse report

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000
@eyecatchup
eyecatchup / tree.sh
Created October 5, 2014 10:13
Tiny bash script to display a hierarchical directory structures.
#!/bin/sh
#######################################################
# UNIX TREE #
# Version: 2.3 #
# File: ~/apps/tree/tree.sh #
# #
# Displays Structure of Directory Hierarchy #
# ------------------------------------------------- #
# This tiny script uses "ls", "grep", and "sed" #
# in a single command to show the nesting of #