This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class DottedExpandArray{ | |
/* This class will expand dotted array to multidimensional array. | |
For eg, | |
array( | |
'fish.in.pond' => 'its there', | |
'fish.on.tree' => 'Not possible', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function getDottedExpandedArray($array){ | |
$finalArray = array(); | |
foreach ($array as $key => $value) { | |
$sub_count = substr_count($key, '.')+1; | |
$json = '{"' . str_replace('.', '" : {"', $key); | |
$json .= '" : "'.$value.'"'.str_repeat('}', $sub_count); | |
$array = json_decode($json, true); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from formencode import FancyValidator, Invalid | |
import dateutil | |
import formencode | |
class validators: | |
class ISODateTime(FancyValidator): | |
""" | |
Validate and converts ISO formatted datetime string to python | |
datetime object |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* Simple script to send mail using php mail(). | |
The content of the mail will generating by iterating each | |
key in $_POST variable. | |
If you want to verify captch please send reCAPTCHA='yes' in | |
request form | |
Response: It'll be in JSON containing two element. | |
'response' and 'msg' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.dispatch.dispatcher import Signal | |
from celery import shared_task | |
# Warning. Monkey patch. | |
# in the kwargs signal recievers are passed an instance of django.display.dispatcher.Signal and | |
# this contains an instance of threading.Lock - an object that can't be pickled. | |
# This leads me to the monkey patch that was shown at the start of this article which | |
# simply adds a __reduce__ method to the Signal class that alters the pickle behaviour and only | |
# pickles the provided_args property of the Signal instance. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function formatSizeUnits($bytes) { | |
if ($bytes >= 1073741824) { | |
$bytes = number_format($bytes / 1073741824, 2) . ' GB'; | |
} elseif ($bytes >= 1048576) { | |
$bytes = number_format($bytes / 1048576, 2) . ' MB'; | |
} elseif ($bytes >= 1024) { | |
$bytes = number_format($bytes / 1024, 2) . ' KB'; | |
} elseif ($bytes > 1) { | |
$bytes = $bytes . ' bytes'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Get Virtual Thermostat here: http://forum.micasaverde.com/index.php?topic=8363.0 | |
local lul_vdev_thermostat = 48 | |
local lul_dev_sensor = 43 | |
local lul_dev_ac = 37 | |
local DEFAULT_COOL_SP = 26 | |
-- Desired temperature mode in Virtual Thermostate | |
local modeStatus = luup.variable_get ("urn:upnp-org:serviceId:HVAC_UserOperatingMode1", "ModeStatus", lul_vdev_thermostat) | |
-- Desired temperature set in Virtual Thermostate | |
local coolSp = tonumber (luup.variable_get ("urn:upnp-org:serviceId:TemperatureSetpoint1_Cool", "CurrentSetpoint", lul_vdev_thermostat), 10) or DEFAULT_COOL_SP |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
cnt = 0 | |
o = None | |
with open('/tmp/00001.vcf') as f: | |
for l in f.readlines(): | |
if 'BEGIN:VCARD' in l: | |
o = open('/tmp/contacts/%s.vcf' % cnt, 'w') | |
o.write(l) | |
if 'END:VCARD' in l: | |
o.close() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
UseCanonicalName Off | |
DocumentRoot "/var/www/vhosts/example-wildcard" | |
<Directory "/var/www/vhosts/example-wildcard"> | |
Options FollowSymLinks | |
AllowOverride All | |
Order allow,deny | |
Allow from all | |
</Directory> |
OlderNewer