Check whether an array is empty

function in_multi_dimensional_array($multidimarray, $multidimarray_key, $lookingfor ) {
 $found = false;
 foreach ($multidimarray as $key => $data) {
  if ($data[$multidimarray_key] == $lookingfor) {
   // item found => add new keys & data if (!empty($multidimarray_newdata))
   $found = true;
   break; // no need to loop anymore, as we have found the item => exit the loop
  }
 }
 return $found;
}

function in_multi_dimensional_modifiable_array($multidimarray, $multidimarray_key, $lookingfor, $multidimarray_newdata = array() ) {
 $found = false;
 foreach ($multidimarray as $key => $data) {
  if ($data[$multidimarray_key] == $lookingfor) {
   // item found => add new keys & data if (!empty($multidimarray_newdata))
   foreach($multidimarray_newdata as $key => $value) {
    $data[$key] = $value;
   }
   $found = true;
   break; // no need to loop anymore, as we have found the item => exit the loop
  }
 }
 return $found;

// if ($found === false) {
 // The id you were looking for has not been found,
 // which means the corresponding item is not already present in your array
 // => Add a new item to the array
// }
}

Source: Check whether an array is empty

Posted in Hacks | Comments Off on Check whether an array is empty

Can I get a list of files marked –assume-unchanged?

What have I marked as –assume-unchanged? Is there any way to find out what I’ve tucked away using that option? I’ve dug through the .git/ directory and don’t see anything that looks like what I’d

Source: Can I get a list of files marked –assume-unchanged?

This is a great way to hide changes to files (e.g., db config files):

git config --global alias.hidden '!git ls-files -v | grep "^[a-z]"'

Here’s a complete selection of nice additions:

git config --global alias.hide '!git update-index --assume-unchanged'
git config --global alias.unhide '!git update-index --no-assume-unchanged'
git config --global alias.unhide-all '!git update-index --really-refresh'
git config --global alias.hidden '!git ls-files -v | grep "^[a-z]"'
git config --global alias.ignored '!git !git status -s --ignored | grep \"^!!\"'' 

Nifty!

Posted in Hacks | Tagged , | Comments Off on Can I get a list of files marked –assume-unchanged?

crontab.guru – the cron schedule expression editor

An easy to use editor for crontab schedules.

Source: crontab.guru – the cron schedule expression editor

1 8 4 * *
“At 08:01 on the 4th of every month.”
next at 2016-09-04 08:01
random

[minute] [hour] [date] [month] [weekday]

* any value
, value list separator
range of values
/ step values
@yearly (non-standard)
@annually (non-standard)
@monthly (non-standard)
@weekly (non-standard)
@daily (non-standard)
@hourly (non-standard)

More info here:

https://en.wikipedia.org/wiki/Cron

Posted in Hacks | Comments Off on crontab.guru – the cron schedule expression editor

Hangin w Common Sense

Isn’t it great! Talking to Billy on the phone!

Posted in Uncategorized | Comments Off on Hangin w Common Sense

XAMPP or MAMP – Can’t connect to mysql

You’ll need to update your DB config file…

What worked for me was adding this:

'mysql' => [
 'driver' => 'mysql',
 'host' => env('DB_HOST', 'localhost'),
 'database' => env('DB_DATABASE', 'db_name'),
 'username' => env('DB_USERNAME', 'db_user'),
 'password' => env('DB_PASSWORD', 'db_password'),
 'unix_socket' => '/Applications/XAMPP/xamppfiles/var/mysql/mysql.sock',
 'charset' => 'utf8',
 'collation' => 'utf8_unicode_ci',
 'prefix' => '',
 'strict' => false,
 'options' => [
 #PDO::MYSQL_ATTR_MAX_BUFFER_SIZE => 16777216
 PDO::MYSQL_ATTR_LOCAL_INFILE => true
 ]
],

Here’s one other solution:

I was getting some similar error and ended up here. I am using OSX 10.9.5. This solved my problems (hope it helps someone).

1) sudo mkdir /var/mysql
2) sudo ln -s /private/tmp/mysql.sock /var/mysql/mysql.sock

More informations: http://glidingphenomena.blogspot.com.br/2010/03/fixing-warning-mysqlconnect-cant.html

Thanks!

NOTE: Replace /var/mysql/mysql.sock with the path to your actual mysql.sock file (w XAMPP, it would be /Applications/XAMPP/xamppfiles/var/mysql/mysql.sock)

