Skip to content

Instantly share code, notes, and snippets.

View tilmanschweitzer's full-sized avatar

Tilman Schweitzer tilmanschweitzer

View GitHub Profile
@tilmanschweitzer
tilmanschweitzer / date
Created September 10, 2014 21:20
Date Variable (sh)
DATE=$(date +"%Y-%m-%d--%H-%M-%S")
// load the $http module
var $http = angular.injector(["ng"]).get("$http");
$http.
while [[ ! $RELATIVE_PATH_CHECKED =~ ^[Yy]$ ]]
do
read -p "Is the relative path to the dev folder '${RELATIVE_PATH}' correct? [y/n] " -n 1 -r RELATIVE_PATH_CHECKED
echo ""
if [[ $RELATIVE_PATH_CHECKED =~ ^[Nn]$ ]]
then
read -p "Type in the correct path: " -r RELATIVE_PATH
fi
done
var scopeElements = Array.prototype.slice.apply(document.querySelectorAll(".ng-scope"));
var scopes = scopeElements.map(function (element) {
return angular.element(element).scope();
});
var scopeIds = scopes.map(function(scope) {
return scope.$id;
});
var uniqueScopeIds = scopeIds.filter(function(scopeId, index){
return scopeIds.indexOf(scopeId) === index;
});
@tilmanschweitzer
tilmanschweitzer / gist:d5985da95e2df27440dd
Last active August 29, 2015 14:07
intercept scope prototype 1.0.x
function interceptFunction (object, fnName, options) {
var noop = function () {};
var fnToWrap = object[fnName];
var before = options.before || noop;
var after = options.after || noop;
object[fnName] = function () {
before.apply(this, arguments);
var result = fnToWrap.apply(this, arguments);
after.apply(this, arguments);
@tilmanschweitzer
tilmanschweitzer / gist:1bad4f98c0c986fa78e1
Last active August 29, 2015 14:25
angular - analyse scopes and watchers
function analyseScopeAndWatchers() {
// fetch all elements with ng-scope class
var scopeElements = Array.prototype.slice.apply(document.querySelectorAll(".ng-scope"));
// map elements to scopes
var scopes = scopeElements.map(function (element) {
return angular.element(element).scope();
});
// filter duplicated scopes created by ng-view
@tilmanschweitzer
tilmanschweitzer / cdalias
Created November 10, 2011 13:34
Makes an alias for cd'ing to the current directory.
#!/bin/sh
###
# cdalias
###
# Makes an alias for cd'ing to the current directory.
#!/bin/bash
#
# Bash script to setup headless Selenium (uses Xvfb and Chrome)
# (Tested on Ubuntu 12.04) trying on ubuntu server 14.04
# Add Google Chrome's repo to sources.list
sudo add-apt-repository ppa:chromium-daily/stable
sudo apt-get update
#echo "deb http://dl.google.com/linux/chrome/deb/ stable main" | sudo tee -a /etc/apt/sources.list
COMPONENT_NAME=timepicker
GREP_E_MATCHER="(timepicker|other_string)"
TMP_BRANCH=$COMPONENT_NAME-tmp
git checkout -b $TMP_BRANCH
git filter-branch -f --prune-empty --index-filter 'git ls-files | grep -v -E "$GREP_E_MATCHER" | xargs git rm --cached --ignore-unmatch --quiet' HEAD
git checkout --orphan $COMPONENT_NAME
function interceptFunction (object, fnName, options) {
var noop = function () {};
var fnToWrap = object[fnName];
var before = options.before || noop;
var after = options.after || noop;
object[fnName] = function () {
before.apply(this, arguments);
var result = fnToWrap.apply(this, arguments);
after.apply(this, arguments);