Skip to content

Instantly share code, notes, and snippets.

@maplpro
maplpro / gist:647056
Created October 26, 2010 15:01
how to run Google Closure through Selenium
package example;
import org.junit.Before;
import org.junit.Test;
import com.thoughtworks.selenium.SeleneseTestCase;
public class GoogStringTest extends SeleneseTestCase {
private final String DIRECTORY_PREFIX =
@maplpro
maplpro / gist:646628
Created October 26, 2010 09:59
how to get next random diff. from prev. one
var func = function () { var a = Math.random(); return ( ( a === func.a ) && func() ) || ( func.a = a ); }
@maplpro
maplpro / gist:627986
Created October 15, 2010 10:41
how to find all scenarios on the page
var scenarios = function () {
return $( 'table' ).find( 'td:eq(0)' ).filter( ':contains(scenario)' );
};
@maplpro
maplpro / config.txt
Created October 14, 2010 11:19
cherrypy just serving static content
[global]
server.socket_host: '0.0.0.0'
log.error_file: 'host.log'
[/]
tools.staticdir.root = os.getcwd()
tools.staticdir.on = True
tools.staticdir.dir = "."
@maplpro
maplpro / gist:611383
Created October 5, 2010 11:23
how to call jQuery from Chrome Dev Console
$.ajax( { url: 'http://wss3single:9570/request/user_info', dataType: 'json', success: function (data) { x = data; alert( 'Done' ); }, error: function() { alert( 'UPS' ); } } )
@maplpro
maplpro / gist:604716
Created September 30, 2010 15:04
JavaScript templates
infoportal.ui.show_search_result = function ( search_result ) {
t = $.template( $( '#result_template' ).html() )
for ( var r in search_result ) {
$( '#result_table' ).append( t, search_result[ r ] );
if ( r % 2 === 0 ) {
$( '#result tr.resultItem:last' ).addClass( 'odd' );
@maplpro
maplpro / gist:602544
Created September 29, 2010 10:43
How to change app.yaml before you deploy it
import yaml
res = yaml.load( file( 'app.yaml', 'r' ) )
to_change = [x for x in res[ 'handlers' ] if x[ 'url' ] == '/project' ][ 0 ]
to_change[ 'login' ] = 'admin'
yaml.dump( res, file( 'app.yaml', 'w' ) )
yaml.dump( { 'proxy_urls' : 'urls' }, file( 'settings.yaml', 'w' ) )
@maplpro
maplpro / gist:601176
Created September 28, 2010 15:17
How to insert JavaScript into documents
el = document.createElement( "script" )
el.src = "http://code.jquery.com/jquery-1.4.2.min.js"
document.body.insertBefore(el)
@maplpro
maplpro / gist:595554
Created September 24, 2010 15:34
how to create table with jQuery
var table = $( '<table>' ).append( $( '<tr>' ).append( $('<td>') ).append( $('<td>') ) )
@maplpro
maplpro / gist:594062
Created September 23, 2010 18:03
testing with goog.testing
goog.require('goog.testing.asserts');
goog.require('infoportal.ui');
var tb;
function setUp() {
tb = infoportal.ui.init();
}
function tearDown() {