Skip to content

Instantly share code, notes, and snippets.

View eristoddle's full-sized avatar

Stephan Miller eristoddle

View GitHub Profile
@danioyuan
danioyuan / pre_render_d3_graph.js
Last active May 9, 2019 03:11
Render d3 force-directed graph on server side. Require Node.js, d3.js, and jsdom.
// Pre-render d3 force-directed graph at server side
// Call node pre_render_d3_graph.js to generate d3_graph.html
// Original idea and framework borrowed from https://gist.github.com/mef/7044786
var d3 = require('d3')
, jsdom = require('jsdom')
, fs = require('fs')
, htmlStub = '<html><head> \
<style>.node { stroke: #fff; fill: #ccc; stroke-width: 1.5px; } \
.link { stroke: #333; stroke-opacity: .5; stroke-width: 1.5px; }</style> \
@rzrbld
rzrbld / bash-artifactxml-gen.sh
Created March 20, 2014 21:09
wso2 studio developer artifact.xml generator
#!/bin/bash
# using: bash-artifactxml-gen.sh my.project.folder
#
ROOTFOLDER=$*
#set src dir
SRCDIR=$ROOTFOLDER'/src/';
#cd to src dir
cd $SRCDIR;
#start gen artifact.xml
echo '<?xml version="1.0" encoding="UTF-8"?><artifacts>';
@mef
mef / pre-render.js
Last active May 20, 2022 16:56
proof-of-concept pre-rendering d3.js svgs on the server using node.js and jsdom module.
// pre-render d3 charts at server side
var d3 = require('d3')
, jsdom = require('jsdom')
, fs = require('fs')
, htmlStub = '<html><head></head><body><div id="dataviz-container"></div><script src="js/d3.v3.min.js"></script></body></html>'
jsdom.env({
features : { QuerySelector : true }
, html : htmlStub
, done : function(errors, window) {
@fastmover
fastmover / countCSSRules.js
Last active October 12, 2015 00:08 — forked from psebborn/countCSSRules.js
Count the number of rules and selectors for CSS files on the page. Flags up the >4096 threshold that confuses IE
function countCSSRules() {
var results = '',
log = '',
totalCount = 0,
totalRules = 0,
fileCount = 0;
if (!document.styleSheets) {
return;
}
for (var i = 0; i < document.styleSheets.length; i++) {
@toomuchpete
toomuchpete / Form.php
Created April 3, 2012 16:36
Lithium Form Helper for Twitter Bootstrap
<?php
namespace app\extensions\helper;
class Form extends \lithium\template\helper\Form {
/**
* String templates used by this helper.
*
* @var array
@supasympa
supasympa / updateShareThisButtons.js
Created December 5, 2011 14:54
Some code to update ShareThis buttons with custom images - useful in SPAs or AJAX apps
function updateShareButtons(location, title, imgsrc) {
$('.share').hide();
$('.sharethis').html('');
var services = [
{type : 'facebook',
image : './css/img/social-facebook.png'},
{type : 'twitter',
image : './css/img/social-twitter.png'},
{type : 'email',
@rich97
rich97 / gist:1063377
Created July 4, 2011 14:14
Access control configuration.
<?php
use lithium\security\Auth;
use lithium\security\Password;
use li3_access\security\Access;
use li3_admin\models\Staffs;
Auth::config(array(
'root' => array(
'adapter' => 'Form', 'model' => 'Staffs', 'with' => 'Accounts',
@sym3tri
sym3tri / MongoDB update all matching.js
Created March 7, 2011 06:15
How to update a single field in a MongoDB collection for all documents matching a specific criteria
// FROM: http://www.mongodb.org/display/DOCS/Updating#Updating-update%28%29
//
// db.collection.update( criteria, objNew, upsert, multi )
// criteria - query which selects the record to update;
// objNew - updated object or $ operators (e.g., $inc) which manipulate the object
// upsert - if this should be an "upsert"; that is, if the record does not exist, insert it
// multi - if all documents matching criteria should be updated
//
// SQL VERSION:
// UPDATE myTable SET dateField = '2011-01-01' WHERE condField = 'condValue'
@acdha
acdha / helium-bookmarklet.js
Created January 15, 2010 15:06
Bookmarklet to load Helium without modifying the page
/*
Loads http://github.com/geuis/helium-css for testing without modifying the source pages
Crunched by http://ted.mielczarek.org/code/mozilla/bookmarklet.html to:
javascript:(function(){(function(msg,target){var loader=function(){if(arguments.callee._executed)return;arguments.callee._executed=true;if(typeof target==="function"){target();}else{jQuery.getScript(target);}var el=document.createElement('div');el.style.position='absolute';el.style.height='30px';el.style.width='200px';el.style.margin='0 auto 0 auto';el.style.top='0';el.style.left='40%';el.style.padding='5px 10px';el.style.backgroundColor='#F00';el.style.fontWeight="bold";el.style.textAlign="center";el.innerHTML=msg;document.body.appendChild(el);window.setTimeout(function(){jQuery(el).fadeOut('slow',function(){jQuery(this).remove();});},2500);};if(typeof jQuery!=='undefined'){loader();}else{var s=document.createElement('script');s.type="text/javascript";s.setAttribute('src',document.location.protocol+'//ajax.googleapis.com/ajax/libs