Skip to content

Instantly share code, notes, and snippets.

View tbuckel's full-sized avatar

Thomas Buckel tbuckel

  • Perth, Australia
View GitHub Profile
@tbuckel
tbuckel / gist:7137034
Created October 24, 2013 13:11
Mac OS: Setting the environment for new processes started by Spotlight
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:7349789
Created November 7, 2013 06:07
JPA2 - Downcast
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:6190883
Created August 9, 2013 03:06
Subversion/SVN : Show revisions eligible to be merged from branch
svn mergeinfo http://[server]/branches/[branch] --show-revs eligible
@tbuckel
tbuckel / gist:5927485
Last active December 19, 2015 08:39
HTML5 Application Cache refresh
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.
@tbuckel
tbuckel / insert.sql
Created March 27, 2014 01:52
SQL Insert only of not exists
INSERT INTO example_table
(id, name)
SELECT 1, 'John'
WHERE
NOT EXISTS (
SELECT id FROM example_table WHERE id = 1
);