Skip to content

Instantly share code, notes, and snippets.

View ZackMattor's full-sized avatar

Zachary Mattor ZackMattor

View GitHub Profile
@ZackMattor
ZackMattor / gist:b1f3f00b7b01dc9dfe4d2bd7dfdd0b06
Created December 6, 2016 17:56
Story of locking myself out
"So I was locked in out my PJs, no phone, keys, wallet, nothing... Luckily i had a light jacket on. My neighbors weren't home... and even if I could get online there isn't a company that manages my building it's just a dude who owns it. I couldn't log into Gmail to get my contacts because i have 2fa setup and my phone is in my apartment. It was a pretty great feeling. I just kinda walked around my place checking windows. Probably looked sketchy as shit. I decided to take the 1.5 mile walk downtown to find internet or somethign so I could google my landlords name or some shit. On my walk I passed 2 people who I asked if i could use their phone, one person laughed and said they only had a flip phone, the other turned out to be some insane lady and she legit barked at me. So i get downtown, go up to the office and no-one is here yet so the door is locked. I wait 20 minutes and noone shows up... I decide to walk down to this cafe where I know the owner. Lukily she is here and lets me use their POS system to googl
defmodule FacePP do
use HTTPoison.Base
@expected_fields ~w(
api_key api_secret url mode attribute tag async
)
def process_url(url) do
"https://apius.faceplusplus.com" <> url
end
var Apple = function(selector, type) {
this.selector = selector;
this.type = type;
$(selector).click(this.onAppleClick.bind(this));
};
Apple.prototype = {
onAppleClick: function(evt) {
$apple = $(evt.currentTarget);
@ZackMattor
ZackMattor / jquery-spy.js
Created July 7, 2016 20:34
A way to track how many times a selector has been manipulated with jQuery commands.
var jquerySpy = {
analytics: {},
reset: function() {
this.analytics = {};
},
install: function(base) {
spyOn((base || window), '$').and.callFake(function(selector) {
var jquery_proxy = $(selector);
@ZackMattor
ZackMattor / jquery_mock.js
Created July 7, 2016 19:57
jquery jasmine analytics
var analytics = {};
spyOn(instance, '$').and.callFake(function(selector) {
var jquery_proxy = $(selector);
['show', 'hide', 'scrollTop'].forEach(function(method) {
jquery_proxy[method] = jasmine.createSpy().and.callFake(function() {
analytics[selector] = analytics[selector] || {};
if(typeof analytics[selector][method] === 'undefined') analytics[selector][method] = 0;
@ZackMattor
ZackMattor / component-test.js
Created July 7, 2016 14:42
meta bind checking test
describe('init', function() {
[ // array of classes and methods to be called
['.item', 'onItemSelect'],
['.search', 'search'],
['.input', 'inputClicked'],
['.clear-item', 'clearItem']
].forEach(function(item) {
it('binds ' + item[0] + ' click to the correct method', function() {
ComponentEngine.process();
@ZackMattor
ZackMattor / renderProgress.js
Created June 8, 2016 19:09
Renders a circular progress bar
renderProgress: function(percent) {
var rads = percent* 3.6 * Math.PI/180;
var $canvas = this.$('canvas');
var canvas = this.$('canvas')[0];
var offset = 5;
canvas.height = this.$().height() + offset*2;
canvas.width = this.$().width() + offset*2;
for($i=0; $i<count($json->Search); $i++) {
$search = $json->Search[$i];
$link = $json->{(string)$i};
}
// OR
foreach($json->Search as $key=>$search) {
$link = $json->{(string)$key};
}
module ComponentHelper
def render_component(name, data={})
erb_string = FileCache.read(Rails.root.join('app', 'components', name, "template.html.erb"))
view_context = ApplicationController.new.view_context
data.each do |key, value|
view_context.instance_variable_set("@#{key}".to_sym, value)
end
;(function($, Pusher) {
/* Resets all callbacks */
Pusher.prototype.reset = function() {
$.each(this.channels.channels, function(name, channel) {
channel.callbacks._callbacks = {}
})
}
$(document).on('pjax:send', function() {
$.each(Pusher.instances, function(index, instance) {