Skip to content

Instantly share code, notes, and snippets.

View mudgen's full-sized avatar

Nick Mudge mudgen

View GitHub Profile
@mudgen
mudgen / scoping.py
Created July 13, 2014 07:06
Examples and results of variable scoping rules in Python 2.1, Python 2.5 and Ignition 7.6.
"""
Summary:
Functions in Ignition 7.6 and earlier can access variables defined in outer functions but cannot access
variables defined in module scope.
Functions in Python 2.1 can access variables defined in module scope but cannot access variables defined
in outer functions.
Functions in Python 2.5 can access variables defined in module scope and can access variables defined in
outer functions.
class Story < ActiveRecord::Base
validates_presence_of :name, :link
has_many :votes
def to_param
"#{id}-#{name.gsub(/\W/, '-').downcase}"
end
end
nick@mudge:~/potion$ git commit -a
# On branch master
# Your branch and 'origin/master' have diverged,
# and have 1 and 1 different commit(s) each, respectively.
#
@mudgen
mudgen / gist:4033999
Created November 7, 2012 19:58
Hyphen in Clojure namespace
(ns com.perfectabstractions.im-client.components.ImComponent
(:gen-class :extends com.inductiveautomation.vision.api.client.components.model.AbstractVisionComponent
:main true
:state state
:init init
:constructors {[] []})
(:import (java.awt BasicStroke Color Dimension
Font FontMetrics Graphics
Graphics2D Rectangle RenderingHints
Shape Stroke)
(ns com.perfectabstractions.im-designer.ImDesignerHook
(:import (com.perfectabstractions.im-client.components ImComponent)
(com.inductiveautomation.ignition.designer.model AbstractDesignerModuleHook
DesignerContext)
(com.inductiveautomation.ignition.common.licensing LicenseState)
(com.inductiveautomation.vision.api.designer VisionDesignerInterface)
(com.inductiveautomation.vision.api.designer.palette Palette
PaletteItemGroup
JavaBeanPaletteItem))
(:gen-class :extends com.inductiveautomation.ignition.designer.model.AbstractDesignerModuleHook
(ns build.util
(:require [fs.core :as fs]
[clojure.java.io :as io])
(:import [java.util.zip ZipOutputStream
ZipEntry]))
(defn zip-dir
[name dir]
(with-open [zip-out (ZipOutputStream. (io/output-stream (fs/absolute-path name)))]
(let [read-buffer (make-array Byte/TYPE 2156)]
(defn -getIcon
[this kind]
(condp some #(= kind %)
[BeanInfo/ICON_COLOR_16x16
BeanInfo/ICON_MONO_16x16] (load-icon this "/images/hello_world_16.png")
[BeanInfo/ICON_COLOR_32x32
BeanInfo/ICON_MONO_32x32] (load-icon this "/images/hello_world_32.png")))
public class EquipmentSettingsPage extends RecordActionTable<EquipmentRecord> {
public EquipmentSettingsPage(IConfigPage configPage) {
super(configPage);
// TODO Auto-generated constructor stub
}
@Override
public String[] getMenuPath() {
// TODO Auto-generated method stub
enum ConnectionMode {
ACTIVE,PASSIVE,ALTERNATING
}
public static final EnumField<ConnectionMode> Mode =
new EnumField<ConnectionMode>(META, "ConnectionMode", ConnectionMode.class, SFieldFlags.SMANDATORY);
package com.inductiveautomation.gemsecs;
import simpleorm.dataset.SFieldFlags;
import com.inductiveautomation.ignition.gateway.localdb.persistence.BooleanField;
import com.inductiveautomation.ignition.gateway.localdb.persistence.Category;
import com.inductiveautomation.ignition.gateway.localdb.persistence.EnumField;
import com.inductiveautomation.ignition.gateway.localdb.persistence.FormMeta;
import com.inductiveautomation.ignition.gateway.localdb.persistence.IdentityField;
import com.inductiveautomation.ignition.gateway.localdb.persistence.IntField;