Skip to content

Instantly share code, notes, and snippets.

View greyaperez's full-sized avatar

Grey Perez greyaperez

View GitHub Profile
@greyaperez
greyaperez / AngularJS-Best-Practices.md
Last active May 2, 2018 14:31
Angular Best Practices

Angular Best Practices

by Tim A. Perez


Important Common Pitfalls to Avoid:

  • $watch, $watchCollection, etc – Avoid using any kind of watches in General. These can quickly and exponentially increase digest cycles and can be completely avoided with good usage of inheritance.
  • Event Driven Logic – this makes code extremely difficult to maintain/debug as it grows. This includes $broadcast, $emit, $on, etc…
describe('WidgetFactory', function () {
var Factory;
var $rootScope;
var $q;
var mockDI = {
index: [
'MyConstants',
'MyFactory',
@greyaperez
greyaperez / konami-code.js
Last active September 2, 2015 12:45
Konami Code
function konamiCode () {
var keys = [];
var valid = _.map("38384040373937396665".match(/.{1,2}/g), _.parseInt);
document.onkeydown = function (key) {
if (key > 10) {
document.onkeydown = null;
return;
}
keys.push(key.which);
@greyaperez
greyaperez / sort-algorithm-sandbox.js
Created July 27, 2015 07:09
Sort Algorithm Sandbox (js)
/**
* A Quick Set of Sort Algorithms Expirements
* @author Tim Perez <[email protected]>
*/
// Pre-cache Sample Sets
var sampleSet = [
[7,0,2,8,3,1,5,6,9,4], // Small Random Set
[9,8,7,6,5,4,3,2,1,0], // Reversed Small Set
shuffleArr(genSeqArr(1000)), // 1000 Random
function research-ui () {
local results=($(grep -Iir \
--include='*.ts' \
--include='*.less' \
--include='*.scss' \
--include='*.css' \
--include='*.js' \
--include='*.html' \
--include='*.json' \
--exclude-dir='node' \
@greyaperez
greyaperez / autoCSS.js
Created May 28, 2014 18:53
Auto Reload CSS
/*
* Usage (2 Choices):
* Option 1 - Auto Reload on Interval
* -- autoCSS.start()
*
* Option 2 - Reload on Demand
* -- autoCSS.init()
* -- autoCSS.refresh()
*/
var autoCSS = {
@greyaperez
greyaperez / restore_console.log.js
Created May 2, 2014 17:46
Restores console.log() if undefined or set to null.
// Restores Native console.log()
delete console.log
@greyaperez
greyaperez / get_time_ms.js
Created April 23, 2014 19:33
Prints Time including milliseconds
new Date / 1000
@greyaperez
greyaperez / exclude_filter.sh
Created April 14, 2014 20:45
Exclude Filter
function not(){
grep -v $1
}
#usage
find . -name something* | not somethingelse
# Just Change the port or hostname as needed
curl -IL http://localhost:8080