Skip to content

Instantly share code, notes, and snippets.

#!/bin/bash
#
# Purpose: Write the passed in parameter as hostid to /etc/hostid
# If no parameter is passed, write current hostid to /etc/hostid
# Original Author: Fazle Arefin <fazlearefin@yahoo.com>
# http://fazlearefin.blogspot.ca/2013/03/set-hostid-etchostid-of-linux-hosts.html
# Modified by David Manouchehri <david@davidmanouchehri.com>
if [ -n "$1" ]; then
@Manouchehri
Manouchehri / Canon.txt
Last active August 29, 2015 14:13
Canon SX260 HS - Info
Running 1.01A (1.0.1.0)
http://chdk.wikia.com/wiki/SX260
http://mighty-hoernsche.de/trunk/ - Unstable New Development Version 1.4
sx260hs-101a-1.4.0-[THIS CHANGES]-full.zip
unzip sx260hs-101a-1.4.0-*-full.zip to SD card
Go to menu, update firmware (needed for each initial boot)
After that initial boot happens, go into the CHDK menu and make the card bootable
mount -o rw,remount /system
sed -i 's/qemu.hw.mainkeys=1/qemu.hw.mainkeys=0/g' /system/build.prop
/qemu.hw.mainkeys=0/g' /system/build.prop # Turn softkeys back on.
@Manouchehri
Manouchehri / acceptgzipped.py
Last active May 29, 2022 11:44
Allowing gzip encoding with urllib
__author__ = 'David Manouchehri'
from bs4 import BeautifulSoup
import urllib.request
import gzip
import io
url = 'http://yoururlgoesherehopefullythisisntavalidurl.com/pages.html'
headers = {'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
@Manouchehri
Manouchehri / gpsglonassusbreceiver.txt
Last active August 29, 2015 14:15
GPS/GLONASS USB Receiver
Product: http://www.aliexpress.com/snapshot/6329414611.html
Title: VK-172 GMOUSE USB GPS/GLONASS USB FZ1007
Price: $10.07 USD
Chip info:
ublox
G7020-XT
C1010A
01119364
alias aria2c='aria2c -x16 -j32 -s32 --header="User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:35.0) Gecko/20100101 Firefox/35.0" --header="Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8" --header="Accept-Encoding: gzip, deflate" --header="Accept-Language: en-US,en;q=0.5"'
alias rc.d='systemctl'
alias xzip='zip -9'
alias xtar='XZ_OPT="-9e" tar --owner=root --group=root -Jcvf'
shopt -s histappend
PROMPT_COMMAND='history -a; history -n'
export EDITOR="vim"
mkdir smi2021-tree/ && cd smi2021-tree/
git init
git config core.sparseCheckout true
echo drivers/media/usb/smi2021/ >> .git/info/sparse-checkout
git remote add origin https://github.com/jonjonarnearne/smi2021.git
git fetch origin --depth=33
git pull origin smi2021v3-wip
# mkdir smi2021-tree/ && cd smi2021-tree/
# git init
# git config core.sparseCheckout true
# echo drivers/media/usb/smi2021/ >> .git/info/sparse-checkout
# git remote add origin https://github.com/jonjonarnearne/smi2021.git
# git fetch origin --depth=1
# git pull origin smi2021v3-wip
# cd drivers/media/usb/smi2021/
# make -C /lib/modules/$(uname -r)/build M=$PWD
@Manouchehri
Manouchehri / config
Created March 7, 2015 18:15
.ssh/config
Host *
ControlMaster auto
ControlPath /home/dave/.ssh/sockets/%r@%h-%p
ControlPersist 8760h
ServerAliveInterval 5
ServerAliveCountMax 1
Host *.mun.ca
User dave
IdentityFile /home/dave/.ssh/keymun
@Manouchehri
Manouchehri / https.py
Created March 8, 2015 16:23
Run a simple HTTPS server
# http://www.piware.de/2011/01/creating-an-https-server-in-python/
import BaseHTTPServer, SimpleHTTPServer
import ssl
httpd = BaseHTTPServer.HTTPServer(('localhost', 4443), SimpleHTTPServer.SimpleHTTPRequestHandler)
httpd.socket = ssl.wrap_socket (httpd.socket, certfile='path/to/localhost.pem', server_side=True)
httpd.serve_forever()