Skip to content

Instantly share code, notes, and snippets.

View jfinstrom's full-sized avatar
💭
making stuff

James Finstrom jfinstrom

💭
making stuff
View GitHub Profile
@jfinstrom
jfinstrom / yum.class.py
Created November 24, 2012 17:35
Yum install class.
class pack_install:
import yum
packages = []
def addPackage(self,p):
self.packages.append(p)
def runInstall(self):
sys.path.append('/usr/share/yum-cli')
import cli
y = cli.YumBaseCli()
@jfinstrom
jfinstrom / rpm.spec.class.py
Created November 24, 2012 17:42
spec File generator
class specfile:
def __init__(self):
self.package = ''
self.version = ''
self.release = '1'
self.files = []
self.configs = []
self.license = 'GPL'
self.packager = 'RPM Generator <rpm@generator>'
self.vendor = 'none'
@jfinstrom
jfinstrom / newegg.gs
Created December 3, 2012 23:14
Adds neweggPrice("neweggpartnumber") as a custom spreadsheet function in google docs.
function neweggPrice(part) {
var response = UrlFetchApp.fetch('http://www.ows.newegg.com/Products.egg/' + part);
var j = response.getContentText();
var data = Utilities.jsonParse(j);
var price = data["FinalPrice"];
return(price);
}
@jfinstrom
jfinstrom / asterisk.py
Last active July 14, 2021 14:37
Example of using the Asterisk Manager API in python...
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# asterisk.py
#
# Copyright 2014 James Finstrom<jfinstrom at gmail>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
def boxtext(msg):
lines = msg.split("\n")
width = len(max(lines, key=len))+4
topline = u"\u2554" + u"\u2550"*width + u"\u2557"+"\n"
side = u"\u2551"
bottom = u"\u255a"+ u"\u2550"*width + u"\u255d"+"\n"
box = topline
for l in lines:
if len(l)<2:
continue
def grabFile(url, dest):
"""grabFile(fileUrl, saveLocation)
By James Finstrom
Grabs file and saves to specified location
"""
#file = get_threeohtwo(url)
request = urllib2.Request(file)
filename = url.split('/')[-1].split('#')[0].split('?')[0]
@jfinstrom
jfinstrom / flash-all.sh
Created July 25, 2013 04:23
A modified flash-all.sh from https://dl.google.com/dl/android/aosp/nakasi-jwr66v-factory-d341d356.tgz (the 4.3 factory image for the Nexus7) This has been modified not to wipe user data. Your bootloader MUST be unlocked. If you have to unlock your boot loader it will wipe your data making the use of this pointless....
#!/bin/sh
# Copyright 2012 The Android Open Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
@jfinstrom
jfinstrom / buzzer
Created September 30, 2013 23:00
Set the buzzer on or off by physical button or by serial...
int btn = 2;
int spkr = 10;
int incomingByte = 0;
int bybtn = 0;
void setup()
{
Serial.begin(9600);
Serial.println("Arduino Online");
Serial.println("..............");
//setup board
@jfinstrom
jfinstrom / ingressmail.py
Created January 9, 2014 21:58
wrote this to parse my ingress portal submissions from my gmail box. It is not the prettiest thing in the world but does the task I need it to. This may be useful in implementing your own solution.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# ingressmail.py
#
# Copyright 2014 James Finstrom <jfinstrom at gmail.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
#!/bin/bash
# THIS SCRIPT SETS UP SOME BASIC IP TABLES RULES FOR YOUR SYSTEM.
# YOU SHOULD BUY A BOOK AND GOOGLE TO UNDERSTAND WHAT IS GOING ON HERE.
# YOUR SYSTEM'S SECURITY SHOULD NOT BE LEFT UP TO A SCRIPT APPLICATION
# OR ME. IT IS YOUR RESPONSIBILITY TO ENSURE YOUR OWN SECURITY.
# THIS IS PRESENTED WITHOUT ANY WARRANTY. ANY USE OF THIS IS AT YOUR OWN RISK
#
# Written by James Finstrom ([email protected])
#