Skip to content

Instantly share code, notes, and snippets.

Avatar
☢️

John Andersen pdxjohnny

☢️
View GitHub Profile
@pdxjohnny
pdxjohnny / string_split.cpp
Last active Aug 29, 2015
Split On Substring
View string_split.cpp
std::vector<std::string> split_line(std::string str, std::string sub)
{
std::vector<std::string> vector_split_line;
std::string split_line = "";
std::string sub_line = "";
bool skip = false;
for ( int current_char = 0; current_char < str.length(); current_char++ )
{
if ( str[current_char] == sub[0] )
{
@pdxjohnny
pdxjohnny / flash-all.py
Created Oct 13, 2014
Simultaneous Android Device Flasher
View flash-all.py
#!/bin/python
from multiprocessing import Process
import sys
import subprocess
import time
def device_ids():
device_ids = []
devices = subprocess.check_output(["adb", "devices"]).split()
@pdxjohnny
pdxjohnny / mail.py
Created Nov 26, 2014
Send email via gmail
View mail.py
import smtplib
import sys
class gmail(object):
"""docstring for gmail"""
def __init__( self, username, password ):
self.username = username
self.password = password
self.login()
@pdxjohnny
pdxjohnny / resize.py
Last active Aug 29, 2015
Resizes images to whatever sizes are listed in the resize_config.txt file, great for creating iPhone icons
View resize.py
#! /usr/bin/python
from PIL import Image
import sys
import os
imageFile = sys.argv[1]
file_name = imageFile.split(".")[0]
ext = imageFile.split(".")[-1]
sizes = []
@pdxjohnny
pdxjohnny / mysql.py
Created Mar 4, 2015
Ultimate python MySQL functions
View mysql.py
import MySQLdb
db_config = {
"host":"localhost",
"username":"username",
"password":"password",
"name":"name_of_database"
}
def query( query, bindings = False ):
@pdxjohnny
pdxjohnny / AndroidManifest.xml
Last active Aug 29, 2015
Android Socket Server
View AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.intel.camerawebserver" >
<uses-permission android:name="android.permission.INTERNET"
android:required="true" />
<uses-feature android:name="android.hardware.camera"
android:required="true" />
<application
@pdxjohnny
pdxjohnny / image_video.js
Created Apr 9, 2015
Grabs an image over and over to create a video, pass it the id of the Image element you want made into a video
View image_video.js
var image_video = function image_video ( id )
{
this.image_element = document.getElementById( id );
this.page = this.image_element.src;
this.running = false;
return this;
}
image_video.prototype.get_image = function get_image ( page, callback )
{
@pdxjohnny
pdxjohnny / startvms.sh
Created Apr 23, 2015
Start Virtualbox VMs on boot
View startvms.sh
#!/bin/bash
# Run as root
touch /etc/init.d/startvms
chmod +x /etc/init.d/startvms
update-rc.d startvms defaults 99 01
cat <<'EOF' >> /etc/init.d/startvms
#! /bin/sh
# /etc/init.d/startvms
#
@pdxjohnny
pdxjohnny / swap_bits.c
Last active Aug 29, 2015
C Shifting bits in a byte
View swap_bits.c
char swap_bits( char byte, int one, int two )
{
char tmp_1, tmp_2, swap;
int hex_1 = pow(2, one);
int hex_2 = pow(2, two);
tmp_1 = byte & hex_1;
tmp_1 = tmp_1 >> abs( one - two );
tmp_2 = byte & hex_2;
tmp_2 = tmp_2 << abs( one - two );
if ( tmp_1 == 0 && tmp_2 != 0 )
@pdxjohnny
pdxjohnny / apache_proxy.conf
Created Apr 30, 2015
Passes data from another port
View apache_proxy.conf
<VirtualHost *:80>
ServerName something.example.com
ProxyRequests Off
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
ProxyPass / http://server:port/
You can’t perform that action at this time.