Skip to content

Instantly share code, notes, and snippets.

<?php
namespace gadgetron\doctrine;
use Doctrine\ORM\Events;
class EventSubscriber implements \Doctrine\Common\EventSubscriber
{
public function getSubscribedEvents()
{
@dmdeller
dmdeller / volume-down.scpt
Created August 20, 2011 17:40
PowerMate volume scripts
set myVolume to output volume of (get volume settings)
set myVolume to (myVolume - 2)
set volume output volume myVolume
tell application "PowerMate"
set aDevice to first device
tell aDevice
make light state with properties {state type:steady, brightness:(myVolume / 100), name:"Volume"}
end tell
end tell
@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
@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 / 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;
#!/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)
#!/usr/bin/env ruby
require 'net/http'
require 'digest/sha2'
require 'fileutils'
require 'date'
show = ARGV[0]
case show
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
@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>
@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