Skip to content

Instantly share code, notes, and snippets.

View achudars's full-sized avatar
🥔
every challenge is an opportunity

Aleks achudars

🥔
every challenge is an opportunity
View GitHub Profile
@achudars
achudars / states.xml
Last active August 29, 2015 14:16
XML containing all (or most) HTML4 and HTML5 elements
<?xml version="1.0" encoding="UTF-8"?>
<journey>
<!-- sample transitions -->
<state id="1">
<transition id="transition_11" event="onsubmit" target="2"/>
<html>
<head>
<title>Search</title>
</head>
<body>
@achudars
achudars / model
Created March 8, 2015 10:51
sample IFML model
<?xml version="1.0" encoding="UTF-8"?>
<core:IFMLModel xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:core="http://www.omg.org/spec/20130218/core" xmlns:ext="http://www.omg.org/spec/20130218/ext" xmlns:uml="http://www.eclipse.org/uml2/5.0.0/UML" id="_QwKrAM7OEeOGsv3AxEnrmw" name="Movies">
<interactionFlowModel id="_YON7gM7PEeOGsv3AxEnrmw" name="InteractionFlowModel">
<interactionFlowModelElements xsi:type="ext:IFMLWindow" id="_BTIDUM7QEeOGsv3AxEnrmw" name="MovieList" isDefault="true">
<viewElements xsi:type="ext:List" id="_LjeRwM7QEeOGsv3AxEnrmw" name="MovieList" inInteractionFlows="//@interactionFlowModel/@interactionFlowModelElements.3/@outInteractionFlows.0">
<parameters id="_4Fxrgs7mEeOGsv3AxEnrmw" name="SelectedMovie">
<type xsi:type="uml:Class" href="model.uml#__W1boJ6PEeGdnpRmAZh-dQ"/>
</parameters>
<viewElementEvents xsi:type="ext:OnSelectEvent" id="_js4hwM7QEeOGsv3AxEnrmw" name="Select a movie" viewElement="//@interactionFlowModel/@interactio
@achudars
achudars / attributes
Created March 8, 2015 10:51
CasperJS capture
var searchAttributes = ['form[action="/search"]','[class*="search"]','[name*="search"]','[id*="search"]','[type="search"]','[placeholder*="search"]'];
@achudars
achudars / HTML2IFML.etl
Last active August 29, 2015 14:16
HTML2IFML mapping
pre {
// initial setup of the IFML model structure
var IFMLModel := new IFML!IFMLModel;
IFMLModel.id = "journey";
IFMLModel.name = "journey";
IFMLModel.contentModel := new IFML!ContentModel;
IFMLModel.contentModel.id = "ContentModel";
IFMLModel.contentModel.name = "ContentModel";
IFMLModel.interactionFlowModel := new IFML!InteractionFlowModel;
IFMLModel.interactionFlowModel.id = "InteractionFlowModel";
@achudars
achudars / IFML.emf
Last active August 29, 2015 14:16
IFML (IFML 1.0 Beta2) Emfatic file with all HTML5 events added as an extension
@namespace(uri="top", prefix="top")
package top;
@namespace(uri="http://www.omg.org/spec/IFML", prefix="ifml")
package ifml {
@namespace(uri="http://www.omg.org/spec/IFML/ext", prefix="ext")
package extensions {
class Form extends core.ViewComponent {
!ordered ref SubmitEvent[*] submitEvent;
}
@achudars
achudars / HTML5.java
Last active August 29, 2015 14:16
HTML 5 metamodel in EMF (being updated)
@namespace(
uri="HTML",
prefix="HTML")
package HTML;
class Model {
val HTMLHtmlElement HTMLHtmlElement;
}
abstract class HTMLHtmlElement {
@achudars
achudars / simpleCasperJSCapture
Created February 19, 2015 10:47
Simple CasperJS Capture of Search Interaction (to be deleted)
//casperjs
var casper = require('casper').create({
pageSettings: {
webSecurityEnabled: false
},
clientScripts: []
//verbose: true,
//logLevel: "debug"
});
@achudars
achudars / qrw.py
Created January 29, 2014 11:24
Quantum Random Walk
# import NumPy
from numpy import *
from matplotlib.pyplot import *
# add a line to print out floating point numbers to 3 decimal places
set_printoptions(precision=3) # float precision for printing
N = 100 # define number of random steps
P = 2*N+1 # define the number of positions
@achudars
achudars / rainbow.py
Last active December 31, 2015 08:39
decryption of rainbow encryption ( created by @abradbury ) WARNING! The code might eat up all your RAM
import itertools
import binascii
# R - red
# O - orange
# Y - yellow
# G - green
# B - blue
# I - indigo
# V - violet
@achudars
achudars / roles.php
Created November 26, 2013 18:21
Different user roles with PHP and PDO
<?php
// username and password sent from form
$myusername=$_POST['myusername'];
$mypassword=$_POST['mypassword'];
try {
// Connect to server and select database.
$db = new PDO("mysql:host=$host;dbname=$db_name", $username, $password);
$db->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION );