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 / omnomnomnom.md
Created September 20, 2012 17:12
to nom

to nom

Definition

to eat or drink something and enjoying to do so.

Examples

@Prinzhorn
Prinzhorn / gist:4132330
Created November 22, 2012 17:39
fake scrolling using real scrolling

On iOS and Android as well JavaScript is throttled/stopped while scrolling. That's one use-case of iScroll because it doesn't use native scrolling.

Let alone the other use-cases, is it possible to prevent native scrolling (preventDefault) but then use touchmove/start/end and window.scroll to basically use the native scrollbar but no the native scrolling. In short: looks like you are scrolling (and you are), but JS still works.

Just wondering if you ever experimented with this. It's nothing I want for iScroll, just curious.

  • You could have mentioned relative-mode, as this would make the keyframes independent from where the header starts and how high it is. With relative mode you can resize the header and add a top margin without needing to adjust the keyframes (0 and 500).
  • In the last paragraph (mobile) you're including the IE plugin without mentioning what it does (and you say it's the mobile version).
    • The IE plugin adds support for rgb and hsl colors and patches querySelector to at least support ID selectors (for data-anchor-target)

But the relative mode stuff would make a great follow up I guess.

@Prinzhorn
Prinzhorn / message.md
Last active December 12, 2015 03:28
nodejitsu

The nodejitsu website doesn't say anything about databases. It took me some Googling (e.g. "site:nodejitsu.com mongodb") to find out that you in fact offer database hosting. I mean, I knew the nodejitsu website for quite some time and never knew about it and thus never evaluated for my use case. The same goes for which cloud host is used. I was implying that nodejitsu runs in it's own cloud (maybe Rackspace hosted, or Joyent, because it appears in nodejitsu context). But I now found out that you can choose where to run it (e.g. aws EU Ireland, which is what I want).

Long story short, you guys should really take a look at other PAAS and put the damn USPs on your homepage

  • You are THE node.js experts (you specialized in that. No rails, php, java or whatever)
  • It's not just application hosting but anything I need (list everything you offer, e.g. mongodb, redis, mysql, rabbitmq, whatever)
  • Free to get started with limited DB (e.g. "Free to get started for small apps with 100mb of free MongoDB")
  • Choos
@Prinzhorn
Prinzhorn / index.js
Created April 4, 2013 21:04
When preventing touch events from their default action, you can't click links or form elements. By checking if the move distance was small (i.e. it was just a tap) we can trigger a click on this element.
//Check if it was more like a tap.
var distanceY = initialTouchY - currentTouchY;
var distanceX = initialTouchX - currentTouchX;
var distance2 = distanceX * distanceX + distanceY * distanceY;
//Why use Math.sqrt when you can just compare the square number ;-).
if(distance2 < 49) {
//It was a tap, grab the element and click it.
var elementToClick = document.elementFromPoint(initialTouchX, initialTouchY);
elementToClick.click();
@Prinzhorn
Prinzhorn / AvgRingBuffer.js
Created April 9, 2013 09:20
AvgRingBuffer
var AvgRingBuffer = function(length) {
var _this = this;
var index = 0;
var data = [];
//Push a value to the oldest spot.
_this.push = function(value) {
data[index] = value;
index = (index + 1) % length;
};
@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.

@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 / 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 / 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...