Skip to content

Instantly share code, notes, and snippets.

@iammart
iammart / internal.storage.sh
Last active August 29, 2015 14:25
Android adb listing files stored for Cordova Application
# Read files from your internal storage (/data/data/com.app.name)
# You cannot read these files directly, but you can move them
# to the external storage and read from there
$ adb shell "run-as com.yourappname ls /data/data/com.yourappname/files/ > /sdcard/Downloads/log.txt"
@iammart
iammart / encodingfix.php
Created July 7, 2015 11:22
Issues with phonetical characters in the database. This script will alter the tables and database to the correct character set
<?php
$char_set = 'utf8';
// Adds the header information
header('Content-type: text/plain');
// Runs the SQL query on teh database
$sql = 'SHOW TABLES'; $result = mysql_query($sql) or die( mysql_error() );
@iammart
iammart / gist:a90fd99a8326a56a103a
Created June 2, 2015 07:54
Extracting a table & data from a MySQL dump
$ sed -n "/^-- Table structure for table \`emails\`/,/^-- Table structure for table/p" DUMP.sql > DUMP-table.sql
@iammart
iammart / .htaccess
Created March 3, 2015 15:37
Protected Directories
AuthType Basic
AuthName "Restricted Area"
AuthUserFile /home/{USERNAME}/public_html/{DIRECTORY}/.htpasswd
require valid-user
# You would need to generate the .htpasswd file using a tool like
# http://www.kxs.net/support/htaccess_pw.html
@iammart
iammart / access-log.bash
Created February 24, 2015 09:57
Sum of awk column output in MB
zcat xxxx-Jan-2015.gz | grep autodiscover | awk '{ SUM +=$10 } END { print SUM/1024/1024 }'
@iammart
iammart / archive.sh
Created February 18, 2015 10:33
Loop through a list of directories, grab relevant database and archive the files.
#!/usr/bin/bash
filename="$1"
USER=root
PASS=
while read -r line
do
name=$line
hasfound=false
@iammart
iammart / gist:324efc943ad07a1403a5
Created January 30, 2015 10:55
Image Compression
# Resizing and compressing images using mogrify & jpegoptim
find hiresbk/ -iname "*.jpg" -exec mogrify -resize '1000>' -limit memory 32 -verbose {} \;
find hiresbk/ -iname "*.jpg" -exec jpegoptim --strip-all {} \; >> log.txt
RewriteLog "/web/logs/mywebsite.rewrite.log"
RewriteLogLevel 9
RewriteEngine On
var COOKIE_NAME = 'iphone_redirect';
$go = $.cookie(COOKIE_NAME);
function appstore() {
var answer = confirm("Download the FREE \nTorbay Hotels App today")
if (answer) window.location = "http://itunes.apple.com/app/id532107287?mt=8";
$.cookie(COOKIE_NAME, 'notice', { path: '/', expires: 10})
}