Skip to content

Instantly share code, notes, and snippets.

View salbahra's full-sized avatar

Samer Albahra salbahra

View GitHub Profile
@salbahra
salbahra / extract-sms-backup.py
Created August 1, 2024 19:32
Windows Mobile 6 SMS backup tool created a binary file. This script attempts to restore the content from the binary file into human readable text files.
import re
file_path = 'SMS_DATE_TIME.jaf'
def readable_parts(binary_data, encoding='utf-16'):
try:
return binary_data.decode(encoding, errors='ignore')
except:
return "Unable to decode with specified encoding."
@salbahra
salbahra / organize-eml.py
Created July 30, 2024 18:04
Takes a flat list of EML files and organizes them into a year, month and day folder structure with a more compliant filename based on the subject
import os
import email
from email.utils import parsedate_to_datetime
import shutil
import re
import unicodedata
from email.header import decode_header
import base64
import quopri
@salbahra
salbahra / imessage-export.py
Last active August 2, 2024 14:15
Script to perform monthly exports of iMessage to a remote SSH server using rsync.
import subprocess
import shutil
from datetime import datetime, timedelta
import netifaces
import os
SUCCESS_FILE = os.path.expanduser('~/.imessage_export/last_success')
REMOTE_BASE_PATH = "/path/to/messages"
SSH_HOST = "user@192.168.1.2"
@salbahra
salbahra / google-photos-tools.ipynb
Created July 25, 2024 11:03
Tools for working with Google Photos and Google Takeout exports.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@salbahra
salbahra / google-photos-processing.py
Last active July 25, 2024 11:04
Processes Google Takeout data for Photos by pairing JSON and media files and updating media files with metadata from the JSON.
import os
import re
import json
from collections import defaultdict
import urllib.parse
from fractions import Fraction
from datetime import datetime
from PIL.ExifTags import GPSTAGS
import piexif
import subprocess
@salbahra
salbahra / 030_update_platform_config.js
Last active August 25, 2017 06:15 — forked from victorcpereira/030_update_platform_config.js
Ionic/Cordova update platform config
#!/usr/bin/env node
/** This hook updates platform configuration files based on preferences and config-file data defined in config.xml.
Currently only the AndroidManifest.xml and IOS *-Info.plist file are supported.
Prerequistes:
npm install -D lodash elementtree plist
See http://stackoverflow.com/questions/28198983/ionic-cordova-add-intent-filter-using-config-xml
@salbahra
salbahra / pssh.sh
Created August 25, 2015 04:47
Allow parallel SSH commands using a list of servers
tmp=${TMPDIR:-/tmp}pssh.$RANDOM.log;
machines=${2:-~/.pssh/machines.list};
while read -u10 host; do
ssh $host "$1" 2>&1 | sed "s/^/[$host] /" >> $tmp;
done 10< $machines
cat "$tmp";
@salbahra
salbahra / backup.sh
Last active August 29, 2015 14:21
Small script to backup a server (MySQL and key files) and rsync the backup, if needed
#!/bin/bash
#Server name being backed up (also the filename of the zip)
SERVER="SERVER"
#RSync destination if you want to copy the backup to a remote server (serverip:folder_location)
OFFSITE=""
#Local folder to save the backup into
BACKUP="/mnt/backup"
@salbahra
salbahra / pgbhook.php
Created March 22, 2015 00:25
PhoneGap Build Github Webhook
<?php
header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
$userAuth = isset($_REQUEST["user"]) && isset($_REQUEST["pass"]);
$url = "https://build.phonegap.com/apps/".$_REQUEST["id"]."/push";
if (($userAuth || isset($_REQUEST["token"])) && isset($_REQUEST["id"])) {
@salbahra
salbahra / find_router.js
Last active August 29, 2015 14:13
jQuery Method to Find Router
function find_router(callback) {
callback = callback || function(){};
var routerIPs = ["192.168.1.1","10.0.1.1","192.168.1.220","192.168.2.1","10.1.1.1","192.168.11.1","192.168.0.1","192.168.0.30","192.168.0.50","192.168.10.1","192.168.20.1","192.168.30.1","192.168.62.1","192.168.102.1","192.168.1.254","192.168.0.227","10.0.0.138","192.168.123.254","192.168.4.1","10.0.0.2","10.0.2.1","10.0.3.1","10.0.4.1","10.0.5.1"],
total = routerIPs.length,
scanprogress = 0,
reply = function(status,ip){
scanprogress++;
if (status === true) {
routerFound = ip;