Skip to content

Instantly share code, notes, and snippets.

View clintmjohnson's full-sized avatar

Clint Johnson clintmjohnson

View GitHub Profile
@clintmjohnson
clintmjohnson / nimbletext_insert
Last active September 6, 2015 20:02
Use nimbletext to create SQL Insert query - http://nimbletext.com/HowTo/GenerateInsert
$ONCE
Insert into Contacts (FirstName, LastName, Company)
Values
$EACH+
('$0', '$1', '$2')<% if ($rownumOne != $numrows) {','} %>
@clintmjohnson
clintmjohnson / nimbletext_replace
Created September 6, 2015 20:57
this line of code replaces text in each line for nimbletext - http://nimbletext.com/HowTo/ManipulateText
<% $row
.replace(/a dull boy/,'an axe-wielding maniac')
.replace(/an axe/,'a teddy bear')
.replace(/work/,'sex')
%>
@clintmjohnson
clintmjohnson / dotoeachvalueinlist.py
Created September 16, 2015 23:21
Do something to every item in a list function - python
n = [3, 5, 7]
def double_list(x):
for i in range(0, len(x)):
x[i] = x[i] * 2
return x
print double_list(n)
@clintmjohnson
clintmjohnson / findItemsIneBayStores.py
Last active February 14, 2017 02:39
Find Items in eBay Stores.
# encoding=utf8 # This eliminates issues with Unicode errors that I was previously encountering.
import sys
reload(sys)
sys.setdefaultencoding('utf8')
from ebaysdk.finding import Connection as Finding
import csv
"""The first function only finds a total page count. This func outputs the Page count,
and will be used as Range in the next Func."""
@clintmjohnson
clintmjohnson / LnS_Product_Query.sql
Last active December 13, 2016 23:43
Land n Sea - eBay / Magento SQL Server Query
USE companydb
DECLARE @companyname_active TABLE
(
[Custom Label] VARCHAR(75)
,[Purchases] INT
,[Category Number] INT
,[Price] DECIMAL(6,2)
,[Item Title] VARCHAR(90)
)
@clintmjohnson
clintmjohnson / MSSQL_Python.py
Last active November 26, 2015 16:37
This Gist Uses Python and SQL Server - It queries results from a MSSQL table and appends the results to a python list
import _mssql
# Connect to the SQL Server Database
conn = _mssql.connect(server='Servernamehere', user='serverusername', password='serverpassword', \
database='databasename')
# Run The Select Query against the Database
conn.execute_query('SELECT TOP 10 [Item ID],[Custom Label],[Quantity Available] FROM [bsusa_active_staging]')
# Create the Lists
@clintmjohnson
clintmjohnson / scrapeamazonproducts.py
Last active October 18, 2017 20:08
This program scrapes Product Details from ASIN from Amazon.
from lxml import html
import csv, os, json
import requests
#from exceptions import ValueError
from time import sleep
def AmzonParser(url):
headers = {
'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.90 Safari/537.36'}
@clintmjohnson
clintmjohnson / Stock Tracker
Last active October 2, 2017 19:52
This Python program Tracks Sample Stock buying and selling, using Yahoo Finance live Data
def stocktrack(stock,buysell,qty):
import sqlite3
from yahoo_finance import Share
conn = sqlite3.connect('Stocks.db')
c = conn.cursor()
c.execute('''CREATE TABLE IF NOT EXISTS stocks
(date text, trans text, symbol text, qty real, price real, total real)''')
@clintmjohnson
clintmjohnson / gist:2ab673ba31489e6aa0ef694b9d9f892e
Created October 4, 2017 21:07
Historic Stock Price Data Download to CSV
import pandas as pd
import io
import requests
import time
def google_stocks(symbol, startdate=(1, 1, 2005), enddate=None):
startdate = str(startdate[0]) + '+' + str(startdate[1]) + '+' + str(startdate[2])
if not enddate: