Skip to content

Instantly share code, notes, and snippets.

View p4535992's full-sized avatar
🙄
I may be slow to respond.

4535992 p4535992

🙄
I may be slow to respond.
View GitHub Profile
import org.json.JSONArray;
import org.json.JSONObject;
import java.sql.ResultSet;
import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;
import java.util.Locale;
/**
* Utility for converting ResultSets into some Output formats
<bean id="entityManagerFactory"
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="dataSource" ref="dataSource"/>
<property name="jpaVendorAdapter">
<bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
<property name="showSql" value="true" />
<property name="databasePlatform" value="${hibernate.databasePlatform}" />
</bean>
</property>
<property name="jpaProperties">
<div id="me" vocab="http://xmlns.com/foaf/0.1/" prefix="v: http://rdf.data-vocabulary.org/#" typeof="Person v:Person" resource="http://carlboettiger.info#me">
<p>
<img property="depiction" src="assets/img/carlboettiger.png" alt="Photo of Carl Boettiger" style="float: right; margin: 10px 10px"/> I am
<a property="homepage v:url" href="http://carlboettiger.info">
<span property="name v:name">
<span property="firstName v:givenName">Carl
</span>
<span property="lastName v:familyName">Boettiger
</span>
</span></a>,
@p4535992
p4535992 / python-batchfile.bat
Created May 20, 2016 14:01 — forked from jadient/python-batchfile.bat
Run python code directly from a batch file
@echo off & python -x "%~f0" %* & goto :eof
# ==========================================================
# one way to place python script in a batch file
# place python code below (no need for .py file)
# ==========================================================
import sys
print "Hello World!"
for i,a in enumerate(sys.argv):
@p4535992
p4535992 / pQuery.js
Created July 22, 2016 09:32 — forked from niyazpk/pQuery.js
Add or update query string parameter
// Add / Update a key-value pair in the URL query parameters
function updateUrlParameter(uri, key, value) {
// remove the hash part before operating on the uri
var i = uri.indexOf('#');
var hash = i === -1 ? '' : uri.substr(i);
uri = i === -1 ? uri : uri.substr(0, i);
var re = new RegExp("([?&])" + key + "=.*?(&|$)", "i");
var separator = uri.indexOf('?') !== -1 ? "&" : "?";
if (uri.match(re)) {
@p4535992
p4535992 / uri.js
Created July 25, 2016 07:57 — forked from jlong/uri.js
URI Parsing with Javascript
var parser = document.createElement('a');
parser.href = "http://example.com:3000/pathname/?search=test#hash";
parser.protocol; // => "http:"
parser.hostname; // => "example.com"
parser.port; // => "3000"
parser.pathname; // => "/pathname/"
parser.search; // => "?search=test"
parser.hash; // => "#hash"
parser.host; // => "example.com:3000"
@p4535992
p4535992 / gist:72141b88c2f4ce9f89909835176f6b0b
Created August 4, 2016 12:37
Convert ivy.xml to build.gradle
/*Method 1*/
/* Original reference http://gradle.1045684.n5.nabble.com/converting-from-ant-ivy-to-gradle-td4408318.html */
task generateDependencies() << {
ivyFile = new File('ivy.xml')
gather = { dependencies, conf ->
dependencies.findAll( {
it['@conf'].toString().contains(conf.ivyConf) }).each {
String line = "\t${conf.gradleConf} group:
'${it['@org']}', name: '${it['@name']}', version: '${it['@rev']}'"
if(it['@org'].toString().contains('carfax'))
namespace YourNamespace
{
/// <summary>
/// Uses the Name value of the <see cref="ColumnAttribute"/> specified to determine
/// the association between the name of the column in the query results and the member to
/// which it will be extracted. If no column mapping is present all members are mapped as
/// usual.
/// </summary>
/// <typeparam name="T">The type of the object that this association between the mapper applies to.</typeparam>
public class ColumnAttributeTypeMapper<T> : FallbackTypeMapper
@p4535992
p4535992 / Loader.cs
Created December 9, 2016 21:18 — forked from dbuksbaum/Loader.cs
Loader for loading embedded assemblies
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.InteropServices;
namespace Utility
{
public class Loader
@p4535992
p4535992 / Extension to @ondravondra 's: "C# extension for executing upsert (MERGE SQL command) in EF with MSSQL" EF6 extension to perform an UPSERT. Original here: https://gist.github.com/ondravondra/4001192. This is actually an extension of a fork from this by @x4m, which allowed for an IEnumerable to be passed in. This version contains the additions: i) Get the name of the primary key for the table from the EntityContainerMapping as we wish to exclude th…
using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Data.Entity.Core.Mapping;
using System.Data.Entity.Core.Metadata.Edm;
using System.Data.Entity.Infrastructure;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
using System.Text;