text:
<!DOCTYPE html>

        <meta charset="utf-8">
        <title>Login</title>
        <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
        <meta name="apple-mobile-web-app-capable" content="yes">
        <link href="{{ asset('assets-penduduk/css/bootstrap.min.css') }}" rel="stylesheet">
        <link href="{{ asset('assets-penduduk/css/bootstrap-responsive.min.css') }}" rel="stylesheet">
        <link href="http://fonts.googleapis.com/css?family=Open+Sans:400italic,600italic,400,600" rel="stylesheet">
        <link href="{{ asset('assets-penduduk/css/font-awesome.css') }}" rel="stylesheet">
        <link href="{{ asset('assets-penduduk/css/style.css') }}" rel="stylesheet">
        <link href="{{ asset('assets-penduduk/css/pages/dashboard.css') }}" rel="stylesheet">
        <link href="{{ asset('assets-penduduk/css/pages/signin.css') }}" rel="stylesheet" type="text/css">

                    Kependudukan dan Pencatatan Sipil

                            @if (count($errors) > 0)

                                    Whoops! There were some problems with your input.

                                        @foreach ($errors->all() as $error)

{{ $error }}

                                        @endforeach

                            @endif
                            <form action="" method="post">
								<input type="hidden" name="_token" value="{{ csrf_token() }}">

Halaman Masuk Penduduk

Mohon isi detil akun anda

                                        Nomor Induk Kependudukan
                                        <input type="text" id="username" name="email" placeholder="Nomor Induk Kependudukan" class="login username-field">

                                        Sandi
                                        <input type="password" id="password" name="password" placeholder="Sandi" class="login password-field">

                                    <button class="button btn btn-success btn-large">Masuk</button>

                            </form>


text:
Homer - Responsive Admin Theme

Special Admin Theme for small and medium webapp with very clean and aesthetic style and feel.

404

    Page Not Found

        Sorry, but the page you are looking for has not been found. Try checking the URL for error, then hit the refresh button on your browser or try found something else in our app

redpajama_set_name: RedPajamaGithub


text:
namespace System.Drawing.Toolkit
{

using System;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Toolkit;
using DotGNU.Images;
using Xsharp;

internal sealed class DrawingWindow : InputOutputWidget, IToolkitWindow
{
	// Internal state.
	private IToolkit toolkit;
	private IToolkitEventSink sink;
	private ButtonName button;
	private bool hasCapture;
	private static Xsharp.Cursor[] cursors;

	// Constructor.
	public DrawingWindow(IToolkit toolkit, Widget parent,
						 int x, int y, int width, int height, IToolkitEventSink sink)
			: base(parent, x, y, width, height)
			{
				this.sink = sink;
				this.toolkit = toolkit;
				this.AutoMapChildren = false;
				this.DrawBackground = false;
			}

	// Get the toolkit that owns this window.
	public IToolkit Toolkit
			{
				get
				{
					return toolkit;
				}
			}

	// Get the toolkit parent window.
	IToolkitWindow IToolkitWindow.Parent
			{
				get
				{
					return (IToolkitWindow)Parent;
				}
			}

	// Get the current dimensions of this window.
	public System.Drawing.Rectangle Dimensions
			{
				get
				{
					return new System.Drawing.Rectangle(X, Y, Width, Height);
				}
			}

	// Get or set the mapped state of the window.
	bool IToolkitWindow.IsMapped
			{
				get
				{
					return IsMapped;
				}
				set
				{
					IsMapped = value;
				}
			}

	// Determine if this window currently has the input focus.
	bool IToolkitWindow.Focused
			{
				get
				{
					return Focused;
				}
			}

	// Get or set the mouse capture on this window.  Mouse captures
	// typically aren't required in the same place where Windows
	// needs them.  It is also highly dangerous to allow X applications
	// to capture the mouse without very careful thought.
	bool IToolkitWindow.Capture
			{
				get
				{
					return hasCapture;
				}
				set
				{
					hasCapture = value;
				}
			}

	// Set the focus to this window.
	void IToolkitWindow.Focus()
			{
				RequestFocus();
			}

	// Destroy this window and all of its children.
	void IToolkitWindow.Destroy()
			{
				Destroy();
				/*
				 * if the window is destroyed, set toolkit and sink to zero.
				 * otherwise, we couold get events like LostFocus...
				*/
				toolkit = null;
				sink    = null;
			}

	// Move or resize this window.
	void IToolkitWindow.MoveResize(int x, int y, int width, int height)
			{
				DrawingToolkit.ValidateWindowPosition(ref x, ref y);
				DrawingToolkit.ValidateWindowSize(ref width, ref height);
				Move(x, y);
				Resize(width, height);
			}

	// Raise this window respective to its siblings.
	void IToolkitWindow.Raise()
			{
				Raise();
			}

	// Lower this window respective to its siblings.
	void IToolkitWindow.Lower()
			{
				Lower();
			}

	// Reparent this window to underneath a new parent.
	void IToolkitWindow.Reparent(IToolkitWindow parent, int x, int y)
			{
				if(parent == null)
				{
					Reparent(((DrawingToolkit)Toolkit).placeholder, x, y);
				}
				else
				{
					Reparent((Widget)parent, x, y);
				}
			}

	// Get a toolkit graphics object for this window.
	IToolkitGraphics IToolkitWindow.GetGraphics()
			{
				return new DrawingGraphics
					(toolkit, new Xsharp.Graphics(this));
			}

	// Set the foreground of the window to a solid color.
	void IToolkitWindow.SetForeground(System.Drawing.Color color)
			{
				Foreground = DrawingToolkit.DrawingToXColor(color);
			}

	// Set the background of the window to a solid color.
	void IToolkitWindow.SetBackground(System.Drawing.Color color)
			{
				if(color.A < 128)
				{
					BackgroundPixmap = null;
				}
				else
				{
					Background = DrawingToolkit.DrawingToXColor(color);
				}
			}

	// Move this window to above one of its siblings.
	void IToolkitWindow.MoveToAbove(IToolkitWindow sibling)
			{
				// Move this window below the sibling widget.
				MoveToAbove(sibling as Widget);
			}

	// Move this window to below one of its siblings.
	void IToolkitWindow.MoveToBelow(IToolkitWindow sibling)
			{
				// Move this window below the sibling widget.
				MoveToBelow(sibling as Widget);
			}

	// Get the HWND for this window.  IntPtr.Zero if not supported.
	IntPtr IToolkitWindow.GetHwnd()
			{
				return IntPtr.Zero;
			}

	// Invalidate this window.
	void IToolkitWindow.Invalidate()
			{
				Repaint();
			}

	// Invalidate a rectangle within this window.
	void IToolkitWindow.Invalidate(int x, int y, int width, int height)
			{
				DrawingToolkit.ValidateWindowPositionPaint(ref x, ref y);
				DrawingToolkit.ValidateWindowSize(ref width, ref height);
				Repaint(x, y, width + 1, height + 1);
			}

	// Force an update of all invalidated regions.
	void IToolkitWindow.Update()
			{
				Update(false);
				Display.Flush();
			}

	// Set the cursor.  The toolkit may ignore "frame" if it already
	// has a system-defined association for "cursorType".  Setting
	// "cursorType" to "ToolkitCursorType.InheritParent" will reset
	// the cursor to be the same as the parent window's.
	void IToolkitWindow.SetCursor(ToolkitCursorType cursorType, Frame frame)
			{
				ModifyCursor(this, cursorType, frame);
			}

	// Map an Xsharp key description into a "ToolkitKeys" value.
	private static ToolkitKeys MapKey(KeyName key)
			{
				switch(key)
				{
					case KeyName.XK_BackSpace:		return ToolkitKeys.Back;
					case KeyName.XK_Tab:			return ToolkitKeys.Tab;
					case KeyName.XK_KP_Tab:			return ToolkitKeys.Tab;
					case KeyName.XK_ISO_Left_Tab:	return ToolkitKeys.Tab;
					case KeyName.XK_Linefeed:		return ToolkitKeys.LineFeed;
					case KeyName.XK_Clear:			return ToolkitKeys.Clear;
					case KeyName.XK_Return:			return ToolkitKeys.Enter;
					case KeyName.XK_KP_Enter:		return ToolkitKeys.Enter;
					case KeyName.XK_Pause:			return ToolkitKeys.Pause;
					case KeyName.XK_Scroll_Lock:	return ToolkitKeys.Scroll;
					case KeyName.XK_Escape:			return ToolkitKeys.Escape;
					case KeyName.XK_Delete:			return ToolkitKeys.Delete;
					case KeyName.XK_KP_Delete:		return ToolkitKeys.Delete;
					case KeyName.XK_Home:			return ToolkitKeys.Home;
					case KeyName.XK_KP_Home:		return ToolkitKeys.Home;
					case KeyName.XK_Begin:			return ToolkitKeys.Home;
					case KeyName.XK_KP_Begin:		return ToolkitKeys.Home;
					case KeyName.XK_Left:			return ToolkitKeys.Left;
					case KeyName.XK_KP_Left:		return ToolkitKeys.Left;
					case KeyName.XK_Up:				return ToolkitKeys.Up;
					case KeyName.XK_KP_Up:			return ToolkitKeys.Up;
					case KeyName.XK_Right:			return ToolkitKeys.Right;
					case KeyName.XK_KP_Right:		return ToolkitKeys.Right;
					case KeyName.XK_Down:			return ToolkitKeys.Down;
					case KeyName.XK_KP_Down:		return ToolkitKeys.Down;
					case KeyName.XK_Prior:			return ToolkitKeys.Prior;
					case KeyName.XK_KP_Prior:		return ToolkitKeys.Prior;
					case KeyName.XK_Next:			return ToolkitKeys.Next;
					case KeyName.XK_KP_Next:		return ToolkitKeys.Next;
					case KeyName.XK_End:			return ToolkitKeys.End;
					case KeyName.XK_KP_End:			return ToolkitKeys.End;
					case KeyName.XK_Select:			return ToolkitKeys.Select;
					case KeyName.XK_Print:			return ToolkitKeys.Print;
					case KeyName.XK_Execute:		return ToolkitKeys.Execute;
					case KeyName.XK_Insert:			return ToolkitKeys.Insert;
					case KeyName.XK_KP_Insert:		return ToolkitKeys.Insert;
					case KeyName.XK_Help:			return ToolkitKeys.Help;
					case KeyName.XK_Num_Lock:		return ToolkitKeys.NumLock;
					case KeyName.XK_space:			return ToolkitKeys.Space;
					case KeyName.XK_KP_Space:		return ToolkitKeys.Space;
					case KeyName.XK_F1:				return ToolkitKeys.F1;
					case KeyName.XK_KP_F1:			return ToolkitKeys.F1;
					case KeyName.XK_F2:				return ToolkitKeys.F2;
					case KeyName.XK_KP_F2:			return ToolkitKeys.F2;
					case KeyName.XK_F3:				return ToolkitKeys.F3;
					case KeyName.XK_KP_F3:			return ToolkitKeys.F3;
					case KeyName.XK_F4:				return ToolkitKeys.F4;
					case KeyName.XK_KP_F4:			return ToolkitKeys.F4;
					case KeyName.XK_F5:				return ToolkitKeys.F5;
					case KeyName.XK_F6:				return ToolkitKeys.F6;
					case KeyName.XK_F7:				return ToolkitKeys.F7;
					case KeyName.XK_F8:				return ToolkitKeys.F8;
					case KeyName.XK_F9:				return ToolkitKeys.F9;
					case KeyName.XK_F10:			return ToolkitKeys.F10;
					case KeyName.XK_F11:			return ToolkitKeys.F11;
					case KeyName.XK_F12:			return ToolkitKeys.F12;
					case KeyName.XK_F13:			return ToolkitKeys.F13;
					case KeyName.XK_F14:			return ToolkitKeys.F14;
					case KeyName.XK_F15:			return ToolkitKeys.F15;
					case KeyName.XK_F16:			return ToolkitKeys.F16;
					case KeyName.XK_F17:			return ToolkitKeys.F17;
					case KeyName.XK_F18:			return ToolkitKeys.F18;
					case KeyName.XK_F19:			return ToolkitKeys.F19;
					case KeyName.XK_F20:			return ToolkitKeys.F20;
					case KeyName.XK_F21:			return ToolkitKeys.F21;
					case KeyName.XK_F22:			return ToolkitKeys.F22;
					case KeyName.XK_F23:			return ToolkitKeys.F23;
					case KeyName.XK_F24:			return ToolkitKeys.F24;
					case KeyName.XK_KP_Multiply:	return ToolkitKeys.Multiply;
					case KeyName.XK_KP_Add:			return ToolkitKeys.Add;
					case KeyName.XK_KP_Separator:
							return ToolkitKeys.Separator;
					case KeyName.XK_KP_Subtract:	return ToolkitKeys.Subtract;
					case KeyName.XK_KP_Decimal:		return ToolkitKeys.Decimal;
					case KeyName.XK_KP_Divide:		return ToolkitKeys.Divide;
					case KeyName.XK_KP_0:			return ToolkitKeys.NumPad0;
					case KeyName.XK_KP_1:			return ToolkitKeys.NumPad1;
					case KeyName.XK_KP_2:			return ToolkitKeys.NumPad2;
					case KeyName.XK_KP_3:			return ToolkitKeys.NumPad3;
					case KeyName.XK_KP_4:			return ToolkitKeys.NumPad4;
					case KeyName.XK_KP_5:			return ToolkitKeys.NumPad5;
					case KeyName.XK_KP_6:			return ToolkitKeys.NumPad6;
					case KeyName.XK_KP_7:			return ToolkitKeys.NumPad7;
					case KeyName.XK_KP_8:			return ToolkitKeys.NumPad8;
					case KeyName.XK_KP_9:			return ToolkitKeys.NumPad9;
					case KeyName.XK_Shift_L:
							return ToolkitKeys.LShiftKey;
					case KeyName.XK_Shift_R:
							return ToolkitKeys.RShiftKey;
					case KeyName.XK_Control_L:
							return ToolkitKeys.LControlKey;
					case KeyName.XK_Control_R:
							return ToolkitKeys.RControlKey;
					case KeyName.XK_Meta_L:
					case KeyName.XK_Alt_L:
					case KeyName.XK_Super_L:
					case KeyName.XK_Hyper_L:
							return ToolkitKeys.LMenu;
					case KeyName.XK_Meta_R:
					case KeyName.XK_Alt_R:
					case KeyName.XK_Super_R:
					case KeyName.XK_Hyper_R:
							return ToolkitKeys.RMenu;
					case KeyName.XK_Caps_Lock:		return ToolkitKeys.CapsLock;
					case KeyName.XK_0:				return ToolkitKeys.D0;
					case KeyName.XK_1:				return ToolkitKeys.D1;
					case KeyName.XK_2:				return ToolkitKeys.D2;
					case KeyName.XK_3:				return ToolkitKeys.D3;
					case KeyName.XK_4:				return ToolkitKeys.D4;
					case KeyName.XK_5:				return ToolkitKeys.D5;
					case KeyName.XK_6:				return ToolkitKeys.D6;
					case KeyName.XK_7:				return ToolkitKeys.D7;
					case KeyName.XK_8:				return ToolkitKeys.D8;
					case KeyName.XK_9:				return ToolkitKeys.D9;
					case KeyName.XK_A:				return ToolkitKeys.A;
					case KeyName.XK_B:				return ToolkitKeys.B;
					case KeyName.XK_C:				return ToolkitKeys.C;
					case KeyName.XK_D:				return ToolkitKeys.D;
					case KeyName.XK_E:				return ToolkitKeys.E;
					case KeyName.XK_F:				return ToolkitKeys.F;
					case KeyName.XK_G:				return ToolkitKeys.G;
					case KeyName.XK_H:				return ToolkitKeys.H;
					case KeyName.XK_I:				return ToolkitKeys.I;
					case KeyName.XK_J:				return ToolkitKeys.J;
					case KeyName.XK_K:				return ToolkitKeys.K;
					case KeyName.XK_L:				return ToolkitKeys.L;
					case KeyName.XK_M:				return ToolkitKeys.M;
					case KeyName.XK_N:				return ToolkitKeys.N;
					case KeyName.XK_O:				return ToolkitKeys.O;
					case KeyName.XK_P:				return ToolkitKeys.P;
					case KeyName.XK_Q:				return ToolkitKeys.Q;
					case KeyName.XK_R:				return ToolkitKeys.R;
					case KeyName.XK_S:				return ToolkitKeys.S;
					case KeyName.XK_T:				return ToolkitKeys.T;
					case KeyName.XK_U:				return ToolkitKeys.U;
					case KeyName.XK_V:				return ToolkitKeys.V;
					case KeyName.XK_W:				return ToolkitKeys.W;
					case KeyName.XK_X:				return ToolkitKeys.X;
					case KeyName.XK_Y:				return ToolkitKeys.Y;
					case KeyName.XK_Z:				return ToolkitKeys.Z;
					case KeyName.XK_a:				return ToolkitKeys.A;
					case KeyName.XK_b:				return ToolkitKeys.B;
					case KeyName.XK_c:				return ToolkitKeys.C;
					case KeyName.XK_d:				return ToolkitKeys.D;
					case KeyName.XK_e:				return ToolkitKeys.E;
					case KeyName.XK_f:				return ToolkitKeys.F;
					case KeyName.XK_g:				return ToolkitKeys.G;
					case KeyName.XK_h:				return ToolkitKeys.H;
					case KeyName.XK_i:				return ToolkitKeys.I;
					case KeyName.XK_j:				return ToolkitKeys.J;
					case KeyName.XK_k:				return ToolkitKeys.K;
					case KeyName.XK_l:				return ToolkitKeys.L;
					case KeyName.XK_m:				return ToolkitKeys.M;
					case KeyName.XK_n:				return ToolkitKeys.N;
					case KeyName.XK_o:				return ToolkitKeys.O;
					case KeyName.XK_p:				return ToolkitKeys.P;
					case KeyName.XK_q:				return ToolkitKeys.Q;
					case KeyName.XK_r:				return ToolkitKeys.R;
					case KeyName.XK_s:				return ToolkitKeys.S;
					case KeyName.XK_t:				return ToolkitKeys.T;
					case KeyName.XK_u:				return ToolkitKeys.U;
					case KeyName.XK_v:				return ToolkitKeys.V;
					case KeyName.XK_w:				return ToolkitKeys.W;
					case KeyName.XK_x:				return ToolkitKeys.X;
					case KeyName.XK_y:				return ToolkitKeys.Y;
					case KeyName.XK_z:				return ToolkitKeys.Z;
				}
				return ToolkitKeys.None;
			}

	// Map an Xsharp key description into a "ToolkitKeys" value.
	internal static ToolkitKeys MapKey(KeyName key, ModifierMask modifiers)
			{
				ToolkitKeys toolkitKey = MapKey(key);
				if((modifiers & ModifierMask.ControlMask) != 0)
				{
					toolkitKey |= ToolkitKeys.Control;
				}
				if((modifiers & ModifierMask.ShiftMask) != 0)
				{
					toolkitKey |= ToolkitKeys.Shift;
				}
				if((modifiers & ModifierMask.Mod1Mask) != 0)
				{
					toolkitKey |= ToolkitKeys.Alt;
				}
				return toolkitKey;
			}

	// Map an Xsharp button name into a "ToolkitMouseButtons" value.
	internal static ToolkitMouseButtons MapButton(ButtonName button)
			{
				switch(button)
				{
					case ButtonName.Button1:
						return ToolkitMouseButtons.Left;
					case ButtonName.Button2:
						return ToolkitMouseButtons.Middle;
					case ButtonName.Button3:
						return ToolkitMouseButtons.Right;
					case ButtonName.Button4:
						return ToolkitMouseButtons.XButton1;
					case ButtonName.Button5:
						return ToolkitMouseButtons.XButton2;
					default:
						return ToolkitMouseButtons.None;
				}
			}

	// Override the button press event from Xsharp.
	protected override void OnButtonPress(int x, int y, ButtonName button,
									      ModifierMask modifiers)
			{
				if(sink != null)
				{
					sink.ToolkitMouseDown
						(MapButton(button),
						 MapKey(KeyName.XK_VoidSymbol, modifiers),
						 1, x, y, 0);
				}
				this.button = button;
			}

	// Override the button release event from Xsharp.
	protected override void OnButtonRelease(int x, int y, ButtonName button,
									  	    ModifierMask modifiers)
			{
				if(sink != null)
				{
					sink.ToolkitMouseUp
						(MapButton(button),
						 MapKey(KeyName.XK_VoidSymbol, modifiers),
						 1, x, y, 0);
				}
				this.button = 0;
			}

	// Override the mouse wheel event from Xsharp.
	protected override bool OnButtonWheel(int x, int y, ButtonName button,
									  	   ModifierMask modifiers, int iDelta)
			{
				if(sink != null)
				{
					sink.ToolkitMouseWheel
						(MapButton(button),
						MapKey(KeyName.XK_VoidSymbol, modifiers),
						1, x, y, iDelta);
				}
				this.button = 0;

				return true;
			}

	// Override the button double click event from Xsharp.
	protected override void OnButtonDoubleClick
				(int x, int y, ButtonName button, ModifierMask modifiers)
			{
				if(sink != null)
				{
					sink.ToolkitMouseDown
						(MapButton(button),
						 MapKey(KeyName.XK_VoidSymbol, modifiers),
						 2, x, y, 0);
				}
			}

	// Override the pointer motion event from Xsharp.
	protected override void OnPointerMotion
				(int x, int y, ModifierMask modifiers)
			{
				if(sink != null)
				{
					sink.ToolkitMouseMove
						(MapButton(button),
						 MapKey(KeyName.XK_VoidSymbol, modifiers),
						 0, x, y, 0);
				}
			}

	// Override the key press event from Xsharp.
	protected override bool OnKeyPress(KeyName key,
									   ModifierMask modifiers, String str)
			{
				bool processed = false;
				if(sink != null)
				{
					// Emit the "KeyDown" event.
					ToolkitKeys keyData = MapKey(key, modifiers);
					if(sink.ToolkitKeyDown(keyData))
					{
						processed = true;
					}

					// Emit the "KeyChar" event if necessary.
					if(str != null)
					{
						foreach(char ch in str)
						{
							// Clean old ASCII DEL (0x7F)
							if(ch != (char)0x7F)
							{
								if(sink.ToolkitKeyChar(ch))
								{
									processed = true;
								}
							}
						}
					}
				}
				return processed;
			}

	// Override the key release event from Xsharp.
	protected override bool OnKeyRelease(KeyName key, ModifierMask modifiers)
			{
				if(sink != null)
				{
					// Emit the "KeyUp" event.
					ToolkitKeys keyData = MapKey(key, modifiers);
					return sink.ToolkitKeyUp(keyData);
				}
				return false;
			}

	// Override the mouse enter event from Xsharp.
	protected override void OnEnter(Widget child, int x, int y,
								    ModifierMask modifiers,
								    CrossingMode mode,
								    CrossingDetail detail)
			{
				if(sink != null)
				{
					sink.ToolkitMouseEnter();
				}
			}

	// Override the mouse leave event from Xsharp.
	protected override void OnLeave(Widget child, int x, int y,
								    ModifierMask modifiers,
								    CrossingMode mode,
								    CrossingDetail detail)
			{
				if(sink != null)
				{
					sink.ToolkitMouseLeave();
				}
			}

	// Override the focus enter event from Xsharp.
	protected override void OnFocusIn(Widget other)
			{
				if(sink != null)
				{
					sink.ToolkitFocusEnter();
				}
			}

