If you are lazy like me, you can use these images to quickly build spacers or blind images to layout your site.
This will generate an image with 350x150 pixels.
http://www.placehold.it/350x150
http://www.placehold.it/350x150
bool string_startsWith(const std::string &str, const std::string &prefix) { return std::equal(prefix.begin(), prefix.end(), str.begin()); }
/** * Computes the difference vector between two vectors. * @param p1 First vector (from (0,0). * @param p2 Second vector (from (0,0). * @return The difference vector between p1 and p2. */ public static function differenceVector(p1 : Point, p2 : Point) : Point { return new Point(p2.x - p1.x, p2.y - p1.y); } /** * Projects a point onto a line. Returns the projected point or null if * the projection does not fall within the segment. * * @param lineStart First point of the line. * @param lineEnd Second point of the line. * @param p Point that should be projected onto the line given by * lineStart and lineEnd. * @return The projected point on the line or null if the projection line * falls not between lineStart and lineEnd. */ public static function projectPointOntoLine(lineStart : Point, lineEnd : Point, p : Point) : Point { // Difference vector is the line. var l : Point = differenceVector(lineEnd, lineStart); // Determine determinant and divide it by the length of the line. var u : Number = (((p.x - lineStart.x) * (lineEnd.x - lineStart.x)) + ((p.y - lineStart.y) * (lineEnd.y - lineStart.y))) / (l.length * l.length); // Check whether the projection lies between lineStart and lineEnd. if ((u < 0) || (u > 1)) { return null; } // Compute projection point. var pp : Point = new Point(lineStart.x + u * (lineEnd.x - lineStart.x), lineStart.y + u * (lineEnd.y - lineStart.y)); return pp; } /** * Computes the shortest distance between a line and a point. If the * point cannot be projected onto the line segment specified by * lineStart and lineEnd, the function will return -1. * * @param lineStart First point of the line. * @param lineEnd Second point of the line. * @param p Point that should be projected onto the line given by * lineStart and lineEnd. * @return The distance between p and the line or -1 if p cannot be * projected onto the line. */ public static function distanceLinePoint(lineStart : Point, lineEnd : Point, p : Point) : Number { var projection : Point = projectPointOntoLine(lineStart, lineEnd, p); if (projection != null) { return differenceVector(p, projection).length; } else { return -1; } }
myLayoutManager
Go to Settings -> Storage -> click on the three small squares in the upper right corner -> USB computer connection -> enable Media Device (MTP)2. Add HP Touchpad Vendor and Product IDs to the INF file
Edit the android_winusb.inf either from the CyanodgenMod wiki or the original file from the Android SDK. Add these lines at the end of the sections for [Google.NTx86] and [Google.NTamd64].
; HP TouchPad %SingleAdbInterface% = USB_Install, USB\VID_0BB4&PID_6860&REV_0227&MI_01 %CompositeAdbInterface% = USB_Install, USB\VID_0BB4&PID_6860&MI_01
Open the Device Manager in Windows, selection the unknown USB device and update drivers. Select the android_winusb.inf file you just modified.
sc create SERVICENAME binpath= "<path to executable> -arg1 -arg2"
sc delete SERVICENAME
int main(int argc, char **argv) { SERVICE_TABLE_ENTRY serviceTable[2]; serviceTable[0].lpServiceName = "ServiceTest"; serviceTable[0].lpServiceProc = (LPSERVICE_MAIN_FUNCTION) ServiceMain; serviceTable[1].lpServiceName = NULL; serviceTable[1].lpServiceProc = NULL; StartServiceCtrlDispatcher(serviceTable); }
SERVICE_STATUS ServiceStatus; SERVICE_STATUS_HANDLE hServiceStatus; // Control handler function callback void ControlHandler(DWORD request) { switch(request) { case SERVICE_CONTROL_STOP: // Service has been stopped ServiceStatus.dwWin32ExitCode = 0; ServiceStatus.dwCurrentState = SERVICE_STOPPED; SetServiceStatus (hServiceStatus, &ServiceStatus); return; case SERVICE_CONTROL_SHUTDOWN: ServiceStatus.dwWin32ExitCode = 0; ServiceStatus.dwCurrentState = SERVICE_STOPPED; SetServiceStatus (hServiceStatus, &ServiceStatus); return; default: break; } // Report current status SetServiceStatus (ServiceStatusHandle, &ServiceStatus); } // Service main function callback void ServiceMain(int argc, char **argv) { int count = 0; int result; ServiceStatus.dwServiceType = SERVICE_WIN32; ServiceStatus.dwCurrentState = SERVICE_START_PENDING; ServiceStatus.dwControlsAccepted = SERVICE_ACCEPT_STOP | SERVICE_ACCEPT_SHUTDOWN; ServiceStatus.dwWin32ExitCode = 0; ServiceStatus.dwServiceSpecificExitCode = 0; ServiceStatus.dwCheckPoint = 0; ServiceStatus.dwWaitHint = 0; hServiceStatus= RegisterServiceCtrlHandler( "ServiceTest", (LPHANDLER_FUNCTION) ControlHandler); if (hServiceStatus == (SERVICE_STATUS_HANDLE) 0) { // Registering Control Handler failed return; } ServiceStatus.dwCurrentState = SERVICE_RUNNING; SetServiceStatus (hServiceStatus, &ServiceStatus); while (ServiceStatus.dwCurrentState == SERVICE_RUNNING) { // Do you important service stuff here Sleep(5000); } }
find ../src -name "*.cpp" -or -name "*.h" | xargs wc -l
shutdown /s
shutdown /r
shutdown /h
RUNDLL.EXE user.exe,exitwindowsexec
RUNDLL32.EXE user,exitwindows
org.lwjgl.opengl.Window.undecorated=<true|false>
java -Dorg.lwjgl.opengl.Window.undecorated=true -jar application.jar
System.setProperty(" org.lwjgl.opengl.Window.undecorated", "true");
void tokenize(const std::string &str, std::vector<std::string> &tokens, const std::string &delimiters = " ") { string::size_type lastPos = str.find_first_not_of(delimiters, 0); string::size_type pos = str.find_first_of(delimiters, lastPos); while (std::string::npos != pos || std::string::npos != lastPos) { tokens.push_back(str.substr(lastPos, pos - lastPos)); lastPos = str.find_first_not_of(delimiters, pos); pos = str.find_first_of(delimiters, lastPos); } }
vector<std::string> tokens; tokenize("I want to tokenize this!", tokens); tokenize("2012-02-20", tokens, "-");
package codebrocken.drones; import org.newdawn.slick.AppGameContainer; import org.newdawn.slick.BasicGame; import org.newdawn.slick.GameContainer; import org.newdawn.slick.Graphics; import org.newdawn.slick.SlickException; public class Drones extends BasicGame { public Drones(String title) { super(title); } @Override public void render(GameContainer arg0, Graphics arg1) throws SlickException { // TODO Auto-generated method stub } @Override public void init(GameContainer arg0) throws SlickException { // TODO Auto-generated method stub } @Override public void update(GameContainer arg0, int arg1) throws SlickException { // TODO Auto-generated method stub } public static void main(String[] args) { try { AppGameContainer appContainer = new AppGameContainer(new Drones("Drones")); appContainer.start(); } catch (SlickException e) { e.printStackTrace(); } } }
std::string trim(std::string &str, const std::string &trimChars = " ") { std::string result = str.erase(str.find_last_not_of(trimChars) + 1); return result.erase(0, result.find_first_not_of(trimChars)); }
string s = trim("Hello World! "); std::cout << s; // prints: Hello World! s = trim("xxx Hello World! xxx", "x"); std::cout << s; // prints: Hello World!
In the likely situation that no update to older devices is pushed out including enyo, here is a solution...it isn't pretty, but it will get the job done.
The very first thing you need to do is mention in your app description that your app requires "updated system software" included in the Maps app. This way, the users should know to expect this as a requirement, and even though many users don't read the description (grr...) you're still covered by mentioning this.
Then use the following code in your app:
Code: <!doctype html> <html> <head> <title></title> <meta name="viewport" content="height=device-height" /> <script src="C:\Program Files (x86)\HP webOS\SDK\share\framework\enyo\1.0\framework\enyo.js" type="text/javascript"></script> </head> <body> <script type="text/javascript"> if (typeof enyo == "undefined") window.location = "./requiresEnyo.html"; else new MyApp().renderInto(document.body); </script> </body> </html>
Code: <!doctype html> <html> <head> <title>Install Maps and Enyo</title> <meta name="viewport" content="height=device-height" /> <script src="/usr/palm/frameworks/mojo/mojo.js" type="text/javascript" x-mojo-version="1" /> </head> <body> <div style="padding: 5px"> Attention: This application requires an updated version of the system software which is not available on your phone. To install this updated software, you must install the updated Maps app by tapping the below button (will open the App Catalog): </div> <div class="palm-button" onclick="installEnyo()">Install</div> <script> window.onload = function() { PalmSystem.stageReady(); // required for page to load }; function installEnyo() { window.location = "http://developer.palm.com/appredirect/?packageid=com.palm.app.maps"; } </script> </body> </html>
Note that this loads Mojo (which will obviously be on the device) in a separate HTML file *if* enyo isn't already on the device (i.e. a Pre2). This was tested to work on my Pre2.
Also note that to put enyo in your app, your users must be using webOS 1.4.5 or newer because the maps app has a minimum webOS version of 1.4.5 (and thus, users prior to 1.4.5 won't see it in the Catalog and won't be able to update) due to (I'm assuming) using the version 2.0 packaging format.
If you have your app currently deployed to users running webOS versions prior to 1.4.5, you will have to retain a Mojo version in it (because the app can still be updated even if you change minimum OS version to 1.4.5 unless changes have recently gone into effect to fix that; this doesn't cause issues for the Maps app because technically, that app is not update-capable on devices prior to the Pre3 without the workaround they came up with).
Arthur Thornton
webOS Application Engineer
Appstuh
webservice.login(username, password).then( function loginSuccess(response) { enyo.log("Login successful"); }, function loginFailed(response) { enyo.log("Login failed."); });
enyo.kind({ name : "LoginComponent", kind : enyo.Component, components : [ { kind : "WebService", name : "loginWebService", url : "https://<your service URL here>", method : "post", onSuccess : "loginSuccess", onFailure : "loginFailure" } ], loginSuccess : function(inSender, inResponse, inRequest) { enyo.log("Login successful."); }, loginFailure : function(inSender, inResponse, inRequest) { enyo.log("Login failed."); } });
enyo.kind({ name : "LoginWebservice", kind : enyo.Component, deferred : undefined, components : [ { kind : "WebService", name : "loginWebService", url : "https://<your service URL here>", method : "post", onSuccess : "loginSuccess", onFailure : "loginFailure" } ], login : function(inUsername, inPassword) { this.deferred = when.defer(); var params = { Username : inUsername, Password : inPassword }; this.$.loginWebService.call(params); return this.deferred.promise; }, loginSuccess : function(inSender, inResponse, inRequest) { this.deferred.resolve(inResponse); }, loginFailure : function(inSender, inResponse, inRequest) { this.deferred.reject(inResponse); } });
enyo.kind({ name : "LoginWebServiceTest", kind : "Component", components : [ { kind : "LoginWebservice", name: "wsLogin" }, { kind : "Button", onclick: "loginTest" } ], loginTest : function(inSender) { this.$.wsLogin.login("Username", "MySecretPassword").then( function loginSuccess(response) { enyo.log("Login successful"); }, function loginFailed(response) { enyo.log("Login failed."); } ); } });
enyo.kind({ kind : "ModalDialog", name : "FFComputing.LoginDialog", caption : "Login", events: { onOK: "", onCancel: "" }, components : [ { kind : "Group", name : "LoginCaption", caption : "Login", components : [ { kind : "Input", name : "loginInput", hint : "Login...", autoWordComplete : false, spellCheck : false, autocorrect : false } ] }, { kind : "Group", name : "PasswordCaption", caption : "Password", components : [ { kind : "PasswordInput", name : "passwordInput", hint : "Password...", spellCheck : false, autocorrect : false } ] }, { layoutKind : "HFlexLayout", components : [ { kind : "Button", flex : 1, caption : "OK", onclick : "okClicked", className : "enyo-button-blue" }, { kind : "Button", flex : 1, caption : "Cancel", onclick : "cancelClicked" }] }, ], okClicked: function(sender) { this.close(); this.doOK(this.$.loginInput.getValue(), this.$.passwordInput.getValue()); }, cancelClicked: function(sender) { this.close(); this.doCancel(); } });
// import node.js net library var net = IMPORTS.require('net'); // constructor for service assistant var socketAssistant = function() { }; // function is called by framework to execute the service socketAssistant.prototype.run = function(future) { // future contains the result of the function call // use it to transfer information to your program future.result = { reply : "Hello " + this.controller.args.name + "!" }; // check if the node.js net library has been loaded if (!net) { console.error("net == NULL"); } // create a new client connection var client = net.createConnection(28820, '172.20.1.65'); // event handler when data arrives from the server client.on("data", function(data) { console.error("Received data: " + data.toString()); }); // event handler called after a connection has been established client.on("connect", function() { console.error("Connection established !"); client.write("HELLO\n")); }); // event handler called in case of an error client.on('end', function() { console.error("Connection killed."); }); };
<property name="appinfo.id" value="codebrocken.test" /> <property name="appinfo.version" value="1.0.0" /> <property name="appinfo.title" value="TestProject" /> <property name="appinfo.vendor" value="CodeBrocken" /> <!-- ================================= target: package ================================= --> <target name="package" depends="depends" description="Package the application."> <copy file="appinfo.json.in" tofile="src/appinfo.json"> <filterchain> <replacetokens> <token key="id" value="${appinfo.id}" /> <token key="version" value="${appinfo.version}" /> <token key="title" value="${appinfo.title}" /> <token key="vendor" value="${appinfo.vendor}" /> </replacetokens> </filterchain> </copy> <exec executable="cmd"> <arg value="/c" /> <arg value="palm-package" /> <arg value="src" /> <arg value="-o" /> <arg value="bin" /> </exec> </target>
{ "id": "@id@", "version": "@version@", "vendor": "@vendor@", "type": "web", "main": "index.html", "title": "@title@", "uiRevision": "2", "icon": "images/icon.png" }
<?xml version="1.0" encoding="UTF-8"?> <project name="TestProject" default="all"> <description> ANT project for HP Touchpad development </description> <property name="appinfo.id" value="codebrocken.test" /> <property name="appinfo.version" value="1.0.0" /> <property name="appinfo.title" value="TestProject" /> <property name="appinfo.vendor" value="CodeBrocken" /> <!-- ================================= target: all ================================= --> <target name="all" depends="depends" description="Build the project."> </target> <!-- - - - - - - - - - - - - - - - - - target: depends - - - - - - - - - - - - - - - - - --> <target name="depends"> </target> <!-- ================================= target: package ================================= --> <target name="package" depends="depends" description="Package the application."> <copy file="appinfo.json.in" tofile="src/appinfo.json"> <filterchain> <replacetokens> <token key="id" value="${appinfo.id}" /> <token key="version" value="${appinfo.version}" /> <token key="title" value="${appinfo.title}" /> <token key="vendor" value="${appinfo.vendor}" /> </replacetokens> </filterchain> </copy> <exec executable="cmd"> <arg value="/c" /> <arg value="palm-package" /> <arg value="src" /> <arg value="-o" /> <arg value="bin" /> </exec> </target> <!-- ================================= target: deploy ================================= --> <target name="deploy" depends="package" description="Deploy to device."> <exec executable="cmd"> <arg value="/c" /> <arg value="palm-install" /> <arg value="bin/${appinfo.id}_${appinfo.version}_all.ipk" /> </exec> </target> <!-- ================================= target: launch ================================= --> <target name="launch" depends="deploy" description="Launch the application on the device."> <exec executable="cmd"> <arg value="/c" /> <arg value="palm-launch" /> <arg value="${appinfo.id}" /> </exec> </target> <!-- ================================= target: log ================================= --> <target name="log" depends="depends" description="Start logging for the application on the device."> <exec executable="cmd"> <arg value="/c" /> <arg value="palm-log" /> <arg value="-f" /> <arg value="${appinfo.id}" /> </exec> </target> <!-- ================================= target: emulator ================================= --> <target name="emulator" depends="depends" description="Start the emulator"> <exec executable="cmd"> <arg value="/c" /> <arg value="palm-emulator" /> </exec> </target> </project>