Skip to content

Instantly share code, notes, and snippets.

View ProLoser's full-sized avatar

Dean Sofer ProLoser

  • Playstation
  • San Francisco
View GitHub Profile
@ProLoser
ProLoser / Complexity.md
Last active January 17, 2018 00:45
Code Complexity

Code Complexity Anti-Patterns

This document is designed to illustrate different examples of code complexity I've encountered and potential solutions to combat it. Code complexity can keep changing through the lifecycle of code, but one of my primary goals I try to keep in mind above all else is refactorability. No matter what, code will eventually become dated and need refactoring. Documentation, organization, cleanliness, unit tests are all aspects that help contribute to refactorable code. While quick prototypes and one-time use codebases will typically not be as concerned with code quality and complexity, long-lasting applications and libraries should be mindful of some of these anti patterns and work to reduce them when possible.

All of these are my own opinion and should not be treated as rules, just as suggestions.

In alphabetical order:

@ProLoser
ProLoser / focusOn.js
Created November 24, 2015 01:19
Focuses on input/element
/**
* focusOn - Focuses an input on scope event
*
* @example
* <input focus-on="someEventName">
* or
* <input focus-on="focus-row-{{$index}}">
* or
* <p focus-on="anotherEvent"></p>
* ...
@ProLoser
ProLoser / .slate.js
Last active August 29, 2015 14:17
Slate Config
$ = (function() {
$ = function() {
var args = _.toArray(arguments);
var sequence = false;
var func;
if (args.length == 1 && _.isArray(args[0])) {
sequence = true;
} else {
func = args.shift();
}
@ProLoser
ProLoser / config.fish
Last active February 23, 2018 01:41
My OSX fish (oh-my-fish) shell configuration file
# Path to your oh-my-fish.
set fish_path $HOME/.oh-my-fish
# Theme
set fish_theme agnoster
# Which plugins would you like to load? (plugins can be found in ~/.oh-my-fish/plugins/*)
# Custom plugins may be added to ~/.oh-my-fish/custom/plugins/
# Path to your custom folder (default path is $FISH/custom)
@ProLoser
ProLoser / Recruiting.md
Last active April 4, 2017 19:14
Answers to common recruiting questions

Your Questions:

  • Updated Resume?
    PDF Resume
  • What is your availability?
    My Availability Calendar (use my email at the top for invites)
    I prefer scheduling meetings after 10am.
    Please try to avoid unsolicited / unscheduled phone calls.
  • Are you looking for a new job?
    Only in the Video Game industry.
  • What positions are you most interested in?
@ProLoser
ProLoser / bash.org.php
Created September 10, 2013 06:25
Bash.org scraper written in PHP
<?php
$con = mysqli_connect("localhost","root","","password");
if(isset($_GET['scan'])) {
for($i=$_GET['scan'];$i<$_GET['scan']+10;$i++){
$string = file_get_contents('http://bash.org/?browse&p='.$i);
preg_match_all('/<p class="quote"><a href="\?(\d+)".*?>\((-?\d+)\)<.*?<p class="qt">(.*?)<\/p>/si',$string,$matches);
echo '<br>Page '.$i.':';
for($j=0;$j<count($matches[0]);$j++){
@ProLoser
ProLoser / AngularJS-Cachebusting.js
Last active September 10, 2020 12:54
Elegant cache-busting for AngularJS HTML assets
anglar.module('myApp',['ui']).config(["$provide", function($provide) {
return $provide.decorator("$http", ["$delegate", function($delegate) {
var get = $delegate.get;
$delegate.get = function(url, config) {
// Check is to avoid breaking AngularUI ui-bootstrap-tpls.js: "template/accordion/accordion-group.html"
if (!~url.indexOf('template/')) {
// Append ?v=[cacheBustVersion] to url
url += (url.indexOf("?") === -1 ? "?" : "&");
url += "v=" + cacheBustVersion;
}
@ProLoser
ProLoser / $scope.$apply().js
Created July 19, 2013 17:19
AngularJS: When to use $scope.$apply()?
/*** BAD: ***
* Never put $scope.$apply() deep down a call stack
* You may end up calling the same method inside a
* $digest, and find yourself using $scope.$$phase
* or $timeout to hack around it.
*/
setTimeout(function(){
a();
})
elm.bind('click', function(){
@ProLoser
ProLoser / alerts.html
Last active October 9, 2019 18:38
AngularJS Bootstrap implemented without any additional code
<h1>Alert</h1>
<p>Bootstrap JS</p>
<div class="alert fade in">
<button type="button" class="close" data-dismiss="alert">×</button>
<strong>Holy guacamole!</strong> Best check yo self, you're not looking too good.
</div>
<p></p><a ng-click="alert=true">Open Alert (AngularJS)</a></p>
<div class="alert fade" ng-class="{in:alert}">
<button type="button" class="close" ng-click="alert=false">×</button>
@ProLoser
ProLoser / dabblet.css
Created March 15, 2012 00:19
Facebook Timeline in CSS
/**
* Facebook Timeline in CSS
*/
* {
box-sizing: border-box;
}
body {
background: #f06;
background: linear-gradient(45deg, #fff, #fff);
min-height:100%;