Skip to content

Instantly share code, notes, and snippets.

View jakebellacera's full-sized avatar

Jake Bellacera jakebellacera

View GitHub Profile
@jakebellacera
jakebellacera / sass_function_var.rb
Created March 14, 2014 04:52
Dynamically calls a SASS variable by a string (e.g. var("foo" + "bar") => $foobar).
# To use this in your SASS project, simply load this module into
# your environment.
module Sass::Script::Functions
# Dynamically calls a variable by a string
# e.g. var("foo" + "bar") => $foobar
def var(name)
assert_type name, :String, :name
@environment.var(name.value)
@jakebellacera
jakebellacera / css_time_to_milliseconds.js
Created February 27, 2014 22:45
CSS Time to Milliseconds - useful for timing functions around CSS animations
/*
* CSS Time to Milliseconds
* by Jake Bellacera (http://jakebellacera.com)
* ============================================
*
* Converts CSS time into milliseconds. Useful for timing functions around CSS animations.
* It supports both seconds (s) and milliseconds (ms).
*
* Arguments:
* time_string - string representation of a CSS time unit (e.g. "1500ms" or "1.5s")
@jakebellacera
jakebellacera / scripts_list.php
Last active January 21, 2016 00:40
Scripts List - PHP managed scripts list
<?php
// Default scripts
$script_list = array(
'vendor/jquery.js',
'vendor/bootstrap.js',
'vendor/video.js',
'`videojs.options.flash.swf = "' . get_bloginfo('stylesheet_directory') . '/assets/swf/videojs.swf"',
'global.js'
);
var appName = "yourAppName",
keywords = encodeURI("my search term"),
url = "http://svcs.ebay.com/services/search/FindingService/v1?OPERATION-NAME=findItemsByKeywords&SERVICE-VERSION=1.0.0&SECURITY-APPNAME=" + appName + "&RESPONSE-DATA-FORMAT=XML&REST-PAYLOAD&keywords=" + keywords;
$.get(url, function (response) {
console.log(response);
// response would be the parsed XML body.
// you could then work with this by treating it as an DOM
// node in jQuery. For example:
// response.find('elementName').html()
@jakebellacera
jakebellacera / vine.rb
Last active December 2, 2016 17:56
vine ruby api
require "httparty"
require "json"
module Vine
# Public: The unofficial interface for the Vine API. Vine requires all
# requests to be authenticated when accessing the API.
#
# Examples
#
# vine = Vine::API.new("username", "password")
@jakebellacera
jakebellacera / focus
Last active December 25, 2015 17:59
focus - blacklists certain websites
#!/bin/bash
################################################################################
# FOCUS
# =====
# Blacklists certain websites.
#
# How to use:
# 1. Edit the DOMAINS variable with the domains you'd like to blacklist
# 2. run `/path/to/focus start` to start focusing
@jakebellacera
jakebellacera / browserstack
Last active December 22, 2015 10:19
BrowserStack tunnel bash script
#!/bin/bash
# BrowserStack Tunnel bash script
# By: Jake Bellacera (http://jakebellacera.com)
#
# Usage:
# browserstack
# browserstack start [opts=localhost,80,0] # starts a tunnel
TUNNEL_KEY="abcdefg12345"
@jakebellacera
jakebellacera / sass_retinize.rb
Last active December 18, 2015 11:39
The non-clunky approach to supporting retina images in SASS.
module Sass::Script::Functions
# Appends "_2x" to the end of a filename before the extension
# e.g. foobar.jpg => foobar_2x.jpg
def retinize(string)
assert_type string, :String
Sass::Script::String.new string.value.gsub(/\.(\w+)$/, '_2x.\\1')
end
declare :retinize, :args => [:string]
@jakebellacera
jakebellacera / bike-shop.js
Last active December 18, 2015 01:09
BikeShop - simple AJAX template manager (with caching!) for Handlebars.js. http://jsfiddle.net/jakebellacera/89XER/
// BikeShop
//
// Simple asynchronous template management for Handlebars.js.
//
// By Jake Bellacera (http://jakebellacera.com)
//
// Usage:
// 1. Include Handlebars in your project.
// 2. Include BikeShop in you project.
// 4. Initialize a new BikeShop instance with the path to the templates dir as
@jakebellacera
jakebellacera / crossdomain.xml
Created May 6, 2013 17:00
crossdomain.xml example
<cross-domain-policy>
<allow-access-from domain="*" />
</cross-domain-policy>