Skip to content

Instantly share code, notes, and snippets.

View joshuakemmerling's full-sized avatar

Joshua Kemmerling joshuakemmerling

View GitHub Profile
@joshuakemmerling
joshuakemmerling / index.html
Created March 29, 2013 13:45
Pure CSS horizontal scrolling shadows
<!DOCTYPE html>
<html>
<head>
<style>
.scrollbox {
overflow: auto;
width: 200px;
max-height: 200px;
margin: 50px auto;
@joshuakemmerling
joshuakemmerling / browser.js
Last active May 25, 2018 12:28
Browser detect object
var BrowserDetect =
{
init: function ()
{
this.browser = this.searchString(this.dataBrowser) || "Other";
this.version = this.searchVersion(navigator.userAgent) || this.searchVersion(navigator.appVersion) || "Unknown";
},
searchString: function (data)
{
for (var i = 0; i < data.length; i++) {
@joshuakemmerling
joshuakemmerling / shortcode.rb
Created July 15, 2014 05:16
Ruby shortcode
# http://rubular.com/
def shortcode (input)
regex = /\[([a-zA-Z0-9]+\s.+)\]/i
matches = regex.match(input)
splits = matches[1].split(" ")
attrs = Hash.new
splits[1, splits.length].each do |attr|
attr = attr.strip().split("=")
http://petapixel.com/2015/02/21/a-practical-guide-to-creating-superresolution-photos-with-photoshop/
Camera Settings
- Handheld
- f/5.6 to f/11
- Hand holdable shutter speed – 1/(2*focal length) recommended
- Lower ISOs are preferable, set as f/number and shutter dictate for a neutral exposure or set Auto ISO
- Continuous burst mode – minimum of 20 images
- RAW
@joshuakemmerling
joshuakemmerling / connect.js
Last active October 1, 2019 01:04
Grunt snippets.
module.exports = function (grunt) {
grunt.initConfig({
connect: {
server: {
options: {
port: 8080,
hostname: '*',
keepalive: true,
onCreateServer: function (server, connect, options) { },
}
@joshuakemmerling
joshuakemmerling / sql-geo.sql
Last active May 25, 2018 12:43
This is a SQL query for nearest places using latitude and longitude. Uses “as the crow flies” equation.
SELECT id, name, latitude, longitude, (3959 * acos(cos(radians({$this->lat})) * cos(radians(latitude)) * cos(radians(longitude) - radians({$this->lng})) + sin(radians({$this->lat})) * sin(radians(latitude)))) AS distance
FROM trailers
WHERE latitude IS NOT NULL
ORDER BY distance
@joshuakemmerling
joshuakemmerling / global.js
Last active May 25, 2018 12:46
Vanilla pub/sub system.
events.publish('/page/load', {
url: '/some/url/path' // any argument
});
var subscription = events.subscribe('/page/load', function(obj) {
// Do something now that the event has occurred
});
// ...sometime later where I no longer want subscription...
subscription.remove();
@joshuakemmerling
joshuakemmerling / global.js
Last active October 1, 2019 01:12
Promise JS
new Promise(function (reject) {
}).then(function (reject) {
reject('this is an error');
}).then(function () {
console.log('never run');
}).catch(function (err) {
console.log('err', err);
}).finally(function () {
@joshuakemmerling
joshuakemmerling / dynamic-urls.md
Last active May 25, 2018 12:49
Filter list of dynamic URLs.

Steps

1. Get incoming URL

var url = '/product/shoes/234'

2. Create regex from incoming URL

var regex = '/(product|:[a-zA-Z0-9]+)/(shoes|:[a-zA-Z0-9]+)/(234|:[a-zA-Z0-9+)'

@joshuakemmerling
joshuakemmerling / article.scss
Created August 27, 2016 15:11
Default typography for an article. Does not apply to the entire site.
article {
h1, h2, h3, h4, h5, h6, img, ul, ol { margin-bottom: 20px; }
h1 { font-size: 2em; line-height: 1.5; }
h2 { font-size: 1.5em; line-height: 1.5; }
h3 { font-size: 1.17em; line-height: 1.5; }
h4 { font-size: 1em; line-height: 1.5; }
h5 { font-size: 0.83em; line-height: 1.5; }
h6 { font-size: 0.67em; line-height: 1.5; }
strong { font-weight: bold; }
img { display: block; max-width: 100%; margin-bottom: 20px; }