Skip to content

Instantly share code, notes, and snippets.

View Baztoune's full-sized avatar
🏠
Working from home

Bastien Colmard Baztoune

🏠
Working from home
  • Paris
View GitHub Profile
(function(){
var textareas = document.getElementsByTagName('textarea');
var len = textareas.length;
while(len--){
var htmlContent = Base64.decode(textareas[len].innerHTML);
try{
textareas[len].innerHTML = htmlContent;
} catch (err){
//ie
textareas[len].value = htmlContent;
@Baztoune
Baztoune / hashtaglol.user.js
Created May 25, 2011 23:11
Adds background on tweets with special hashtag (#trollface #likeaboss #foreveralone)
// ==UserScript==
// @author Baztoune
// @name hashtaglol
// @namespace http://codeblessyou.com/
// @include http://twitter.com/*
// @description Adds background on tweets with special hashtag (#trollface #likeaboss #foreveralone so far, more later)
// ==/UserScript==
function stuf(){
@Baztoune
Baztoune / baseLayout.jsp
Created September 7, 2011 09:46
Allows to manage finely CSS/JS overload in struts-tiles 1.2.8 templating system
<%@ include file="../include/taglib_include.jsp" %>
<%@ page contentType="text/html; charset=UTF-8" %>
<!DOCTYPE html>
<html>
<head>
<title><tiles:getAsString name="title"/></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<!-- We load JS 'modules' depending on the tiles definition-->
@Baztoune
Baztoune / banner.fla
Created September 25, 2011 18:14
Embed flash in HTML
if(exit_url !=null){
getURL(exit_url , "_blank");
} else {
getURL("http://www.mysite.com/default", "_blank");
}
;
; AutoHotkey Version: 1.x
; Language: English
; Platform: Win9x/NT
; Author: A.N.Other <myemail@nowhere.com>
;
; Script Function:
; Template script (you can customize this template by editing "ShellNew\Template.ahk" in your Windows folder)
;
@Baztoune
Baztoune / my_job_run.bat
Created October 18, 2011 14:42
Launch Talend job (.jar) with parameters
%~d0
cd %~dp0
@echo off
echo Parameter?
set /p my_parameter=
echo Parameter2?
set /p my_parameter2=
java -Xms256M -Xmx1024M -cp classpath.jar; The.path.my_job_0_1.my_job --context=Default --context_param my_parameter=%my_parameter% --context_param my_parameter2=%my_parameter2%
@Baztoune
Baztoune / MyLevenshteinUtils.java
Created July 18, 2012 15:33
Search for a city, based on (french) zipcode and name, with Levenshtein implementation
import org.apache.commons.lang.StringUtils;
public class MyLevenshteinUtils {
/**
* http://en.wikibooks.org/wiki/Algorithm_Implementation/
* Strings/Levenshtein_distance#Java
*
* @param str1
* @param str2
@Baztoune
Baztoune / EmailValidator.java
Created August 8, 2012 14:46
Email validation with RegExp (JSF validator + Seam component)
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.faces.application.FacesMessage;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.validator.Validator;
import javax.faces.validator.ValidatorException;
import org.jboss.seam.annotations.Name;
@Baztoune
Baztoune / SqlQueryHelper.java
Created August 24, 2012 13:49
Return available fields and their type from SQL Query
public class SqlQueryHelper {
public List<SimpleEntry<String, Type>> getAvailableFieldsFromQuery(
String sqlQuery) {
List<SimpleEntry<String, Type>> availableFields = new ArrayList<SimpleEntry<String, Type>>();
Connection c = null;
Statement st = null;
Session sess = null;
try {
Session delegate = (Session) entityManager.getDelegate();
@Baztoune
Baztoune / page.xhtml
Created November 23, 2012 14:59
Emulate an HTML select optgroup with RichFaces 3.3 (seam is optional, just use <f:selectItems/> and a converter)
<h:selectOneMenu value="#{myObject.value}">
<s:selectItems value="#{app.globalList}" var="_o" label="#{_o.label}" noSelectionLabel="-" />
<f:selectItem itemValue="-1" itemLabel="-------" itemDisabled="true" />
<s:selectItems value="#{app.globalListComplement}" var="_o" label="#{_o.label}" />
<s:convertEntity />
</h:selectOneMenu>