Skip to content

Instantly share code, notes, and snippets.

View kbshl's full-sized avatar

Konstantin Büschel kbshl

  • Marburg, Hessen, Deutschland
  • 13:10 (UTC +02:00)
  • X @iskostja
View GitHub Profile
@kbshl
kbshl / minNonMinVersionOutputGulp.js
Created September 16, 2014 15:09
Gulp Receipe: Output both a minified and non-minified version
// Outputting both a minified and non-minified version of your combined JavaScript files can be achieved by using gulp-rename and piping to dest twice (once before minifying and once after minifying):
'use strict';
var gulp = require('gulp');
var rename = require('gulp-rename');
var uglify = require('gulp-uglify');
var DEST = 'build/';
@kbshl
kbshl / gatekeeper.sh
Created September 18, 2014 15:40
Removing Gatekeeper flag that causes Gatekeeper to check Application
cd /Applications
xattr -d com.apple.quarantine APPNAME # e.g. Xcode6-Beta7.app
@kbshl
kbshl / dispatcher.js
Last active October 30, 2017 18:36
Titanium Mobile: Using JS-only event dispatcher
var dispatcher = require('dispatcher');
function onLogOutButtonClick(e) {
dispatcher.trigger('logout');
}
@kbshl
kbshl / convert.js
Created October 15, 2014 11:23
Convert HTML Links to Titanium Mobile App Links that fire Ti.App.Events
var convertedHTML = htmlString;
// event-handler for app
convertedHTML = htmlString.replace(/<a href="((http|https)[^"]+)"[^>]*>(.*?)<\/a>/gmi, '<a href="$1" onclick="Ti.App.fireEvent(\'app:webViewClick\', {link: \'$1\'}); return false;">$3</a>');
// mailto special
convertedHTML = convertedHTML.replace(/<a href="mailto:([^"]+)"[^>]*>(.*?)<\/a>/gmi, '<a href="mailto:$1" onclick="Ti.App.fireEvent(\'app:webViewClick\', {linkType: \'email\', link: \'$1\'}); return false;">$2</a>');
@kbshl
kbshl / shell
Last active October 30, 2017 18:39 — forked from rborn/gist:63113167aace181f4f8b
Delete iOS8 simulator NSUserDefaults (Ti.App.Properties) on app uninstall
Delete this file
/Users/YOUR_USER/Library/Developer/CoreSimulator/Devices/SIM_UDID/data/Library/Preferences/APP_ID.plist
@kbshl
kbshl / app.js
Last active October 30, 2017 18:40 — forked from FokkeZB/app.js
Titanium Mobile: Add event listener once respectively remove event listener for anonymous callback function
var win = Ti.UI.createWindow({
backgroundColor: 'white'
});
win.addEventListener('click', function foo(e) { // note the named function expression needed for the second way
// oringal idea by @fukhaos
// http://www.tidev.io/2014/09/10/the-case-against-ti-app-fireevent-2/#comment-13013
e.source.removeEventListener(e.type, arguments.callee);
@kbshl
kbshl / app.js
Last active October 30, 2017 18:40
Titanium Mobile: Fire Google Analytics Screen View
// fire tracking event
require('/helpers/analytics/ga').screen(SCREENNAME);
@kbshl
kbshl / eventTracking.js
Last active October 30, 2017 18:40
Titanium Mobile: Fire Google Analytics Event
// fire analytics event
require('/helpers/analytics/ga').event(CATEGORY, ACTION, LABEL, 1);
@kbshl
kbshl / androidPrefs.js
Last active October 30, 2017 18:40 — forked from IGx89/android_prefs
Titanium Mobile: Emulates the standard Android preferences grid
// the following code is both the logic and examples of using it
var win = Titanium.UI.currentWindow;
// I've set anyDensity to true in my app and this function enables the UI to properly scale
// you can safely delete this function and all references to it if you'd like
var adj = function(pixels) {
if(Titanium.Platform.name == 'iPhone OS') {
return pixels;
} else {
@kbshl
kbshl / adbDatabasePull.sh
Last active October 30, 2017 18:41
Android: Pull database form emulator per adb command
# on genymotion emulator adb has root access
# also possible for directories
adb pull /data/data/<package_name>/databases/<database_name> <local_file_path>