Posted in apache, MariaDB, MySQL, XAMPP | Tagged , , , , , | Comments Off on XAMPP or MAMP – Can’t connect to mysql

Common Sense | SoCal Reggae-Rock Band

This is a great band I love.

Source: Common Sense | SoCal Reggae-Rock Band

Posted in Hacks | Comments Off on Common Sense | SoCal Reggae-Rock Band

JavaScript version of var_dump

[et_pb_section admin_label=”section”][et_pb_row admin_label=”row”][et_pb_column type=”4_4″][et_pb_text admin_label=”Text” background_layout=”light” text_orientation=”left” use_border_color=”off” border_color=”#ffffff” border_style=”solid”]

<script>
function dump(obj) {
  var out = '';
  for (var i in obj) {
    out += i + ": " + obj[i] + "\n";
  }
  alert(out);
}
</script>

// or, if you wanted to avoid alerts and var_dump() on the page…

<script>
function dump(obj) {
  var out = '';
  for (var i in obj) {
    out += i + ": " + obj[i] + "\n";
  }
var pre = document.createElement('pre');
  pre.innerHTML = out;
  document.body.appendChild(pre)
}
</script>

// or var_dump() to the console…

<script>
function dump(obj) {
  var out = '';
  for (var i in obj) {
    out += i + ": " + obj[i] + "\n";
  }
  console.log(out);
}
</script>

 

[/et_pb_text][/et_pb_column][/et_pb_row][/et_pb_section]

Posted in coding | Tagged , , | Comments Off on JavaScript version of var_dump

Divi Theme: Add Copyright & Add Social Icons to Footer

[et_pb_section admin_label=”section”][et_pb_row admin_label=”row”][et_pb_column type=”4_4″][et_pb_text admin_label=”Text” background_layout=”light” text_orientation=”left” use_border_color=”off” border_color=”#ffffff” border_style=”solid”]

Here’re a couple of Divi Theme tips & tricks:

[/et_pb_text][et_pb_text admin_label=”Text – Code – CSS Color Footer Social Media Icons on :hover” background_layout=”light” text_orientation=”left” use_border_color=”off” border_color=”#ffffff” border_style=”solid” module_class=”ourLilCodeSnippet”]

/* CSS Color Footer Social Media Icons on :hover */
#footer-bottom .et-social-facebook a:hover { color: blue; }
#footer-bottom .et-social-twitter a:hover { color: powderblue; }
#footer-bottom .et-social-linkedin a:hover { color: #1c87be; }
#footer-bottom .et-social-rss a:hover { color: orange; }

[/et_pb_text][/et_pb_column][/et_pb_row][et_pb_row admin_label=”row”][et_pb_column type=”4_4″][et_pb_text admin_label=”Text – JavaScript Footer” background_layout=”light” text_orientation=”left” use_border_color=”off” border_color=”#ffffff” border_style=”solid”]

Replace Divi’s footer shout out via JavaScript with a Copyright notice & also add a Social Media Icon (LinkedIn):

[/et_pb_text][et_pb_text admin_label=”Text – Code – JS Replace Divi stuff w Copyright in Footer + add LinkedIn icon” background_layout=”light” text_orientation=”left” use_border_color=”off” border_color=”#ffffff” border_style=”solid” module_class=”ourLilCodeSnippet”]

<script type=”text/javascript”>

/* replace Divi shout out w Copyright for My Company */

var theYear = new Date().getFullYear();
document.getElementById(‘footer-info’).innerHTML = ‘&copy; ‘+theYear+’ My Comany. All rights reserved.’;

/* Add LinkedIn Social Networking Icon */

jQuery(“#footer-bottom .et-social-icons”).append(‘<li class=”et-social-icon et-social-linkedin”><a href=”https://www.linkedin.com/company/the-dalai-lama-foundation” class=”icon”><span>LinkedIn</span></a></li>’)
</script>

[/et_pb_text][et_pb_text admin_label=”Text” background_layout=”light” text_orientation=”left” use_border_color=”off” border_color=”#ffffff” border_style=”solid”]

I’m using jQuery .append() to append the LinkedIn icon. You can choose other social media icons by using one from the approved list. You’ll find instructions on that page to create a Divi Child Theme, which you can modify to make these changes. Not sure why anyone would want to muck around w PHP, which might cause other issues if you’re not careful, when you can use JavaScript?

There are jQuery-less methods that are really easy if you’re using IDs for this, but a bit more challenging if you’re not… 😉

[/et_pb_text][/et_pb_column][/et_pb_row][/et_pb_section]

Posted in coding | Tagged , , , | Comments Off on Divi Theme: Add Copyright & Add Social Icons to Footer

Cost to charge an iPhone for a year?

[et_pb_section admin_label=”section”][et_pb_row admin_label=”row”][et_pb_column type=”4_4″][et_pb_text admin_label=”Text” background_layout=”light” text_orientation=”left” use_border_color=”off” border_color=”#ffffff” border_style=”solid”]

Ever thought how much your iPhone (or Android smartphone) is costing you in power a year to charge? What about your tablet or laptop? Or your ebook reader? And do wall warts consume power when there’s nothing connected to them?

Source: How much does it cost to charge an iPhone for a year? | ZDNet

 


Cost per year at $0.12 / kWh

[/et_pb_text][et_pb_pricing_tables admin_label=”Pricing Tables” show_bullet=”on” center_list_items=”off” use_border_color=”off” border_color=”#ffffff” border_style=”solid” custom_button=”off” button_letter_spacing=”0″ button_use_icon=”default” button_icon_placement=”right” button_on_hover=”on” button_letter_spacing_hover=”0″ remove_featured_drop_shadow=”off”] [et_pb_pricing_table featured=”off” title=”iPhone” currency=”$” sum=”0.84″ header_font_select=”default” header_font=”||||” subheader_font_select=”default” subheader_font=”||||” currency_frequency_font_select=”default” currency_frequency_font=”||||” price_font_select=”default” price_font=”||||” body_font_select=”default” body_font=”||||” custom_button=”off” button_font_select=”default” button_font=”||||” button_use_icon=”default” button_icon_placement=”right” button_on_hover=”on” subtitle=”iPhone 6 Plus”]

+ 19.2 Wh overnight charge

+ 7kWh / year

[/et_pb_pricing_table][et_pb_pricing_table featured=”off” title=”iPad” currency=”$” sum=”1.55″ header_font_select=”default” header_font=”||||” subheader_font_select=”default” subheader_font=”||||” currency_frequency_font_select=”default” currency_frequency_font=”||||” price_font_select=”default” price_font=”||||” body_font_select=”default” body_font=”||||” custom_button=”off” button_font_select=”default” button_font=”||||” button_use_icon=”default” button_icon_placement=”right” button_on_hover=”on” subtitle=”iPad Air 2″]

+ 35.3 Wh overnight charge

+ 12.9kWh / yr

[/et_pb_pricing_table][et_pb_pricing_table featured=”off” title=”MacBook Pro” subtitle=”15″ currency=”$” sum=”5.63″ header_font_select=”default” header_font=”||||” subheader_font_select=”default” subheader_font=”||||” currency_frequency_font_select=”default” currency_frequency_font=”||||” price_font_select=”default” price_font=”||||” body_font_select=”default” body_font=”||||” custom_button=”off” button_font_select=”default” button_font=”||||” button_use_icon=”default” button_icon_placement=”right” button_on_hover=”on”]

+ 128.5 Wh overnight charge

+ 46.9kWh / yr

[/et_pb_pricing_table][et_pb_pricing_table featured=”off” title=”Kindle” currency=”$” sum=”0.01″ header_font_select=”default” header_font=”||||” subheader_font_select=”default” subheader_font=”||||” currency_frequency_font_select=”default” currency_frequency_font=”||||” price_font_select=”default” price_font=”||||” body_font_select=”default” body_font=”||||” custom_button=”off” button_font_select=”default” button_font=”||||” button_use_icon=”default” button_icon_placement=”right” button_on_hover=”on” subtitle=”Paperwhite”]

+ 7.7 Wh overnight charge

+ 0.1kWh / year

[/et_pb_pricing_table] [/et_pb_pricing_tables][/et_pb_column][/et_pb_row][/et_pb_section]

Posted in Hacks | Comments Off on Cost to charge an iPhone for a year?

Daring Fireball: RSS Readers

Daring Fireball[OT] Not sure if it’s open to discussion, but I don’t understand why all browsers don’t just display RSS (don’t get me wrong… NetNewswire is great, but sometimes I don’t want to launch another app… I just want to see an RSS feed).
But I tend to spend 80% of my browsing in Safari! 😉
FWIW, as for the subject of your article, IMNSHO RSS feeds are here to stay!

Source: Daring Fireball: RSS Readers

Posted in Browsers | Tagged , | Comments Off on Daring Fireball: RSS Readers