Skip to content

Instantly share code, notes, and snippets.

View serweb-labs's full-sized avatar

Luciano Rodríguez serweb-labs

View GitHub Profile
@kentcdodds
kentcdodds / get-watchers.js
Last active December 4, 2023 22:34
Get Watchers of element and its children
function getWatchers(root) {
root = angular.element(root || document.documentElement);
var watcherCount = 0;
function getElemWatchers(element) {
var isolateWatchers = getWatchersFromScope(element.data().$isolateScope);
var scopeWatchers = getWatchersFromScope(element.data().$scope);
var watchers = scopeWatchers.concat(isolateWatchers);
angular.forEach(element.children(), function (childElement) {
watchers = watchers.concat(getElemWatchers(angular.element(childElement)));
@bennadel
bennadel / eval-async.htm
Created April 9, 2014 11:41
$scope.$evalAsync() vs. $timeout() In AngularJS
<!doctype html>
<html ng-app="Demo">
<head>
<meta charset="utf-8" />
<title>
$scope.$evalAsync() vs. $timeout() In AngularJS
</title>
</head>
<body>
@demisx
demisx / angularjs-providers-explained.md
Last active December 26, 2024 05:39
AngularJS Providers: Constant/Value/Service/Factory/Decorator/Provider
Provider Singleton Instantiable Configurable
Constant Yes No No
Value Yes No No
Service Yes No No
Factory Yes Yes No
Decorator Yes No? No
Provider Yes Yes Yes

Constant

@danburzo
danburzo / README.md
Last active July 29, 2021 08:41
Get all event listeners on the page in Google Chrome
@amatiasq
amatiasq / new.js
Created December 10, 2013 15:45
A simple .new() method to create instances without constructors. This allow us to rewrite the "new" in order to do other things but create objects.
function $new() {
var obj = Object.create(this);
obj.init.apply(obj, arguments);
return obj;
}
@xeoncross
xeoncross / ajax.js
Last active August 3, 2023 06:06
Simple, cross-browser Javascript POST/GET xhr request object. Supports request data and proper AJAX headers.
/**
* IE 5.5+, Firefox, Opera, Chrome, Safari XHR object
*
* @param string url
* @param object callback
* @param mixed data
* @param null x
*/
function ajax(url, callback, data, x) {
try {
@scribu
scribu / test.php
Created February 8, 2013 03:12
Simulate threads in PHP using only proc_open() and co.
<?php
include __DIR__ . '/threads.php';
$commands = array();
for ( $i=0; $i<10; $i++ ) {
$commands[] = "bash -c 'sleep `shuf -i 1-5 -n 1`; echo $i'";
}
@KartikTalwar
KartikTalwar / Documentation.md
Last active February 28, 2025 10:57
Rsync over SSH - (40MB/s over 1GB NICs)

The fastest remote directory rsync over ssh archival I can muster (40MB/s over 1gb NICs)

This creates an archive that does the following:

rsync (Everyone seems to like -z, but it is much slower for me)

  • a: archive mode - rescursive, preserves owner, preserves permissions, preserves modification times, preserves group, copies symlinks as symlinks, preserves device files.
  • H: preserves hard-links
  • A: preserves ACLs
@pwenzel
pwenzel / perpetual-rsync.sh
Created December 1, 2012 15:15
Automatically resume rsync over SSH after broken connection
#!/bin/bash
while [ 1 ]
do
rsync -avz --partial source dest
if [ "$?" = "0" ] ; then
echo "rsync completed normally"
exit
else
echo "Rsync failure. Backing off and retrying..."
@edwerner
edwerner / Vector2.js
Last active March 26, 2019 16:34
Base Vector2 JavaScript math helper class serves methods to perform operations on object values within Cartesian coordinate systems.
var Vector2 = function () {
this._x = 0;
this._y = 0;
this.DEGRAD = 0;
};
Vector2.prototype.initialize = function (x, y) {
_x = x;
_y = y;
};