Skip to content

Instantly share code, notes, and snippets.

View adamdehaven's full-sized avatar

Adam DeHaven adamdehaven

View GitHub Profile
@adamdehaven
adamdehaven / ShortTail-Bookmarklet
Created February 12, 2014 16:05
ShortTail Bookmarklet
javascript:(function()%7Bjavascript%3Awindow.location.href%3D'ShortTail%3A%2F%2F'%2Bwindow.location.href%7D)();
@adamdehaven
adamdehaven / calculate-dates-obj-c
Created March 13, 2014 19:48
Calculate Dates in Objective-C
- (void) calculateDates {
NSDate *todayDate = [[NSDate alloc] init];
NSCalendar *gregorian = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
NSDateComponents *tomorrowOffset = [[NSDateComponents alloc] init];
[tomorrowOffset setDay:1];
NSDateComponents *yesterdayOffset = [[NSDateComponents alloc] init];
[yesterdayOffset setDay:-1];
NSDate *tomorrowDate = [gregorian dateByAddingComponents:tomorrowOffset toDate:todayDate options:0];
NSDate *yesterdayDate = [gregorian dateByAddingComponents:yesterdayOffset toDate:todayDate options:0];
@adamdehaven
adamdehaven / Blur Current View
Last active August 29, 2015 14:01
Blur current view
#import "UIImage+ImageEffects.h"
// Blur view while sidebar is open
UIGraphicsBeginImageContext(self.tableView.contentSize);
CGContextRef c = UIGraphicsGetCurrentContext();
CGContextTranslateCTM(c, 0, 0);
[self.view.layer renderInContext:c];
UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();
viewImage = [viewImage applyBlurWithRadius:3.5 tintColor:nil saturationDeltaFactor:1.4 maskImage:nil];
UIGraphicsEndImageContext();
@adamdehaven
adamdehaven / http-status-code.php
Last active September 28, 2015 17:13
Easily return HTTP status messages on success and failure
<?php
function getStatusCodeMessage($status)
{
// these could be stored in a .ini file and loaded
// via parse_ini_file()... however, this will suffice
// for an example
$codes = Array(
100 => 'Continue',
101 => 'Switching Protocols',
200 => 'OK',
@adamdehaven
adamdehaven / 01-circle.html
Last active November 18, 2020 00:10 — forked from hatefulcrawdad/01-circle.html
The Wonderful World of SVGs
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Shape Examples</title>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<svg class="circles" viewBox="0 0 10 5" preserveAspectRatio="xMinYMin meet">
@adamdehaven
adamdehaven / human-time-diff.php
Last active September 28, 2015 17:13
Wordpress function to insert post or comment timestamp as relative (i.e. 2 weeks ago), or as date, depending on $duration (Default 60 days)
<?php
// Show relative time if more recent than 60 days for post or comment
function adamdehaven_human_time_diff( $type = 'post', $duration = 60 ) {
if($type == 'comment') {
$post_time = get_comment_time('U');
} else {
$post_time = get_the_time('U');
}
$human_time = '';
@adamdehaven
adamdehaven / bgimage.css
Last active March 7, 2024 17:38
Bootstrap full-width hero section with text and image
.bgimage {
width:100%;
height:500px;
background: url('https://images.unsplash.com/photo-1438109491414-7198515b166b?q=80&fm=jpg&s=cbdabf7a79c087a0b060670a6d79726c');
background-repeat: no-repeat;
background-position: center;
background-size:cover;
background-attachment: fixed;
}
.bgimage h5 {
@adamdehaven
adamdehaven / sjbpost.txt
Last active November 18, 2020 00:09
SJBpost() Command/Event Names in Google Play Music
"addAlbumMenus",
"addFreeSongs",
"addPlaylistMenus",
"addSongListToCache",
"addSongsToPlaylist",
"addSongToList",
"addSongToList",
"addToAnimation",
"albumDeleted",
"albumDeleted",
/* =============================================================================
CSS Declarations
========================================================================== */
/* ==|== The Standard Way =================================================== */
.foo::before {
/* ...css rules... */
}
@adamdehaven
adamdehaven / http-status.sh
Last active April 27, 2016 19:46
Bash/Terminal to return the HTTP status code of a URL via cURL. Includes following redirects to final URL
#!/bin/bash
status=$(curl $1 -s -L -I -o /dev/null -w '%{http_code}')
echo $status
### Run
# $ bash http-status.sh http://google.com/