	// Override the focus leave event from Xsharp.
	protected override void OnFocusOut(Widget other)
			{
				if(sink != null)
				{
					sink.ToolkitFocusLeave();
				}
			}

	// Handle a paint event from Xsharp.
	protected override void OnPaint(Xsharp.Graphics graphics)
			{
				if(sink != null)
				{
					System.Drawing.Region clip = RegionToDrawingRegion(graphics.ExposeRegion);
					DrawingGraphics g = new DrawingGraphics(toolkit, graphics);
					using(System.Drawing.Graphics gr =
								ToolkitManager.CreateGraphics(g, clip))
					{
						sink.ToolkitExpose(gr);
					}
				}
			}

	// Convert an Xsharp.Region to System.Drawing.Region
	internal static System.Drawing.Region RegionToDrawingRegion
				(Xsharp.Region region)
			{
				Xsharp.Rectangle[] rectangles = region.GetRectangles();
				System.Drawing.Region newRegion = new System.Drawing.Region();
				newRegion.MakeEmpty();
				for(int i = 0; i < rectangles.Length; i++)
				{
					Xsharp.Rectangle rect = rectangles[i];
					newRegion.Union(new System.Drawing.Rectangle
							(rect.x, rect.y, rect.width, rect.height));
				}
				return newRegion;
			}

	// Modify the cursor on a widget.
	internal static void ModifyCursor
				(Widget widget, ToolkitCursorType cursorType, Frame frame)
			{
				if(cursorType == ToolkitCursorType.InheritParent)
				{
					// Change the cursor back to the same value as the parent.
					widget.Cursor = null;
				}
				else if(cursorType == ToolkitCursorType.Default)
				{
					// Set the default cursor to something matching X.
					widget.Cursor = new Cursor(CursorType.XC_left_ptr);
				}
				else
				{
					// Create a cursor based on the supplied image.
					if(frame != null &&
									 /* irgnore pixel format !
									 frame.PixelFormat == DotGNU.Images.PixelFormat.Format1bppIndexed
									 &&
									 */
					   frame.Mask != null)
					{
						if(cursorType != ToolkitCursorType.UserDefined)
						{
							lock(typeof(DrawingWindow))
							{
								if(cursors == null)
								{
									cursors = new Xsharp.Cursor [32];
								}
								Xsharp.Cursor curs = cursors[(int)cursorType];
								if(curs == null)
								{
									cursors[(int)cursorType] = curs =
										new Xsharp.Cursor
											(widget.Screen, frame);
								}
								widget.Cursor = curs;
							}
						}
						else
						{
							widget.Cursor = new Xsharp.Cursor
								(widget.Screen, frame);
						}
						return;
					}

					// Last ditch attempt - use the nearest X11 cursor.
					CursorType type;
					switch(cursorType)
					{
						case ToolkitCursorType.AppStarting:
							type = CursorType.XC_watch;
							break;
						case ToolkitCursorType.Arrow:
						case ToolkitCursorType.Default:
							type = CursorType.XC_left_ptr;
							break;
						case ToolkitCursorType.Cross:
							type = CursorType.XC_crosshair;
							break;
						case ToolkitCursorType.IBeam:
							type = CursorType.XC_xterm;
							break;
						case ToolkitCursorType.No:
							type = CursorType.XC_X_cursor;
							break;
						case ToolkitCursorType.SizeAll:
							type = CursorType.XC_fleur;
							break;
						case ToolkitCursorType.SizeNS:
						case ToolkitCursorType.VSplit:
							type = CursorType.XC_sb_v_double_arrow;
							break;
						case ToolkitCursorType.SizeWE:
						case ToolkitCursorType.HSplit:
							type = CursorType.XC_sb_h_double_arrow;
							break;
						case ToolkitCursorType.UpArrow:
							type = CursorType.XC_sb_up_arrow;
							break;
						case ToolkitCursorType.WaitCursor:
							type = CursorType.XC_watch;
							break;
						case ToolkitCursorType.Help:
							type = CursorType.XC_question_arrow;
							break;
						case ToolkitCursorType.Hand:
							type = CursorType.XC_hand2;
							break;
						case ToolkitCursorType.SizeNWSE:
						case ToolkitCursorType.SizeNESW:
						case ToolkitCursorType.NoMove2D:
						case ToolkitCursorType.NoMoveHoriz:
						case ToolkitCursorType.NoMoveVert:
						case ToolkitCursorType.PanEast:
						case ToolkitCursorType.PanNE:
						case ToolkitCursorType.PanNorth:
						case ToolkitCursorType.PanNW:
						case ToolkitCursorType.PanSE:
						case ToolkitCursorType.PanSouth:
						case ToolkitCursorType.PanSW:
						case ToolkitCursorType.PanWest:
						case ToolkitCursorType.UserDefined:
						default:
							type = CursorType.XC_circle;
							break;
					}
					widget.Cursor = new Cursor(type);
				}
			}

	void IToolkitWindow.SendBeginInvoke(IntPtr i_gch)
			{
				base.SendBeginInvoke(i_gch);
			}

	protected override void OnBeginInvokeMessage(IntPtr i_gch)
			{
				if( sink != null )
					sink.ToolkitBeginInvoke(i_gch);
			}

}; // class DrawingWindow

}; // namespace System.Drawing.Toolkit


text:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3c.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />

<title>TESTING CHILI 3.0 - Filters</title>

<link type="text/css" rel="stylesheet" href="examples.css" />

highlight now

This page has the following setup.

JavaScript

Chili highlights jQuery

/**
 * Shows a dialog containing the text selected by the user
 */
function displaySelectedTextDialog( event )
{
    if (! (element && element == this))
    {
        return;
    }
    element = null;

    {:off()[var selectedText = getSelectedText();]off:}
{:background('#FFC')[    if ( '' == selectedText )
    {
        return;
    }
]background:}    selectedText = cleanText(selectedText);

    var $container = makeDialog(selectedText, event);
    selectTextAgain($container);
}


text:
'use strict'

const path = require('path')
const express = require('express')
const http = require('http')
const mongo = require('mongodb').MongoClient
const cors = require('cors')
const bodyParser = require('body-parser')
const BadLanguageFilter = require('bad-language-filter')
const ObjectId = require('mongodb').ObjectID;

const app = express()

const dbUrl = process.env.MONGODB_URI || 'mongodb://localhost:27018/data'

app.use(express.static(__dirname+'/public/'))
app.use(cors())
app.use(bodyParser.urlencoded({ extended: true }))
app.enable('trust proxy')

function langFilter(words){
  const filter = new BadLanguageFilter()
  let clean = filter.replaceWords(words + " ", "naughty-word ")
  return clean
}

function fetchPolls(callback) {
  mongo.connect(dbUrl, (err, db) => {
    if (err) throw err
    let polls = db.collection('polls')
    let data = polls.find().toArray((err, all) => {
      if (err) throw err
      callback(all)
      db.close()
    })
  })
}

function postPolls(title, username, options, callback) {
  let poll = {
    date: Date.now(),
    users:{
      creator: username,
      usernames: [ ],
      ips: [ ]
    },
    data:{
      title: title,
      options: options,
      results: options.map( () => 0 )
    }
  }
  mongo.connect(dbUrl, (err, db) => {
   if (err) throw err
   let polls = db.collection('polls')
   polls.insert(poll, (err, data) => {
      if (err) throw err
      let id=JSON.stringify(poll._id)
      callback(id)
      db.close()
    })
  })
}

function votePoll(id, vote, user, ip) {
  mongo.connect(dbUrl, (err, db) => {
   if (err) throw err
   let polls = db.collection('polls')
   polls.update(
     { "_id": ObjectId(id) },
     {
       $set: {
         "data.results": vote,
       },
       $push: {
         "users.usernames": user,
         "users.ips": ip
       }

    },
    function(err) {
      if (err) throw err
      db.close()
    })
 })
}

function deletePoll(id) {
  mongo.connect(dbUrl, (err, db) => {
   if (err) throw err
   let polls = db.collection('polls')
   polls.remove( {"_id": ObjectId(id)});
   db.close()
 })
}

function addOption(options, results, id) {
  mongo.connect(dbUrl, (err, db) => {
   if (err) throw err
   let polls = db.collection('polls')
   polls.update(
     { "_id": ObjectId(id) },
     {
       $set: {
         "data.options": options,
         "data.results": results
       }
    },
    function(err) {
      if (err) throw err
      db.close()
    })
 })
}

function addUser(email, password) {
  let username = email.split("@")[0]//+"theGreat" TODO check if user exists
  let user = {
    username,
    email,
    password
  }
  mongo.connect(dbUrl, (err, db) => {
   if (err) throw err
   let users = db.collection('users')
   users.insert(user, (err, data) => {
      if (err) throw err
      db.close()
    })
  })
}

function getUsers(callback) {
  mongo.connect(dbUrl, (err, db) => {
    if (err) throw err
    let users = db.collection('users')
    let data = users.find().toArray((err, all) => {
      if (err) throw err
      callback(all)
      db.close()
    })
  })
}

function getUserHash(email, callback) {
  mongo.connect(dbUrl, (err, db) => {
    if (err) throw err
    let users = db.collection('users')
    users.find(
      {
        'email': email
      }
    ).toArray((err, user) => {
      if (err) throw err
      if(user.length>0)
        callback(user[0].password)
      else
        callback("error: no user")
      db.close()
    })
  })
}

app.get('/api/polls', (req, res) => {
  fetchPolls( data => {
    res.writeHead(200, { "Content-Type": "application/json" });
    let json = JSON.stringify(data)
    res.end(json)
  })
})
app.post('/api/polls/POST', (req, res) => {
  postPolls(langFilter(req.body.title), req.body.creator || "guest", req.body.options, (id) => {
    res.end('{"success" : "POST success", "id" : '+id+', "status" : 200}');
  })
  res.writeHead(200, { 'Content-Type':  'application/json' })
})
app.post('/api/polls/VOTE', (req, res) => {
  votePoll(req.body.id, req.body.vote, req.body.user, req.ip)
  res.writeHead(200, { 'Content-Type':  'application/json' })
  res.end('{"success" : "POST success", "status" : 200}');
})
app.get('/api/GET/IP', (req, res) => {
  res.writeHead(200, { 'Content-Type':  'application/json' })
  res.end(JSON.stringify(req.ip));
})
app.post('/api/polls/DELETE', (req, res) => {
  deletePoll(req.body.id)
  res.writeHead(200, { 'Content-Type':  'application/json' })
  res.end('{"success" : "POST success", "status" : 200}');
})
app.post('/api/polls/OPTION', (req, res) => {
  addOption(req.body.options, req.body.results, req.body.id)
  res.writeHead(200, { 'Content-Type':  'application/json' })
  res.end('{"success" : "POST success", "status" : 200}');
})
app.post('/api/POST/USER', (req, res) => {
  addUser(req.body.email, req.body.hash)
  res.writeHead(200, { 'Content-Type':  'application/json' })
  res.end('{"success" : "POST success", "status" : 200}');
})
app.get('/api/GET/USERS', (req, res) => {
  getUsers( data => {
    res.writeHead(200, { "Content-Type": "application/json" });
    let json = JSON.stringify(data)
    res.end(json)
  })
})
app.get('/api/GET/USER/:email', (req, res) => {
  getUserHash(req.params.email, data => {
    res.writeHead(200, { "Content-Type": "application/json" });
    let json = JSON.stringify(data)
    res.end(json)
  })
})
app.get('*', (req, res) => {
  res.writeHead(200, { 'Content-Type': 'text/plain' })
  res.end('404!')
})

const port = process.env.PORT || 8081
http.createServer(app).listen(port)
console.log('Server Running on port: ' + port)


