Skip to content

Instantly share code, notes, and snippets.

@shanestillwell
shanestillwell / jstest.js
Created October 10, 2013 15:21
Tell me what's wrong with this code?
var userService = (function() {
// This array will store all users
var userList = [
{
id: 1,
name: 'First User',
email: 'first.user@example.com'
}
];
<?php
namespace DoctrineMigrations;
use Doctrine\DBAL\Migrations\AbstractMigration,
Doctrine\DBAL\Schema\Schema;
/**
* Add comments and collection_method to metricdata
*/
Puppet::Type.type(:a2mod).provide(:amazon) do
desc "Manage Apache 2 modules on Amazon OS"
confine :operatingsystem => :amazon
defaultfor :operatingsystem => :amazon
require 'pathname'
# modpath: Path to default apache modules directory /etc/httpd/mod.d
# modfile: Path to module load configuration file; Default: resides under modpath directory
zapImageCache = function() {
var appDataDir, cacheDir, dir, externalRoot;
if (Ti.Filesystem.isExternalStoragePresent()) {
appDataDir = Ti.Filesystem.getFile('appdata://').nativePath;
externalRoot = appDataDir.substring(0, appDataDir.lastIndexOf('/'));
cacheDir = "" + externalRoot + "/Android/data/" + Ti.App.id + "/cache/_tmp/remote-cache";
dir = Ti.Filesystem.getFile(cacheDir);
} else {
dir = Ti.Filesystem.getFile(Ti.Filesystem.applicationCacheDirectory, '_tmp', 'remote-cache');
}
@shanestillwell
shanestillwell / packages.js
Created March 22, 2013 03:28
Query your node_modules to build a list for packages.json
var fs = require("fs");
function main() {
fs.readdir("./node_modules", function (err, dirs) {
if (err) {
console.log(err);
return;
}
dirs.forEach(function(dir){
if (dir.indexOf(".") !== 0) {
@shanestillwell
shanestillwell / assets.js
Created February 25, 2013 17:24
Files used with node version assets
[ 'public/css/angular-ui.min.css',
'public/css/app.css',
'public/css/bootstrap.min.css',
'public/css/plugins.css',
'public/css/style.css',
'public/css/ui-lightness/images/ui-bg_diagonals-thick_18_b81900_40x40.png',
'public/css/ui-lightness/images/ui-bg_diagonals-thick_20_666666_40x40.png',
'public/css/ui-lightness/images/ui-bg_flat_10_000000_40x100.png',
'public/css/ui-lightness/images/ui-bg_glass_100_f6f6f6_1x400.png',
'public/css/ui-lightness/images/ui-bg_glass_100_fdf5ce_1x400.png',
@shanestillwell
shanestillwell / find-version-assets.js
Created February 22, 2013 13:40
Find assets and version them.
'use strict';
var mime = require('mime');
var subDir = '/public';
var files = [];
var assets = [];
var grepFiles = [];
// Mime types that we consider assets
@shanestillwell
shanestillwell / gist:4963712
Created February 15, 2013 21:33
Get the short SHA for a file
git log --pretty=format:'%h' -n 1 tiapp.xml
function ApplicationWindow(title) {
var self = Ti.UI.createWindow({
title:title,
backgroundColor:'white'
});
var button = Ti.UI.createButton({
height:44,
width:200,
title:L('openWindow'),
@shanestillwell
shanestillwell / app.js
Created January 31, 2013 15:57
Appcelerator code for click and drag an object. This particular one is constrained to just moving up and down.
var self = Titanium.UI.createWindow({
title:'Window',
left:0,
top:0,
backgroundColor:'#FFF',
name:'win1'
});
var container = Ti.UI.createView({
height: 300,