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: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>
@peterblazejewicz
peterblazejewicz / gist:995257
Created May 27, 2011 13:34
hide scrollbars in browser via javascript
javascript:document.body.style.overflow = 'hidden'
javascript:document.body.style.overflowX = 'hidden'
@peterblazejewicz
peterblazejewicz / gist:998586
Created May 30, 2011 08:00
save xml with flash.net.FileReference
<?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="320" height="480"
applicationComplete="mdm.Application.init(this);"
creationComplete="Controller.instance.model.existingDataObj.existingDataXML = xml;">
<fx:Declarations>
<fx:XML format="e4x" id="xml" xmlns="">
@peterblazejewicz
peterblazejewicz / gist:1006205
Created June 3, 2011 11:15
prevent CMD+Q default action
import mdm.Application;
import mx.controls.Alert;
import mx.events.CloseEvent;
//
// when application starts
// enable exit handler
// and route exit event to custom handler
// to get user action
//