Marc Blase

2014 Top Listens

Straight from my LastFM profile:

  1. Iron Chic 193
  2. Mac DeMarco 167
  3. Spoon 164
  4. The War on Drugs 157
  5. Yo La Tengo 147
  6. TV on the Radio 144
  7. Real Estate 140
  8. Guided by Voices 122
  9. San Fermin 112
  10. Nude Beach 111
  11. Tweedy 108
  12. My Morning Jacket 107
  13. Woods 106
  14. BOAT 102
  15. Painted Palms 102
  16. Radical Dads 101
  17. Ultimate Painting 99
  18. Ryan Adams 96
  19. Mr. Gnome 96
  20. Modest Mouse 93
  21. Beck 92
  22. Built to Spill 92
  23. Black Lips 91
  24. Arcade Fire 91
  25. Sleepy Sun 90
  26. Ásgeir 90
  27. Paws 86
  28. Courtney Barnett 86
  29. The Skygreen Leopards 84
  30. Tops 84
  31. Shy Boys 83
  32. King Tuff 81
  33. Late Bloomer 81
  34. Wye Oak 81
  35. Alvvays 81
  36. Diarrhea Planet 80
  37. Chet Faker 80
  38. Lee Bains III & The Glory Fires 80
  39. Morrissey 77
  40. Stephen Malkmus and the Jicks 77
  41. Interpol 73
  42. Temples 73
  43. Hooray For Earth 73
  44. The Sea and Cake 70
  45. Elliott Smith 68
  46. The Velvet Underground 67
  47. jj 67
  48. Turbo Fruits 66
  49. Christopher Owens 66
  50. The New Pornographers 65
Published on December 31, 2014

Fix WordPress’ default attachment “link to” setting

I say fix since this is a mild annoyance of mine. Anywho, here’s the fix.

1. Direct your web browser to: http://MY_DOMAIN_NAME.TLD/wp-admin/options.php

2. Look for image_default_link_type

3. Fix it. Delete the contents of the corresponding field. If you want to change it, the available values are: “”, “file”, “post”.

Published on August 15, 2014

World Clock

Awesome World Clock created by xkcd.

Published on February 26, 2014

How to CHMOD web files properly

To change all the directories to 755 (-rwxr-xr-x):

find /path/to/web/dir -type d -exec chmod 755 {} \;

To change all the files to 644 (-rw-r–r–):

find /path/to/web/dir -type f -exec chmod 644 {} \;

chmod 644 {} \; specifies the command that will be executed by find for each file. {} is replaced by the file path, and the semicolon denotes the end of the command (escaped, otherwise it would be interpreted by the shell instead of find).

or alternatively, you could do the following:

