Skip to content

Instantly share code, notes, and snippets.

@dominickp
dominickp / forEach.js
Created July 8, 2016 20:09
Switch forEach helper function
/*
Foreach helper function
callback
Function to execute for each element, taking three arguments:
currentValue
The current element being processed in the array.
index
The index of the current element being processed in the array.
array
The array that forEach() is being applied to.
@dominickp
dominickp / pre-commit
Last active July 24, 2019 13:47
Switch scripting .sscript inflating pre-commit hook
#!/bin/sh
# Create a file with these contents in your repo at
# .git/hooks/pre-commit
# Place any .sscript files in a folder called Packed/
# Extract any .sscript files from a Packed/ directory
for i in `find . -name "*.sscript" -type f -exec echo \{\} \;`; do
# Only act if within a Packed directory
@dominickp
dominickp / get_date_diff.php
Last active November 8, 2023 20:56 — forked from ozh/gist:8169202
Add text to tell whether date was past/future. "2 days ago" or "2 days from now".
<?php
/**
* Get human readable time difference between 2 dates
*
* Return difference between 2 dates in year, month, hour, minute or second
* The $precision caps the number of time units used: for instance if
* $time1 - $time2 = 3 days, 4 hours, 12 minutes, 5 seconds
* - with precision = 1 : 3 days
* - with precision = 2 : 3 days, 4 hours
* - with precision = 3 : 3 days, 4 hours, 12 minutes
#!/bin/sh
#
# Postgresql backup script
# http://www.bitweaver.org/wiki/pg_backup+PostgreSQL+backup+script
#
# Author
# |
# +-- speedboy (speedboy_420 at hotmail dot com)
# +-- spiderr (spiderr at bitweaver dot org)
# +-- flexiondotorg (code at flexion dot org)