Skip to content

Instantly share code, notes, and snippets.

@handleman
handleman / services.js
Last active January 8, 2021 01:03 — forked from bullgare/services.js
serialize form - pure js
serialize: function serialize(form)
{
if (!form || form.nodeName !== "FORM") {
return;
}
var i, j,
obj = {};
for (i = form.elements.length - 1; i >= 0; i = i - 1) {
if (form.elements[i].name === "") {
continue;
@handleman
handleman / gmaps_controls_classifier.js
Last active August 29, 2015 14:10 — forked from matellis/gmaps_controls_classifier.js
hack to give classes on goole map interface elements
controlList = {
'map_type_control': 'margin-top: 5px; margin-right: 5px; margin-bottom: 5px; margin-left: 5px; z-index: 11; position: absolute; cursor: pointer; right: 0px; top: 0px; ',
'pan_control': 'cursor: url(https://maps-api-ssl.google.com/intl/en_us/mapfiles/openhand_8_8.cur), default; width: 78px; height: 78px; position: absolute; left: 0px; top: 0px; ',
'zoom_control': 'position: absolute; left: 27px; top: 128px; ',
'streetmap_control': 'width: 32px; height: 38px; overflow-x: hidden; overflow-y: hidden; position: absolute; left: 0px; top: 0px; ',
};
function labelControls() {
$.each(controlList, function(id, attr) {
$('div[style^="' + attr + '"]').attr('class',id);
@handleman
handleman / hideOnClickOutside.js
Last active August 29, 2015 14:10 — forked from thisgeek/gist:399081
hide element when user clicks outside the element
$.fn.hideOnClickOutside = function () {
target = $(this);
$(document).on('click', function() {
target.hide();
});
target.click( function(event) {
event.stopPropagation();
});
return target;
}
/** Global override to make all AJAX calls as POST type */
Backbone.ajax = function() {
var args = Array.prototype.slice.call(arguments, 0);
return Backbone.$.ajax.apply(Backbone.$, _.extend(args, {type: 'POST'}));
};
/** Manual override per call */
Collection.fetch({data: {id: 34}, type: 'POST'});
@handleman
handleman / filesize-filter.js
Last active August 29, 2015 14:26 — forked from yrezgui/filesize-filter.js
This is a custom filter to show a bytes filesize in better way.
// add the filter to your application module
angular.module('myApp', ['filters']);
/**
* Filesize Filter
* @Param length, default is 0
* @return string
*/
angular.module('filters', [])
.filter('Filesize', function () {
@handleman
handleman / anchor_smooth_scroll.js
Last active August 29, 2015 14:27 — forked from justinmc/anchor_smooth_scroll.js
Anchor Smooth Scroll - Angular Directive
/**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* Anchor Smooth Scroll - Smooth scroll to the given anchor on click
* adapted from this stackoverflow answer: http://stackoverflow.com/a/21918502/257494
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
angular.module('yourapp').directive('anchorSmoothScroll', function($location) {
'use strict';
return {
restrict: 'A',
replace: false,
@handleman
handleman / grunt.copy.includeFile.js
Created June 21, 2016 16:15 — forked from purtuga/grunt.copy.includeFile.js
A Grunt Copy process function to embed content of files into other files.
/**
* includeFile() - embeds a file content within another. Meant to be
* used from the copy task as a 'processContent' function. The following
* tokens can be used in files: <br>
*
* - BUILD_INCLUDE('file')
* - /* BUILD_INCLUDE('file') *\x47
* - &lt;!-- BUILD_INCLUDE("file") --&gt;
*
* In addition, options can be added to the token above that further
@handleman
handleman / findOffsetTop
Created June 28, 2016 09:26 — forked from waaronking/findOffsetTop
Find the offsetTop of any item by recursively looking at the parent element until parent offset is 0
/* Finds the total offset of an item inside a window */
var findOffsetTop = function(el) {
var offset = el.offsetTop;
if (el.parentNode.offsetTop !== 0) {
offset += findOffsetTop(el.parentNode);
}
return offset;
};
@handleman
handleman / Install Composer to use MAMP's PHP.md
Created October 11, 2018 07:04 — forked from kkirsche/Install Composer to use MAMP's PHP.md
How to install Composer globally using MAMP's PHP

##Create an alias to MAMP's PHP installation

To do this, we can simply create an alias for our bash profile. We'll be doing this is nano, though you can do it in vim or a number of other editors as well.

Within the terminal, run:

nano ~/.bash_profile

This will open nano with the contents, at the top in a blank line add the following line:

@handleman
handleman / Install-php-mysql-apache-on-osx-with-brew.md
Last active October 11, 2018 11:42 — forked from GabLeRoux/Install-php-mysql-apache-on-osx-with-brew.md
Detailed steps to install PHP, MySQL, Apache and some usefull extensions such as xDebug on a mac running Mac Os X. Also included: PostgreSQL.

Install PHP, MySQL, PostgreSQL, Apache and xDebug on a Mac

You should have some tools installed like Homebrew, a text editor such as Sublime Text and it's subl command line app inside a bin folder and some basic terminal knowledge.

This gist is a more detailed version of niepi's gist with things that worked for me. It may help someone :)

Install PHP

$ brew install php --with-apache --with-mysql --with-pgsql --with-intl