Skip to content

Instantly share code, notes, and snippets.

@FranciscoG
FranciscoG / tinyRouter.js
Last active August 29, 2015 13:56
A super tiny router. Don't even know if you can call this a router, it's more of an module organizer thingy.
/*
* tinyRouter.js
*
* Super simple JS router class, like super super simple
* doesn't use any regex to match url pathnames or hashes
* just takes a route name, looks for that function that matches it and runs it
* this is really only useful in small projects where you have a few pages and not a ton of JS
* but enough so where you still want to keep things organized
*
* there is one reserved route name
@FranciscoG
FranciscoG / html5tmpl.js
Last active August 29, 2015 13:57
Mini library wrapping HTML5 <template> to make it work sort of like current templating libraries but with less features (for now)
/**
* mini templating library using native html5 templating
* important to note: since html5 templating is basically a wrapper over documentFragment you need to have content nested 1 level deep.
* You can't grab innerHTML of the documentFragment itself, but you can for its children.
* @param {string} id id attribute of the template tag
* @param {object} tmplData data to be added to the template
*
*/
var html5tmpl = (function(id, tmplData) {
@FranciscoG
FranciscoG / maximize.scpt
Created May 5, 2014 14:49
Applescript snippet to maximize current window. Use with Alfred for shortcut keys
-- source http://apple.stackexchange.com/questions/98187/applescript-the-activate-command-makes-application-half-active
-- tested on Mavericks, needs a Security & Privacy -> Accessibility feature turned on.
tell application "System Events" to tell (process 1 where frontmost is true)
click (button 1 where subrole is "AXZoomButton") of window 1
end tell
activate application (path to frontmost application as text)
@FranciscoG
FranciscoG / oocss.css
Last active August 29, 2015 14:02
some helpful css that I keep forgetting and looking up so I'm finally saving it here
/*
sources:
http://www.stubbornella.org/content/2010/06/25/the-media-object-saves-hundreds-of-lines-of-code/
http://jsfiddle.net/necolas/rZvEF/
*/
/* ----- REUSABLE IMG BLOCK ----- */
.imgblock {
// source: https://gist.github.com/adunkman/2580972
// background transparency
background-transparency(hexColor, alpha = 1)
ms-color = argb(hexColor, alpha)
background hexToRgb(hexColor)
background rgba(hexColor, alpha)
.mod-no-rgba &
*zoom 1
background transparent
@FranciscoG
FranciscoG / color.js
Created July 28, 2014 17:41
Stylus extension to support full 6 digit hex colors when needed
/*
* Extend Stylus to allow use of 6 digit hex color
* modified from this StackOverflow answer
* http://stackoverflow.com/a/9378924/395414
*/
module.exports = function() {
var hex = function(n) {
return n.toString(16)
};
@FranciscoG
FranciscoG / server.js
Created August 28, 2014 04:22
simple node server to work on static simple pages
var http = require("http"),
url = require("url"),
path = require("path"),
fs = require("fs"),
port = process.argv[2] || 8888;
http.createServer(function(request, response) {
var uri = url.parse(request.url).pathname,
filename = path.join(process.cwd(), uri);
@FranciscoG
FranciscoG / hhehehe.css
Last active August 29, 2015 14:06
styles for the header in the subreddit r/hhehehe
body{background-color:#96806B;color:black}
#siteTable > div{background-color:white;}
#siteTable{background-color:white;padding:10px;border-radius:10px;border:2px solid rgba(0,0,0,0.5);margin-top:10px;}
#header{background-color:#96806B;margin:10px;}
.side{background-color:white;border: 2px solid rgba(0,0,0,0.5);border-radius:10px;padding:10px;}
#sr-header-area{background-color:#96806B;}
#header-bottom-right{background-color:#96806B;color:black;margin-top:4px;}
#header{border:2px solid rgba(0,0,0,0.5);border-radius:10px;}
#RESShortcutsEditContainer{display:none}
.content{margin:10px;}
/**
* A snippet I created to screen capture full webpages
* relies on html2canvas: http://html2canvas.hertzen.com/
* and also requires local proxy for images embedded from other sites: https://github.com/niklasvh/html2canvas/wiki/Proxies
*
* In this gist I'm using the node.js version of the proxy: https://github.com/BugHerd/html2canvas-proxy-node
*
* Issues:
*
* For longer/larger pages I had an issue where the chrome tab would crash if I used PNG or JPEG, but WEBP seems
@FranciscoG
FranciscoG / csv_upload.php
Last active August 29, 2015 14:07
Just a simple file I created to upload and parse a CSV and insert that data into a MySQL db. mysql_* functions are deprecated, should use mysqli_* instead
<?php
error_reporting(E_ALL);
ini_set('display_errors', 'on');
class DbClass
{
// MAMP default credentials for testing. These are not actually real creds that mean anything
private $db_url = 'localhost';
private $db_login = 'root';
private $db_pw = 'root';