Skip to content

Instantly share code, notes, and snippets.

@cgravolet
cgravolet / updateXcodeBuildVersionWithSVNRevision.sh
Created May 2, 2016 14:38
Update the Xcode build number with current SVN revision
svnVer=`sh /etc/profile; which svnversion`
appBuild=`"$svnVer" | sed -e 's/:[0-9]\{1,\}//' | sed -e 's/[^0-9]//g'`
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $appBuild" "${TARGET_BUILD_DIR}/${INFOPLIST_PATH}"
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $appBuild" "${BUILT_PRODUCTS_DIR}/${WRAPPER_NAME}.dSYM/Contents/Info.plist"
echo "Incremented the build number ${TARGET_BUILD_DIR}/${INFOPLIST_PATH}"
@cgravolet
cgravolet / parseTime.js
Created June 15, 2012 19:38
Takes any input and parses it into a valid time string. Requires moment.js
/**
* Parses a valid time string from ANY string that is passed to it
*
* @param {string} time
* @return {object} a Date object in a Moment wrapper
* @private
*/
function parseTime(time) {
var ampm, currentDay, hour, minute, timeArray;
@cgravolet
cgravolet / jquery.ba-tinypubsub.js
Created February 22, 2012 20:53 — forked from cowboy/HEY-YOU.md
jQuery Tiny Pub/Sub: A really, really, REALLY tiny pub/sub implementation for jQuery.
/* jQuery Tiny Pub/Sub - v0.7 - 10/27/2011
* http://benalman.com/
* Copyright (c) 2011 "Cowboy" Ben Alman; Licensed MIT, GPL */
(function($) {
var o = $({});
$.subscribe = function() {
o.on.apply(o, arguments);
@cgravolet
cgravolet / PaginationController.js
Created September 1, 2011 03:57
Pagination controller
(function(vod, $j){
vod.PaginationController = function(){};
$j.extend(vod.PaginationController.prototype, {
attributes: {
endIndex: 1,
itemsPerPage: 25,
itemsPerRow: 5,
@cgravolet
cgravolet / gup.js
Created September 11, 2009 18:33
Get URL Parameter
gup: function(name){
name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
var regexS = "[\\?&]"+name+"=([^&#]*)";
var regex = new RegExp(regexS);
var results = regex.exec(window.location.href);
if (results == null) {
return '';
} else {
return results[1];
}
@cgravolet
cgravolet / trim.js
Created September 11, 2009 18:32
Trim
trim: function(str, max){
if(str.length > max){
str = str.substring(0, max-4)+" ...";
}
return str;
} // trim()
@cgravolet
cgravolet / dataBind.js
Created September 11, 2009 18:22
Data bind
dataBind: function(data, ctrl){
var regexp = null;
for (var key in data) {
regexp = new RegExp("{" + key + "}","gi");
ctrl = ctrl.replace(regexp, data[key]);
}
return ctrl;
} // dataBind()
@cgravolet
cgravolet / supplant.js
Created September 11, 2009 18:21
Alternative data bind method
if (typeof String.prototype.supplant !== 'function') {
String.prototype.supplant = function (o) {
return this.replace(/{([^{}]*)}/g,
function (a, b) {
var r = o[b];
return typeof r === 'string' ? r : a;
});
};
}