Skip to content

Instantly share code, notes, and snippets.

View boneskull's full-sized avatar
💀

Christopher Hiller boneskull

💀
View GitHub Profile
@boneskull
boneskull / persistence.js
Created August 14, 2013 22:52
persistance: __type__ will match a factory
/*global angular*/
(function () {
'use strict';
angular.module('reportServices').service('Persistence', function ($injector) {
this.transform = function transform(data) {
try {
if (angular.isObject(data)) {
data = JSON.stringify(data);
@boneskull
boneskull / placeholder.js
Last active December 21, 2015 03:59
extremely simple placeholder directive for select boxes
/*global angular*/
(function () {
'use strict';
/**
* @ngdoc directive
* @name placeholder.directive:placeholder
* @todo FIX the example so the demo works. How? I don't know.
* @description
* Provides an empty placeholder for a SELECT tag. Should work with
@boneskull
boneskull / gist:6301500
Created August 21, 2013 23:28
example of controller mixin
schema.controller('ListMixinCtrl', function ($scope, config) {
$scope.noOfPages = Math.ceil(config.list.length / PAGE_LENGTH);
$scope.currentPage = $scope.currentPage || 1;
$scope.$watch('currentPage', function (page) {
if (config.list) {
$scope.begin = (page - 1) * PAGE_LENGTH;
$scope.end = $scope.begin + PAGE_LENGTH;
}
@boneskull
boneskull / ladda.js
Created August 27, 2013 06:11
ladda directives/services
/*global angular*/
(function () {
'use strict';
var ladda = angular.module('ladda', []);
/**
* @ngdoc directive
* @restrict A
* @author Dean Sofer
@boneskull
boneskull / ladda.spec.js
Created August 27, 2013 06:11
tests for ladda module
'use strict';
describe('Module: ladda', function () {
beforeEach(function () {
module('ladda');
});
describe('Directive: ladda', function () {
var markup = '<button ladda="foo"></button>',
@boneskull
boneskull / index.ejs
Created August 27, 2013 06:11
ladda button tpl
<script type="text/ng-template" id="ladda">
<button data-spinner-size="30" type="submit" class="btn ladda-button"
style="overflow: visible;" data-style="zoom-in"><span
class="ladda-label" ng-transclude></span></button>
</script>
/*global angular*/
(function () {
'use strict';
angular.module('ultron.common').filter('titleCase', function () {
return function titleCase(text) {
var words = text.split(' ');
var wordCount = words.length;
for (var i = 0; i < wordCount; i++) {
/*global angular*/
(function () {
'use strict';
/**
* Takes a promise, and if it is rejected, displays an ERROR in a popup!!
*
* attempt($http.post(url, data).then(function successCallback(promise) { .. },
* function failureCallback(promise) { .. }));
*
@boneskull
boneskull / select2.js
Created December 29, 2013 01:11
select2 with some ngOptions support
/**
* Enhanced Select2 Dropmenus
*
* @AJAX Mode - When in this mode, your value will be an object (or array of objects) of the data used by Select2
* This change is so that you do not have to do an additional query yourself on top of Select2's own query
* @params [options] {object} The configuration options passed to $.fn.select2(). Refer to the documentation
*/
/* global angular */
angular.module('ui.select2', []).value('uiSelect2Config', {}).directive('uiSelect2', ['uiSelect2Config', '$timeout', '$parse', function (uiSelect2Config, $timeout, $parse) {
var options = {},
@boneskull
boneskull / uninstall_vmware.sh
Created January 14, 2014 04:46
completely uninstall vmware on mac
#!/usr/bin/env bash
# Usage: bash uninstall_vmware.bash
remove() {
entry="$1"
echo -ne "Removing \e[1;34m$entry\e[0m... "
sudo rm -rf "$entry" &> /tmp/uninstall-vmware.log
if [[ ! -e "$entry" ]]; then
echo -e "\e[1;32mOK\e[0m"