Skip to content

Instantly share code, notes, and snippets.

View geeksunny's full-sized avatar

Justin Swanson geeksunny

View GitHub Profile
@geeksunny
geeksunny / supersu-install.sh
Created September 22, 2018 00:29
Commands executed in an attempt to manually install SuperSU 2.82 SR5 on AndroidThings 1.0.4. The resulting su binary is unable to write to the filesystem after adb remount.
cd ~/Downloads/SuperSU-2.82-SR5
adb connect [IP_ADDRESS]:5555
adb root
adb remount
adb push common/install-recovery.sh /system/etc/install-recovery.sh
adb shell chmod 0755 /system/etc/install-recovery.sh
adb shell chcon u:object_r:toolbox_exec:s0 /system/etc/install-recovery.sh
adb shell ln -s /system/etc/install-recovery.sh /system/bin/install-recovery.sh
import json
import requests
#
class ApiResponse(object):
statusCode = 0
body = {}
#
def __init__(self, statusCode, body):
self.statusCode = statusCode
@geeksunny
geeksunny / bind9_docker-compose.yml
Last active August 9, 2016 15:09
Docker compose file for launching a bind9 image with a separate volume for configuration files.
bind9-data:
image: emsi/bind9-data
bind9:
image: emsi/bind9
volumes_from:
- emsi/bind9-data
ports:
- "53:53"
- "53:53/udp"
@geeksunny
geeksunny / find_replace.py
Created October 14, 2013 15:37
A quick'n'dirty Python script to make find & replace operations on large text files fast and automated. Creates a duplicate file copy and leaves the original file unchanged.
#!/usr/bin/python
## Configuration ##
__target_file__ = "example.txt" # Relative path to the target file to process.
__find__ = "found" # Block of text to find.
__replace__ = "replaced" # Block of text to replace with.
###################
with open(__target_file__) as file_in: # Open source file for reading.
file_out = open(__target_file__+"_replaced", 'w') # Open destination file for writing.
for line in file_in: # Loop through source, line by line.
new_line = line.replace(__find__,__replace__) # Perform find & replace on current line.
@geeksunny
geeksunny / ssh_tunnel.py
Created October 14, 2013 15:32
A quick'n'dirty Python script for starting / stopping a port-forwarded SSH tunnel.
#!/usr/bin/python
import os # For running system commands.
import argparse # For command-line argument parsing.
## Configuration ##
__command__ = "ssh -L [LOCAL PORT]:127.0.0.1:[REMOTE PORT] [USER]@[REMOTE HOST] -f -N"
###################
## TODO ##
# * Build out the argparse system to parameterize the connection details.
@geeksunny
geeksunny / gist:5986271
Created July 12, 2013 17:39
A simple jQuery-based tooltip solution.
$('.tooltip')
.mouseenter(function(e) {
e.preventDefault();
pos = $(this).offset();
$(this).append('<div class="tooltip">'+$(this).attr('rel')+'</div>');
div = $('div.tooltip',$(this));
div.attr('top',pos['top']+5).attr('left',pos['left']).fadeIn(200);
})
.mouseleave(function(e) {
e.preventDefault();
@geeksunny
geeksunny / class.facebook_connect.php
Last active December 10, 2015 20:28
A simple class for interfacing with the Facebook API.
<?php
/* // EXAMPLE CODE!!!
error_reporting("E_ALL");
ini_set('display_errors', '1');
//session_start();$_SESSION = '';var_dump($_SESSION);die; // RESET SESSION
// Facebook App credentials
$app_id = "xxxxxxxxxxxxxxx";
$app_secret = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
$my_url = "http://xxx.xxx.xxx/xxx.xxx";
@geeksunny
geeksunny / class.urlstring.php
Created January 6, 2013 13:11
A simple class for handling URL strings for links.
<?php
class urlstring {
private $params = array();
function __construct() {
// Pulling parameters from the URL string.
$str = explode("&",$_SERVER['QUERY_STRING']);
foreach ($str as $item) {
$split = explode("=",$item);
$this->params[$split[0]] = $split[1];
@geeksunny
geeksunny / class.yelp.php
Created January 6, 2013 12:40
A simple class for interfacing with the Yelp API.
<?php
//error_reporting("E_ALL");
//ini_set('display_errors', '1');
// ~~~ EXAMPLE CODE ~~~ //
/*
// Set your keys here
$consumer_key = "xxxxxxxxxxxxxxxxxxxxx";
$consumer_secret = "xxxxxxxxxxxxxxxxxxxxxxxxxx";
$token = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
@geeksunny
geeksunny / class.pagination.php
Last active December 10, 2015 17:18
Simple class for generating pagination links.
<?php
class pagination {
private $forward = true;
private $backward = true;
private $current_page;
private $last_page;
function __construct($current_page=false, $last_page=false, $generate=false) {
if ($current_page) {
$this->current_page = $current_page;