Skip to content

Instantly share code, notes, and snippets.

View peterblazejewicz's full-sized avatar
:octocat:
@code #remote #ssh #raspberrypi

Piotr Błażejewicz (Peter Blazejewicz) peterblazejewicz

:octocat:
@code #remote #ssh #raspberrypi
View GitHub Profile
@peterblazejewicz
peterblazejewicz / gist:1203054
Created September 8, 2011 09:59
drag/minimize/maximize/close using {mdm} script
package
{
import flash.events.MouseEvent;
import mdm.Application;
import mdm.Forms;
import mx.core.UIComponent;
import spark.components.Application;
@peterblazejewicz
peterblazejewicz / gist:1260360
Created October 3, 2011 21:52
jQuery Mobile page fragment logic scripting with dom-caching
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
<link rel="stylesheet" href="./jquery.mobile.css" />
<script type="application/javascript" src="./jquery.js"></script>
<script type="application/javascript" src="./jquery.mobile.js"></script>
</head>
<body>
<!-- page start -->
@peterblazejewicz
peterblazejewicz / gist:1267819
Created October 6, 2011 16:13
computing paths in Flash/Zinc/Xcode
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
width="800" height="600" applicationComplete="appInit()" backgroundColor="#000000">
<fx:Script>
<![CDATA[
import mdm.Application;
import mdm.FileSystem;
@peterblazejewicz
peterblazejewicz / gist:1270160
Created October 7, 2011 12:25
Mac OS X set desktop image with AppleScript
tell application "Finder"
set backgroundFile to POSIX file "/Users/kacper/desktop/runningApplication.jpg" as string
set desktop picture to file backgroundFile
end tell
@peterblazejewicz
peterblazejewicz / gist:1286558
Created October 14, 2011 08:27
sending mail client side with AppleScript
# content of message
set messageContent to "Hello Johh,\rCan you check below information for me?\r....\n...\nregards,\rPeter"
# code to script Mail.app to create new message in new window
tell application "Mail"
# bring to front
activate
# create new message and make it visible for edition
set newMessage to make new outgoing message with properties {visible:true, subject:"message subject", content:messageContent}
# set properties of message
tell newMessage
@peterblazejewicz
peterblazejewicz / gist:1447697
Created December 8, 2011 17:22
git primary MAC address using AppleScript
set theEthernetAddress to primary Ethernet address of (get system info)
@peterblazejewicz
peterblazejewicz / gist:1753084
Created February 6, 2012 16:23
paths convertion for authoring/deployment
function computePath(path:String):String
{
// in Zinc context convert path to absolute one
// and to file protocol notation
if(mdm.Application && mdm.Application.path)
{
// convert path to FILE protocol Unix notation
return "file://"+mdm.Application.path.split("\\").join("/")+path;
};
// otherwise return as-is
@peterblazejewicz
peterblazejewicz / gist:1760366
Created February 7, 2012 15:54
exit on mouse move
protected function applicationCompleteHandler(event:FlexEvent):void
{
mdm.Application.init();
this.stage.addEventListener(MouseEvent.MOUSE_MOVE, onMouseMoveHandler);
}
protected function onMouseMoveHandler(event:MouseEvent):void
{
// first unregister event
this.stage.removeEventListener(MouseEvent.MOUSE_MOVE, onMouseMoveHandler);
// then exit lazily
@peterblazejewicz
peterblazejewicz / gist:1760374
Created February 7, 2012 15:55
exit on key down
protected function applicationCompleteHandler(event:FlexEvent):void
{
mdm.Application.init();
this.stage.addEventListener(KeyboardEvent.KEY_DOWN, onKeyboardEventDownHandler);
}
protected function onKeyboardEventDownHandler(event:MouseEvent):void
{
// first unregister event
this.stage.removeEventListener(KeyboardEvent.KEY_DOWN, onKeyboardEventDownHandler);
// then exit lazily
@peterblazejewicz
peterblazejewicz / gist:1760991
Created February 7, 2012 17:54
amIFirst util method (simple one) based on LocalConnection object properties
// util method
protected function isFirstInstance():Boolean
{
const CONNNECTION_NAME:String = "__MY_APP_CHECK_HASH__";
var lc:LocalConnection = new LocalConnection();
// try/catch
// assume that ArgumentError is thrown when connection already exists
// as per documentation
try{
lc.connect(CONNNECTION_NAME);