Skip to content

Instantly share code, notes, and snippets.

@bsphere
bsphere / timestamp.go
Last active January 23, 2024 02:50
UNIX timestamps in Golang
package timestamp
import (
"fmt"
"labix.org/v2/mgo/bson"
"strconv"
"time"
)
type Timestamp time.Time
@dominic-p
dominic-p / website-checker.sh
Last active April 13, 2022 16:03
This is a shell script to check a provided list of URLs to see if the websites are working or not. It was based on the answers provided to this question: http://stackoverflow.com/q/21391776/931860
#!/bin/sh
# ---- website-checker.sh ----
# Pings a list of websites using cURL to see if they are up and
# there are no errors. If there are problems, we send an email using mailx
# to let ourselves know about the problem.
################################################################################
# Recipient of the errors email
admin_email=youremail@host.com
@leommoore
leommoore / Express_Logging.md
Last active August 20, 2021 19:27
Express - Logging

#Express - Logging The express.js node.js web application framework comes with a built-in logging module called logger which is the connect.js logger. It is really handy to enable and you can use it just like any other Express module. app.use(express.logger());

Without any configuration, the logger middleware will generate a detailed log using what is called the default format. The logger actually supports four predefined log formats: default, short ,tiny, and dev. Each of these predefined formats show various amounts of detail. You can specify one of them this way:

app.use(express.logger('dev'));

If you prefer, you can customize the precise details to be logged using the the following options to format the output of the logger:

@lisamelton
lisamelton / encode.sh
Last active March 31, 2024 21:13
This is the shell script I use to drive HandBrakeCLI to re-encode video files in a format suitable for playback on Apple TV, Roku 3, iOS, OS X, etc.
#!/bin/bash
# encode.sh
#
# Copyright (c) 2013 Don Melton
#
# This version published on June 7, 2013.
#
# Re-encode video files in a format suitable for playback on Apple TV, Roku 3,
# iOS, OS X, etc.
@dantuck
dantuck / jquery-boilerplate.js
Last active October 13, 2015 20:28
jquery plugin boilerplate
+function ($, window, undefined) {
"use strict"; // jshint ;_;
/* MYPLUGIN PUBLIC CLASS DEFINITION
* ================================ */
var MyPlugin = function (element, options) {
this.$element = $(element);
@lancew
lancew / gist:4001624
Created November 2, 2012 14:19
xmonad natural scrolling
echo "pointer = 1 2 3 5 4 7 6 8 9 10 11 12" > ~/.Xmodmap && xmodmap ~/.Xmodmap
@border
border / mgoExample.go
Created August 27, 2012 15:33
mgo example
package main
import (
"fmt"
"labix.org/v2/mgo"
"labix.org/v2/mgo/bson"
"time"
)
type Person struct {
@geuis
geuis / json.js
Created November 15, 2011 16:01
Better error handling for JSON.parse (javascript)
(function(){
var parse = JSON.parse;
JSON = {
stringify: JSON.stringify,
validate: function(str){
@Swizec
Swizec / paragraph_counter.js
Created September 16, 2011 14:52
Simple script to see how far users scroll on a website
(function ($) {
$.waypoints.settings.scrollThrottle = 30;
try {
mpmetrics = new MixpanelLib("<api_key>");
} catch(err) {
var null_fn = function () {};
mpmetrics = {
track: null_fn,
track_funnel: null_fn,
@dantuck
dantuck / TransactionManagement.sql
Created September 16, 2011 14:52
TSQL Transaction Management
DECLARE @ERRORCODE INT
BEGIN TRANSACTION
-- do action
-- check for errors after each transaction if desired
SELECT @ERRORCODE = @@ERROR
IF (@ERRORCODE <> 0) GOTO PROBLEM