Skip to content

Instantly share code, notes, and snippets.

@demaisj
demaisj / batcheck.sh
Created December 4, 2016 15:31
Low Battery Alert
#!/bin/bash
#
# TO BE RUN EACH 5 MINUTES
#
BATTERY="/sys/class/power_supply/BAT0"
CRITICAL=10
ICON="battery-caution"
NOT_CHARGING="Discharging"
@demaisj
demaisj / build_get_url.php
Created August 1, 2014 12:46
Builds an URL with GET params in PHP
<?php
/**
* Build an URL with GET params
* @param string $url The URL
* @param array $params The GET params to append to the url
* @return string The new builded URL
*/
function build_get_url($url, $params){
$index = 0;
<link rel="import" href="../core-icon-button/core-icon-button.html">
<link rel="import" href="../core-toolbar/core-toolbar.html">
<link rel="import" href="../core-menu-button/core-menu-button.html">
<link rel="import" href="../core-icons/core-icons.html">
<link rel="import" href="../core-item/core-item.html">
<link rel="import" href="../core-menu/core-submenu.html">
<link rel="import" href="../core-drawer-panel/core-drawer-panel.html">
<link rel="import" href="../core-icons/iconsets/av-icons.html">
<link rel="import" href="../paper-fab/paper-fab.html">
@demaisj
demaisj / improved_native_for_loop.php
Created September 3, 2013 10:00
PHP : Improved native for loop variations for much speed when iterating
<?php
$array = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
for($i = count($array)-1;$i >= 0; $i--) {
echo $array[$i].", ";
};
/* Will produce :
10, 9, 8, 7, 6, 5, 4, 3, 2, 1,
@demaisj
demaisj / checkbox_checked_state.php
Last active December 21, 2015 15:38
PHP : Check if checkbox is checked
<?php
// <input type="checkbox" name="checkbox" value="1" />
$checked = isset($_GET['checkbox']) && $_GET['checkbox'] ? true : false;