Skip to content

Instantly share code, notes, and snippets.

View hagope's full-sized avatar

Omar Al-Jadda hagope

  • Sunnyvale, CA
View GitHub Profile
@hagope
hagope / fix_exif_dates.sh
Created January 19, 2016 17:31
There's a bug in the Android Camera that doesn't set Create Date and Date Time Original in the photo's EXIF meta data, but only when the images are NOT set to HDR+
# There's a bug in the Android Camera that doesn't set Create Date and Date Time Original in the photo's EXIF meta data, but only when the images are NOT set to HDR+
# The following is fix using exiftool (brew install exiftool) to set these fields
# Run these in the terminal in sequence
# First fix DateTimeOriginal
exiftool "-datetimeoriginal<filemodifydate" -r -if '(not $datetimeoriginal or ($datetimeoriginal eq "0000:00:00 00:00:00")) and ($filetype eq "JPEG")' *.jpg
# Then fix CreateDate
exiftool "-createdate<datetimeoriginal" -r -if '(not $createdate or ($createdate eq "0000:00:00 00:00:00")) and ($filetype eq "JPEG")' *.jpg
@hagope
hagope / dash-listen-3.py
Last active November 21, 2015 20:26 — forked from courtsimas/dash-listen-3.py
listen on network for push of Amazon dash button; this version uses arp-scan instead of scapy
import subprocess
import requests
import time
import os,sys
MAGIC_FORM_URL = 'http://api.cloudstitch.io/...your_url'
def record_wake():
data = {
"Timestamp": time.strftime("%Y-%m-%d %H:%M"),
@hagope
hagope / rename-pictures-for-dropbox.sh
Created November 20, 2015 04:52
renames jpg files using exif creation date as filename in the same format as Dropbox Camera Uploads folder YYYY-MM-DD HH.MM.SS.jpg
#!/bin/bash
# requires exif command line utility
shopt -s nocaseglob #find both *.jpg and *.JPG
for i in *.JPG; do
j=`exif -t 0x9003 "$i" | grep Value: | sed 's/Value://' | sed s/:/-/g | sed s/-/./3 | sed s/-/./3`.jpg
mv -i "$i" "$j"
done
@hagope
hagope / windows-power-commands.txt
Created August 3, 2015 04:36
useful command line hacks for windows command prompt and powershell
# Get hard drive info
wmic logicaldisk get
# Quicky create a system image backup
wbAdmin start backup -backupTarget:E: -include:C: -allCritical -quiet
// Solution 1:
Timestamp = ConvertToLocalTime(Date(MakeDate(1970, 1, 1) + (<timestamp_field> / 86400)), '<time_zone>')
// Solution 2:
Timestamp = ConvertToLocalTime(Date(25569 + (<timestamp_field> / 86400)), '<time_zone>')
// my need
ConvertToLocalTime(Date(MakeDate(1970, 1, 1) + (epoch_ts / 86400)))
/*****************************************************************************
* FILE: join.c
* DESCRIPTION:
* This example demonstrates how to "wait" for thread completions by using
* the Pthread join routine. Threads are explicitly created in a joinable
* state for portability reasons. Use of the pthread_exit status argument is
* also shown. Compare to detached.c
* AUTHOR: 8/98 Blaise Barney
* LAST REVISED: 01/30/09
******************************************************************************/
@hagope
hagope / stock.sh
Created August 6, 2014 16:14
Realtime Stock Quote from Google Finance using cURL
#!/bin/bash
# Usage: stock.sh TWTR 30
# Say TWTR current price every 30 seconds
while true
do
curl -s https://www.google.com/finance?q=$1 | grep ref_ -m 1 | sed 's|<[^>]*>||g' | say
sleep $2
done
# http://makezine.com/projects/tutorial-raspberry-pi-gpio-pins-and-python/
import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BCM)
GPIO.setup(23, GPIO.IN, pull_up_down = GPIO.PUD_DOWN)
GPIO.setup(24, GPIO.IN, pull_up_down = GPIO.PUD_UP)
def printFunction(channel):
print(“Button 1 pressed!”)
print(“Note how the bouncetime affects the button press”)

Description

This simple script will take a picture of a whiteboard and use parts of the ImageMagick library with sane defaults to clean it up tremendously.

The script is here:

#!/bin/bash
convert $1 -morphology Convolve DoG:15,100,0 -negate -normalize -blur 0x1 -channel RBG -level 60%,91%,0.1 $2

Results

@hagope
hagope / isbns.py
Created February 25, 2014 19:22
convert isbn10 to isbn13 and accounts for 8,9 digit isbn without leading zeroes
def check_digit_10(isbn):
assert len(isbn) == 9
sum = 0
for i in range(len(isbn)):
c = int(isbn[i])
w = i + 1
sum += w * c
r = sum % 11
if r == 10: return 'X'
else: return str(r)