Skip to content

Instantly share code, notes, and snippets.

View jtrain's full-sized avatar
🏠
Working from home

jtrain

🏠
Working from home
View GitHub Profile

Keybase proof

I hereby claim:

  • I am jtrain on github.
  • I am jervis (https://keybase.io/jervis) on keybase.
  • I have a public key whose fingerprint is 1AC9 A2AB F8E0 8326 F2AF 9920 68EB 6C8F DB03 5FD6

To claim this, I am signing this object:

@jtrain
jtrain / child.py
Created January 9, 2014 23:31
Spawn a long-lived process outside of PSS/E
"""
Child thread
constantly writes to a file for 60 seconds
"""
from __future__ import with_statement
import time
FILE = 'demo.txt'
import psspy
psspy.throwPsseExceptions = True
def ierr_doc(psspyFunc, ierr):
if not ierr:
return ''
# Find all the errors documented in the doc string
errDoc = psspyFunc.__doc__[psspyFunc.__doc__.find('IERR = 0'):]
errs = {}
@jtrain
jtrain / embedly.fluid.js
Last active December 17, 2015 13:39
Embedly's iframe in a fluid layout using inline replace.
(function() {
window.embedlyFluid = function(selector, key, options) {
$(selector).each(function() {
// set the video to the width of the parent container
var width = $(this).parent().width();
defaults = {
secure: true
@jtrain
jtrain / qv.csv
Created July 2, 2012 17:55
QV curve data for bus number 20001
V Q
0.87 0
0.88 -50
0.89 -75
0.9 -90
0.905 -98
0.91 -103
0.92 -105
0.93 -106
0.94 -107
@jtrain
jtrain / boostrap-tables.html
Created January 4, 2012 09:42
Tables styles from bootstrap
<style>
table {
width: 100%;
margin-bottom: 18px;
padding: 0;
font-size: 13px;
border-collapse: collapse;
}
table th, table td {
padding: 10px 10px 9px;
@jtrain
jtrain / addgens_fromcsv.py
Created October 5, 2011 23:57
Add generators to PSSE case from csv file: Restructured version
"""
Add machines (gens and svcs) to the working case from a CSV file named:
``genslist.csv ``
This csv file **must** exist in the current directory. For
gens we add all to the case with status off. ECDI will take care of status.
For SVCs we only want them to be in service in and after the year specified in
the CSV. (Neither ECDI nor OPF [since fict SVCs control their own bus] will
control status of fict SVCs) NOTE: Script only works correctly IF case name
@jtrain
jtrain / addgens_fromcsv.py
Created October 5, 2011 23:55
add generators to PSSE case from csv file
from __future__ import with_statement
import os
import sys
import csv
# Location of libraries
sys.path.append("C:\\Code\\trunk\\libs\\psselib") # psse_utilities
sys.path.append("C:\\Code\\trunk\\libs\\filelib") # file utils
sys.path.append("C:\\program files\\pti\\psse32\\pssbin") # psspy
@jtrain
jtrain / example_transaction.py
Created September 26, 2011 07:29
Example code running in a Python for PSSE transaction
from __future__ import with_statement
import os
from transactions import transaction, psspy, PSSE_EXAMPLES
psspy.throwPsseExceptions = False
def validate_solved():
"""
Return true if the last psse case has solved.
@jtrain
jtrain / transactions.py
Created September 26, 2011 07:10
Transaction based Python script for PSSE
"""
Transaction
-----------
Wrap your PSSe Python code in this transaction and watch it rollback
when the case blows up.
"""
from __future__ import with_statement
import contextlib
import os