Skip to content

Instantly share code, notes, and snippets.

View Prinzhorn's full-sized avatar
🌚
Existing

Alexander Prinzhorn Prinzhorn

🌚
Existing
View GitHub Profile
@Prinzhorn
Prinzhorn / pre-push
Created November 11, 2013 10:33
pre-push hook to prevent pushing when untracked files are present. i.e. breaking your production server because you forgot to add a new file in your commit and the tests run locally inside the repo.
git status --porcelain | grep '^??'
rc=$?
#grep exits with 0 when a match is found.
if [ $rc = 0 ] ; then
echo "Untracked files present. Aborting push.";
exit 1;
fi
@Prinzhorn
Prinzhorn / example1.js
Created October 24, 2013 11:39
skrollr constants
function initSkrollr()
{
var constants = {
container: 400, //TODO delete
container2: 50, //TODO delete
pausingCumulative0 : 0,
pausingCumulative1 : getStartingPercentageOfSection(1),
pausingCumulative2 : getStartingPercentageOfSection(2),
pausingCumulative3 : getStartingPercentageOfSection(3),
pausingCumulative4 : getStartingPercentageOfSection(4),
@Prinzhorn
Prinzhorn / README.md
Last active December 25, 2015 22:59
QR code bookmarklet

Just add the snipped as a bookmarklet and instantly turn the current website's URL in a QR code. Very useful when you quickly want to open the page on mobile.

@Prinzhorn
Prinzhorn / WAT.md
Last active December 25, 2015 16:49
File upload library

I'm currently using https://github.com/blueimp/jQuery-File-Upload, but it's a mess. It does it's job, but the API is...suboptimal.

I took a look at several other solutions, but most of the examples looked like this (which made me cry a little):

$(document).ready(function() {
    $('#some-input').myPlugin({
        option1: 1,
        /*
            A list of thousands of options
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2011 YOUR_NAME_HERE <YOUR_URL_HERE>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE

Create unique "users like items".

CREATE CONSTRAINT ON (user:User) ASSERT user._id IS UNIQUE
CREATE CONSTRAINT ON (item:Item) ASSERT item._id IS UNIQUE
@Prinzhorn
Prinzhorn / SOLUTION.md
Last active December 21, 2015 13:59
Android default browser renders some JPEG images blank.

Well, diffing the output of identify -verbose solved the mystery: The not-working image was saved as CMYK...

@Prinzhorn
Prinzhorn / example.js
Created June 17, 2013 12:35
Tiny jQuery plugin which makes refreshing elements a breeze.
//Enlarge all the bacon.
$('.bacon').height(10000).refresh();
@Prinzhorn
Prinzhorn / 16106952.js
Created April 19, 2013 15:50
StackOverflow 16106952
function waitForKeyElements (selectorTxt, actionFunction) {
if (!getElementByXPath(selectorTxt)) {
setTimeout(function () {
waitForKeyElements(selectorTxt, actionFunction);
}, 300);
} else {
actionFunction();
}
}
@Prinzhorn
Prinzhorn / documentation.md
Last active December 16, 2015 08:08
MongoDB unique+sparse bug?

From http://docs.mongodb.org/manual/core/indexes/#sparse-indexes

Any document that is missing the field is not indexed.

--

You can combine the sparse index option with the unique indexes option so that mongod will reject documents that have duplicate values for a field, but that ignore documents that do not have the key.