Skip to content

Instantly share code, notes, and snippets.

View etuchscherer's full-sized avatar

Eric Tuchscherer etuchscherer

  • Classmates
  • Seattle, WA
View GitHub Profile
@etuchscherer
etuchscherer / main.js
Created February 28, 2014 03:37
Protecting against console is not defined
/**
* Protect window.console method calls, e.g. console is not defined on IE
* unless dev tools are open, and IE doesn't define console.debug
*/
(function() {
if (!window.console) {
window.console = {};
}
// union of Chrome, FF, IE, and Safari console methods
var m = [
@etuchscherer
etuchscherer / bootstrap.php
Created February 28, 2014 04:08
requiring autoloader.php
<?php
/**
* Loading this way throws an error when pointing to the wrong dir.
* It also makes it super simple to debug, via the $loader var.
*/
if (($loader = require_once __DIR__ . '/../vendor/autoload.php') == null) {
die('Vendor directory not found, Please run composer install.');
}
@etuchscherer
etuchscherer / miner.sh
Created March 7, 2014 00:20
Script that can be used for mining test user info via Graph Api.
#!/bin/bash
# Mine the Facebook Graph API for data.
# //////////////////////////////////////////////////
# ////////////// Options //////////////////////////
# //////////////////////////////////////////////////
#
# -i Input file. Must contain a list of ids,
# separated by line.
@etuchscherer
etuchscherer / go.rb
Created March 24, 2014 20:41
Script for mass uploading images to Facebook test users profiles.
# This script gets test users' access tokens, and
# uploads public images to those accounts
# At the time of this writing, it takes an input file ( of facebook UIDs )
# an queries an external JSON file for those users ( filtering ). The remaining
# filtered users will have images uploaded to their profiles, via the graph
# api.
require "json";
@etuchscherer
etuchscherer / scrape.sh
Created March 24, 2014 20:48
Use to quickly scrape a list of images
#!/bin/bash
# Useage
# ./scrape list
#
# list must be a plain text file, containing
# image urls, separated by line.
#
# Example:
# http://www.example.com/foo.jpg
@etuchscherer
etuchscherer / gist:11379505
Created April 28, 2014 18:05
Get JavaScript Parameters by name
function getParameterByName(name) {
name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
results = regex.exec(location.search);
return results == null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
}
/**
* Protect window.console method calls, e.g. console is not defined on IE
* unless dev tools are open, and IE doesn't define console.debug
*/
(function() {
if (!window.console) {
window.console = {};
}
// union of Chrome, FF, IE, and Safari console methods
var m = [
import Ember from 'ember';
export default Ember.Component.extend({
tagName: 'ul',
didReceiveAttrs() {
if (this.get('limit')) {
this.set('list.length', this.get('limit'));
}
}
});
import Ember from 'ember';
export default Ember.Controller.extend({
val1: 1,
val2: 2,
comparison: Ember.computed.equal('val1', 'val2'),
actions: {
click() {
this.set('val1', 2);
}
@etuchscherer
etuchscherer / components.my-component.js
Last active June 9, 2016 16:19
didUpdateAttrs hook
import Ember from 'ember';
export default Ember.Component.extend({
didUpdateAttrs(options) {
console.log('I updated a value', options);
}
});