Skip to content

Instantly share code, notes, and snippets.

@simon-lang
simon-lang / flag-rename.php
Created May 30, 2011 15:04
Batch replace flag names from wikipedia to iso2 codes.php
$baseDir = 'C:\wamp\www\nations\web\images\flags\replace\\';
$dir = new DirectoryIterator($baseDir);
foreach ($dir as $file) {
$name = explode('_of_', $file);
if (count($name) == 1) {
continue;
}
$name = str_replace('.svg.png', '', $name[1]);
$country = Doctrine_Core::getTable('Country')
@simon-lang
simon-lang / console.log.ie6.js
Created October 28, 2011 10:10
console log for ie6? (untested)
$(function() {
if (typeof(console) === 'undefined') {
$('body').append('<div id="consoleLog" style="display: none;"></div>');
console = { log: function(msg){ $('#consoleLog').append(msg); } };
}
});
@simon-lang
simon-lang / gist:2418883
Created April 19, 2012 05:37
Sitecore sublayout parameters
NameValueCollection parameters = WebUtil.ParseUrlParameters(((Sitecore.Web.UI.WebControls.Sublayout) this.Parent).Parameters);
var x = parameters[“x”];
@simon-lang
simon-lang / gist:2418884
Created April 19, 2012 05:38
Sitecore download file field MediaItem
var DownloadLink = Sitecore.Resources.Media.MediaManager.GetMediaUrl(((Sitecore.Data.Fields.FileField) Sitecore.Context.Item.Fields["Prospectus"]).MediaItem);
@simon-lang
simon-lang / buckets.cs
Created May 8, 2012 06:47
Sitecore bucket sublayout query
var items = BucketManager.ParseDataSourceQueryForItems(((Sublayout)this.Parent).DataSource, Sitecore.Context.Item, 1, 200);
@simon-lang
simon-lang / dynamic-json.cs
Created June 29, 2012 02:40
C# dynamic json response
dynamic response;
response = new {
success = false,
message = "No spaces available, sorry.",
spacesAvailable = TrainingEvent.SpacesAvailable
};
var jss = new JavaScriptSerializer();
Response.Write(jss.Serialize(response));
@simon-lang
simon-lang / tooltips.js
Created July 27, 2012 02:02
tooltips.js
/*!
* ProjectName Tooltips
* @requires jQuery v1.7.2+
* @requires bootstrap-tooltip.js
*
* Simple wrapper for the Bootstrap Tooltip module
*
* @author Digicon http://www.digicon.com.au/
*/
;(function($) {
@simon-lang
simon-lang / script.coffee
Created July 27, 2012 06:33
Learning Coffeescript
a = 12
Pimptown = {}
Pimptown.Calculator =
$el: null
init: ->
this.$el = $('#output')
sqrt: (x) ->
x*x
@simon-lang
simon-lang / responsive-modules.js
Created July 31, 2012 22:48
broken sample responsive modules
;(function($) {
window.Digicon.Navigation = window.ProjectName.SomeModule || window.ProjectName.Module(function() {
var _queries = [
{
context: 'mobile',
callback: Digicon.Navigation.triggerMobile
},
@simon-lang
simon-lang / revealing-module.coffee
Created August 7, 2012 06:43
Revealing Module Pattern in CoffeeScript
# Revealing Module Pattern
# coffee -o lib/ -cwb src/
do ($ = jQuery.noConflict()) ->
ProjectName =
BaseModule: (module) ->
$ ->
if module.init
module.init()