Skip to content

Instantly share code, notes, and snippets.

Kai Conragan kconragan

Block or report user

Report or block kconragan

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@kconragan
kconragan / gist:2690877
Created May 14, 2012
Example of using connect-mongo for session management with a single db
View gist:2690877
app.use(express.session({
secret:'awesome unicorns',
maxAge: new Date(Date.now() + 3600000),
store: new MongoStore({
db:mongoose.connection.db},
function(err){
console.log(err || 'connect-mongodb setup ok');
})
}));
@kconragan
kconragan / index.js
Created May 9, 2012
list surf sessions
View index.js
exports.listLogs = function(req, res) {
SurfSession.find()
.populate('location')
.run(function(err, log) {
Wave.find(function(err, waves) {
var surfHeight = SurfSession.schema.path('surfHeight').enumValues;
var surfConditions = SurfSession.schema.path('surfConditions').enumValues;
var surfStoke = new SurfSession().generateStoke();
var currentYear = moment().year();
var surfSessionsThisYear = 0;
@kconragan
kconragan / gist:2637953
Created May 8, 2012
Google Maps custom tile overlay
View gist:2637953
// Set up the copyright information
// Each image used should indicate its copyright permissions
var myCopyright = new GCopyrightCollection("© ");
myCopyright.addCopyright(new GCopyright('Demo',
new GLatLngBounds(new GLatLng(-90,-180), new GLatLng(90,180)),
0,'©2007 Google'));
// Create the tile layer overlay and
// implement the three abstract methods
var tilelayer = new GTileLayer(myCopyright);
@kconragan
kconragan / helpers.js
Created Apr 30, 2012
Generic request handler for returning a promise when requesting a url
View helpers.js
/*
* Internal: Convert the request for a url into a promise
*
* url - the String to fetch
*
* Example: return request('http://www.google.com')
*
* Returns a promise
*/
var request = function(url) {
@kconragan
kconragan / keyrepeat.shell
Last active Sep 3, 2019
Enable key repeat in Apple Lion for Sublime Text in Vim mode
View keyrepeat.shell
# Mac OS X Lion introduced a new, iOS-like context menu when you press and hold a key
# that enables you to choose a character from a menu of options. If you are on Lion
# try it by pressing and holding down 'e' in any app that uses the default NSTextField
# for input.
#
# It's a nice feature and continues the blending of Mac OS X and iOS features. However,
# it's a nightmare to deal with in Sublime Text if you're running Vintage (Vim) mode,
# as it means you cannot press and hold h/j/k/l to move through your file. You have
# to repeatedly press the keys to navigate.
@kconragan
kconragan / dabblet.css
Created Apr 26, 2012
Subtle CSS hatch pattern
View dabblet.css
body {
background-color:#f1f2f3;
background-image:
linear-gradient(rgba(0,0,0,.015) 1px, transparent 1px),
linear-gradient(0, rgba(0,0,0,.015) 1px, transparent 1px);
background-size:5px 5px;
background-position:-1px -1px, -1px -1px
}
@kconragan
kconragan / dabblet.css
Created Apr 26, 2012 — forked from LeaVerou/dabblet.css
Scrolling shadows by @kizmarh and @LeaVerou
View dabblet.css
/**
* Scrolling shadows by @kizmarh and @leaverou
* Only works in browsers supporting background-attachment: local; & CSS gradients
* Degrades gracefully
*/
html {
background: white;
font: 120% sans-serif;
}
View gist:2481948
// controller
exports.createWave = function(req, res) {
// buoys come in from client sorted
var buoys = req.body.wave.buoys;
// how would I add an index to them
// and save below?
var wave = new Wave({
View gist:2410086
for(i = 0; i < results.length; i++) {
var row = results[i];
// construct timestamp for raw results
// YYYY-MM-DD H:H ZZ
// Sample: 2012-04-13 00:10 +0000
var t =row[0] + "-" + row[1] + "-" + row[2] + ' ' + row[3] + ":" + row[4] + ' +0000'
// TODO
// format date an respect timezone
View gist:2408364
// Takes NDBC Buoy ID, and returns
// series of readings
var fetchBuoy = function(buoyId) {
var path = 'http://www.ndbc.noaa.gov/data/5day2/' + buoyId + '_5day.txt';
request(path, function(err, response, body) {
if(err) {
throw err;
}
return body;
});
You can’t perform that action at this time.