Skip to content

Instantly share code, notes, and snippets.


Dylan Jhaveri dylanjha

  • Mux
  • San Francisco
View GitHub Profile
dylanjha / script.js
Created Jul 16, 2013
a little javascript flash message. see demo at:
View script.js
<div id='nav'>
<ul class='nav-list'>
<li class='nav-item'><a href="javascript://">Home</a></li>
<li class='nav-item'><a href="javascript://">There</a></li>
<div id='flash-container' class='flash-container'>
<div id='content'>
Here is some content.
dylanjha / gatsby-config.js
Last active Jan 12, 2021 — forked from ajmalafif/gatsby-config.js
single rss.xml from 2 sources (MDX &
View gatsby-config.js
// Load variables from `.env` as soon as possible
path: `.env.${process.env.NODE_ENV || 'development'}`
const clientConfig = require('./client-config')
const isProd = process.env.NODE_ENV === 'production'
// Portable Text Serialization
const PortableText = require("@sanity/block-content-to-html")
dylanjha / 0. sprockets_depend_on_config.rb
Last active May 11, 2020
Adds Sprockets Directive `depend_on_config`. I'm using this to load .yml locale translations on the server into the client in json
View 0. sprockets_depend_on_config.rb
//= depend_on_config 'locales/es.yml'

Keybase proof

I hereby claim:

  • I am dylanjha on github.
  • I am dylanj ( on keybase.
  • I have a public key ASCL1W5WGRpMp0XKfIrTOB6SUQYlzB35MH3D6zVR5tLbmAo

To claim this, I am signing this object:

dylanjha / test.html.erb
Created Mar 22, 2015
Rake task to load erb
View test.html.erb
<%# Put this file in app/views/test.html.erb %>
<h1>Here is some html</h2>
<%= name %>
dylanjha / airports.json
Created Dec 26, 2018 — forked from tdreyno/airports.json
JSON data for airports and their locations
View airports.json
This file has been truncated, but you can view the full file.
"code": "AAA",
"lat": "-17.3595",
"lon": "-145.494",
"name": "Anaa Airport",
"city": "Anaa",
"state": "Tuamotu-Gambier",
"country": "French Polynesia",

Inconsistent uri encoding with parenthesis. Notice in the first 3 examples the parenthesis are still there, in the fourth example the parenthesis are replaced with %28 and %29:

This is the string being encoded in each example: string with (parens)


Javascript (node 6.9.0):

encodeURI(" string with (parens)")
View font-resize.js
// an element with class 'font_resize' with css properties:
// * max-height
// * max-width
// * font-size
// the element has children span elements, the font size inside these spans will re resized.
$.fn.fontResize = function(options){
var spans = $('span:visible', this);
var heightMax = parseInt($(this).css('max-height'), 10),
View setup.js
const execa = require('execa')
const Listr = require('listr')
const PROD_APP_NAME = '<replace with: heroku name of prod app>'
const STAGING_APP_NAME = '<replace with: heroku name of staging app>'
const tasks = new Listr([
title: 'setup git remote - staging',
task: () =>
dylanjha / crypto-pbkdf2-example.js
Created Nov 15, 2017 — forked from skeggse/crypto-pbkdf2-example.js
Example of using crypto.pbkdf2 to hash and verify passwords asynchronously, while storing the hash and salt in a single combined buffer along with the original hash settings
View crypto-pbkdf2-example.js
var crypto = require('crypto');
// larger numbers mean better security, less
var config = {
// size of the generated hash
hashBytes: 32,
// larger salt means hashed passwords are more resistant to rainbow table, but
// you get diminishing returns pretty fast
saltBytes: 16,
// more iterations means an attacker has to take longer to brute force an