Skip to content

Instantly share code, notes, and snippets.

View hopewise's full-sized avatar

Samir Sabri hopewise

View GitHub Profile
@hopewise
hopewise / socket.js
Created March 28, 2013 09:27
I am serving a static page, which will connect to socket.io at my node js app, I don't know why socket connection event takes about 10 seconds! as a result the server response takes about 10 seconds to reach the client, I added a link at html page to test the time, emit and emit call back, it takes about one second .. also, its too long .. pleas…
// server static file
var fs = require('fs'),
http = require('http');
var app= http.createServer(function (req, res) {
console.log(__dirname);
@hopewise
hopewise / gist:5285305
Last active December 15, 2015 15:58
ping results at windows 7/ Jordan/ Middle East
C:\af>ping samirapps.jit.su
Pinging samirapps.jit.su [165.225.130.237] with 32 bytes of data:
Reply from 165.225.130.237: bytes=32 time=154ms TTL=241
Reply from 165.225.130.237: bytes=32 time=147ms TTL=241
Reply from 165.225.130.237: bytes=32 time=169ms TTL=241
Reply from 165.225.130.237: bytes=32 time=172ms TTL=241
Ping statistics for 165.225.130.237:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
@hopewise
hopewise / gist:7274950
Created November 2, 2013 02:57
the above will look different on windows/ android, but it will look correct on flash .. its related to the filter it self, not the swf library I think
var glow:GlowFilter = new GlowFilter(0xdc2127, 1, 25, 25,8 );
glow.inner = true;
glow.knockout = false;
var sh:Shape = new Shape();
sh.graphics.beginFill(0xeeeeee);
sh.graphics.drawCircle(0, 0, 100);
sh.graphics.endFill();
sh.x = 300;
sh.y = 300;
@hopewise
hopewise / Battery.hx
Last active December 27, 2015 07:29
Here is my setup for showing properties for battery.xml or resistor.xml, I depend on property "name" which I set differently on each widget, see Battery.hx, Resistor.hx resistance.xml is a field which should be used in different components ..
package com.clientside.compoents;
import com.clientside.board.Board;
import com.clientside.compoents.core.Component;
import com.clientside.main.Main;
import com.clientside.meters.Meter;
#if !html5
import flash.display.MovieClip;
#end
@hopewise
hopewise / gist:7384868
Created November 9, 2013 12:18
Button defaults are not effective, although I am setting them by code, other buttons using "Default,OnOf" in XML works fine ..
class Button extends ru.stablex.ui.widgets.Button
{
public function new(aCaption:String)
{
super();
text = aCaption;
format.size = Utils.DPS(12);
@hopewise
hopewise / haxe
Last active December 28, 2015 13:38
When I remove a child from HBox within a Scroll, all elements will shift down, each time I remove a child from HBox, all elements will shift down, this happens only when HBox within a Scroll ..
var myComponents:HBox= UIBuilder.get('myComponents').as(HBox);
myComponents.addChildAt(component, myComponents.getChildIndex(this)+1);
myComponents.removeChild(this);
myComponents.alignElements();
@hopewise
hopewise / index.xml
Created November 17, 2013 14:29
in index.xml, I set w of main widget (Floating) to 1000, to see how Scroll would set its widthPt 100, it has exceeded its limited width ..
<?xml version="1.0" encoding="UTF-8"?>
<!-- root element for our UI -->
<Floating id="'root'" w="1000" heightPt="100" skin:Paint-color="0x000000"
on-resize="
#screens.h = $this.h - #bottomMenu.h - #topMenu.h;
if( $Lib.current.stage.stageWidth < 320 || $Lib.current.stage.stageHeight < 480 ){
var popup = $Main.alert({
@hopewise
hopewise / Floating
Created December 8, 2013 07:54
How to use autoHeight of Floating?
<Floating autoHeight="true" skin:Paint-border="20" skin:Paint-borderColor="0xFF0000" skin:Paint-color="0xff0000" align= "'left,top'" left="Utils.DPS(150)" top="Utils.DPS(150)" id="'propertiesInspector'" w="Main.InspectorWidth" >
<HBox id="'propertiesInspectorBar'" autoHeight="true" widthPt="100" skin:Paint-color="0x000000" align = "'left,middle'" >
<Text defaults="'Default,H2'" text="'Component Properties'" format-color = "0xffffff"/>
<Box right="Utils.DPS(5)" w="Utils.DPS(35)" h="Utils.DPS(30)" skin:Paint-color="0x00ff00" align="'middle'">
<Bmp src="'ui/android/img/ico/dark/settings.png'" autoSize="true" on-click="
var propertiesInspector:Floating = cast (UIBuilder.get('propertiesInspector'), Floating);
@hopewise
hopewise / LabScroll
Created January 12, 2014 14:58
Some times, I need to start scrolling after mouse down, here is my custom class that extends ru.stablex.ui.widgets.Scroll
package com.clientside.ui;
import flash.events.Event;
import flash.events.MouseEvent;
import flash.Lib;
import ru.stablex.ui.events.ScrollEvent;
import ru.stablex.ui.events.WidgetEvent;
import ru.stablex.ui.widgets.Scroll;
/**
@hopewise
hopewise / PropertiesViewStack.hx
Created January 13, 2014 05:21
as for ru.stablex.ui.widgets.ViewStack, visible = false is not sufficient to eliminate any mouse related logic in android, so I forced scaleX, scaleY to zero when view is invisible
package com.clientside.ui;
import com.clientside.Utils;
import ru.stablex.ui.widgets.ViewStack;
/**
* ...
* @author Samir Sabri
*/
class PropertiesViewStack extends ViewStack