GoPro Hero III White Edition User Manual
GoPro Hero III Silver Edition User Manual
GoPro Hero III Black Edition User Manual
Saturday, November 3, 2012
Wednesday, October 31, 2012
Tuesday, August 28, 2012
How do I get iTunes to scrub backwards or forwards using my Mac's keyboard?
To scrub BACKWARDS, perform the following 3 key combination:
option command left-arrowTo scrub FORWARDS, simply use the right arrow rather than the left as shown below:
option command right-arrowOkay, it's official, you can now effectively and efficiently soak up iTunes U video lectures and tutorials (or any other iTunes content). Have fun.
Wednesday, August 22, 2012
How do I show hidden files in Finder in Mac OS X?
Execute the following two commands via Terminal.app:
To hide hidden files simply run the following two commands via Terminal.app:
defaults write com.apple.finder AppleShowAllFiles -bool YES killall Finder
To hide hidden files simply run the following two commands via Terminal.app:
defaults write com.apple.finder AppleShowAllFiles -bool NO killall Finder
Tuesday, August 14, 2012
How do I set a directory's owner, group, and permissions recursively on a *nix machine via the command line?
Execute the following commands via the command line:
The second command sets the owner and group permissions to rwx recursively.
The third command makes it so all new directories get created with the correct permissions (i.e. 2770).
The fourth command makes it so all new files get created with the correct permissions (i.e. rwx).
This post is simply a guide. Your values will differ depending on your desired outcome. In your case you may want to set only the group permissions or only the owner permissions (as opposed to both as illustrated in this post). The actual permission values you end up setting may differ too.
sudo chgrp -R _www /Users/user_dir/target_dir sudo chmod -R ug=rwx /Users/user_dir/target_dir sudo find /Users/user_dir/target_dir -type d -exec chmod 2770 {} \; sudo find /Users/user_dir/target_dir -type f -exec chmod ug=rwx {} \;The first command sets the group to _www recursively.
The second command sets the owner and group permissions to rwx recursively.
The third command makes it so all new directories get created with the correct permissions (i.e. 2770).
The fourth command makes it so all new files get created with the correct permissions (i.e. rwx).
This post is simply a guide. Your values will differ depending on your desired outcome. In your case you may want to set only the group permissions or only the owner permissions (as opposed to both as illustrated in this post). The actual permission values you end up setting may differ too.
Sunday, July 8, 2012
What's the fastest way to uninstall devtools on Mac OS X?
Open Terminal.app and then copy & paste the following command:
sudo /Developer/Library/uninstall-devtools –mode=allNote that a full uninstall like this will take some time to complete.
Monday, May 7, 2012
Does PHP have an array_map_recursive function that gives my callback access to the array's keys?
No. However, you can add this functionality to your project via the following code:
<?php function array_map_recursive(Array &$arr, $fnMap) { $fnHelper = function (Array $arr, $fnMap, $fnHelper) { $result = array(); foreach ($arr as $key => $value) { if (is_array($value)) { $fnMap($key, $null = NULL, $isKeyOnly = TRUE); $result[$key] = $fnHelper($value, $fnMap, $fnHelper); continue; } $fnMap($key, $value, $isKeyOnly = FALSE); $result[$key] = $value; } return $result; }; $arr = $fnHelper($arr, $fnMap, $fnHelper); }Note that array_walk_recursive provides similar functionality but falls short of our requirements due to the following caveat copy and pasted directly from php.net:
"You may notice that the key 'sweet' is never displayed. Any key that holds an array will not be passed to the function."Example usage would look like:
<?php // EXAMPLE CALLBACK $urldecode = function (&$key, &$value, $isKeyOnly) // NOTE THE 3 ARGS AND THE FACT THAT THE FIRST TWO ARE BY REF { $key = urldecode($key); $value = urldecode($value); }; // EXAMPLE DATA $data = array( '%21' => '%21', '%40' => '%40', '%23' => array( '1' => '%23', '3' => '%23', '2' => '%23', ), '%24' => '%24', '%25' => '%25', '%5E' => '%5E', '%26' => '%26', '%2A' => '%2A', ); // DEMO... echo "BEFORE:\n"; print_r($data); array_map_recursive($data, $urldecode); echo "\nAFTER:\n"; print_r($data); /* THE EXAMPLE CODE ABOVE OUTPUTS: BEFORE: Array ( [%21] => %21 [%40] => %40 [%23] => Array ( [1] => %23 [3] => %23 [2] => %23 ) [%24] => %24 [%25] => %25 [%5E] => %5E [%26] => %26 [%2A] => %2A ) AFTER: Array ( [!] => ! [@] => @ [#] => Array ( [1] => # [3] => # [2] => # ) [$] => $ [%] => % [^] => ^ [&] => & [*] => * ) */Looking for a cloud-based catalog and CRM platform? Checkout http://rocware.com/
Saturday, May 5, 2012
What's the fastest way to locate a WORD in a file via the command line?
cat path/to/your/file.txt | grep the_word_you_want_to_findThis technique comes in handy when you're trying to locate a certain configuration directive within a configuration file (as illustrated in the following example):
cat /etc/php5/apache2/php.ini | grep upload_max_filesize upload_max_filesize = 2M
What's the fastest way to locate a FILE via the command line?
find / -name 'file.txt'This technique comes in handy when you're trying to locate certain configuration files (as illustrated in the following example):
find / -name 'php.ini' /Applications/MAMP/bin/php/php5.2.17/conf/php.ini /Applications/MAMP/bin/php/php5.3.6/conf/php.ini
How can I tell which user Apache is running as using PHP?
Create a file in your root web directory named whoami.php with the following code inside:
http://YOURdomain.com/whoami.php
The name of the user Apache is running as will be displayed in your browser.
When you're finished testing, delete whoami.php.
<?php echo shell_exec('whoami');Then, access whoami.php using your browser at an address such as:
http://YOURdomain.com/whoami.php
The name of the user Apache is running as will be displayed in your browser.
When you're finished testing, delete whoami.php.
Monday, April 30, 2012
How can I capture user input from the cmd line using PHP?
Copy and paste the following command into your shell to create a new file in your current directory:
Next, experience your new PHP program (example.php) capture your user input from the cmd line by copying and pasting the following command into your shell:
vim example.phpCopy and paste the following text into your new example.php file:
<?php $name = trim(shell_exec("read -p 'Enter your name: ' name\necho \$name")); echo "Hello $name this is PHP speaking\n"; exit;Save the example.php file.
Next, experience your new PHP program (example.php) capture your user input from the cmd line by copying and pasting the following command into your shell:
php example.phpIt will prompt you with the following:
Enter your name:You will type your name and then hit enter as shown here:
Enter your name: JohnAfter you hit enter you'll see the PHP program we wrote print out the following text:
Hello John this is PHP speakingLooking for a cloud-based catalog and CRM platform? Checkout http://rocware.com/
Saturday, April 28, 2012
How do I add syntax highlighting to my Blogger blog?
Step 1) Via Blogger's admin panel, navigate to your "Template" section
Step 2) Click "Edit HTML"
Step 3) Accept the warning by clicking "Proceed"
Step 4) Find your template's </head> tag
Step 5) Copy and paste the following HTML code (omit the .js includes that aren't relevant to your site to increase page load time):
Step 6) Click "Save template"
Step 7) Click "Close"
Step 8) Create a new post in HTML mode using the following markup:
Step 9) Click "Publish" and you're done!
Additional information on the syntax highlighting code utilized on this blog and illustrated in this tutorial can be found at http://alexgorbatchev.com/SyntaxHighlighter/.
Looking for a cloud-based catalog and CRM platform? Checkout http://rocware.com/
Step 2) Click "Edit HTML"
Step 3) Accept the warning by clicking "Proceed"
Step 4) Find your template's </head> tag
Step 5) Copy and paste the following HTML code (omit the .js includes that aren't relevant to your site to increase page load time):
<!-- Syntax Highlighter Additions START --> <link href="http://alexgorbatchev.com/pub/sh/current/styles/shCore.css" rel="stylesheet" type="text/css" /> <link href="http://alexgorbatchev.com/pub/sh/current/styles/shThemeEmacs.css" rel="stylesheet" type="text/css" /> <script src="http://alexgorbatchev.com/pub/sh/current/scripts/shCore.js" type="text/javascript" /> <script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushAS3.js" type="text/javascript" /> <script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushBash.js" type="text/javascript" /> <script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushColdFusion.js" type="text/javascript" /> <script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushCSharp.js" type="text/javascript" /> <script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushCpp.js" type="text/javascript" /> <script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushCss.js" type="text/javascript" /> <script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushDelphi.js" type="text/javascript" /> <script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushDiff.js" type="text/javascript" /> <script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushErlang.js" type="text/javascript" /> <script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushGroovy.js" type="text/javascript" /> <script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushJScript.js" type="text/javascript" /> <script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushJava.js" type="text/javascript" /> <script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushJavaFX.js" type="text/javascript" /> <script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushPerl.js" type="text/javascript" /> <script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushPhp.js" type="text/javascript" /> <script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushPlain.js" type="text/javascript" /> <script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushPowerShell.js" type="text/javascript" /> <script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushPython.js" type="text/javascript" /> <script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushRuby.js" type="text/javascript" /> <script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushScala.js" type="text/javascript" /> <script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushSql.js" type="text/javascript" /> <script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushVb.js" type="text/javascript" /> <script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushXml.js" type="text/javascript" /> <script language="javascript" type="text/javascript"> SyntaxHighlighter.config.bloggerMode = true; SyntaxHighlighter.all(); </script> <!-- Syntax Highlighter Additions END -->
Step 6) Click "Save template"
Step 7) Click "Close"
Step 8) Create a new post in HTML mode using the following markup:
<pre class="brush:php;"> <?php $example = range(0, 9); foreach ($example as $value) { echo $value; } </pre>
Step 9) Click "Publish" and you're done!
Additional information on the syntax highlighting code utilized on this blog and illustrated in this tutorial can be found at http://alexgorbatchev.com/SyntaxHighlighter/.
Looking for a cloud-based catalog and CRM platform? Checkout http://rocware.com/
Is it possible to pass array keys by reference using PHP's native foreach control structure?
Answer: No. However, you can have by ref access to an array's keys using the following code:
Looking for a cloud-based catalog and CRM platform? Checkout http://rocware.com/
<?php ArrayUtil::ForEachFn($array, function (&$key, &$value) { // YOUR CODE HERE });To use this technique in your project simply add the following class:
<?php class ArrayUtil { public static function ForEachFn(Array &$array, $fn) { $newArray = array(); foreach ($array as $key => $value) { $fn($key, $value); $newArray[$key] = $value; } $array = $newArray; } }To see it all in action checkout the following example:
<?php // EXAMPLE ARRAY $array = array( 'key1' => 'value1', 'key2' => 'value2', 'key3' => 'value3', ); // BEFORE print_r($array); // EXAMPLE USAGE ArrayUtil::ForEachFn($array, function (&$key, &$value) { // NOTE THE FUNCTION'S SIGNATURE (USING & FOR BOTH $key AND $value) if ($key === 'key2') { $key = 'BY REF KEY EXAMPLE'; // THIS IS THE WHOLE POINT OF THIS POST } if ($value === 'value2') { $value = 'BY REF VALUE EXAMPLE'; } }); // AFTER print_r($array); /* THE ABOVE "EXAMPLE USAGE" OUTPUTS: Array ( [key1] => value1 [key2] => value2 [key3] => value3 ) Array ( [key1] => value1 [BY REF KEY EXAMPLE] => BY REF VALUE EXAMPLE [key3] => value3 ) */
Looking for a cloud-based catalog and CRM platform? Checkout http://rocware.com/
Friday, April 27, 2012
What's Visa's test credit card number?
4007000000027
Note: The expiration date submitted with the above number must be the current date or later.
Looking for a cloud-based catalog and CRM platform? Checkout http://rocware.com/
Note: The expiration date submitted with the above number must be the current date or later.
Looking for a cloud-based catalog and CRM platform? Checkout http://rocware.com/
What does PHP's print_r($_SERVER) output?
<?php print_r($_SERVER); /* THE ABOVE CODE OUTPUTS: Array ( [HTTP_HOST] => localhost:8888 [HTTP_USER_AGENT] => Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:11.0) Gecko/20100101 Firefox/11.0 [HTTP_ACCEPT] => text/html,application/xhtml+xml,application/xml; [HTTP_ACCEPT_LANGUAGE] => en-us,en;q=0.5 [HTTP_ACCEPT_ENCODING] => gzip, deflate [HTTP_CONNECTION] => keep-alive [HTTP_REFERER] => http://localhost:8888/?m=settings!subscription!upgrade [HTTP_COOKIE] => __utma=111872281.1314222649.1332850396.1335657071.1335660029.147 [PATH] => /Users/johnerck/svn/rocphp/path:/usr/bin:/bin:/usr/sbin:/sbin [SERVER_SIGNATURE] => [SERVER_SOFTWARE] => Apache/2.2.21 (Unix) mod_ssl/2.2.21 OpenSSL/0.9.8r DAV/2 PHP/5.3.6 [SERVER_NAME] => localhost [SERVER_ADDR] => ::1 [SERVER_PORT] => 8888 [REMOTE_ADDR] => ::1 [DOCUMENT_ROOT] => /Users/johnerck/git/rocware.com/www [SERVER_ADMIN] => you@example.com [SCRIPT_FILENAME] => /Users/johnerck/git/rocware.com/www/index.php [REMOTE_PORT] => 53964 [GATEWAY_INTERFACE] => CGI/1.1 [SERVER_PROTOCOL] => HTTP/1.1 [REQUEST_METHOD] => GET [QUERY_STRING] => m=dashboard [REQUEST_URI] => /?m=dashboard [SCRIPT_NAME] => /index.php [PHP_SELF] => /index.php [REQUEST_TIME] => 1335661670 [argv] => Array ( [0] => m=dashboard ) [argc] => 1 ) */Looking for a cloud-based catalog and CRM platform? Checkout http://rocware.com/
Monday, April 9, 2012
Why does wkhtmltopdf work via Terminal and fail via PHP's shell_exec() when using MAMP?
Question: Why does the following command line command:
wkhtmltopdf /path/to/html/input/file.html /path/to/pdf/output/file.pdf
work as expected when executed via Mac OSX Terminal but fail when executed via PHP's shell_exec() function via MAMP?
Answer: You need to comment out two lines of code within one of MAMP's configuration files.
Within MAMP's /Applications/MAMP/Library/bin/envvars file you'll notice the following two lines:
DYLD_LIBRARY_PATH="/Applications/MAMP/Library/lib:$DYLD_LIBRARY_PATH"
export DYLD_LIBRARY_PATH
Comment both of them out as demonstrated below (note the "#" prefix on each line):
#DYLD_LIBRARY_PATH="/Applications/MAMP/Library/lib:$DYLD_LIBRARY_PATH"
#export DYLD_LIBRARY_PATH
Lastly, within the same file, add the following command to make sure the $PATH environment variable inherited by PHP from Apache includes the directory that contains your wkhtmltopdf executable. Your command will look something like:
export PATH=/parent/path/of/wkhtmltopdf/executable:$PATH
Looking for a cloud-based catalog and CRM platform? Checkout http://rocware.com/
wkhtmltopdf /path/to/html/input/file.html /path/to/pdf/output/file.pdf
work as expected when executed via Mac OSX Terminal but fail when executed via PHP's shell_exec() function via MAMP?
Answer: You need to comment out two lines of code within one of MAMP's configuration files.
Within MAMP's /Applications/MAMP/Library/bin/envvars file you'll notice the following two lines:
DYLD_LIBRARY_PATH="/Applications/MAMP/Library/lib:$DYLD_LIBRARY_PATH"
export DYLD_LIBRARY_PATH
Comment both of them out as demonstrated below (note the "#" prefix on each line):
#DYLD_LIBRARY_PATH="/Applications/MAMP/Library/lib:$DYLD_LIBRARY_PATH"
#export DYLD_LIBRARY_PATH
Lastly, within the same file, add the following command to make sure the $PATH environment variable inherited by PHP from Apache includes the directory that contains your wkhtmltopdf executable. Your command will look something like:
export PATH=/parent/path/of/wkhtmltopdf/executable:$PATH
Looking for a cloud-based catalog and CRM platform? Checkout http://rocware.com/
Subscribe to:
Posts (Atom)
About Me
- John Erck
- I code. I figured I should start a blog that keeps track of the many questions and answers that are asked and answered along the way. The name of my blog is "One Q, One A". The name describes the format. When searching for an answer to a problem, I typically have to visit more than one site to get enough information to solve the issue at hand. I always end up on stackoverflow.com, quora.com, random blogs, etc before the answer is obtained. In my blog, each post will consist of one question and one answer. All the noise encountered along the way will be omitted.