Skip to content

Instantly share code, notes, and snippets.

@xcriptus
xcriptus / task_to_url.sh
Created February 13, 2019 19:17
Convert a modelscript task list to a list of url
cat task_list.txt | gawk '{ print "[" $1 "](https://modelscript.readthedocs.io/en/latest/methods/concepts/"$1")" }'
print reduce((lambda x,y:y+x+y),[('%04i %s\n'%(sum(range(1,i+1)),' .'*i)).rjust((63+1)*2+9) for i in range(0,(63+1))]+[(str(sum(range(0,63+1)))*((63+5)/2)+'\n')*2])
@xcriptus
xcriptus / gist:abba6637d8a94ee87617
Created December 30, 2015 11:41
PyCharm autorload ipython module
%load_ext autoreload
%autoreload 2
print "reload enabled"
import sys; print('Python %s on %s' % (sys.version, sys.platform))
sys.path.extend([WORKING_DIR_AND_PYTHON_PATHS])
@xcriptus
xcriptus / modelio SWT GUI
Last active August 29, 2015 14:17
Shows how to build a basic SWT windows from Modelio
#
# This code show how to translates SWI Widgets snippets into a simple
# script that can be run directly in the Script window of Modelio.
# The code has been translated from java to jython and the first
# lines have been accomodated to fit within Modelio (indeed the
# eclipse part of modelio).
#
# This example take a particular exemple "Paint a cirle in a canvas".
# You should read th
# http://git.eclipse.org/c/platform/eclipse.platform.swt.git/tree/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet245.java
@xcriptus
xcriptus / ModelioCreateClass.py
Last active August 29, 2015 13:57
Modelio Factory Create Model Transaction Jython Class 3.1
# This code creates two classes in the package MyPackage
# The library modelioscriptor is used
# The code assume that "MyPackage" is in the model
trans = theSession().createTransaction("Class creation")
try:
fact= theUMLFactory()
myp = instanceNamed(Package,"MyPackage")
c1 = fact.createClass()
c1.setOwner(myp)
c1.setName("Class1")
@xcriptus
xcriptus / PredefinedInTemplates
Created December 14, 2012 17:22
Predefined function in staruml templates
/////////////////////////////////////////////////
// createFile :
//
function createFile(path) {
notify('Creating file '+ path + '...');
return fileObject.CreateTextFile(path, true, false);
}
/////////////////////////////////////////////////
// deleteFile :
@xcriptus
xcriptus / ModelExploration.js
Created December 10, 2012 21:45
StarUML - Model Exploration - OwnedElement & Namespaces
var staruml = new ActiveXObject("StarUML.StarUMLApplication");
var project = staruml.GetProject();
VisitOwnedElement(project,"");
function VisitOwnedElement(owner,indent){
for (var i = 0; i < owner.GetOwnedElementCount(); i++){
var element = owner.GetOwnedElementAt(i);
// Process the current element
staruml.AddMessageItem(1,indent+element.Name+" : "+element.getClassName(),element) ;
@xcriptus
xcriptus / Glossary.vbs
Created December 9, 2012 23:17
ExcelGlossary - VB Script
Option Explicit
Const kOpenTermChar = "{"
Const kCloseTermChar = "}"
Const kExternalTermChar = "^"
Const kQuotingChar = """"
Const kNewTermIdPrefix = "-"
Const kTermIdDelimiter = "#"
@xcriptus
xcriptus / recursive.js
Created December 9, 2012 22:23
StarUML - Translator - Recursive Traversal
// These functions allow to get a list of elements according to the
// REPEAT feature of staruml templates
// This piece of code comes from the StarUML translators
////////////////////////////////////////////////
// getAllRecursiveElements :
//
function getAllRecursiveElements(isDeep, rootElem, filterType) {
// 1.get elem's type
@xcriptus
xcriptus / FileSystem.js
Created December 9, 2012 22:18
StarUML - Translator - Predefined functions
// Here comes some code that initialize some global variables
// This code is an excerpt of StarUML translators
////////////////////////////////////////////////
// createFile :
//
function createFile(path) {
notify('Creating file '+ path + '...');
return fileObject.CreateTextFile(path, true, false);