Skip to content

Instantly share code, notes, and snippets.

View timhudson's full-sized avatar

Tim Hudson timhudson

View GitHub Profile
@timhudson
timhudson / custom_instructions.md
Last active September 25, 2023 20:18
Collection of prompts

Precision Engineering Mode

- Be highly organized
- Suggest solutions that I didn’t think about—be proactive and anticipate my needs
- Treat me as an expert in all subject matter
- Mistakes erode my trust, so be accurate and thorough
- Provide detailed explanations, I’m comfortable with lots of detail
- Value good arguments over authorities, the source is irrelevant
- Consider new technologies and contrarian ideas, not just the conventional wisdom
@timhudson
timhudson / app-code.js
Last active October 30, 2020 12:28
Scroll start/stop events using jQuery
$(function() {
$(document).on('scrollstart', function() {
console.log('scroll started')
})
$(document).on('scrollend', function() {
console.log('scroll ended')
})
@timhudson
timhudson / pre-save-update.js
Last active July 3, 2020 08:58
Update the `lastUpdated` field every time a mongoose model is saved
var schema = mongoose.Schema({
lastUpdated: {type: Date, 'default': Date.now}
})
schema.pre('save', function(next) {
this.lastUpdated = Date.now()
next()
})
@timhudson
timhudson / express.js
Last active January 17, 2019 11:34
Internal routing within a single node process using express
var request = require('request')
, express = require('express')
, app = express()
var port = process.env.PORT || 5000
app.get('/api', function(req, res) {
res.send('I am from the API')
})
@timhudson
timhudson / RootQuery.js
Created May 1, 2017 19:51
Colocating GraphQL resolvers with types
export default `
type RootQuery {
user(id = String, email = String) User
}
`
export const user = async (_, { id, email }, ctx) => {
return {
id: 'this',
name: 'that'
@timhudson
timhudson / analytics-ql.js
Last active March 14, 2017 20:57
Analytics.ql
const query = `
query ($workspaceSlug: String, $sourceSlug: String) {
segment {
workspace(slug: $workspaceSlug) {
id
}
source(slug: $sourceSlug) {
id
}
}
@timhudson
timhudson / index.js
Created February 25, 2016 20:33
Budo with iframe
console.log('oh snap!')
var redux = require('redux')
console.log('we made it!')
var resourceModels = {}
function getModel(app) {
if (resourceModels[app]) return resourceModels[app]
return resourceModels[app] = mongoose.model('resource'+app, schema)
}
#! /bin/sh
### BEGIN INIT INFO
# Provides: redis-server
# Required-Start: $syslog
# Required-Stop: $syslog
# Should-Start: $local_fs
# Should-Stop: $local_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: redis-server - Persistent key-value db