Skip to content

Instantly share code, notes, and snippets.

@ianthrive
ianthrive / macos-save-new-documents-to-cloud.sh
Created February 19, 2013 11:12
Disable/enable the default iCloud selection in the save window of new documents.
defaults write NSGlobalDomain NSDocumentSaveNewDocumentsToCloud -bool false
defaults write NSGlobalDomain NSDocumentSaveNewDocumentsToCloud -bool true
@ianthrive
ianthrive / bcrypt-example.php
Last active October 13, 2015 12:37 — forked from rk/bcrypt.php
Simple bcrypt object to wrap crypt() with.
<?php
// Originally by Andrew Moore
// Src: http://stackoverflow.com/questions/4795385/how-do-you-use-bcrypt-for-hashing-passwords-in-php/6337021#6337021
//
// Heavily modified by Robert Kosek, from data at php.net/crypt
class Bcrypt {
private $rounds;
private $prefix;
@ianthrive
ianthrive / safari-validate-popup.js
Created October 28, 2012 04:06
Make HTML5 form validation appear the same way in all recent browsers as Safari
window.addEventListener('load', function(event) {
// for each form on the page
for(i=0; i < document.forms.length; i++) {
f = document.forms[i];
// add a 'submit' event listener
f.noValidate = true;
// except for safari, the event never triggers without noValidate=true
f.addEventListener('submit', function(event) {
// if form is not valid don't let it submit
if(!event.target.checkValidity()) {
@ianthrive
ianthrive / dir-listing.php
Last active May 2, 2020 16:48
Directory listing of file repository on bluffdale.com
if(is_dir($currentPath)) {
?><table class="file-list"><?
$scan = scandir($currentPath);
array_shift($scan);
array_shift($scan);
foreach($scan as $name) {
if($name[0] != '.' && $name[0] != '_') {
$path = $currentPath.'/'.$name;
$icon = 'unknown';
if(is_dir($path)) {
@ianthrive
ianthrive / sql-list-months-days.sql
Created October 19, 2012 11:07
SQL: list all days in a month given a date within that month
PREPARE test AS
WITH RECURSIVE T(n) AS (
SELECT date_trunc('month', $1::date)::date AS start
UNION
SELECT n+1 FROM T WHERE n < date_trunc('month', $1)::date + '1 month'::interval - '1 day'::interval
)
SELECT * FROM T;
EXECUTE test('15 nov 2012');