Skip to content

Instantly share code, notes, and snippets.

View dustinsmith1024's full-sized avatar
🏀
⛹️

Dustin Smith dustinsmith1024

🏀
⛹️
View GitHub Profile
@karlseguin
karlseguin / now.go
Created June 9, 2013 07:28
Testable time.Now in GoLang
package t
import (
"time"
)
type NowFunc func() time.Time
var Now = func() time.Time { return time.Now() }
func NowForce(unix int) {
@aheuermann
aheuermann / error_api.js
Last active March 30, 2016 23:55
Not Found Error vs Return Null w/ handlers
var facade = require('facade'),
handlers = require('handlers');
app.use("/verification/:verificationId", funciton (req, res) {
facade.getUserForVerificationId(req.params.verificationId)
.then(handlers.successHandler, handlers.errorHandler);
});
@dustinsmith1024
dustinsmith1024 / postgres_queries_and_commands.sql
Last active March 28, 2018 14:58 — forked from rgreenjr/postgres_queries_and_commands.sql
Useful PostgreSQL Queries and Commands
https://www.postgresql.org/docs/9.4/static/monitoring-stats.html
https://www.postgresql.org/docs/9.4/static/functions-admin.html
-- show blocking pids in a nice tree
-- query as blocked_query
-- 9.6++
select pid, usename,
age(query_start, clock_timestamp()),
pg_blocking_pids(pid) as blocked_by,
query
@rmw
rmw / hash.rb
Created May 16, 2012 13:50
Extend Ruby Hash with method to return a recursive OpenStruct
class Hash
# options:
# :exclude => [keys] - keys need to be symbols
def to_ostruct_recursive(options = {})
convert_to_ostruct_recursive(self, options)
end
private
def convert_to_ostruct_recursive(obj, options)
result = obj
@nruth
nruth / cookie_steps.rb
Created July 21, 2010 17:16
Testing login "remember me" feature with Capybara (rack::test or selenium) - deleting the session cookie (only)
@jakebathman
jakebathman / botPost.php
Last active July 12, 2020 00:10
GroupMe bot post function including @mentions
<?php
/**
* Post a message from a bot to a group
*
* $groupId (string) GroupId of the group to post the message
* $strMessage (string) Text of the message to post (limit of 1000 characters)
* $strBotId (string) ID of the bot which will post the message
* $mentionUsers (array) [optional] array of userIds to mention (uses attachment)
* Example array of userIds:
@JeffreyWay
JeffreyWay / gist:1525217
Created December 27, 2011 21:29
Instant Server for Current Directory
alias server='open http://localhost:8000 && python -m SimpleHTTPServer'
@a1phanumeric
a1phanumeric / gist:5346170
Created April 9, 2013 14:35
Grep exclusions. Demonstrates how to exclude multiple directories, and files.
grep -r --color --exclude-dir={custom,lib,scripts} --exclude={*.xml,error_log} "beta" .
@DavidVaini
DavidVaini / round.go
Created April 9, 2014 19:58
Arggh Golang does not include a round function in the standard math package. So I wrote a quick one.
package main
import (
"log"
"math"
)
func Round(val float64, roundOn float64, places int ) (newVal float64) {
var round float64
pow := math.Pow(10, float64(places))
@mlynch
mlynch / autofocus.js
Last active August 24, 2022 15:03
AngularJS Autofocus directive
/**
* the HTML5 autofocus property can be finicky when it comes to dynamically loaded
* templates and such with AngularJS. Use this simple directive to
* tame this beast once and for all.
*
* Usage:
* <input type="text" autofocus>
*
* License: MIT
*/