Skip to content

Instantly share code, notes, and snippets.

@sevir
sevir / base64.js
Created October 24, 2012 15:38
base64 for javascript in browser that it hasn't support window.atob or window.btoa (implemented in Firefox, Webkit and Opera latest versions)
/*
* Implements base64 decode and encode in browser that
* it hasn't support of window.btoa and window.atob
* methods.
* Based in Nick Galbreath
* http://code.google.com/p/stringencoders/source/browse/#svn/
* and Carlo Zottmann jQuery port
* http://github.com/carlo/jquery-base64
* Adapted by SeViR in DIGIO
*/
@jordiboehme
jordiboehme / gist:3168819
Created July 24, 2012 08:25
iOS Pixel-to-Points conversion
+(CGFloat)pixelToPoints:(CGFloat)px {
CGFloat pointsPerInch = 72.0; // see: http://en.wikipedia.org/wiki/Point%5Fsize#Current%5FDTP%5Fpoint%5Fsystem
CGFloat scale = 1; // We dont't use [[UIScreen mainScreen] scale] as we don't want the native pixel, we want pixels for UIFont - it does the retina scaling for us
float pixelPerInch; // aka dpi
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
pixelPerInch = 132 * scale;
} else if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) {
pixelPerInch = 163 * scale;
} else {
pixelPerInch = 160 * scale;