Skip to content

Instantly share code, notes, and snippets.

View saarmstrong's full-sized avatar

Andy Armstrong saarmstrong

View GitHub Profile
{
"social": {
"title": "Social Networks",
"subtitle": "Lorem ipsum dorem.",
"active": true,
"services": {
"twitter": {
"fields": [
{
"name": "username"
@saarmstrong
saarmstrong / pre-commit
Last active August 29, 2015 14:24 — forked from timsweb/pre-commit
#!/bin/sh
if git-rev-parse --verify HEAD >/dev/null 2>&1; then
against=HEAD
else
against=4b825dc642cb6eb9a060e54bf8d69288fbee4904
fi
for FILE in `git diff --cached --name-only` ; do
# Check if the file contains 'debugger'
<link rel="import" href="../components/polymer/polymer.html">
<polymer-element name="my-element" attributes="elements">
<template>
<style>
#core_menu {
font-size: 16px;
left: 110px;
top: 40px;
@saarmstrong
saarmstrong / jquery.getselector.js
Last active August 29, 2015 14:04
jQuery getSelector Plugin: returns current element's selector string
(function($){
$.fn.getSelector = function() {
element = this[0];
var str = '';
while(element && element.nodeType == 1) {
var id = $(element.parentNode).children(element.tagName).index(element) + 1;
id > 1 ? (id = ':nth-child(' + id + ')') : (id = '');
if(str.length > 0) {
str = ' > ' + str;
}
@saarmstrong
saarmstrong / jquery.getselector.js
Last active July 24, 2019 04:46
jQuery getSelector plugin: return jQuery selector string from a provided jQuery object.
/*
* jquery.getselector.js
*
* Get the CSS Selector string for a provided jQuery object.
*
* Based heavily on jquery-getpath (http://davecardwell.co.uk/javascript/jquery/plugins/jquery-getpath/),
* and this xPath SO answer (http://stackoverflow.com/a/3454579).
*
* Usage: var select = $('#foo').getSelector();
*/
<link rel="import" href="../core-icon-button/core-icon-button.html">
<link rel="import" href="../core-toolbar/core-toolbar.html">
<link rel="import" href="../core-menu/core-submenu.html">
<link rel="import" href="../core-item/core-item.html">
<polymer-element name="my-element">
<template>
<style>
:host {
@saarmstrong
saarmstrong / test.json
Last active August 29, 2015 14:02
test json file
{
"foo": "bar",
"baz": [
1,
3,
5,
7
]
}
@saarmstrong
saarmstrong / clicktoedit.js
Created October 22, 2013 17:20
example of click to edit directive module
var cms = angular.module('cms', []);
cms.directive("clickToEdit", function() {
var editorTemplate = $j('#editTemplate').html();
return {
restrict: "A",
replace: true,
template: editorTemplate,
scope: {
value: "=clickToEdit",
idx: '@'
@saarmstrong
saarmstrong / script.js
Created October 19, 2013 19:51
Example of a Cross Domain Angular GET request
var myApp = angular.module('angularAppApp', ['$httpProvider'])
.config(function ($httpProvider) {
$httpProvider.defaults.useXDomain = true;
delete $httpProvider.defaults.headers.common['X-Requested-With'];
});
function FetchCtrl($scope, $http, $templateCache) {
$scope.method = 'GET';
$scope.url = 'http://echo.jsontest.com/key/value/one/two';