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:936484
Created April 22, 2011 11:36
locally save and load data example snippet
protected function saveToFileHandler(event:MouseEvent):void
{
var data:String = inputText.text;
debug("data to save: "+data);
var path:String = mdm.Application.path+"myFile.txt";
debug("saving data at: "+path);
mdm.FileSystem.saveFileUnicode(path, data);
// now load it back
var request:URLRequest = new URLRequest(path);
urlLoader = new URLLoader();
@peterblazejewicz
peterblazejewicz / gist:946107
Created April 28, 2011 09:56
helper to compute paths
/**
* this method help to construct paths
* at runtime and will work during authoring
* and in ZINC application and on Win/Mac/Linux
*/
public function getPath(path:String):String
{
if(mdm.Application && mdm.Application.path.length > 0)
{
path = "file://"+mdm.Application.path.split("\\").join("/")+path;
@peterblazejewicz
peterblazejewicz / gist:964412
Created May 10, 2011 12:55
URL Access scripting: download a file using AppleScript
# destination as file path
set destination_file to ((path to desktop as string) & "myImage.jpg") as string
# source as url string
set source_file_url to "http://www.nasa.gov/images/content/180842main_access-lca.jpg"
# start download - it returns reference to a file if created
tell application "URL Access Scripting"
download source_file_url to destination_file replacing yes
end tell
@peterblazejewicz
peterblazejewicz / gist:966291
Created May 11, 2011 11:08
simple wrapper around Kernel32.dll GetDriveType function
package
{
import mdm.DLL;
import mdm.System;
public class Kernel32
{
/* The drive type cannot be determined. */
public static const DRIVE_UNKNOWN:int = 0;
/* The root path is invalid; for example, there is no volume mounted at the specified path. */
@peterblazejewicz
peterblazejewicz / gist:966558
Created May 11, 2011 14:35
downloading file into plugin with copy saved into local drive
<?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="mdm.Application.init(this);">
<fx:Script>
<![CDATA[
import mdm.Application;
@peterblazejewicz
peterblazejewicz / gist:968268
Created May 12, 2011 09:57
downloading zip file using URLStream for optimized memory use
package
{
import flash.events.Event;
import flash.events.IOErrorEvent;
import flash.events.ProgressEvent;
import flash.net.URLRequest;
import flash.net.URLStream;
import flash.utils.ByteArray;
import mdm.Application;
@peterblazejewicz
peterblazejewicz / gist:970224
Created May 13, 2011 08:55
printing from embedded browser instance on Win/Mac
protected function printHandler(event:MouseEvent):void
{
if(browser)
{
if(flash.system.Capabilities.os.toLowerCase().substr(0, 1) == "w")
{
browser.print();
} else
{
browser.goto("javascript:window.print();");
@peterblazejewicz
peterblazejewicz / gist:974346
Created May 16, 2011 12:21
send HEAD request with flash.net.Socket
protected function sendRequestHandler(event:MouseEvent):void
{
var request:URLRequest = new URLRequest("http://www.multidmedia.com/downloads/exchange/files/Simple_Applescript_Sample_042011.zip");
sendHeadRequest(request);
request = null;
}
//
private var socket:Socket = null;
private var httpRequest:String = null;
private var httpServer:String = null;
@peterblazejewicz
peterblazejewicz / gist:974631
Created May 16, 2011 15:19
scaling html content in Adobe Air
<?xml version="1.0" encoding="utf-8"?>
<s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx">
<fx:Script>
<![CDATA[
protected function zoomInHandler(event:MouseEvent):void
{
html.htmlLoader.window.document.body.style.zoom = 1.5;
@peterblazejewicz
peterblazejewicz / gist:975491
Created May 16, 2011 22:09
center application NativeWindow on screen with semi-transparent background and content centered on screen
<?xml version="1.0" encoding="utf-8"?>
<s:WindowedApplication 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"
backgroundAlpha="0.90" backgroundColor="#000000"
initialize="visible = false"
creationComplete="setupStage();" >
<!-- -->
<fx:Script>