Skip to content

Instantly share code, notes, and snippets.

View pdxjohnny's full-sized avatar
🐢
Rolling Alice...

John Andersen pdxjohnny

🐢
Rolling Alice...
View GitHub Profile
@pdxjohnny
pdxjohnny / string_split.cpp
Last active August 29, 2015 14:06
Split On Substring
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 / mail.py
Created November 26, 2014 07:35
Send email via gmail
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 August 29, 2015 14:13
Resizes images to whatever sizes are listed in the resize_config.txt file, great for creating iPhone icons
#! /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 March 4, 2015 22:41
Ultimate python MySQL functions
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 August 29, 2015 14:18
Android Socket Server
<?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 April 9, 2015 15:11
Grabs an image over and over to create a video, pass it the id of the Image element you want made into a video
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 April 23, 2015 15:23
Start Virtualbox VMs on boot
#!/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 August 29, 2015 14:20
C Shifting bits in a byte
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 April 30, 2015 15:38
Passes data from another port
<VirtualHost *:80>
ServerName something.example.com
ProxyRequests Off
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
ProxyPass / http://server:port/
@pdxjohnny
pdxjohnny / sub.sh
Created April 30, 2015 17:44
Add srt subtitles to mp4
#!/bin/bash
ffmpeg -i ${1}.srt ${1}.ass
ffmpeg -i ${1}.mp4 -vf ass=${1}.ass ${1}_subtitles.mp4