Skip to content

Instantly share code, notes, and snippets.

View timyates's full-sized avatar

Tim Yates timyates

  • Manchester, UK
View GitHub Profile
@brock
brock / psql-with-gzip-cheatsheet.sh
Last active September 5, 2024 23:48
Exporting and Importing Postgres Databases using gzip
# This is just a cheat sheet:
# On production
sudo -u postgres pg_dump database | gzip -9 > database.sql.gz
# On local
scp -C production:~/database.sql.gz
dropdb database && createdb database
gunzip < database.sql.gz | psql database
@timyates
timyates / ACLcounting.md
Last active December 20, 2015 13:29
A quick method for performing Object.count() with Grails and ACL security

When doing pagination in Grails, you need to know the total number of objects a person can see.

When Domain Objects (in this example a Domain Class Project) are secured by ACL, this becomes problematic.

Here's a quick solution to find the number of objects under ACL security that a given user can see.

Basically, if the user is not ROLE_ADMIN, then we join the ACL tables, and return a count of those where the current user is the owner, or has READ | WRITE | ADMINISTRATION flags set

@piscisaureus
piscisaureus / pr.md
Created August 13, 2012 16:12
Checkout github pull requests locally

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = [email protected]:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:

@timyates
timyates / match.groovy
Created June 27, 2012 09:17
match/when implemented with Groovy's GEP-3
// No commas
def a = 'tim'
def nocom = match( a ) {
when 'dave' 'Hi Dave'
when 'tim' 'Hi Tim'
otherwise 'none of the above'
}
assert nocom == 'Hi Tim'
// Commas