text:
[![Build Status](https://travis-ci.org/fschr/mo.png)](https://travis-ci.org/fschr/mo)

# Math Problems
This repostiory contains a bunch of math problems and their solutions in plain English. I will try to include the source for each problem. Sources might be erroneous or not original.

PRs are welcome.

## Probability and Statistics

1. Find the probability of obtaining four of a kind in an ordinary five-card poker hand. [Ash, Basic Probability Theory]

2. Three balls are dropped into three boxes. Find the probability that exactly one box will be empty. [Ash, Basic Probability Theory]

3. Find the probability of obtaining the A K Q J 10 of at least one suit in a 13-card bridge hand. That is, the probability that the A K Q J 10 of spades, or of hearts, and so on. [Ash, Basic Probability Theory]

4. If a three digit number (000 to 999) is chosen at random, find the probability that the exactly one of the digits is > 5. [Ash, Basic Probability Theory]

## Algorithms and Data Structures

# Solutions

## Probability and Statistics

### 1.

(13)(48) / (52 choose 5)

There are (52 choose 5) distinct poker hands (without regard to order). To obtain four of a kind,

(a) choose the face value to appear four times (13 choices: A, K, Q, ..., 2)

(b) choose the fifth card (52 - 4 = 48 remaing cards to choose from)

Thus *p* = (13)(48) / (52 choose 5)

### 2.

2/3

There are (3 choose 2) ways to choose two non-empty boxes. Now select which box of those two to contain just one (rather than two) balls. Thus *p* = (2) / (3 choose 2) = 2/3

### 3.

(4(47 choose 8) - 6(42 choose 3)) / (52 choose 13)

The number of ways to draw a 13-card bridge hand from a 52-card deck is (52 choose 13). Now, given that the five A K Q J 10 of spades are all in the hand, select 8 of the remaining 47 cards. Thus the probability of drawing the A K Q J 10 of spades in a 13-card bridge hand is (47 choose 8) / (52 choose 13).

Now recall that there are 4 suits in a standard 52-card deck. The probability of drawing the A K Q J 10 of spades or the A K Q J 10 of hearts is thus

(47 choose 8) / (52 choose 13) + (47 choose 8) / (52 choose 13)

= 2(47 choose 8) / (52 choose 13)

However, this does not account for the 13-card hand in which both the A K Q J 10 of spades and the A K Q J 10 of hearts are drawn. Given the fact that those 10 cards are already in the hand, select 3 from the remaining 42 cards to be the remainder cards in the hand. Thus, probability of drawing the A K Q J 10 of either suit, but not both, is (2(47 choose 8) - (42 choose 3)) / (52 choose 13).

It is possible to generalize this problem to all 4 suits. There are 4 different suits, and 6 different unordered pairs of suits. Thus the probability of drawing the A K Q J 10 of any suit is (4(47 choose 8) - 6(42 choose 3)) / (52 choose 13).

### 4.

0.432

This is a simple Bernoulli problem. Let *A* be the probability that the first digit > 5. *A* = 4/10 * (6/10) * (6/10) = 0.144. (The first digit could be 6, 7, 8, or 9 and the remaining two digits could each be 0-5). The probability that the second digit > 5 is independent of A. Similarly, this extends to the third digit. So there are 3 ways---3 digits, choose 1---each with probability 0.144 that a single digit is > 5. Thus *p* =  3 * 0.144 = 0.432.

## Algorithms and Data Structures


text:
<?php
namespace Craft;

/**
* Element Action to queue emails
*/
class Emailer_SendEmailElementAction extends BaseElementAction
{
  public function getName()
  {
    return Craft::t('Send Emails');
  }

  public function getConfirmationMessage()
  {
    return Craft::t('Are you sure you wish to send out emails?');
  }

  public function performAction(ElementCriteriaModel $criteria)
  {
    $elements = $criteria->find();
    $settings = craft()->plugins->getPlugin('Emailer')->getSettings();
    $recipients = explode(',', $settings->getAttribute('testers'));

    foreach ($elements as $element) {
      EmailerPlugin::log('Queuing entry: '.$element->title);

      $task = craft()->tasks->createTask('Emailer', 'Email: '.$element->title, array(
        'email_id' => $element->id,
        'recipients' => $recipients,
      ));

      EmailerPlugin::log('Queued '.$element->title.' to be sent to '.count($recipients).' recipients.');
    }

    $this->setMessage(Craft::t('Emails queued successfully'));
    return true;
  }
}


text:
from webapp2_extras.routes import RedirectRoute
import users

_routes = [
    RedirectRoute('/admin/logout/', users.AdminLogoutHandler, name='admin-logout', strict_slash=True),
    RedirectRoute('/admin/', users.AdminGeoChartHandler, name='geochart', strict_slash=True),
    RedirectRoute('/admin/users/', users.AdminUserListHandler, name='user-list', strict_slash=True),
    RedirectRoute('/admin/connections/', users.AdminConnectionHandler, name='connection-list', strict_slash=True),
    RedirectRoute('/admin/connection/<connection_id>', users.AdminConnectionEditHandler, name='connection-edit', strict_slash=True),
    RedirectRoute('/admin/map', users.AdminMapEditHandler, name='admin-map', strict_slash=True),
    RedirectRoute('/admin/users/<user_id>/', users.AdminUserEditHandler, name='user-edit', strict_slash=True, handler_method='edit')
]

def get_routes():
    return _routes

def add_routes(app):
    for r in _routes:
        app.router.add(r)


text:
package com.zhonglushu.example.hovertab.views;

import android.content.Context;
import android.os.Parcel;
import android.os.Parcelable;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.util.Log;
import android.util.SparseIntArray;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewConfiguration;
import android.view.ViewGroup;
import android.widget.AbsListView;
import android.widget.Adapter;
import android.widget.ListView;

import com.zhonglushu.example.hovertab.R;
import com.zhonglushu.example.hovertab.Utils.Mode;
import com.zhonglushu.example.hovertab.Utils.OnPullUpRefreshListener;
import com.zhonglushu.example.hovertab.observable.ObservableScrollViewCallbacks;
import com.zhonglushu.example.hovertab.observable.ScrollState;
import com.zhonglushu.example.hovertab.observable.Scrollable;
import java.util.ArrayList;
import java.util.List;

/**
 * ListView that its scroll position can be observed.
 */
public class ObservableListView extends ListView implements Scrollable {

    // Fields that should be saved onSaveInstanceState
    private int mPrevFirstVisiblePosition;
    private int mPrevFirstVisibleChildHeight = -1;
    private int mPrevScrolledChildrenHeight;
    private int mPrevScrollY;
    private int mScrollY;
    private SparseIntArray mChildrenHeights;

    // Fields that don't need to be saved onSaveInstanceState
    private ObservableScrollViewCallbacks mCallbacks;
    private List<ObservableScrollViewCallbacks> mCallbackCollection;
    private ScrollState mScrollState;
    private boolean mFirstScroll;
    private boolean mDragging;
    private boolean mIntercepted;
    private MotionEvent mPrevMoveEvent;
    private ViewGroup mTouchInterceptionViewGroup;
    private boolean isRefreshing = false;
    private ObservableRefreshView mRefreshView = null;
    private OnPullUpRefreshListener mOnRefreshListener = null;
    private Mode mCurrentMode = Mode.getDefault();
    private boolean hasNoMore = false;
    private boolean isNetworkError = false;
    private String networkErrorStr = null;
    private float mInitTouchX;
    private float mInitTouchY;
    private int mTouchSlop;

    private OnScrollListener mOriginalScrollListener;
    private OnScrollListener mScrollListener = new OnScrollListener() {
        @Override
        public void onScrollStateChanged(AbsListView view, int scrollState) {
            if (mOriginalScrollListener != null) {
                mOriginalScrollListener.onScrollStateChanged(view, scrollState);
            }
        }

        @Override
        public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
            if (mOriginalScrollListener != null) {
                mOriginalScrollListener.onScroll(view, firstVisibleItem, visibleItemCount, totalItemCount);
            }
            // AbsListView#invokeOnItemScrollListener calls onScrollChanged(0, 0, 0, 0)
            // on Android 4.0+, but Android 2.3 is not. (Android 3.0 is unknown)
            // So call it with onScrollListener.
            onScrollChanged();
        }
    };

    public ObservableListView(Context context) {
        super(context);
        init();
    }

    public ObservableListView(Context context, AttributeSet attrs) {
        super(context, attrs);
        init();
    }

    public ObservableListView(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
        init();
    }

    @Override
    public void onRestoreInstanceState(Parcelable state) {
        SavedState ss = (SavedState) state;
        mPrevFirstVisiblePosition = ss.prevFirstVisiblePosition;
        mPrevFirstVisibleChildHeight = ss.prevFirstVisibleChildHeight;
        mPrevScrolledChildrenHeight = ss.prevScrolledChildrenHeight;
        mPrevScrollY = ss.prevScrollY;
        mScrollY = ss.scrollY;
        mChildrenHeights = ss.childrenHeights;
        super.onRestoreInstanceState(ss.getSuperState());
    }

    @Override
    public Parcelable onSaveInstanceState() {
        Parcelable superState = super.onSaveInstanceState();
        SavedState ss = new SavedState(superState);
        ss.prevFirstVisiblePosition = mPrevFirstVisiblePosition;
        ss.prevFirstVisibleChildHeight = mPrevFirstVisibleChildHeight;
        ss.prevScrolledChildrenHeight = mPrevScrolledChildrenHeight;
        ss.prevScrollY = mPrevScrollY;
        ss.scrollY = mScrollY;
        ss.childrenHeights = mChildrenHeights;
        return ss;
    }

    private void init() {
        ViewConfiguration config = ViewConfiguration.get(getContext());
        mTouchSlop = config.getScaledTouchSlop();
        networkErrorStr = this.getContext().getResources().getString(R.string.network_error);
        mChildrenHeights = new SparseIntArray();
        super.setOnScrollListener(mScrollListener);
        mRefreshView = new ObservableRefreshView(this.getContext(), true);
        this.addFooterView(mRefreshView);
    }

    @Override
    public boolean onInterceptTouchEvent(MotionEvent ev) {
        if (mCallbacks != null || mCallbackCollection != null) {
            switch (ev.getActionMasked()) {
                case MotionEvent.ACTION_DOWN:
                    // Whether or not motion events are consumed by children,
                    // flag initializations which are related to ACTION_DOWN events should be executed.
                    // Because if the ACTION_DOWN is consumed by children and only ACTION_MOVEs are
                    // passed to parent (this view), the flags will be invalid.
                    // Also, applications might implement initialization codes to onDownMotionEvent,
                    // so call it here.
                    mFirstScroll = mDragging = true;
                    mInitTouchX = ev.getX();
                    mInitTouchY = ev.getY();
                    dispatchOnDownMotionEvent();
                    break;
            }
        }
        return super.onInterceptTouchEvent(ev);
    }

    @Override
    public boolean onTouchEvent(MotionEvent ev) {
        if (mCallbacks != null || mCallbackCollection != null) {
            switch (ev.getActionMasked()) {
                case MotionEvent.ACTION_UP:
                case MotionEvent.ACTION_CANCEL:
                    float deltaX = ev.getX() - mInitTouchX;
                    float deltaY = ev.getY() - mInitTouchY;
                    if(!isRefreshing && !hasNoMore && isNetworkError && Math.abs(deltaY) > Math.abs(deltaX) && deltaY < -mTouchSlop*10) {
                        if (this.getLastVisiblePosition() == (this.getCount() - 1)) {
                            if (mCurrentMode == Mode.PULL_FROM_END) {
                                isNetworkError = false;
                                isRefreshing = true;
                                mRefreshView.setRefreshingText();
                                if(mOnRefreshListener != null){
                                    mOnRefreshListener.onRefresh();
                                    mRefreshView.startRotationAnim();
                                }
                            }
                        }
                    }
                    mInitTouchY = 0.0f;
                    mInitTouchX = 0.0f;
                    mIntercepted = false;
                    mDragging = false;
                    dispatchOnUpOrCancelMotionEvent(mScrollState);
                    break;
                case MotionEvent.ACTION_MOVE:
                    if (mPrevMoveEvent == null) {
                        mPrevMoveEvent = ev;
                    }
                    float diffY = ev.getY() - mPrevMoveEvent.getY();
                    mPrevMoveEvent = MotionEvent.obtainNoHistory(ev);
                    if (getCurrentScrollY() - diffY <= 0) {
                        // Can't scroll anymore.

                        if (mIntercepted) {
                            // Already dispatched ACTION_DOWN event to parents, so stop here.
                            return false;
                        }

                        // Apps can set the interception target other than the direct parent.
                        final ViewGroup parent;
                        if (mTouchInterceptionViewGroup == null) {
                            parent = (ViewGroup) getParent();
                        } else {
                            parent = mTouchInterceptionViewGroup;
                        }

                        // Get offset to parents. If the parent is not the direct parent,
                        // we should aggregate offsets from all of the parents.
                        float offsetX = 0;
                        float offsetY = 0;
                        for (View v = this; v != null && v != parent; ) {
                            offsetX += v.getLeft() - v.getScrollX();
                            offsetY += v.getTop() - v.getScrollY();
                            try {
                                v = (View) v.getParent();
                            } catch (ClassCastException ex) {
                                break;
                            }
                        }
                        final MotionEvent event = MotionEvent.obtainNoHistory(ev);
                        event.offsetLocation(offsetX, offsetY);
                        boolean isShowRefresh = false;
                        if(parent instanceof CustomPullDownRefreshLinearLayout){
                            isShowRefresh = ((CustomPullDownRefreshLinearLayout)parent).isShowHeaderRefreshView();
                        }
                        if (parent.onInterceptTouchEvent(event) && getCurrentScrollY() <= 0 && !isShowRefresh) {
                            mIntercepted = true;

                            // If the parent wants to intercept ACTION_MOVE events,
                            // we pass ACTION_DOWN event to the parent
                            // as if these touch events just have began now.
                            event.setAction(MotionEvent.ACTION_DOWN);

                            // Return this onTouchEvent() first and set ACTION_DOWN event for parent
                            // to the queue, to keep events sequence.
                            post(new Runnable() {
                                @Override
                                public void run() {
                                    parent.dispatchTouchEvent(event);
                                }
                            });
                            return false;
                        }
                        // Even when this can't be scrolled anymore,
                        // simply returning false here may cause subView's click,
                        // so delegate it to super.
                        return super.onTouchEvent(ev);
                    }
                    break;
            }
        }
        return super.onTouchEvent(ev);
    }

    @Override
    public boolean isReadyForPullStart() {
        if (this.getFirstVisiblePosition() <= 1) {
            final View firstVisibleChild = this.getChildAt(0);
            if (firstVisibleChild != null) {
                return firstVisibleChild.getTop() + 10 >= this.getTop();
            }
        }
        return false;
    }

    //刷新完成
    public void onRefreshComplete(){
        if(isRefreshing){
            isRefreshing = false;
            if(isNetworkError){
                mRefreshView.setmFooterViewText(this.networkErrorStr);
            }
            if(hasNoMore) {
                mRefreshView.setHasNoMoreText();
            }
            mRefreshView.stopRotationAnim();
        }
    }

    public void setHasNoMore(boolean hasNoMore) {
        this.hasNoMore = hasNoMore;
    }

    public void setNetworkError(boolean isNetworkError, String networkErrorStr) {
        this.isNetworkError = isNetworkError;
        if(networkErrorStr != null && !TextUtils.isEmpty(networkErrorStr))
            this.networkErrorStr = networkErrorStr;
    }

    @Override
    public void setOnScrollListener(OnScrollListener l) {
        // Don't set l to super.setOnScrollListener().
        // l receives all events through mScrollListener.
        mOriginalScrollListener = l;
    }

    @Override
    public void setScrollViewCallbacks(ObservableScrollViewCallbacks listener) {
        mCallbacks = listener;
    }

    @Override
    public void addScrollViewCallbacks(ObservableScrollViewCallbacks listener) {
        if (mCallbackCollection == null) {
            mCallbackCollection = new ArrayList<>();
        }
        mCallbackCollection.add(listener);
    }

    @Override
    public void removeScrollViewCallbacks(ObservableScrollViewCallbacks listener) {
        if (mCallbackCollection != null) {
            mCallbackCollection.remove(listener);
        }
    }

    @Override
    public void clearScrollViewCallbacks() {
        if (mCallbackCollection != null) {
            mCallbackCollection.clear();
        }
    }

    @Override
    public void setTouchInterceptionViewGroup(ViewGroup viewGroup) {
        mTouchInterceptionViewGroup = viewGroup;
    }

    @Override
    public void scrollVerticallyTo(int y) {
        View firstVisibleChild = getChildAt(0);
        if (firstVisibleChild != null) {
            int baseHeight = firstVisibleChild.getHeight();
            int position = y / baseHeight;
            setSelection(position);
        }
    }

    @Override
    public int getCurrentScrollY() {
        return mScrollY;
    }

    private void onScrollChanged() {
        if (mCallbacks != null || mCallbackCollection != null) {
            if (getChildCount() > 0) {
                int firstVisiblePosition = getFirstVisiblePosition();
                for (int i = getFirstVisiblePosition(), j = 0; i <= getLastVisiblePosition(); i++, j++) {
                    if (mChildrenHeights.indexOfKey(i) < 0 || getChildAt(j).getHeight() != mChildrenHeights.get(i)) {
                        mChildrenHeights.put(i, getChildAt(j).getHeight());
                    }
                }

                View firstVisibleChild = getChildAt(0);
                if (firstVisibleChild != null) {
                    if (mPrevFirstVisiblePosition < firstVisiblePosition) {
                        // scroll down
                        int skippedChildrenHeight = 0;
                        if (firstVisiblePosition - mPrevFirstVisiblePosition != 1) {
                            for (int i = firstVisiblePosition - 1; i > mPrevFirstVisiblePosition; i--) {
                                if (0 < mChildrenHeights.indexOfKey(i)) {
                                    skippedChildrenHeight += mChildrenHeights.get(i);
                                } else {
                                    // Approximate each item's height to the first visible child.
                                    // It may be incorrect, but without this, scrollY will be broken
                                    // when scrolling from the bottom.
                                    skippedChildrenHeight += firstVisibleChild.getHeight();
                                }
                            }
                        }
                        mPrevScrolledChildrenHeight += mPrevFirstVisibleChildHeight + skippedChildrenHeight;
                        mPrevFirstVisibleChildHeight = firstVisibleChild.getHeight();
                    } else if (firstVisiblePosition < mPrevFirstVisiblePosition) {
                        // scroll up
                        int skippedChildrenHeight = 0;
                        if (mPrevFirstVisiblePosition - firstVisiblePosition != 1) {
                            for (int i = mPrevFirstVisiblePosition - 1; i > firstVisiblePosition; i--) {
                                if (0 < mChildrenHeights.indexOfKey(i)) {
                                    skippedChildrenHeight += mChildrenHeights.get(i);
                                } else {
                                    // Approximate each item's height to the first visible child.
                                    // It may be incorrect, but without this, scrollY will be broken
                                    // when scrolling from the bottom.
                                    skippedChildrenHeight += firstVisibleChild.getHeight();
                                }
                            }
                        }
                        mPrevScrolledChildrenHeight -= firstVisibleChild.getHeight() + skippedChildrenHeight;
                        mPrevFirstVisibleChildHeight = firstVisibleChild.getHeight();
                    } else if (firstVisiblePosition == 0) {
                        mPrevFirstVisibleChildHeight = firstVisibleChild.getHeight();
                    }
                    if (mPrevFirstVisibleChildHeight < 0) {
                        mPrevFirstVisibleChildHeight = 0;
                    }
                    mScrollY = mPrevScrolledChildrenHeight - firstVisibleChild.getTop();
                    mPrevFirstVisiblePosition = firstVisiblePosition;

                    dispatchOnScrollChanged(mScrollY, mFirstScroll, mDragging);
                    if (mFirstScroll) {
                        mFirstScroll = false;
                    }

                    if (mPrevScrollY < mScrollY) {
                        mScrollState = ScrollState.UP;
                    } else if (mScrollY < mPrevScrollY) {
                        mScrollState = ScrollState.DOWN;
                    } else {
                        mScrollState = ScrollState.STOP;
                    }
                    mPrevScrollY = mScrollY;

                    if(!isRefreshing && !hasNoMore && !isNetworkError) {
                        if (this.getLastVisiblePosition() == (this.getCount() - 1)) {
                            if (mCurrentMode == Mode.PULL_FROM_END) {
                                isRefreshing = true;
                                mRefreshView.setRefreshingText();
                                if(mOnRefreshListener != null){
                                    mOnRefreshListener.onRefresh();
                                    mRefreshView.startRotationAnim();
                                }
                            }
                        }
                    }
                }
            }
        }
    }

    private void dispatchOnDownMotionEvent() {
        if (mCallbacks != null) {
            mCallbacks.onDownMotionEvent();
        }
        if (mCallbackCollection != null) {
            for (int i = 0; i < mCallbackCollection.size(); i++) {
                ObservableScrollViewCallbacks callbacks = mCallbackCollection.get(i);
                callbacks.onDownMotionEvent();
            }
        }
    }

    private void dispatchOnScrollChanged(int scrollY, boolean firstScroll, boolean dragging) {
        if (mCallbacks != null) {
            mCallbacks.onScrollChanged(scrollY, firstScroll, dragging);
        }
        if (mCallbackCollection != null) {
            for (int i = 0; i < mCallbackCollection.size(); i++) {
                ObservableScrollViewCallbacks callbacks = mCallbackCollection.get(i);
                callbacks.onScrollChanged(scrollY, firstScroll, dragging);
            }
        }
    }

    private void dispatchOnUpOrCancelMotionEvent(ScrollState scrollState) {
        if (mCallbacks != null) {
            mCallbacks.onUpOrCancelMotionEvent(scrollState);
        }
        if (mCallbackCollection != null) {
            for (int i = 0; i < mCallbackCollection.size(); i++) {
                ObservableScrollViewCallbacks callbacks = mCallbackCollection.get(i);
                callbacks.onUpOrCancelMotionEvent(scrollState);
            }
        }
    }

    static class SavedState extends BaseSavedState {
        int prevFirstVisiblePosition;
        int prevFirstVisibleChildHeight = -1;
        int prevScrolledChildrenHeight;
        int prevScrollY;
        int scrollY;
        SparseIntArray childrenHeights;

        /**
         * Called by onSaveInstanceState.
         */
        SavedState(Parcelable superState) {
            super(superState);
        }

        /**
         * Called by CREATOR.
         */
        private SavedState(Parcel in) {
            super(in);
            prevFirstVisiblePosition = in.readInt();
            prevFirstVisibleChildHeight = in.readInt();
            prevScrolledChildrenHeight = in.readInt();
            prevScrollY = in.readInt();
            scrollY = in.readInt();
            childrenHeights = new SparseIntArray();
            final int numOfChildren = in.readInt();
            if (0 < numOfChildren) {
                for (int i = 0; i < numOfChildren; i++) {
                    final int key = in.readInt();
                    final int value = in.readInt();
                    childrenHeights.put(key, value);
                }
            }
        }

        @Override
        public void writeToParcel(Parcel out, int flags) {
            super.writeToParcel(out, flags);
            out.writeInt(prevFirstVisiblePosition);
            out.writeInt(prevFirstVisibleChildHeight);
            out.writeInt(prevScrolledChildrenHeight);
            out.writeInt(prevScrollY);
            out.writeInt(scrollY);
            final int numOfChildren = childrenHeights == null ? 0 : childrenHeights.size();
            out.writeInt(numOfChildren);
            if (0 < numOfChildren) {
                for (int i = 0; i < numOfChildren; i++) {
                    out.writeInt(childrenHeights.keyAt(i));
                    out.writeInt(childrenHeights.valueAt(i));
                }
            }
        }

        public static final Creator<SavedState> CREATOR
                = new Creator<SavedState>() {
            @Override
            public SavedState createFromParcel(Parcel in) {
                return new SavedState(in);
            }

            @Override
            public SavedState[] newArray(int size) {
                return new SavedState[size];
            }
        };
    }

    public Mode getmCurrentMode() {
        return mCurrentMode;
    }

    public void setmCurrentMode(Mode mCurrentMode) {
        this.mCurrentMode = mCurrentMode;
        if(this.mCurrentMode == Mode.DISABLED){
            mRefreshView.setmFooterViewText("");
        }
    }

    public void setmOnRefreshListener(OnPullUpRefreshListener mOnRefreshListener){
        this.mOnRefreshListener = mOnRefreshListener;
    }
}


text:
/** @file
 * @brief Common defines and macros for firmware developed by Nordic Semiconductor.
 */

#ifndef NORDIC_COMMON_H__
#define NORDIC_COMMON_H__

#ifdef __cplusplus
extern "C" {
#endif

/**
 * @brief Check if selected module is enabled
 *
 * This is save function for driver enable checking.
 * Correct from Lint point of view (not using default of undefined value).
 *
 * Usage:
 * @code
   #if NRF_MODULE_ENABLED(UART)
   ...
   #endif
 * @endcode
 *
 * @param module The module name.
 *
 * @retval 1 The macro <module>_ENABLE is defined and is non-zero.
 * @retval 0 The macro <module>_ENABLE is not defined or it equals zero.
 *
 * @note
 * This macro intentionally does not implement second expansion level.
 * The name of the module to be checked has to be given directly as a parameter.
 * And given parameter would be connected with @c _ENABLED postfix directly
 * without evaluating its value.
 */
//lint -emacro(491,NRF_MODULE_ENABLED) // Suppers warning 491 "non-standard use of 'defined' preprocessor operator"
#define NRF_MODULE_ENABLED(module) \
    ((defined(module ## _ENABLED) && (module ## _ENABLED)) ? 1 : 0)

/** The upper 8 bits of a 32 bit value */
//lint -emacro(572,MSB_32) // Suppress warning 572 "Excessive shift value"
#define MSB_32(a) (((a) & 0xFF000000) >> 24)
/** The lower 8 bits (of a 32 bit value) */
#define LSB_32(a) ((a) & 0x000000FF)

/** The upper 8 bits of a 16 bit value */
//lint -emacro(572,MSB_16) // Suppress warning 572 "Excessive shift value"
#define MSB_16(a) (((a) & 0xFF00) >> 8)
/** The lower 8 bits (of a 16 bit value) */
#define LSB_16(a) ((a) & 0x00FF)

/** Leaves the minimum of the two 32-bit arguments */
/*lint -emacro(506, MIN) */ /* Suppress "Constant value Boolean */
#define MIN(a, b) ((a) < (b) ? (a) : (b))
/** Leaves the maximum of the two 32-bit arguments */
/*lint -emacro(506, MAX) */ /* Suppress "Constant value Boolean */
#define MAX(a, b) ((a) < (b) ? (b) : (a))

/**@brief Concatenates two parameters.
 *
 * It realizes two level expansion to make it sure that all the parameters
 * are actually expanded before gluing them together.
 *
 * @param p1 First parameter to concatenating
 * @param p2 Second parameter to concatenating
 *
 * @return Two parameters glued together.
 *         They have to create correct C mnemonic in other case
 *         preprocessor error would be generated.
 *
 * @sa CONCAT_3
 */
#define CONCAT_2(p1, p2)      CONCAT_2_(p1, p2)
/** Auxiliary macro used by @ref CONCAT_2 */
#define CONCAT_2_(p1, p2)     p1##p2

/**@brief Concatenates three parameters.
 *
 * It realizes two level expansion to make it sure that all the parameters
 * are actually expanded before gluing them together.
 *
 * @param p1 First parameter to concatenating
 * @param p2 Second parameter to concatenating
 * @param p3 Third parameter to concatenating
 *
 * @return Three parameters glued together.
 *         They have to create correct C mnemonic in other case
 *         preprocessor error would be generated.
 *
 * @sa CONCAT_2
 */
#define CONCAT_3(p1, p2, p3)  CONCAT_3_(p1, p2, p3)
/** Auxiliary macro used by @ref CONCAT_3 */
#define CONCAT_3_(p1, p2, p3) p1##p2##p3

#define STRINGIFY_(val) #val
/** Converts a macro argument into a character constant.
 */
#define STRINGIFY(val)  STRINGIFY_(val)

/** Counts number of elements inside the array
 */
#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))

/**@brief Set a bit in the uint32 word.
 *
 * @param[in] W  Word whose bit is being set.
 * @param[in] B  Bit number in the word to be set.
 */
#define SET_BIT(W, B)  ((W) |= (uint32_t)(1U << (B)))

/**@brief Clears a bit in the uint32 word.
 *
 * @param[in] W   Word whose bit is to be cleared.
 * @param[in] B   Bit number in the word to be cleared.
 */
#define CLR_BIT(W, B) ((W) &= (~(uint32_t)(1U << (B))))

/**@brief Checks if a bit is set.
 *
 * @param[in] W   Word whose bit is to be checked.
 * @param[in] B   Bit number in the word to be checked.
 *
 * @retval 1 if bit is set.
 * @retval 0 if bit is not set.
 */
#define IS_SET(W, B) (((W) >> (B)) & 1)

#define BIT_0 0x01 /**< The value of bit 0 */
#define BIT_1 0x02 /**< The value of bit 1 */
#define BIT_2 0x04 /**< The value of bit 2 */
#define BIT_3 0x08 /**< The value of bit 3 */
#define BIT_4 0x10 /**< The value of bit 4 */
#define BIT_5 0x20 /**< The value of bit 5 */
#define BIT_6 0x40 /**< The value of bit 6 */
#define BIT_7 0x80 /**< The value of bit 7 */
#define BIT_8 0x0100 /**< The value of bit 8 */
#define BIT_9 0x0200 /**< The value of bit 9 */
#define BIT_10 0x0400 /**< The value of bit 10 */
#define BIT_11 0x0800 /**< The value of bit 11 */
#define BIT_12 0x1000 /**< The value of bit 12 */
#define BIT_13 0x2000 /**< The value of bit 13 */
#define BIT_14 0x4000 /**< The value of bit 14 */
#define BIT_15 0x8000 /**< The value of bit 15 */
#define BIT_16 0x00010000 /**< The value of bit 16 */
#define BIT_17 0x00020000 /**< The value of bit 17 */
#define BIT_18 0x00040000 /**< The value of bit 18 */
#define BIT_19 0x00080000 /**< The value of bit 19 */
#define BIT_20 0x00100000 /**< The value of bit 20 */
#define BIT_21 0x00200000 /**< The value of bit 21 */
#define BIT_22 0x00400000 /**< The value of bit 22 */
#define BIT_23 0x00800000 /**< The value of bit 23 */
#define BIT_24 0x01000000 /**< The value of bit 24 */
#define BIT_25 0x02000000 /**< The value of bit 25 */
#define BIT_26 0x04000000 /**< The value of bit 26 */
#define BIT_27 0x08000000 /**< The value of bit 27 */
#define BIT_28 0x10000000 /**< The value of bit 28 */
#define BIT_29 0x20000000 /**< The value of bit 29 */
#define BIT_30 0x40000000 /**< The value of bit 30 */
#define BIT_31 0x80000000 /**< The value of bit 31 */

#define UNUSED_VARIABLE(X)  ((void)(X))
#define UNUSED_PARAMETER(X) UNUSED_VARIABLE(X)
#define UNUSED_RETURN_VALUE(X) UNUSED_VARIABLE(X)

#ifdef __cplusplus
}
#endif

#endif // NORDIC_COMMON_H__


text:
		{% if site.data.menus %}
		{% for item in site.data.menus.sidebar %}

			{{ item.identifier }}
			{% if item.children %}

			{% for entry in item.children %}

					{{ entry.page }}

			{% endfor %}

			{% endif %}

		{% endfor %}
		{% endif %}


text:
// source:

package nl.uva.vlet.vfs.srbfs;

import static nl.uva.vlet.data.VAttributeConstants.ATTR_DATA_TYPE;
import static nl.uva.vlet.data.VAttributeConstants.ATTR_NRACLENTRIES;
import static nl.uva.vlet.data.VAttributeConstants.ATTR_PERMISSIONS_STRING;

import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;

import nl.uva.vlet.Global;
import nl.uva.vlet.data.StringList;
import nl.uva.vlet.data.VAttribute;
import nl.uva.vlet.data.VAttributeSet;
import nl.uva.vlet.exception.ResourceCreationFailedException;
import nl.uva.vlet.exception.ResourceNotFoundException;
import nl.uva.vlet.exception.VlException;
import nl.uva.vlet.exception.VlIOException;
import nl.uva.vlet.tasks.ActionTask;
import nl.uva.vlet.vfs.VFSTransfer;
import nl.uva.vlet.vfs.VFile;
import nl.uva.vlet.vrl.VRL;
import nl.uva.vlet.vrs.VRenamable;
import nl.uva.vlet.vrs.io.VRandomAccessable;
import nl.uva.vlet.vrs.io.VResizable;
import nl.uva.vlet.vrs.io.VStreamReadable;
import nl.uva.vlet.vrs.io.VStreamWritable;
import edu.sdsc.grid.io.local.LocalFile;
import edu.sdsc.grid.io.srb.SRBFile;
import edu.sdsc.grid.io.srb.SRBFileOutputStream;
import edu.sdsc.grid.io.srb.SRBFileSystem;
import edu.sdsc.grid.io.srb.SRBRandomAccessFile;
/**
 *
 * Implementation of SrbFile (name 'SRBFile' is already taken).
 *
 */

public class SrbFile extends VFile implements VStreamReadable,
VStreamWritable,VRandomAccessable,VRenamable,VResizable
{
    SrbFileSystem server=null;

    /** Jargon GeneralFile interface */

    SRBFile srbnode = null;

    public SrbFile(SrbFileSystem server,SRBFile gfile)
    {
        super(server,null); // will set location init!
        init(server,gfile);
    }

    public SrbFile(SrbFileSystem server,String filepath)
    {
    	 super(server,null); // will set location init!

        SRBFileSystem srbfs=server.getSRBFileSystem();

        init(server,new SRBFile(srbfs,filepath));
    }

    private void init(SrbFileSystem server,SRBFile gfile)
    {
        this.server=server;
        this.srbnode = gfile;
        // use Jargon's toURI
        this.setLocation(new VRL(gfile.toURI()));
    }

    public long getLength()
    {
        return srbnode.length();
    }

    public String getBasename()
    {
        return srbnode.getName();
    }

    public boolean exists()
    {
        return srbnode.exists();

    }

    public String getResource() throws VlIOException
    {
        try
        {
            return srbnode.getResource();
        }
        catch (IOException e)
        {
            throw new VlIOException("SRB IOException",e);
        }
    }

    public void setResource(String resource) throws VlIOException
    {
        try
        {
            srbnode.setResource(resource);
        }
        catch (IOException e)
        {
            throw new VlIOException("SRB IOException",e);
        }
    }

    @Override
    public boolean setAttribute(VAttribute attr) throws VlException
    {
    	String name=attr.getName();

    	try
    	{

    		if (name.compareTo(SrbConfig.ATTR_RESOURCE)==0)
    		{
    			setResource(attr.getStringValue());
    			return true;
    		}
    		else if (name.compareTo(ATTR_DATA_TYPE)==0)
    		{
    			this.srbnode.setDataType(attr.getStringValue());
    			return true;
    		}
    	}
    	catch (IOException e)
    	{
    		throw new VlIOException("SRB IOException",e);
    	}

    	return super.setAttribute(attr);
    }

    public boolean isReadable() throws VlException
    {
        //return this.srbnode.canRead();

        return this.server.isReadable(srbnode,false);
    }

    public boolean isWritable() throws VlException
    {
        //return this.srbnode.canWrite();

        return this.server.isWritable(srbnode,true);
    }

    @Override
    public boolean create(boolean ignoreExisting) throws VlException
    {
        try
        {
            return srbnode.createNewFile();
        }
        catch (IOException e)
        {
            throw new ResourceCreationFailedException("Could not create file:"
                    + this,e);
        }
    }

    public VRL rename(String name,boolean nameIsPath) throws VlException
    {
        try
        {
            SRBFile newSrbFile=SrbFSFactory.srbRename(srbnode,name,nameIsPath);

            if (newSrbFile!=null)
                new VRL(newSrbFile.toURI());
        }
        catch (IOException e)
        {
            throw new VlIOException(e.getMessage());
        }

        return null;
    }

    //@Override
    public boolean delete() throws VlException
    {
    	boolean result=srbnode.delete(true); //Does this mean force==true ???

    	if (result==false)
    		throw new nl.uva.vlet.exception.ResourceDeletionFailedException("Deletion failed. No reason given by server for:"+this);

    	return result;
    }

    @Override
    public long getModificationTime()
    {
        return srbnode.lastModified();
    }
    /*@Override
    public boolean isHidden()
    {
        return srbnode.isHidden();

    }*/

//    /**
//     * Copy/Move SRB File to destination directory.
//     * TODO: Cleanup code and check with super.doCopyMoveTo
//     */
//
//    public VFile doFileTransferToOld(VFSTransfer transfer,VDir targetParentDir, String optNewName,boolean isMove) throws VlException
//    {
//        boolean isSrbMove=false;
//        boolean destIsLocal=false;
//        boolean force=true; // default is to overwite existing files.
//
//        String newName=optNewName;
//
//        if (newName==null)
//            newName=getBasename();
//
//        if (targetParentDir.exists()==false)
//        {
//          /* Parent dir must exist, or else JArgon 'might' use non existing
//           * path as destination file name (AARG), thus performing a RENAME
//           */
//
//           throw new ResourceNotFoundException("destination directory does not exist:"+targetParentDir);
//        }
//
//        try
//        {
//            GeneralFile dest=null;
//            GeneralFile srbParentDir=null;
//
//            if (targetParentDir.isLocal())
//            {
//
//                // copy/move to local path:
//
//                srbParentDir=new LocalFile(targetParentDir.getPath());
//                // destination file:
//                dest=new LocalFile(targetParentDir.getPath(),newName);
//                destIsLocal=true;
//            }
//            else if ( (targetParentDir instanceof SrbDir)
//                      && (this.getVRL().hasSameServer(targetParentDir.getLocation())) )
//            {
//                // SRB2SRB copy/move on same server !
//
//                srbParentDir=((SrbDir)targetParentDir).srbnode;
//                dest=new SRBFile(((SrbDir)targetParentDir).srbnode,newName);
//
//                if (isMove)
//                {
//
//                    // move
//                    SRBFile srbFile=SrbFSFactory.srbMove(srbnode,(SRBFile)srbParentDir,newName);
//                    return new SrbFile(server,srbFile);
//                }
//                else
//                {
//
//                }
//            }
//            else
//            {
//                // copy to another SRB Server or other VFS implementation
//                // Use Default Stream Based  Copy
//            	VRL targetFileVRL=targetParentDir.getVRL();
//            	VFile targetFile=targetParentDir.getFileSystem().newFile(targetFileVRL);
//
//                fileStreamCopy(transfer,this,targetFile,this.getLength());
//
//            	if (isMove)
//            		this.delete();
//
//
//                return targetFile;
//            }
//
//            Debug("local dest="+dest);
//
//            // check if it already exists
//
//            if (dest.exists())
//            {
//                if  (force==false)
//                {
//                    if (dest.isFile()==false)
//                    {
//                        throw new ResourceCreationFailedException("Destination path exists but is not a file:"+dest);
//                    }
//                    else
//                    {
//                        throw new ResourceAlreadyExistsException("Destination File already exists:"+dest);
//                    }
//                 }
//                 else
//                 {
//                	 boolean ret=false;
//
//                	 if (dest instanceof SRBFile)
//                     // must delete it, jargon does not delete if for us.
//                		 ret=((SRBFile)dest).delete(true);
//                	 else
//                		 ret=dest.delete();
//
//                     if (ret==false)
//                          throw new ResourceDeletionFailedException("Could not delete existing location:"+dest);
//                 }
//             }
//
//
//
//
//             // When creating the file first, jargon is triggered
//             // to use a SINGLE upload stream to the new file.
//             // If you want to use parallel (or bulk) load, do NOT
//             // create the file first. For big files this is more efficient.
//
//             // see: https://lists.sdsc.edu/pipermail/srb-chat/2004-December/001480.html
//             /* it says:
//                You can force a serial transfer. Insert one more line in front of your
//                copyTO or copyFrom method calls. so if your code previously read
//
//                local.copyTo(srbFile)
//
//                insert one line
//
//                srbFile.createNewFile();
//                local.copyTo(srbFile);
//             */
//
//             //NOT: boolean ret = dest.createNewFile();
//             //Debug("created dest:"+ret);
//
//            // This method doesn NOT do upload of files, since this
//            // is a SrbFile ! (LocalFile call VDir.uploadFile(...))
//
//            {
//                // start progress task watcher: Does not work for GeneralFile ??
//                ActionTask progressTask=null;
//
//
//                progressTask=server.createProgressWatcher(transfer,srbnode,dest,false,Thread.currentThread());
//
//                progressTask.startTask();
//
//                srbnode.copyTo(dest);
//
//                progressTask.stopTask();
//            }
//
//             if (isMove)
//                 this.delete();
//
//             if (destIsLocal==true)
//             {
//                 return new LFile(server.getLocalFS(),dest.getAbsolutePath());
//             }
//             else
//             {
//                 return new SrbFile(server,(SRBFile)dest);
//             }
//        }
//        catch (SRBException e)
//        {
//            throw new VlIOException("Could not copy/move file:" + this + "\n"
//                    + "to:"+targetParentDir+"\n"
//                    + "Message from SRB server:" + e.getStandardMessage(), e);
//        }
//        catch (IOException e)
//        {
//            throw new VlIOException("Could not copy/move file:" + this + "\n"
//                    + "to:"+targetParentDir+"\n"
//                    +"Message="+e.getMessage(), e);
//        }
//    }

    // Bulk Download b0rken
//    protected VFile downloadTo(VFSTransfer transfer,VDir localDir,String optNewName,boolean isMove)
//    throws VlException
//    {
//    	return this.doFileTransferTo(transfer, localDir, optNewName, isMove);
//    }

    /**
     * Copy/move local file to this location.

     * This method is used by the localfile system when it is requested
     * to upload/copy a file to this implementation.
     * It is more efficient to let the SRB implementation do the
     * local file access because it has bulk up- and download methods.
     */
    @Override
    public void uploadFrom(VFSTransfer transfer,VFile file) throws VlException
    {
        // use Jargon/SRB interface to copy from local
        Debug("cmoveFromLocal:"+file+"to:"+this);

        SRBFile destFile = this.srbnode;
        LocalFile source = new LocalFile(file.getPath()); // file MUST be local !

        /* Extra checking:
         * target directory MUST exist and MUST be a directory
         * or else jargon might do unspecified thingies
         */
        if (srbnode.getParentFile().exists()==false)
        {
            throw new ResourceNotFoundException("Can't copy file. Invalid parent target directory:"+this);
        }

        ActionTask progressTask=null;

        try
        {
            if (destFile.exists()==true)
            {
                if (destFile.isFile()==false)
                {
                    throw new ResourceCreationFailedException("Target destination already exists, but is not a file:"+destFile);
                }
                else
                {
                    // delete EXISTING so that  bulkload can go parallel:
                    destFile.delete(true);
                }
            }
            else
            {
                // try to create it
                //dest.createNewFile(); // srb does this automatically !
            }

            // make sure destination is a file, or else Jargon makes a directory out of it !

            //destDir.copyFrom(source);  // copy to this directory
            Debug("cmoveFromLocal:starting");

            // ===
            // Method One
            // ===

            // destFile.copyFrom(source);  // copy to target file

            // ===
            // Method Two
            // see: https://lists.sdsc.edu/pipermail/srb-chat/2004-December/001480.html
            // ===

            // From the above linke, add this statement forces serial tranfer ???
            //destFile.createNewFile();

            if (this.server.getUsePassiveMode())
                destFile.createNewFile();
            {
                // start progress task watcher
                progressTask=server.createProgressWatcher(transfer,source,destFile,false,Thread.currentThread());

                progressTask.startTask();

                source.copyTo(destFile);

                // Argg. copyTo *might* be asychronous
                while(destFile.length()<source.length())
                {
                    System.err.println("*** Copy NOT yet finished:"+destFile);

                    try
                    {
                        Thread.sleep(100);
                    }
                    catch (InterruptedException e)
                    {
                        System.out.println("***Error: Exception:"+e);
                        e.printStackTrace();
                    }

                }
                // stop the progress watcher
                progressTask.stopTask();
            }

            // ===
            //dest.createNewFile();
            //srbnode.copyTo(dest);

            Debug("cmoveFromLocal:ending");

            return; // ok ?
        }
        catch (IOException e)
        {
            if (progressTask!=null)
            {
                progressTask.stopTask();
            }

            throw SrbFileSystem.convertException("Couldn't copy local file:"+file+"to SRB destination:"+destFile+"\n",e);
        }
    }

    // ===
    // Misc ...
    // ===

    private static void Debug(String string)
    {
       Global.debugPrintln("SrbFile",string);
    }

    /** Returns input stream to remote SRBFile ! */

    public InputStream getInputStream() throws VlException
    {
        try
        {
            // Patched Version: !
            return new PATCHEDSRBFileInputstream(srbnode);
            //return new SRBFileInputStream(srbnode);
        }
        catch (IOException e)
        {
            throw new VlIOException("Could not get InputStream of:"+this+
                    "\nMessage="+e.getMessage(),e);
        }
    }

    public OutputStream getOutputStream() throws VlException
    {
        return getOutputStream(true);
    }

    public OutputStream getOutputStream(boolean truncate) throws VlException
    {
        try
        {
            if (truncate)
            {
                // truncate file BEFORE writing.
                // SBR emulated an outputstream by doing random access
                // writes which do not truncate an existing file.
                this.srbnode.delete();
            }
            return new SRBFileOutputStream(srbnode);
        }
        catch (IOException e)
        {
            throw new VlIOException("Could not get OutputStream of:"+this,e);
        }
    }

    public void setLength(long len) throws VlException
    {
        SRBRandomAccessFile afile=null;

        try
        {
            afile = new SRBRandomAccessFile(srbnode,"rw");
            afile.setLength(len);
            afile.close();
            //afile.finalize();
        }
        catch (Exception e)
        {
        	throw convertException(e);
        }
    }

    public int readBytes(long fileOffset, byte[] buffer, int bufferOffset, int nrBytes) throws VlException
    {
        SRBRandomAccessFile afile=null;

        try
        {
            afile = new SRBRandomAccessFile(srbnode,"r");
            afile.seek(fileOffset);
            int numread=afile.read(buffer,bufferOffset,nrBytes);
            afile.close(); // MUST CLOSE !
            //afile.finalize(); // destroy resources
            afile=null;

            return numread;
        }
        catch (Exception e)
        {
        	throw convertException(e);
        }
    }

    /**
     * From VRandomAccessable Interface
     *
     * @param fileOffset
     * @param buffer
     * @param bufferOffset
     * @param nrBytes
     * @param makeEmpty
     * @throws VlException
     */

    public void writeBytes(long fileOffset, byte[] buffer, int bufferOffset, int nrBytes) throws VlException
    {
        SRBRandomAccessFile afile=null;

        try
        {
            // NOT YET IMPLEMENTED BY JARGON !!! AARRGGGSSSS
            //if (truncate)
            //    afile.setLength(fileOffset+nrBytes);
            // Currently truncate ONLY works when starting to append to the beginning !
            // since jargon doesn't yet implement the setLength method !!!

            afile = new SRBRandomAccessFile(srbnode,"rw");
            afile.seek(fileOffset);
            afile.write(buffer,bufferOffset,nrBytes);
            afile.close(); // MUST CLOSE !
            //afile.finalize();

            return;
        }
        catch (Exception e)
        {
        	throw convertException(e);
        }
    }
    /** Converts:
     *
IllegalArgumentException
     *
FileNotFoundException
     *
SecurityException
     *
IOException
     *
     * @param e
     * @return
     */
    private VlException convertException(Exception e)
    {
    	if (e instanceof IllegalArgumentException)
        {
            return new VlException("SRB IllegalArgumentException",e.getMessage(),e);
        }
    	if (e instanceof FileNotFoundException)
        {
        	return new ResourceNotFoundException("SRB FileNotFoundException",e);
        }
    	if (e instanceof SecurityException)
    	{
        	return new VlException("SRB SecurityException",e.getMessage(),e);
        }
    	if (e instanceof IOException)
        {
        	return new VlIOException("SRB IOException",e);
        }

    	return new VlException("SRB Exception",e.getMessage(), e);
	}

	/** From VRandomAccessable interface */

    public void setLengthToZero() throws VlException
    {
       try
       {
           srbnode.delete(true);
           srbnode.createNewFile();
       }
       catch (IOException e)
       {
          throw new VlIOException("SRB IOException when setting file length to zero:"+this,e);
       }
    }

    /**
     * Fetch atrributes which are not in the Attribute Set.
     * This makes it possible (for subclasses) to merge several getAttributes() calls
     * into one AttributeSet without having to do the attribute checking themselves.
     *
     * The returned array matches the length and order of attrNames[].

     * Entry may be null if VAttribute couln't be fetched.
     * @param attrSet
     * @param attrNames
     * @return
     * @throws VlException
     */
    public VAttribute[] mergedGetAttributes(VAttributeSet attrSet,String attrNames[]) throws VlException
    {
       VAttribute attrs[]=new VAttribute[attrNames.length];
       String missingNames[]=new String[attrNames.length];

       // get attribute names which are not in the given set:
       for (int i=0;i<attrNames.length;i++)
       {
           // check Set for match
           if (attrNames[i]!=null)
               if (attrSet!=null)
                   attrs[i]=attrSet.get(attrNames[i]);

           // attribute not in set:
           if (attrs[i]==null)
           {
               Global.debugPrintln(this,"mergedGetAttributes: fetching Atributename="+attrNames[i]);
               missingNames[i]=attrNames[i];

               //optional filter missingNames[i]...

               // use default method:
               if (missingNames[i]!=null)
                   attrs[i]=getAttribute(missingNames[i]);
           }
           else
           {
               missingNames[i]=null; // do not fetch
           }
       }

       return attrs; // merged attributes
    }

    /**
     * For SRB Optimized getAttributes
     */
    @Override
    public VAttribute[] getAttributes(String attrNames[]) throws VlException
    {
       // Query SRB Attributes:

       VAttributeSet attrSets[]=SrbQuery.Query((SRBFileSystem)srbnode.getFileSystem(),
               this.getLocation().getDirname(),this.getName(),false,attrNames,null);

       if (attrSets==null)
       {
          Global.errorPrintln("SRBFile","Error: SRB Query resulted in NULL attribute sets:"+this);
       }
       // Query duplication (need equivalent of UNIQUE)
       else if (attrSets.length!=1)
       {
         Global.errorPrintln("SRBFile","Error: SRB Query for single file resulted in multiple attribute sets:"+this);
       }

       VAttribute[] attrs=null;

       if (attrSets==null)
           attrs = mergedGetAttributes(null,attrNames);
       else
           attrs = mergedGetAttributes(attrSets[0],attrNames);

       // update editable flag on attribute list
       setEditableAttributes(attrs);

       return attrs;
    }

    private void setEditableAttributes(VAttribute[] attrs)
    {
        if (attrs==null)
            return;

        for (VAttribute attr:attrs)
        {
            // attributes can be null !
            if (attr!=null)
            {
               String name=attr.getName();
               if (name.compareTo(SrbConfig.ATTR_RESOURCE)==0)
                  attr.setEditable(true);
               else if (name.compareTo(ATTR_DATA_TYPE)==0)
                   attr.setEditable(true);
            }
        }

    }

    public VAttribute getAttribute(String name) throws VlException
    {
      if (name==null)
          return null;

      if (name.compareTo(ATTR_NRACLENTRIES)==0)
      {
          return new VAttribute(ATTR_NRACLENTRIES,server.getNrACLEntries(this.srbnode,false));
      }
      else if (name.compareTo(ATTR_PERMISSIONS_STRING)==0)
      {
          // get optimized and custom SRB String:
            return new VAttribute(name,getPermissionsString());
      }
      else if (name.compareTo(SrbConfig.ATTR_RESOURCE)==0)
      {
            VAttribute attr = new VAttribute(name,getResource());
            // Resource should be editable
            attr.setEditable(true);
            return attr;
      }

      // check super object:

      VAttribute attr=super.getAttribute(name);

      if (attr!=null)
          return attr;

       return null;
    }

    public String getPermissionsString() throws VlException
    {
        return this.server.getPermissionsString(srbnode,false);
    }

    /*** // TODO: getAttributes(Nodes[],Names[]) => Query metadata
    public VAttribute[][] getAttributes(VNode nodes[],String attrNames[]) throws VlException
    {
      return null;
    }
    ***/

    /** Returns all default attributes names */
    public String[] getAttributeNames()
    {
        String superNames[]=super.getAttributeNames();

        return StringList.merge(superNames,SrbFSFactory.srbFileAttributeNames);
    }

    public VAttribute[][] getACL() throws VlIOException
    {
        return server.getACL(this.srbnode,false);
    }

    public void setACL(VAttribute acl[][]) throws VlException
    {
        server.setACL(this.srbnode,acl,false);
    }

    public VAttribute[] getACLEntities() throws VlIOException
    {
        SRBFileSystem srbfs=(SRBFileSystem)srbnode.getFileSystem();

        return SrbFileSystem.getACLEntities(srbfs);
    }

    public VAttribute[] createACLRecord(VAttribute entity, boolean writeThrough) throws VlException
    {
        SRBFileSystem srbfs=(SRBFileSystem)srbnode.getFileSystem();

        return SrbFileSystem.createACLRecord(srbfs,entity,false);
    }

    public boolean deleteACLEntity(VAttribute entity) throws VlException
    {
        return SrbFileSystem.deleteACLEntry(this.srbnode,entity);
    }

}


text:
<?php
// GENERATED CODE -- DO NOT EDIT!

// Original file comments:
// Copyright 2020 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
namespace Google\Cloud\Monitoring\V3;

/**
 * The Group API lets you inspect and manage your
 * [groups](#google.monitoring.v3.Group).
 *
 * A group is a named filter that is used to identify
 * a collection of monitored resources. Groups are typically used to
 * mirror the physical and/or logical topology of the environment.
 * Because group membership is computed dynamically, monitored
 * resources that are started in the future are automatically placed
 * in matching groups. By using a group to name monitored resources in,
 * for example, an alert policy, the target of that alert policy is
 * updated automatically as monitored resources are added and removed
 * from the infrastructure.
 */
class GroupServiceGrpcClient extends \Grpc\BaseStub {

    /**
     * @param string $hostname hostname
     * @param array $opts channel options
     * @param \Grpc\Channel $channel (optional) re-use channel object
     */
    public function __construct($hostname, $opts, $channel = null) {
        parent::__construct($hostname, $opts, $channel);
    }

    /**
     * Lists the existing groups.
     * @param \Google\Cloud\Monitoring\V3\ListGroupsRequest $argument input argument
     * @param array $metadata metadata
     * @param array $options call options
     * @return \Grpc\UnaryCall
     */
    public function ListGroups(\Google\Cloud\Monitoring\V3\ListGroupsRequest $argument,
      $metadata = [], $options = []) {
        return $this->_simpleRequest('/google.monitoring.v3.GroupService/ListGroups',
        $argument,
        ['\Google\Cloud\Monitoring\V3\ListGroupsResponse', 'decode'],
        $metadata, $options);
    }

    /**
     * Gets a single group.
     * @param \Google\Cloud\Monitoring\V3\GetGroupRequest $argument input argument
     * @param array $metadata metadata
     * @param array $options call options
     * @return \Grpc\UnaryCall
     */
    public function GetGroup(\Google\Cloud\Monitoring\V3\GetGroupRequest $argument,
      $metadata = [], $options = []) {
        return $this->_simpleRequest('/google.monitoring.v3.GroupService/GetGroup',
        $argument,
        ['\Google\Cloud\Monitoring\V3\Group', 'decode'],
        $metadata, $options);
    }

    /**
     * Creates a new group.
     * @param \Google\Cloud\Monitoring\V3\CreateGroupRequest $argument input argument
     * @param array $metadata metadata
     * @param array $options call options
     * @return \Grpc\UnaryCall
     */
    public function CreateGroup(\Google\Cloud\Monitoring\V3\CreateGroupRequest $argument,
      $metadata = [], $options = []) {
        return $this->_simpleRequest('/google.monitoring.v3.GroupService/CreateGroup',
        $argument,
        ['\Google\Cloud\Monitoring\V3\Group', 'decode'],
        $metadata, $options);
    }

    /**
     * Updates an existing group.
     * You can change any group attributes except `name`.
     * @param \Google\Cloud\Monitoring\V3\UpdateGroupRequest $argument input argument
     * @param array $metadata metadata
     * @param array $options call options
     * @return \Grpc\UnaryCall
     */
    public function UpdateGroup(\Google\Cloud\Monitoring\V3\UpdateGroupRequest $argument,
      $metadata = [], $options = []) {
        return $this->_simpleRequest('/google.monitoring.v3.GroupService/UpdateGroup',
        $argument,
        ['\Google\Cloud\Monitoring\V3\Group', 'decode'],
        $metadata, $options);
    }

    /**
     * Deletes an existing group.
     * @param \Google\Cloud\Monitoring\V3\DeleteGroupRequest $argument input argument
     * @param array $metadata metadata
     * @param array $options call options
     * @return \Grpc\UnaryCall
     */
    public function DeleteGroup(\Google\Cloud\Monitoring\V3\DeleteGroupRequest $argument,
      $metadata = [], $options = []) {
        return $this->_simpleRequest('/google.monitoring.v3.GroupService/DeleteGroup',
        $argument,
        ['\Google\Protobuf\GPBEmpty', 'decode'],
        $metadata, $options);
    }

    /**
     * Lists the monitored resources that are members of a group.
     * @param \Google\Cloud\Monitoring\V3\ListGroupMembersRequest $argument input argument
     * @param array $metadata metadata
     * @param array $options call options
     * @return \Grpc\UnaryCall
     */
    public function ListGroupMembers(\Google\Cloud\Monitoring\V3\ListGroupMembersRequest $argument,
      $metadata = [], $options = []) {
        return $this->_simpleRequest('/google.monitoring.v3.GroupService/ListGroupMembers',
        $argument,
        ['\Google\Cloud\Monitoring\V3\ListGroupMembersResponse', 'decode'],
        $metadata, $options);
    }

}


text:
<?php
namespace Dao\Factory;

use Zend\ServiceManager\FactoryInterface;
use Dao\Mapper\RouterSqlMapper;
use Zend\ServiceManager\ServiceLocatorInterface;
use Zend\Stdlib\Hydrator\ClassMethods;
class RouterSqlMapperFactory implements FactoryInterface
{
    public function createService(ServiceLocatorInterface $serviceLocator)
    {
        return new RouterSqlMapper(
            $serviceLocator->get('Zend\Db\Adapter\Adapter'),
            new ClassMethods()
        );
    }
}