Skip to content

Instantly share code, notes, and snippets.

Thomas Buckel tbuckel

  • Perth, Australia
Block or report user

Report or block tbuckel

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@tbuckel
tbuckel / insert.sql
Created Mar 27, 2014
SQL Insert only of not exists
View insert.sql
INSERT INTO example_table
(id, name)
SELECT 1, 'John'
WHERE
NOT EXISTS (
SELECT id FROM example_table WHERE id = 1
);
View gist:7349789
Root<Employee> empRoot = cq1.from(getEntityManagerFactory().getMetamodel().entity(Employee.class));
Join<Employee, Project> join = empRoot.join("projects");
Path exp = ((Path)join.as(LargeProject.class)).get("budget");
cq1.where(qb1.equal(exp, new Integer(1000)) );
// --------------
Check for type:
cb.equal(join.type(), cb.literal(LargeProject.class))
@tbuckel
tbuckel / gist:7137034
Created Oct 24, 2013
Mac OS: Setting the environment for new processes started by Spotlight
View gist:7137034
From http://stackoverflow.com/questions/135688/setting-environment-variables-in-os-x/3756686
Setting the environment for new processes started by Spotlight
You can set the environment used by launchd (and, by extension, anything started from Spotlight) with launchctl setenv. For example to set the path:
launchctl setenv PATH /opt/local/bin:/opt/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin
Or if you want to set up your path in .bashrc or similar, then have it mirrored in launchd:
PATH=/opt/local/bin:/opt/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin
launchctl setenv PATH $PATH
@tbuckel
tbuckel / gist:6190883
Created Aug 9, 2013
Subversion/SVN : Show revisions eligible to be merged from branch
View gist:6190883
svn mergeinfo http://[server]/branches/[branch] --show-revs eligible
@tbuckel
tbuckel / gist:5927485
Last active Dec 19, 2015
HTML5 Application Cache refresh
View gist:5927485
window.applicationCache.addEventListener('updateready', function(e) {
if (window.applicationCache.status == window.applicationCache.UPDATEREADY) {
// Browser downloaded a new app cache.
// Swap it in and reload the page to get the new hotness.
window.applicationCache.swapCache();
if (confirm('A new version of this site is available. Load it?')) {
window.location.reload();
}
} else {
// Manifest didn't changed. Nothing new to server.
You can’t perform that action at this time.