chmod -R a+rX ./*

The X (that is capital X, not small x!) is ignored for files (unless they are executable for someone already) but is used for directories.

Thanks for the answers once again Stack Overflow.

Published on January 15, 2014

Millionaire Chicken

I am posting this here for the sake of posterity. Without further ado:

Millionaire Chicken Recipe

Published on January 1, 2014

2013 Top Listens

Straight from my LastFM profile:

  1. Guards (244)
  2. Born Ruffians (204)
  3. Courtney Barnett (204)
  4. Ghost Wave (194)
  5. Shout Out Louds (170)
  6. Mikal Cronin (166)
  7. The National (164)
  8. Yo La Tengo (156)
  9. BOAT (147)
  10. Arcade Fire (142)
  11. Diarrhea Planet (142)
  12. Beach Fossils (141)
  13. Colleen Green (134)
  14. Frankie Rose (132)
  15. Phosphorescent (129)
  16. Palma Violets (117)
  17. Bored Nothing (113)
  18. Ducktails (111)
  19. Psychic Ills (110)
  20. IO Echo (108)
  21. Starfucker (105)
  22. Mazes (99)
  23. Portugal. The Man (97)
  24. Belle and Sebastian (96)
  25. Deer Tick (96)
  26. Parenthetical Girls (93)
  27. The Joy Formidable (91)
  28. Those Darlins (89)
  29. HAIM (88)
  30. The Little Ones (88)
  31. The Pack A.D. (88)
  32. Surfer Blood (88)
  33. Psychic Friend (87)
  34. Dead Gaze (86)
  35. Foxygen (84)
  36. Surf City (81)
  37. Bass Drum of Death (80)
  38. The Spinto Band (78)
  39. Gold Fields (78)
  40. Bent Shapes (77)
  41. Nude Beach (76)
  42. Shannon and the Clams (74)
  43. Austra (72)
  44. Brazos (71)
  45. Daughn Gibson (71)
  46. The Thermals (70)
  47. The Avett Brothers (70)
  48. Lightning Dust (70)
  49. Small Black (70)
  50. Crocodiles (69)
Published on January 1, 2014

Sorry ‘cp’ I’m gonna be spending more time with ‘rsync’ now

So just updated my dev machine and was transferring files back to it via cp which was taking a long time. I just wanted to know how far along the command had progressed via a percentage/progress bar/etc. so that I could get a cup of coffee, or make lunch – if it was gonna take a very long time. I know it’s possible to do this but not by using cp alone.

So I found rsync after a little bit of googling. The part that I really like about it is the --progress option, which let’s you know via stdout how far along the command is.

Here is a basic example:

rsync --progress -a /path/to/source /path/to/destination

– This will copy a directory, show progress, and maintain ownership, permissions, modified via the -a option (Archive).

or, over the network:

rsync -zP /path/to/source handle@domain.tld:/path/to/destination

– This will copy source over the network connection specified, use compression, show progress and allow for continuing interrupted transfers.

P.S. As a preemptive measure you could also run du -sh on dirs before copying to get an idea of how big they actually are.

Published on December 3, 2013

Don’t store anything you need in /tmp

I know better but thought I’d write it here so I don’t forget. Again. Darn.

Here’s a black hole.
153309main_hidden_blackhole_lg
Image credit: NASA

Published on October 21, 2013

PHP and JS Email Obfuscator

I have been using some great email obfuscation code created by Ross Killen ,Tim Williams and Andrew Moulden. And like Andrew’s generator that allows for “link text”, I needed a PHP solution for sites I’m developing. So here’s my twist:

function munge($address,$link_text) {
	$address = strtolower($address);
	$coded = "";
	$unmixedkey = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789.@-_";
	$inprogresskey = $unmixedkey;
	$mixedkey="";
	$unshuffled = strlen($unmixedkey);
	for ($i = 1; $i <= strlen($unmixedkey); $i++) {
        // set i = 1 because i = 0 was throwing an offset error in PHP 
		$ranpos = rand(0,$unshuffled-1);
		$nextchar = $inprogresskey{$ranpos};
		$mixedkey .= $nextchar;
		$before = substr($inprogresskey,0,$ranpos);
		$after = substr($inprogresskey,$ranpos+1,$unshuffled-($ranpos+1));
		$inprogresskey = $before.''.$after;
		$unshuffled -= 1;
	}
	$cipher = $mixedkey;
	$shift = strlen($address);
	$txt = "<script type=\"text/javascript\" language=\"javascript\">\n" .
           "<!-"."-\n" .
           "// Email obfuscator script 2.1 by Tim Williams, University of Arizona\n".
		   "// Random encryption key feature by Andrew Moulden, Site Engineering Ltd\n".
		   "// PHP version coded by Ross Killen, Celtic Productions Ltd\n".
		   "// This code is freeware provided these six comment lines remain intact\n".
		   "// A wizard to generate this code is at http://www.jottings.com/obfuscator/\n".
		   "// The PHP code may be obtained from http://www.celticproductions.net/\n\n";
		   
	for ($j=0; $j<strlen($address); $j++) {
		if (strpos($cipher,$address{$j}) == -1 ) {
			$chr = $address{$j};
			$coded .= $address{$j};
		} else {
			$chr = (strpos($cipher,$address{$j}) + $shift) %
			strlen($cipher);
			$coded .= $cipher{$chr};
		}
	}
	
	if($link_text):
	
		$link_text_block = "document.write(\"<a href='mailto:\"+link+\"'>" . $link_text . "</a>\")\n";
		
	else:
		
		$link_text_block = "document.write(\"<a href='mailto:\"+link+\"'>\"+link+\"</a>\")\n";
		
	endif;
		
	$txt .= "\ncoded = \"" . $coded . "\"\n" .
			"  key = \"".$cipher."\"\n".
			"  shift=coded.length\n".
			"  link=\"\"\n".
			"  for (i=0; i<coded.length; i++) {\n" .
			"    if (key.indexOf(coded.charAt(i))==-1) {\n" .
			"      ltr = coded.charAt(i)\n" .
			"      link += (ltr)\n" .
			"    }\n" .
			"    else {     \n".
			"      ltr = (key.indexOf(coded.charAt(i))-shift+key.length) % key.length\n".
			"      link += (key.charAt(ltr))\n".
			"    }\n".
			"  }\n".
			// Original link markup
			//"document.write(\"<a href='mailto:\"+link+\"'>\"+link+\"</a>\")\n" .
			// Link markup from above
                        $link_text_block .
			"\n".
			"//-"."->\n" .
			"<" . "/script><noscript>Please turn on javascript to email me." .
			"<"."/noscript>";
	
	return $txt;
}
Published on October 16, 2013

Force page template on child pages in WordPress

This is something that could come in handy. I’ve found a need for it in using the Nextgen Gallery plugin with the gallery page link setting enabled.

// Force page template on child pages
$page_children = get_pages('child_of=13');
foreach($page_children as $child){
	$current_page_template = get_post_meta($child->ID,'_wp_page_template',true);
	if($current_page_template != 'page-OTHER_PAGE_TEMPLATE.php') update_post_meta($child->ID,'_wp_page_template','page-PARENT_PAGE_TEMPLATE.php');
}
Published on August 21, 2013