Skip to content

Instantly share code, notes, and snippets.

public class NamedParamStatement {
public NamedParamStatement(Connection conn, String statementWithNames) throws SQLException {
Pattern findParametersPattern = Pattern.compile("(?<!')(:[\\w]*)(?!')");
Matcher matcher = findParametersPattern.matcher(statementWithNames);
while (matcher.find()) {
fields.add(matcher.group().substring(1));
}
prepStmt = conn.prepareStatement(statementWithNames.replaceAll(findParametersPattern.pattern(), "?"));
}
@irazasyed
irazasyed / sourceTree-git-fix.md
Created March 11, 2014 15:42
Git: SourceTree - Remote Error fix for Windows Users.

This works if you authenticate using a public/private key pair:

  • Open Sourcetree and go to "Tools > Create or Import SSH Keys" (this will open a PuTTY Key Generator window), Set the number of bits in a generated key to 2048 and click on "Generate".

  • Once generated go to git server panel and navigate to "My account > Profile > SSH Keys" and click "Add a public key".

  • Copy the generated public key from the "PuTTY Key Generator" window ("Public key for pasting into OpenSSH authorized_keys file:") to git panel and save it.

  • In the "PuTTY Key Generator" window enter a "Key passphrase" and "Confirm passphrase" and click "Save private key" and Public Key (for other uses too). Make sure to save it somewhere where you can find it again.

@allanolivei
allanolivei / gist:8982445
Last active March 26, 2022 20:14
Unity 3d : Expose the rendering order of MeshRenderer in the Unity3D
using UnityEngine;
using UnityEditor;
using System.Reflection;
using System;
using UnityEditorInternal;
[CustomEditor(typeof(MeshRenderer)), CanEditMultipleObjects]
public class MeshRendererInspector : Editor
{