Skip to content

Instantly share code, notes, and snippets.

@cluelesscoder
cluelesscoder / gist:2706503
Created May 16, 2012 01:13
SHOW ENGINE INNODB STATUS/G
mysql> SHOW ENGINE INNODB STATUS\G
*************************** 1. row ***************************
Status:
=====================================
120516 1:11:59 INNODB MONITOR OUTPUT
=====================================
Per second averages calculated from the last 41 seconds
----------
SEMAPHORES
----------
mysql> show tables;
+---------------------+
| Tables_in_impindata |
+---------------------+
| countries |
| prioritycodes |
| sectors |
| stocks |
+---------------------+
4 rows in set (0.00 sec)
// loadSectorOptions works but loadCountryOptions does not
function loadSectorOptions() {
$.getJSON(
"list-process.php",
"process=loadSectorOptions",
function(data) {
$.each(data.sectors, function(i, sector) {
var sectorOption = '<option value=\"'
+sector.sector_id+'\">'
@cluelesscoder
cluelesscoder / gist:3072712
Created July 8, 2012 20:41
loading many-to-many divs
function loadStockDivs() {
$.getJSON(
"test.php",
"process=loadstocks",
function(data) {
data.counter = 0;
$.each(data.stocks, function(i,stock) {
if (i != 0) {
counter = i;
counterminus = counter-1;
@cluelesscoder
cluelesscoder / gist:3383623
Created August 18, 2012 00:27
Python test
import csv
testreader = csv.DictReader(open('test.csv', 'rb')
for row in testreader:
print row
@cluelesscoder
cluelesscoder / gist:3406761
Created August 20, 2012 19:04
Python test file opening
import csv
testreader = csv.DictReader(open('C:/Documents and Settings/BJCREASY.SOA/Desktoptestcsv.csv', ''), dialect='excel')
for row in testreader:
print row
# if row['SERFF'] == csv.reader.next().row['SERFF']
# print 'Success'
@cluelesscoder
cluelesscoder / gist:3418362
Created August 21, 2012 19:02
Python 2 testing DictReader
import csv
import re
# testreader = csv.DictReader(open('C:/Documents and Settings/'
# 'BJCREASY.SOA/Desktop/test2.csv', 'rb'))
with open('C:/Documents and Settings/'
'BJCREASY.SOA/Desktop/test2.csv', 'rb') as f:
reader = csv.reader(f)
for row in reader:
@cluelesscoder
cluelesscoder / gist:4208180
Created December 4, 2012 20:09
Enumerate and for loops
numbers = range(10)
for idx, y in enumerate(numbers):
if idx == 1:
continue
else:
print y
@cluelesscoder
cluelesscoder / gist:5616667
Last active December 17, 2015 13:19
random issue: list indices must be integers not tuple python
import sqlite3
from collections import defaultdict
DATABASE = 'C:/Misc/myscripts/workprototype/workprototype.db'
conn = sqlite3.connect(database=DATABASE)
comp = conn.execute('select companies.name from companies')
comp = [dict(co_name=row[0]) for row in comp.fetchall()]
prod = conn.execute('select c.name, p.name, c.desc, p.desc from companies c inner join products p on c.co_id = p.co_id')
import string
with open('C:\Documents and Settings\[trimmed]\Desktop\list.txt',
'rb') as infile:
fread = infile.readlines()
fread = [x.strip() for x in fread]
fread = [x.lstrip('\x95') for x in fread]
fread = [x.strip() for x in fread]
fread = [x for x in fread if x != '']