Skip to content

Instantly share code, notes, and snippets.

@jeremiahmarks
jeremiahmarks / gist:9870542
Created March 30, 2014 10:07
bash confirmation
read -p "do you want to continue?" -n 1 -r
if [[ $REPLY =~ ^[Yy]$ ]]
then
#do whatever you are checking on
fi
@jeremiahmarks
jeremiahmarks / gist:9870919
Created March 30, 2014 10:47
ensure string ends with /
[[ $string != */ ]] && string="$string"/
@jeremiahmarks
jeremiahmarks / KeyLis.java
Created April 18, 2014 02:51
Java snippet to get help with KeyListener
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JLabel;
import java.awt.*;
import java.awt.event.*;
public class KeyLis{
public static void main(String[] args){
JFrame frame=new JFrame("Test Frame");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
/*
* @Author: Jeremiah Marks
* @Date: 2014-04-15 21:38:39
* @Last Modified by: Jeremiah Marks
* @Last Modified time: 2014-04-17 21:04:19
*/
/*
################################################################################
################################################################################
@jeremiahmarks
jeremiahmarks / webanize.tester.sh
Created April 25, 2014 22:24
cleaning up parts of webanize
source ~/.webanize.conf
newstring="START of STRING"
dbloc="url"
myfirstquery="SELECT dateadded,about FROM portfolio WHERE sourcecode LIKE '$dbloc'"
mysql --host=$hostname --user=$username --password=$pw -e "USE $dbname; $myfirstquery;" | while read -r line
do
newstring+=$line
done
@jeremiahmarks
jeremiahmarks / placeOrder.py
Created December 14, 2014 23:19
A simple Gist that shows a Python2.7 implementation of the Infusionsoft APIs OrderService.placeOrder function
AppName='xx000'
APIKey="somethingreallylong"
IdOfContactWithValidCreditCard=5795
IdOfContactsCreditCard=167
PayPlanId=0 #This is immediate AutoCharge... I think. It is in my application anyways
ProductIdsSold=[107]
SubscriptionIdsSold=[]
ProcessSpecials=True
PromoCodes=["apitest"]
LeadAffiliateID=0 #is equivalent to not having an Affiliate
@jeremiahmarks
jeremiahmarks / gist:dcf33161deb50f48ca9f
Created December 14, 2014 23:24
GetAllContactsThatHaveCCData
def getContactsWithCards(self):
records=[]
p=0
while True:
listOfDicts = self.connection.DataService.query(self.infusionsoftAPIKey, 'CreditCard', 1000,p,{},['Id', 'ContactId', 'Email','FirstName', 'LastName', 'Last4'], 'Id', True)
for each in listOfDicts:
interestingData=["Id", 'ContactId', 'Email','FirstName', 'LastName', 'Last4']
for eachbit in interestingData:
if not each.has_key(eachbit):
@jeremiahmarks
jeremiahmarks / fibonacci.py
Created December 28, 2014 20:38
Quick way to test for Fibonacci
##from http://www.geeksforgeeks.org/check-number-fibonacci-number/
def isPerfSquare(x):
return(int(x**(0.5))**2==x)
def isFib(x):
return (isPerfSquare(5*x*x+4) or isPerfSquare(5*x*x-4))
@jeremiahmarks
jeremiahmarks / gist:513fd72e1b0f68e1bb63
Created December 29, 2014 23:46
SampleInput from circle city
144
1 1
1 934547091
25 5
25 1494320997
3 0
3 623690081
12 0
12 476190629
44 0
@jeremiahmarks
jeremiahmarks / ipaddress.sh
Created March 4, 2015 09:27
Simple example of how to get IP address using DNS - dig and openDNS.com
#!/usr/bin/env bash
dig +short myip.opendns.com @resolver1.opendns.com