Skip to content

Instantly share code, notes, and snippets.

View msenkpiel's full-sized avatar
👻

Marco ± msenkpiel

👻
View GitHub Profile
@msenkpiel
msenkpiel / countries.php
Created July 12, 2016 08:31
Zend Locale: Create a country dropdown list
$countries = Zend_Locale::getTranslationList('territory');
asort($countries);
$options = array();
foreach ($countries as $short => $translation) {
if (strlen($short) == 2) {
$options[] = [
'key' => $translation,
'value' => $short
];
@msenkpiel
msenkpiel / 0_reuse_code.js
Created July 11, 2016 11:45
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@msenkpiel
msenkpiel / handlebars-helper.js
Created March 5, 2015 12:45
Handlebars Helper
/**
* when helper
*
* {{#when foo bar}}
* eat this
* {{/when}}
*/
Handlebars.registerHelper('when', function (a, b, options) {
if(String(a).toLowerCase() == String(b).toLowerCase()){
@msenkpiel
msenkpiel / distance
Created January 23, 2015 11:27
Distance
public static function distance($lat1, $lon1, $lat2, $lon2)
{
$theta = $lon1 - $lon2;
$dist = sin(deg2rad($lat1)) * sin(deg2rad($lat2)) + cos(deg2rad($lat1)) * cos(deg2rad($lat2)) * cos(deg2rad($theta));
$dist = acos($dist);
$dist = rad2deg($dist);
$kilometers = $dist * 60 * 1.8531596160;
return $kilometers;
}

#Stay Standalone

A short script to prevent internal links to a "webapp" added to iPhone home screen to open in Safari instead of navigating internally.

@msenkpiel
msenkpiel / _utils.scss
Last active August 29, 2015 14:07
Sass Utilities
$bpLarge:1200;
$bpDesktop:960;
$bpTablet:768;
@mixin breakPoint($name) {
@if $name == large {
@media (min-width: #{$bpLarge}px) {
@content;
}
@msenkpiel
msenkpiel / jquery.plugin.js
Created September 18, 2014 07:01
jQuery Plugin Pattern
;
(function ($, window, document, undefined) {
'use strict';
var pluginName = 'plugin',
defaults = {
propertyName: "value"
};
@msenkpiel
msenkpiel / Website_Tool_Backend.php
Last active August 29, 2015 14:04
Pimcore backend helper to add website properties via code (since 2.0.0)
<?php
/**
* Class WebsiteSettings
*/
class WebsiteSettings extends Zend_Db_Table_Abstract
{
protected $_name = 'website_settings';
protected $_primary = 'id';
}
@msenkpiel
msenkpiel / backbone-view.js
Last active August 29, 2015 13:57
backbone default view
MyView = Backbone.View.extend({
options:{},
className: '',
events: {
},
initialize: function (options) {
if(options){
_.extend(this.options, options);
@msenkpiel
msenkpiel / mobile-detect.js
Created February 26, 2014 09:48
Javascript Mobile Utils
App.utils = {
mobile:{
isAndroid: function() {
return navigator.userAgent.match(/Android/i);
},
isBlackBerry: function() {
return navigator.userAgent.match(/BlackBerry/i);
},
isIos: function() {
return navigator.userAgent.match(/iPhone|iPad|iPod/i);