Skip to content

Instantly share code, notes, and snippets.

View greggnakamura's full-sized avatar

Gregg Nakamura greggnakamura

View GitHub Profile
@greggnakamura
greggnakamura / skip-link.html
Last active May 8, 2017 17:56
Accessibility: Skip Link
@greggnakamura
greggnakamura / visually-hidden-css.html
Created October 5, 2016 03:53
Accessibility: Visualy Hidden CSS for meaningful link content
<style>
.visually-hidden {
border: 0;
clip: rect(1px, 1px, 1px, 1px);
height: 1px;
overflow: hidden;
padding: 0;
position: absolute;
width: 1px;
}
@greggnakamura
greggnakamura / contenteditable-example.html
Created September 17, 2016 05:26
HTML: Content Editable CSS example
<head>
<meta charset="utf-8">
<title>JS Bin</title>
<style>
head, style { display: block; }
[contenteditable] { -webkit-user-modify: read-write-plaintext-only; }
style:first-of-type { display: none; }
style:last-of-type { padding: 1em; font-size: 1.5em; white-space: pre; margin: 0 auto; width: 80%; font-family: monospace; }
</style>
@greggnakamura
greggnakamura / dropdown-list-redirect-on-selection.js
Last active September 1, 2016 17:49
jQuery: Create dropdown list; redirect on selection
(function(d, $) {
load();
$('#dropDown').on('change', function(e) {
e.preventDefault();
var selectedItem = $(this).find(":selected").val();
if (selectedItem !== null) {
d.location.href = selectedItem;
@greggnakamura
greggnakamura / youtube.html
Last active July 15, 2016 15:08
GA: YouTube event tracking
<!--
https://megalytic.com/blog/tracking-youtube-videos-using-google-analytics
Key elements in iframe are 'id' & 'enablejsapi' & 'origin' source parameter values
-->
<iframe allowfullscreen="" data-title="Descriptive title" frameborder="0" height="152" id="youTubePlayer" src="http://www.youtube.com/embed/<YOUTUBEID>?enablejsapi=1&amp;origin=http://www.YOURWEBSITE.com&amp;rel=0&amp;showinfo=0" width="100%"></iframe>
<script>
// get descriptive title
@greggnakamura
greggnakamura / union-no-relationship.sql
Last active May 25, 2016 23:58
SQL: UNION two tables with no relationship, number of columns must match
SELECT [AlertTitle] AS Title
,'' AS Summary
,[AlertBody] AS Description
,[AlertDate] AS Date
,[AlertLink] AS AlertLink
,[AlertType] AS AlertType
,'' AS Location
FROM [Claremont_Kentico8_2].[dbo].[View_claremont_Alert_Joined]
UNION
SELECT [EventName] AS Title
@greggnakamura
greggnakamura / email.html
Last active May 20, 2016 13:53
Email: Boilerplate Template
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8">
<title>Email boilerplate template</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<style type="text/css">
body {
@greggnakamura
greggnakamura / restore.sql
Last active November 12, 2019 19:41
SQL Server: Restore DB with alter and restore in a since query
USE [master]
alter database [databaseName]
set single_user with rollback immediate
GO
RESTORE DATABASE [databaseName] FROM DISK = 'path\to\db\backup.bak'
WITH REPLACE
GO
alter database [databaseName]
@greggnakamura
greggnakamura / snippets.css
Last active April 20, 2016 23:50
CSS: Snippets
/**** definitions ****/
/* font-size units: em, ex, %, px, cm, mm, in, pt, pc, ch, rem, vh, vw, vmin, vmax */
/* em: relative unit based on computed value of font size of parent element. Child elements are always dependent
on their parent to set their font-size*/
/* rem: font size is dependent on the value of the root element */
/* box-sizing best practice - easier to change the box-sizing in plugins or other components that leverage other behavior */
html { box-sizing: border-box; }
*, *:before, *:after { box-sizing: inherit; }
@greggnakamura
greggnakamura / firebase-on-method.js
Last active April 8, 2016 03:23
Firebase: `on`
(function () {
var firebaseRoot = 'https://bookmark-app.firebaseio.com/',
bookmarkRef = new Firebase(firebaseRoot + 'bookmarks');
bookmarkRef.on('value', function (snapshot) {
var snapshotResult = snapshot.val();
keys = Object.keys(snapshotResult);