Skip to content

Instantly share code, notes, and snippets.

View greggnakamura's full-sized avatar

Gregg Nakamura greggnakamura

View GitHub Profile
@greggnakamura
greggnakamura / main.html
Created June 26, 2014 01:11
AngularJS, Firebase: Querying
<h2>{{ title }}</h2>
<div class="jumbotron">
<div ng-repeat="message in messages">
{{ message.user }} - {{ message.text }}
</div>
</div>
<div class="row marketing">
<input type="text" class="form-control" ng-model="currentUser" />
@greggnakamura
greggnakamura / index.htm
Created June 25, 2014 01:49
AngularJS, Firebase: Working with a single-node
<!doctype html>
<html class="no-js">
<head>
<meta charset="utf-8">
<title></title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width">
<!-- Place favicon.ico and apple-touch-icon.png in the root directory -->
<!-- build:css(.) styles/vendor.css -->
<!-- bower:css -->
@greggnakamura
greggnakamura / gist:c21736004a9306e1b4b5
Created June 24, 2014 04:49
Firebase: snapshot functions
/* Firebase snapshot */
snapshot.val()
- Return values from Firebase at a given point in time
snapshot.hasChildren();
snapshot.hasChild('text');
snapshot.name();
@greggnakamura
greggnakamura / gist:99a2b176ca7b188d5ff6
Last active August 29, 2015 14:02
Javascript: Find the index of the smallest element in an array
function indexOfSmallest(a) {
var lowest = 0;
for (var i = 1; i < a.length; i++) {
if (a[i] < a[lowest]) lowest = i;
}
return lowest;
}
var a = [1, 2, 3, 4, 4, 6, 5, 0, 9];
@greggnakamura
greggnakamura / gist:9203537
Created February 25, 2014 06:01
D3: Simple Bar Chart code
// Array of data
var dataSet = [ 8, 48, 14, 31, 23 ];
// SVG container
svg = d3.select('body').append('svg').attr({
width: 600,
height: 400
});
// SVG Elements
(function ($) {
$(function () {
var $html = $('html');
var requests = 0;
function setBusy() {
if (++requests == 1) {
$html.addClass('busy-cursor');
}
}
public void NonQuery()
{
var connectionString = ConfigurationManager.ConnectionStrings["Default"].ConnectionString;
var sqlCommandText = "UPDATE People SET Name = 'John'";
using (var sqlConnection = new SqlConnection(connectionString))
using (var sqlCommand = new SqlCommand(sqlCommandText, sqlConnection))
{
sqlCommand.Connection.Open();
@greggnakamura
greggnakamura / gist:5537968
Created May 8, 2013 03:23
Node: Simple Express get using regular expressions
app.get(/\/users\/(\d*)\/?(edit)?/,function(req, res){
// /users/10
// /users/10/
// /users/10/edit
var message = "user #" + req.params[0] + "'s profile";
if(req.params[1] === 'edit'){
message = "Editing " + message;
} else {
sub, sup {
/* Specified in % so that the sup/sup is the
right size relative to the surrounding text */
font-size: 75%;
/* Zero out the line-height so that it doesn't
interfere with the positioning that follows */
line-height: 0;
/* Where the magic happens: makes all browsers position
@font-face {
font-family: 'GillSans Std Regular';
src: url('/fonts/gillsansstd-webfont.eot');
src: url('/fonts/gillsansstd-webfont.eot?#iefix') format('embedded-opentype'),
url('/fonts/gillsansstd-webfont.ttf') format('truetype'),
url('/fonts/gillsansstd-webfont.svg#GillSansStdRegular') format('svg');
font-weight: normal;
font-style: normal;
}
@font-face { /* for non-IE */