Skip to content

Instantly share code, notes, and snippets.

View witoldsz's full-sized avatar

Witold Szczerba witoldsz

View GitHub Profile
@witoldsz
witoldsz / TableModelSpec.js
Created March 10, 2012 23:25
Unit test for table model.
describe('table model', function() {
var hud, tableModel;
beforeEach(function(){
hud = jasmine.createSpyObj('hud', ['info']);
module('your-module-name', function($provide) {
$provide.value('hud', hud);
});
inject(function(tableModelFactory) {
@witoldsz
witoldsz / angular-auth.js
Created July 14, 2012 14:30
Angular Auth (work-in-progress)
/**
* @license Angular Auth
* (c) 2012 Witold Szczerba
* License: MIT
*/
angular.module('angular-auth', [])
/**
* Holds all the requests which failed due to 401 response,
* so they can be re-requested in the future, once login is completed.
@witoldsz
witoldsz / FileEnvFilter.java
Last active December 10, 2015 23:38
The class filters file (passed as first argument) with system environment entries (properties) to standard out. If file name ends with .xml or .properties it applies proper escaping.
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.PrintStream;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* The class filters file (passed as first argument) with system environment entries to standard out.
@witoldsz
witoldsz / OracleBooleanConverter.java
Created January 27, 2013 17:26
JOOQ Converter for Oracle to support boolean types in generated sources.
package pl.espeo.sgn.jooq;
import org.jooq.Converter;
/**
*
* @author Witold Szczerba
*/
public class OracleBooleanConverter implements Converter<Byte, Boolean> {
package pl.espeo.sgn.e2e;
import java.util.List;
import org.apache.commons.lang3.StringUtils;
import org.openqa.selenium.By;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebDriverException;
import org.openqa.selenium.WebElement;
var vertx = require('vertx')
var console = require('vertx/console')
var eb = vertx.eventBus;
var address = 'example.address'
var creditsAddress = 'example.credits'
var batchSize = 10000;
package test;
import java.util.Hashtable;
import java.util.Scanner;
import javax.naming.Context;
import javax.naming.NamingException;
import javax.naming.directory.DirContext;
import javax.naming.directory.InitialDirContext;
import javax.naming.ldap.LdapContext;
@witoldsz
witoldsz / DbScriptRunner.java
Created January 23, 2014 22:57
This script reads database commands from STDIN (as UTF-8), splits by semicolon, and executes command by command against given database.
import java.sql.Connection;
import java.sql.DriverManager;
import java.util.Scanner;
/**
* This script reads STDIN (as UTF-8), splits by semicolon, and executes command by command.
* Three arguments are required: database URL, username and password.
* Remember to set classpath for database driver.
* @author Witold Szczerba
*/
@witoldsz
witoldsz / socket.js
Created April 12, 2014 11:25
Prototype of AngularJS service for socket.io v.0.9.x
(function(module) {
"use strict";
// THIS IS ALPHA VERSION, JUST A SNIPPET OF A PROTOTYPE
module.factory('socket', function($rootScope, $q, $browser) {
var self = {
_iosocket: io.connect(),
var lockMonitor = {};
function schedule(messageKey, callback) {
function run(messageObject, trace, deferred) {
var lockKey = messageObject[messageKey];
if (!lockMonitor[lockKey]) {
lockMonitor[lockKey] = true;
var result = callback(messageObject, trace);
deferred.resolve(result);