Skip to content

Instantly share code, notes, and snippets.

@dmdeller
dmdeller / 1_before.m
Last active August 29, 2015 13:57
Trying to avoid having ugly weakBlah variables all over the place to avoid retain cycles (or at least having to look at them)
__weak __typeof__(foo) weakFoo = foo;
foo.block = ^
{
[weakFoo doSomething];
};
@dmdeller
dmdeller / HNCSVParser.h
Created July 20, 2013 20:25
CHCSVParser with blocks
//
// HNCSVParser.h
// HNCSVParser
//
// Created by David on 7/20/13.
// Copyright (c) 2013 David Deller. MIT Licensed.
//
#import <CHCSVParser/CHCSVParser.h>
@dmdeller
dmdeller / gist:5126198
Created March 9, 2013 23:09
Justification of colon-style conditionals in PHP (as much as you can justify anything about PHP)
Bad:
<html>
<body>
<p>
Hello there,
<?php if (!empty($name)) { ?>
<?php echo $name; ?>
<?php } else { ?>
whoever
@dmdeller
dmdeller / rss.xml
Last active December 14, 2015 10:39
<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
<channel>
<title>Steven Frank's Posts</title>
<description>Hello, I'm Steven, co-founder of Panic and technology enthusiast.</description>
<link>http://stevenf.com/posts</link>
<item>
<title>Thoughts on the Microsoft Surface Pro</title>
<link>http://stevenf.com/posts/surface-pro</link>
export PATH=$HOME/Applications/homebrew/sbin:$HOME/Applications/homebrew/bin:$PATH
export PATH=$(brew --prefix ruby)/bin:$PATH
export PATH=$(brew --prefix)/share/npm/bin:$PATH
#!/usr/bin/env ruby
require 'net/http'
require 'digest/sha2'
require 'fileutils'
require 'date'
show = ARGV[0]
case show
#!/usr/bin/env ruby -w
require 'cgi'
require 'net/http'
require 'uri'
# Method 1:
# Rewrite article links to Google 'I'm Feeling Lucky' search.
# Site will show article content if referer(sic) is Google.
# Downside: breaks navigation (other links on site lead back to original bostonglobe.com)
@dmdeller
dmdeller / nginx.conf
Created November 28, 2011 19:46
DuckDuckGo nginx config for handling Safari search bar requests
server {
server_name search.yahoo.com;
# only handle requests from Safari search bar
if ($args ~ fr=aaplw.*p=) {
rewrite ^/search https://duckduckgo.com/?q=$arg_p? break;
}
# attempt to redirect other requests back to Yahoo, using alternative server name
rewrite ^ http://search.ystg1.b.yahoo.com$request_uri? break;
@dmdeller
dmdeller / 1. Hosts File help page.markdown
Created November 18, 2011 19:38
DuckDuckGo Hosts File information

Hosts File

NOTE: This feature is currently in beta. The server IP below will change when the beta ends.

As discussed [here][1], Safari doesn’t allow you to customize the search engines available from the search bar.

However, there is a simple hack you can do. DuckDuckGo operates a server that can respond to Safari’s search requests directed at Yahoo, Google, or Bing, and send those to DuckDuckGo instead. To use it, you can either use an app to make the change, or edit your hosts file directly.

Method 1: Mac app

@dmdeller
dmdeller / .htaccess
Created November 6, 2011 17:01
Tiny proxy to redirect Yahoo searches from the Safari search bar to DuckDuckGo
Options +ExecCGI +FollowSymLinks
RewriteEngine On
RewriteRule ^search duckduckgo.rb