Skip to content

Instantly share code, notes, and snippets.

View cgkio's full-sized avatar

Christian Kessler IV cgkio

View GitHub Profile
@cgkio
cgkio / async_series.js
Created September 18, 2013 02:55
example of node.js Async series function
async.series({
one: function (callback) {
setTimeout(function () {
callback(null, 1);
}, 200);
},
two: function (callback) {
setTimeout(function () {
callback(null, 2);
}, 100);
@cgkio
cgkio / Absolute-Centering.css
Created September 18, 2013 16:32
Absolute Centering (CSS)
.Absolute-Center {
margin: auto;
position: absolute;
top: 0; left: 0; bottom: 0; right: 0;
}
/*
ADVANTAGE: Cross-browser (including IE8-10)
CAVEAT: Height must be declared
source: http://coding.smashingmagazine.com/2013/08/09/absolute-horizontal-vertical-centering-css/
@cgkio
cgkio / dir_list.js
Created September 23, 2013 14:55
Getting a directory listing using the fs module in Node.js
#!/usr/bin/env node
var fs = require("fs"),
path = require("path");
var p = "../"
fs.readdir(p, function (err, files) {
if (err) {
throw err;
}
@cgkio
cgkio / ios_webclip.html
Created September 25, 2013 14:58
HTML/meta setting for an iOS web clip
<!-- Hiding Safari User Interface Components -->
<meta name="apple-mobile-web-app-capable" content="yes" />
<!-- to set the viewport width to the width of the device, add this to your HTML file: -->
<meta name="viewport" content="width=device-width">
<!-- to set the initial scale to 1.0, add this to your HTML file: -->
<meta name="viewport" content="initial-scale=1.0">
<!-- to set the initial scale and to turn off user scaling, add this to your HTML file: -->
@cgkio
cgkio / webapp_geolocation.js
Created September 25, 2013 15:11
Getting geographic locations with JavaScript in iOS webapps
// Get the current location
navigator.geolocation.getCurrentPosition(showMap);
// your callback function—the showMap function in this example—should take a position object as the parameter as follows:
function showMap(position) {
// Show a map centered at position
}
// use the coords instance variable of the passed-in position object to obtain the latitude and longitude coordinates as follows:
latitude = position.coords.latitude;
@cgkio
cgkio / parent_node.js
Created September 25, 2013 20:19
Get the parentNode id on a .click event
$(".movedown").click(function () {
console.log('movedown for ' + this.parentNode.id);
});
@cgkio
cgkio / formfields.js
Created September 27, 2013 17:33
Dealing with form fields with jQuery
var textfield_value = $("#textfield_id").val();
var selected_radio_button = $('input:radio[name=name_of_radio_group]:checked').val();
var select_selected_value = $('#select_id :selected').val();
var checked_unchecked = $('#checkbox_id:checked').val();
@cgkio
cgkio / manipulate_select_dropdowns.html
Created September 29, 2013 21:44
Dropdownlist Manipulation using jQuery
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js" type="text/javascript"></script>
</head>
<body>
<h3>Dropdownlist Manipulation using jQuery</h3>
<div style="border:3px dashed black;padding:10px;width:40%"> Countries:
<select id="countries">
</select>
<p>
@cgkio
cgkio / modifying_json.js
Created September 30, 2013 18:54
building/modifying JSON with javascript
// https://developer.mozilla.org/en-US/docs/JSON
var foo = {};
foo.bar = "new property";
foo.baz = 3;
var JSONfoo = JSON.stringify(foo);
// JSONfoo now holds {"bar":"new property","baz":3}
// To make JSONfoo back into a JavaScript object just do:
var backToJS = JSON.parse(JSONfoo);
@cgkio
cgkio / steroids-node-comands.md
Created October 17, 2013 18:16
Basic Steroids.js node.js commands

Login into steroids

$ steroids login

Updating the Steroids npm

$ npm update steroids -g

Updating an existing Steroids project (after updating the NPM)