Skip to content

Instantly share code, notes, and snippets.

View boywhoroared's full-sized avatar

Boy Who Roared boywhoroared

View GitHub Profile
@boywhoroared
boywhoroared / Truncate.cmd
Created June 6, 2011 15:41
Truncate a file via Windows CLI
echo. > errors.log
@boywhoroared
boywhoroared / Zend-View-Url-Helper.php
Created June 6, 2011 16:33
Using the Zend View URL Helper to generate default route URLs
<?php
# When using the Zend View URL helper to generate URLs to controller actions,
# rather than named routes, you have to use 'default' as the route name.
# Generating a URL for the `bar` action in the `foo` controller.
echo $this->url(array('action' => 'bar', 'controller' => 'foo'), 'default', true);
# And NOT this as most people seem to assume (self included).
@boywhoroared
boywhoroared / CopyTable.sql
Created June 15, 2011 18:27
MYSQL: Copy a table from one schema to another.
USE db2;
CREATE TABLE table2 LIKE db1.table1;
INSERT INTO table2
SELECT * FROM db1.table1;
@boywhoroared
boywhoroared / copy-tables.cmd
Created June 15, 2011 18:29
MYSQL: Copy tables from one schema to another (uses mysql client)
mysqldump -u(username) -p(password) (source database name) (table names...) | mysql -u(username) -p(password) (destination database name)
@boywhoroared
boywhoroared / mysql-dump-restore.sql
Created June 29, 2011 13:47
MySQL Dump & Restore Charset Safe
mysqldump -u username -p --default-character-set=latin1 -N database > backup.sql
mysql -u username -p --default-character-set=latin1 database < backup.sql
@boywhoroared
boywhoroared / mysql-duplicates.sql
Created May 15, 2013 19:20
Find duplicated values for a given field.
SELECT `field` FROM `table` GROUP BY `field` HAVING count(field) > 1;
-- Find duplicated values for the column `field`
@boywhoroared
boywhoroared / init-env-wifi.sh
Last active August 29, 2015 13:57
Setup your OS X environment based on your "location" by checking the WiFi network you're connected to.
#!/bin/sh
# the name of your Wireless interface. Might be en1 on some machines.
AIRPORT="en0"
# name of the wifi network
WIFI_WORK="<name-of-your-office-wifi>";
if networksetup -getairportnetwork $AIRPORT | grep -i -a $WIFI_WORK ;
then
server {
index index.php;
set $basepath "/var/www";
set $domain $host;
# check one name domain for simple application
if ($domain ~ "^(.[^.]*)\.dev$") {
set $domain $1;
set $rootpath "${domain}";
<?php
// add this to your php.ini
// auto_prepend_file = /path/to/virtual.prepend.php
$http_host = explode('.',$_SERVER['HTTP_HOST']);
$__mod_vhost_alias_fix_doc_root = $_SERVER['DOCUMENT_ROOT'] .
DIRECTORY_SEPARATOR . $http_host[0] .
DIRECTORY_SEPARATOR . 'public';
if (is_dir($__mod_vhost_alias_fix_doc_root)) {