Skip to content

Instantly share code, notes, and snippets.

View hsyed's full-sized avatar

Hassan Syed hsyed

View GitHub Profile
@hsyed
hsyed / embbeded_upython_qt
Created September 19, 2012 02:45
Embedded Ipython Qt attempt.
import sys
sys.path.insert(0, "../../ipython")
from IPython.embedded.ipkernel import EmbeddedKernel
from IPython.frontend.qt.console.rich_ipython_widget import RichIPythonWidget
from IPython.frontend.qt.embedded_kernelmanager import QtEmbeddedKernelManager
from IPython.lib import guisupport
from PyQt4.QtGui import QFrame,QHBoxLayout
from PyQt4.QtGui import QApplication
objectdef obj_Configuration_MiningLaserCycle
{
variable string SetName = "MiningLaserCycle"
method Initialize()
{
if !${BaseConfig.BaseRef.FindSet[${This.SetName}](exists)}
{
UI:Update["obj_Configuration", " ${This.SetName} settings missing - initializing", "o"]
This:Set_Default_Values[]
objectdef obj_Configuration_MiningLaserCycle
{
variable string SetName = "MiningLaserCycle"
method Initialize()
{
if !${BaseConfig.BaseRef.FindSet[${This.SetName}](exists)}
{
UI:Update["obj_Configuration", " ${This.SetName} settings missing - initializing", "o"]
This:Set_Default_Values[]
objectdef obj_Configuration_MiningLaserCycle
{
variable string SetName = "MiningLaserCycle"
method Initialize()
{
if !${BaseConfig.BaseRef.FindSet[${This.SetName}](exists)}
{
UI:Update["obj_Configuration", " ${This.SetName} settings missing - initializing", "o"]
This:Set_Default_Values[]
Traceback (most recent call last):
File "ipython_widget3.py", line 5, in <module>
from IPython.frontend.qt.console.rich_ipython_widget import RichIPythonWidget
File "../ipython/IPython/frontend/qt/console/rich_ipython_widget.py", line 15, in <module>
from IPython.external.qt import QtCore, QtGui
File "../ipython/IPython/external/qt.py", line 23, in <module>
QtCore, QtGui, QtSvg, QT_API = load_qt(api_opts)
File "../ipython/IPython/external/qt_loaders.py", line 258, in load_qt
api_options))
ImportError:
@hsyed
hsyed / gist:5662570
Last active December 17, 2015 19:48
Code that runs
import sys
from PyQt4.QtGui import QApplication
sys.path.insert(0, "../ipython")
from IPython.frontend.qt.console.rich_ipython_widget import RichIPythonWidget
from IPython.frontend.qt.inprocess import QtInProcessKernelManager
kernel_manager = QtInProcessKernelManager()
kernel_manager.start_kernel()
kernel = kernel_manager.kernel
uto ns = Namespace_("Testing");
ns.Struct("Person").
Fields({ {"name", 0, ":Text"},
{"birthdate", 1, ":Date"},
{"email", 2, ":Text"},
{"phones", 3, ":list(PhoneNumber)"} });
Struct("PhoneNumber").
Fields({ { "number", 0, ":Text"},
{ "type", 1, ":Type"} }).
Enum("Type", { {"mobile", 0 },
@hsyed
hsyed / gist:7685742
Created November 28, 2013 01:00
Postgress record and record array mapper
import org.postgresql.util.PGobject
import scala.util.matching.Regex
import scala.reflect.ClassTag
import scala.slick.lifted.{BaseTypeMapper, TypeMapperDelegate}
import scala.slick.driver.BasicProfile
import scala.slick.session.{PositionedResult, PositionedParameters}
import java.util.{Map => JMap}
abstract class RecordMapper[T: ClassTag]{
def name : String
object Tokenizer extends RegexParsers {
val quoteSymbol = """\\\""""
trait Element
case class ParElement(value: List[Element]) extends Element
case class CurElement(value: List[Element]) extends Element
trait Value extends Element
case class WholeInteger(value: String) extends Value
case class Decimal(value: String) extends Value
package edu.hsyed.nlp
import edu.hsyed.nlp.pgforumdb.forumstats.MyPostgresDriver
import scala.collection.JavaConverters._
import scala.collection.JavaConversions._
import forumavroschema._
import MyPostgresDriver.simple._
import Database.threadLocalSession