Skip to content

Instantly share code, notes, and snippets.

View juliankrispel's full-sized avatar

Julian Krispel juliankrispel

View GitHub Profile
@juliankrispel
juliankrispel / titanium global events
Created January 23, 2012 15:48
Append an event to global app object / This is great for linking events across modules
button.addEventListener("click", function() {
Ti.App.fireEvent("app:updateData", {
field1: 'your',
field2: 'new',
field3: 'data'
});
});
@juliankrispel
juliankrispel / jquery.textfill.js
Created October 24, 2012 10:10
jQuery Plugin to resize text to fit container
(function($) {
$.fn.textfill = function(maxFontSize) {
maxFontSize = parseInt(maxFontSize, 10);
return this.each(function(){
var ourText = $("span", this);
function resizefont(){
var parent = ourText.parent(),
maxHeight = parent.height(),
maxWidth = parent.width(),
fontSize = parseInt(ourText.css("fontSize"), 10),
@juliankrispel
juliankrispel / gist:4160762
Created November 28, 2012 12:07
ie7 cross domain ajax request
if ($.browser.msie && window.XDomainRequest && $.browser.version.toString().indexOf('7') == 0) {
// Use Microsoft XDR
var xdr = new XDomainRequest();
xdr.open("get", url);
xdr.onload = function () {
var JSON = jQuery.parseJSON(xdr.responseText);
if (JSON == null || typeof (JSON) == 'undefined')
{
JSON = jQuery.parseJSON(data.firstChild.textContent);
}
@juliankrispel
juliankrispel / gist:4557898
Created January 17, 2013 17:45
Sass Loop for generating generic helpers
$x: 2;
$classnames: m, p;
$rulenames: margin, padding;
@while $x > 0{
$classname: nth($classnames, $x);
$rulename: nth($rulenames, $x);
$i: 4;
$a: (-top, -right, -bottom, -left);
$b: (-t, -r, -b, -l);
@juliankrispel
juliankrispel / gist:4564177
Created January 18, 2013 12:04
Magento - Get Handles (If you're not sure what tag it is)
<?php print_r($this->getLayout()->getUpdate()->getHandles()) ?>
@juliankrispel
juliankrispel / gist:4588586
Last active December 11, 2015 10:39
Wordpress snippets
<?php
/* Registering Post Types */
add_action( 'init', 'create_post_type' );
function create_post_type() {
register_post_type( 'acme_product',
array(
'labels' => array(
'name' => __( 'Slides' ),
@juliankrispel
juliankrispel / gist:4714777
Last active December 12, 2015 04:28
Instantiating and extending Collection at the same time. Just wrap extend in braces
define( [], function(){
var v_Filters = Backbone.View.extend({
filters: new (Backbone.Collection.extend({
url: 'http://www.google.com'
}))
});
@juliankrispel
juliankrispel / git_cheatsheet.markdown
Last active December 12, 2015 06:38
Git Cheatsheet

Pull from branch from remote repository 'origin'

git pull origin master

push to branch 'master' from remote repository 'origin'

git push origin master
@juliankrispel
juliankrispel / gist:5012097
Last active December 14, 2015 02:18
Thoughts on Javascript Architecture

##1 Plugins vs Modules in an MVC context

I have the impression that the general online developer-community seems to say that if you build a backbone-based application almost every UI problem can be tackled with an MV* like structure. My opinion is that for UI-development it's often more appropriate to delegate a lot of that job to a flat plugin, like a jquery plugin for example. That way you can delegate all the UI-specific code to a sepperate Module.

###Notes

  • But aren't plugins just modules, or shouldn't they structured like MVC modules? A: Depends on the complexity of the job. A lot of UI plugins/libraries would benefit from a more MVC-structured approach I believe.
  • I think there is a need for more style-standards, it would definately be a better world for frontend developers if there weren't as many different ways of doing things in Javascript. On the other hand, it's my firm believe the 'mistakes' and the vagueness inherent in the language allow for the diversity of approaches and usecases that al
@juliankrispel
juliankrispel / bash_cheatsheet.md
Last active December 14, 2015 02:58
Bash Cheatsheet

Dealing with $path

To edit $path on Mac OS lion create a file with a simple list of directories, line per line like this:

path/to/something path/to/something/else

and add the file to /etc/paths.d/

You could also directly edit the paths file under /etc/paths