Skip to content

Instantly share code, notes, and snippets.

View dypsilon's full-sized avatar

Tim Navrotskyy dypsilon

View GitHub Profile
@dypsilon
dypsilon / css3-reset.css
Created April 19, 2011 22:16
CSS3 Reset
/* via http://blog.mostof.it/a-basic-css3-reset/ */
/* had no opportunity to use it yet */
* { outline: 0; }
html, body { min-height: 100%; }
body, ul, ol, dl { margin: 0; }
img { border: 0; }
article, aside, audio, footer, header, nav, section, video { display: block }
input[type="submit"]::-moz-focus-inner, input[type="button"]::-moz-focus-inner { border : 0px; }
input[type="search"] { -webkit-appearance: textfield; }
@dypsilon
dypsilon / gist:961343
Created May 8, 2011 12:33
Explaned to a friend how to use loops in java.
public void printAccounts() {
for (int i = 0; i < accounts.length; i++) {
// schleifenlogik
Account currentAccount = accounts[i];
Customer owner = currentAccount.getOwner();
Integer id = currentAccount.getId();
@dypsilon
dypsilon / index.php
Created May 31, 2011 22:49
Installing Zend Framework strategically (goo.gl/LQ5qO) / index.php
<?php
// Define path to application directory
defined('APPLICATION_PATH')
|| define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../application'));
// Configure the include path.
$zendFrameworkPath = realpath(APPLICATION_PATH . '/../../zf/1.11.6');
if ($zendFrameworkPath === false) {
@dypsilon
dypsilon / BadExample.php
Created June 4, 2011 23:09
The power of empty
<?php
if(isset($someArray) && is_array($someArray)
&& array_key_exists('firstKey', $someArray)
&& array_key_exists('secondKey', $someArray['firstKey'])
&& array_key_exists('thirdKey', $someArray['firstKey']['secondKey'])) {
echo $someArray['firstKey']['secondKey']['thirdKey'];
}
@dypsilon
dypsilon / TheSolution.php
Created June 4, 2011 23:19
The power of empty
if(!empty($someArray['firstKey']['secondKey']['thirdKey'])) {
echo $someArray['firstKey']['secondKey']['thirdKey'];
}
@dypsilon
dypsilon / TheSolution.php
Created June 4, 2011 23:19
The power of empty
<?php
if(!empty($someArray['firstKey']['secondKey']['thirdKey'])) {
echo $someArray['firstKey']['secondKey']['thirdKey'];
}
@dypsilon
dypsilon / ConfigurationUseCase.php
Created June 4, 2011 23:26
The power of empty
<?php
$configuration = array(
'projectName' => 'double-ypsilon',
'useCaching' => true,
);
@dypsilon
dypsilon / InitialCode.php
Created June 4, 2011 23:57
Guard Clause
<?php
public function markActiveNode($navigation, $currentUrl)
{
if(!empty($navigation['nodes']) && is_array($navigation['nodes']) {
foreach ($navigation['nodes'] as $node) {
$node['isActive'] = false;
if(!empty($node['url'])) {
if($node['isVisible']) {
$node['isActive'] = ($node['url'] === $currentUrl);
<?php
public function markActiveNode($navigation, $currentUrl)
{
if(empty($navigation['nodes']) or !is_array($navigation['nodes']) {
return $navigation;
}
foreach ($navigation['nodes'] as $node) {
$node['isActive'] = false;
<?php
foreach ($navigation['nodes'] as $node) {
$node['isActive'] = false;
if(empty($node['url'])) {
continue;
}
if($node['isVisible']) {