Skip to content

Instantly share code, notes, and snippets.

@bhurlow
bhurlow / gist:3861616
Created October 9, 2012 21:36
Better XML to JSON parsing for cdata
// Changes XML to JSON
// fixed some bugs from http://davidwalsh.name/convert-xml-json
// October 9, 2012
// Brian Hurlow
function xmlToJson(xml) {
// Create the return object
var obj = {};
// console.log(xml.nodeType, xml.nodeName );
@steveosoule
steveosoule / javascript-dynamically-fit-text-in-div.html
Created November 14, 2012 18:22
JavaScript Dynmaically Fit Text in Div
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<script src="http://code.jquery.com/jquery.min.js"></script>
<script>
;(function($) {
$.fn.textfill = function(options) {
var fontSize = options.maxFontPixels;
@christophergregory
christophergregory / gist:4195957
Created December 3, 2012 16:05
Shopify:Remove old attributes from the cart
function getCartData(callback) {
Shopify.getCart(function(cart){
callback(cart);
});
}
function updateCartAttributes(data, callback) {
var params = {
type: 'POST',
url: '/cart/update.js',
@inadarei
inadarei / base64.js
Created January 6, 2013 04:11
base64 encode/decode in Node.js
var url = "http://cdn1.giltcdn.com/images/share/uploads/0000/0001/7250/172502872/420x560.jpg";
var encoded = new Buffer(url).toString('base64');
var decoded = new Buffer(encoded, 'base64').toString('ascii')
console.log(encoded);
console.log(decoded);
@caged
caged / svg-to-png.js
Created January 27, 2013 18:11
Convert SVG's to PNGs. This works OK if the SVG's styles are inline. The SVG element must contain an xmlns attribute. Webkit also requires you specify a font size on `text` elements.
var svg = document.getElementById('graph'),
xml = new XMLSerializer().serializeToString(svg),
data = "data:image/svg+xml;base64," + btoa(xml),
img = new Image()
img.setAttribute('src', data)
document.body.appendChild(img)
@blitline-dev
blitline-dev / complexx_css_text_with_image_overlay.json
Last active December 14, 2016 17:29
Complex CSS text with image overlay
{
"application_id":"YOUR_APP_ID",
"src":"https://s3.amazonaws.com/img.blitline/Boston+City+Flow.jpg",
"pre_process":[
{
"job":{
"src":"https://s3.amazonaws.com/web.blitline/css_text.html",
"src_type":"screen_shot_url",
"src_data" : {"delay" : 0},
"functions":[
@dypsilon
dypsilon / frontendDevlopmentBookmarks.md
Last active May 5, 2025 13:05
A badass list of frontend development resources I collected over time.
@blitline-dev
blitline-dev / complicated_multi_step_preprocess
Created July 15, 2013 14:30
Complicated multi-step pre-processing
{
"application_id": "YOUR_APP_ID",
"pre_process": [
{
"job": {
"pre_process": [
{
"job": {
"pre_process": [
{
@msievers
msievers / ungroup_grouped_objects_in_fabricjs.js
Last active October 14, 2022 12:46
Ungroup programatically grouped objects in fabric.js (simply past this code into the "execute" tab of fabricjs kitchensink demo)
// clear canvas
canvas.clear();
// add red rectangl
canvas.add(new fabric.Rect({
width: 50, height: 50, left: 50, top: 50, fill: 'rgb(255,0,0)'
}));
canvas.add(new fabric.Rect({
width: 50, height: 50, left: 110, top: 50, fill: 'rgb(255,0,0)'
{
"application_id":"YOUR_APP_ID",
"src":"http://cdn.blitline.com/filters/boys.jpeg",
"functions":[
{
"name":"convert_command",
"params":{
"-function":"polynomial 3.5,-5.05,2.05,0.3",
"-channel":"R"
},