Skip to content

Instantly share code, notes, and snippets.

@dongwq
dongwq / phonegap-jquerymobile.js
Created March 31, 2012 05:56 — forked from dongyuwei/phonegap-jquerymobile.js
解决jquerymobile用phonegap打包后后退导航失效问题
document.addEventListener("deviceready", function(){
var initUrl = location.href;
if (Device.platform === 'Android') {
//阻止按后退按钮就退出程序
navigator.app.overrideBackbutton(true);
}
/*解决jquerymobile用phonegap打包后后退导航失效问题*/
document.addEventListener("backbutton", function(){
@dongwq
dongwq / Product.groovy
Created October 26, 2012 08:55
use enum in grails
// http://groovy.dzone.com/tips/quicktip-grails-scaffolding
class Product {
static enum Status {
AVAILABLE("Beschikbaar"), SOLD_OUT("Uitverkocht")
final String value
Status(String value) {
this.value = value
@dongwq
dongwq / status.groovy
Created October 26, 2012 08:59
def enum as MesssageSourceResolvable
enum Status implements org.springframework.context.MessageSourceResolvable {
AVAILABLE, SOLD_OUT
public Object[] getArguments() { [] as Object[] }
public String[] getCodes() { [ name() ] }
public String getDefaultMessage() { "?-" + name() }
}
@dongwq
dongwq / ajaxOnA.html
Created April 24, 2013 10:15
ajax on a
update="updateResult_${i}"
onSuccess="function(data,textStatus){ alert('ok'); alert(data) };return true;"
<a href="/ca/tradeOrder/addToDrawback/64" onclick="jQuery.ajax({type:'POST',data:{'id': '64'}, url:'/ca/tradeOrder/addToDrawback',success:function(data,textStatus){jQuery('#updateResult_0').html(data);},error:function(XMLHttpRequest,textStatus,errorThrown){}});return false;" action="addToDrawback">加入退款</a>
import org.vertx.groovy.core.Vertx
class BootStrap {
def init = { servletContext ->
def vertx = Vertx.newVertx()
def httpServer = vertx.createHttpServer()
vertx.createSockJSServer(httpServer).installApp(prefix: '/events') { sock ->
sock.dataHandler { buff ->
sock << buff

Automated solver for 2048

This is a script which runs a "bot" that tries to solve the incredibly addictive 2048 game. It makes use of Groovy and browser automation with Geb.

How to

  • First step, if you don’t have it, you need to install Groovy.

  • Second step is to install the Google Chrome WebDriver (just unzip the appropriate file to a local directory)

  • Next, edit the script to set the path to the Chrome Driver

  • then execute the script: groovy solver2048.groovy

Plan for actually getting shit done
===================================
1. Do not read emails or answer forum questions until 5pm every day. That way they don't piss me off for the rest of the day.
2. Set aside Friday afternoons for shitty process stuff that I can't completely avoid or delegate. That way it doesn't intrude on important work or make me depressed and not want to do anything for the rest of the week.
3. Spend rest of time actually getting shit done and creating cool stuff.
4. Profit!
public class Promises {
private static class PageMetrics {
Integer visits;
Long avgMsOnPage;
@Override
public String toString() {
return String.format("{ avgMsOnPage=%d, visits=%d }", avgMsOnPage, visits);
}
@dongwq
dongwq / grails_update_to_2.4.2.adoc
Last active August 29, 2015 14:03
Upgrading from Grails 2.3.8 to 2.4.2

Upgrading from Grails 2.3.8 to 2.4.2

When upgrading to Grails 2.4.2 i ran into an issue where the following error message would pop up.

Error creating bean with name 'grailsApplication' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Cannot resolve reference to bean 'grailsResourceLoader' while setting bean property 'grailsResourceLoader'; To solve this issue you need to delete some lines in the <grails-app>/web-app/WEB-INF/applicationContext.xml file.

Delete the following lines:

are you ok