Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am tlack on github.
  • I am tlack (https://keybase.io/tlack) on keybase.
  • I have a public key ASAfzQXduVcmaqcGmj495IpYs0u8ynUslUtUcEneasSOPQo

To claim this, I am signing this object:

@tlack
tlack / custom-routes-with-react-page-example.md
Last active September 15, 2016 08:51
How to use custom routes with react-page and react-page-middleware

Note: This article was written December 24 2013, when react-page's version number is 0.2.0. This is all likely to change, so if the advice mentioned doesn't help, please reach out to the React community.

How to use custom URLs with the React-page router

Note: Technically, this functionality is provided by react-page-middleware. I'm going to refer to it generally as react-page, because I don't think they have enough of an independent identity (and usefulness outside of the whole react-page stack) to nitpick the naming.

react-page [https://github.com/facebook/react-page] is a cool new tool to link your ReactJS scripts in to your Node server config so that the entire site can be server rendered.

Unfortunately, it doesn't support custom routes - http://site.co/widget will always look for src/widget/index.js (or whatever your root elem is), even if you want http://site.co/widgets/new to go there instead.

@tlack
tlack / tumblr-better-author-bios.md
Last active December 24, 2015 00:59
Javascript hack to improve Tumblr's lame byline options for group blogs

Tumblr's group blog features do not support per-author homepage links (such as Twitter) or bios. That sucks.

I've written here a Javascript function that kinda outputs something like what you may want. It maintains all the author data inside Javascript as well, for better or for worse. Eventually I'll make this pull from tags I guess.

Put this toward the top of your theme HTML, inside the script tag:

            var AUTHORS = {
                'caropopco': {
                    name: 'Carolina',
@tlack
tlack / gist:5094559
Created March 5, 2013 21:42
example of proxying https -> http
location / { # ~ domain=(.*)& {
rewrite_log on;
if ( $arg_callback ) {
echo_before_body '$arg_callback(';
echo_after_body ');';
}
if ($args ~ "domain=(.*)&") {
set $key1 $1;
echo_before_body "$arg_callback(";
# proxy_pass http://whois.api.go.co/blah=$key1;
@tlack
tlack / gist:4576631
Last active December 11, 2015 08:58
Idea for CodePen plugins
Idea for CodePen plugins (by @tlack)
Step 1: Establish simple plugin architecture/API
```javascript
CP.Plugins.add({
context: CP.Html,
re: /fun ([a-z_][a-z0-9_]+)/,
callback: function(cpPluginContext, match) {
var str = "function "+match.$1+"() {\n// Comment\n\n}\n";
@tlack
tlack / snapchat-secret-key.txt
Created December 31, 2012 10:22
snapchat secret key
iEk21fuwZApXlz93750dmW22pw389dPwOk1356949137
@tlack
tlack / jquery-ui-1.8.23-orig.js
Created September 18, 2012 20:30
possible bug in jquery ui's slider class and closestHandle? Cannot call method 'addClass' of undefined
_mouseCapture: function( event ) {
var o = this.options,
position,
normValue,
distance,
closestHandle,
self,
index,
allowed,
offset,
@tlack
tlack / p01-matraka-explained.js
Created July 3, 2012 11:41
p01's Matraka javascript demo decoded
// Matraka's source code decoded and beautified
// by @tlack
//
// Matraka is a 1005 byte Javascript "demo" by p01. It includes an 'evolving animation'
// and great dirty synth music. View here:
//
// http://www.p01.org/releases/MATRAKA/matraka.png.html
//
// I fondly recall the demo scene of my youth, puzzling over the work of Future
// Creators and those guys. I was puzzled by this worked so I had to figure it
@tlack
tlack / gist:2425247
Created April 20, 2012 01:47
example of node.js + handlebars
var h = require('handlebars');
var tmpl = h.compile("<p>{{name}}</p>");
var data = {name:"tlack"};
console.log(tmpl(data));
@tlack
tlack / gist:2387185
Created April 14, 2012 19:19
express.js / node.js get remote IP address
exports.req_ip = function(req) {
return ( req.headers["X-Forwarded-For"]
|| req.headers["x-forwarded-for"]
|| req.client.remoteAddress );
}