Skip to content

Instantly share code, notes, and snippets.

@sbrissenden
sbrissenden / retention.sql
Last active May 31, 2022 00:51
[BigQuery + Google Analytics for Firebase] Daily N-Day User Retention of September 1 Cohort
#standardSQL
####################################################################
# PART 1: Cohort of New Users starting on SEPT 1
####################################################################
WITH
new_user_cohort AS (
SELECT DISTINCT user_pseudo_id as new_user_id
FROM
`projectId.analytics_YOUR_TABLE.events_*`
WHERE
@grantges
grantges / index.js
Created November 4, 2015 07:38
Example of a custom delete animation for Appcelerator ListView component using straight Ti - no module required.
$.index.open();
// When we click on the item we want to delete it. This can be called at any place actually,
// I just have it on this event.
function onItemClick(e){
// Get the data of the row so we can use it to populate the new templates
var data = $.listView.sections[e.sectionIndex].getItemAt(e.itemIndex);
// Set the counter to zero, we use this for naming the template on an interval
@mwaterfall
mwaterfall / StringExtensionHTML.swift
Last active May 27, 2024 04:36
Decoding HTML Entities in Swift
// Very slightly adapted from http://stackoverflow.com/a/30141700/106244
// 99.99% Credit to Martin R!
// Mapping from XML/HTML character entity reference to character
// From http://en.wikipedia.org/wiki/List_of_XML_and_HTML_character_entity_references
private let characterEntities : [String: Character] = [
// XML predefined entities:
""" : "\"",
"&" : "&",
@benbahrenburg
benbahrenburg / app.js
Created March 15, 2015 02:57
TIMOB-17458
//To test the method use the following
var dir = Ti.Filesystem.getApplicationSupportDirectory();
console.log(dir);
var f = Titanium.Filesystem.getFile(Ti.Filesystem.applicationSupportDirectory);
console.log('Directory Exists: '+ (f.exists() ? 'Yes' : 'No'));
var testfile = Ti.Filesystem.getFile(Ti.Filesystem.applicationSupportDirectory, 'text.txt');
if(testfile.exists()){
testfile.deleteFile();
@jasonkneen
jasonkneen / Alloy.js
Last active November 27, 2018 07:12
Dynamically change languages in a Titanium Alloy app (for testing)
// add this to the Alloy.js file
// Set to run in ENV_DEV mode so it's used for testing withou
// having to change languages on device etc
// NO checks in place so assumes you know what you're doing, have
// the relevant strings files and specify the correct one!
// should work on Android - not tested yet!
if (ENV_DEV) {
Alloy.Globals.setLanguage = function(lang) {
@stephenfeather
stephenfeather / Gruntfile.js
Last active October 2, 2015 18:18
Appcelerator Gruntjs
module.exports = function(grunt) {
require('time-grunt')(grunt);
// Project configuration.
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
CHANGELOG: '',
// add tiapp.xml changes to the repo
gitadd: {
versionBump: {
options: {
@skypanther
skypanther / Gruntfile.js
Last active May 3, 2017 11:48
Grunt - build your Titanium app and upload to Installr
var _ = require('underscore')._;
module.exports = function(grunt) {
grunt.initConfig({
settings: {
appName: 'YourAppName',
ppUuid: 'uuid', /* Provisioning profile UUID */
distributionName: 'cert_name', /* Distr. certificate name */
keystoreLocation: '/Users/path/to/android.keystore', /* path to keystore */
storePassword: 'keystore_password', /* keystore password */
@tonylukasavage
tonylukasavage / .jshintrc
Created June 24, 2014 13:27
generic .jshintrc for ti, alloy, node.js, mocha
{
"browser": true,
"camelcase": true,
"curly": true,
"eqeqeq": true,
"expr": true,
"immed": true,
"indent": 4,
"latedef": "nofunc",
"newcap": true,
@jasonkneen
jasonkneen / index.js
Last active March 15, 2017 18:51
Demo of how to use David Bankier's "Real Switch" for Android here. https://github.com/dbankier/RealSwitch. Add the Module to your TiApp.xml file, add a switch to your Alloy file as normal, but add the module attribute. Drop the ui.js file into your /lib/ folder (you can add to this) and then run the project. On iOS you'll get a regular iOS switc…
$.mySwitch.addEventListener('change',function(e){
Ti.API.info('Switch value: ' + $.mySwitch.value);
});
@tonylukasavage
tonylukasavage / app.js
Created June 2, 2014 14:51
Inject environment variables into Titanium. Makes shared code easier to manage (no more sanitizing keys in repos). Uses Titanium to encrypt the values.
// now you can use it in a titanium app
useSomeApi(Ti.App.Properties.getString('SOME_API_KEY'));