Skip to content

Instantly share code, notes, and snippets.

View cebe's full-sized avatar
☁️
working on cebe.cloud

Carsten Brandt cebe

☁️
working on cebe.cloud
View GitHub Profile
@cebe
cebe / randgraph.php
Last active August 29, 2015 14:01
Create random graphs with php and graphiz
<?php
$maxN = 10;
$maxE = 20;
// generate random edges
$e = [];
for($n = 1; $n <= $maxE; $n++) {
$e[] = [rand(1, $maxN), rand(1, $maxN)];
}
@cebe
cebe / tempcheck.php
Created February 8, 2014 14:08
Script that checks temperature using lm-sensors and reports high temp via beep.
<?php
$templine = `sensors | grep "temp1"`;
//echo $templine . "\n";
if (preg_match('/\+(\d+\.\d+)/', $templine, $matches)) {
$temp = (float) $matches[1];
//echo $temp;
if ($temp > 85) {
`beep -f 2400 -r 3`;
@cebe
cebe / constants.php
Created January 13, 2014 23:25
PHP Tutorial code about constants.
<?php
define('PI', 3.1415);
if (!defined('MY_CONSTANT')) {
define('MY_CONSTANT', 42);
}
echo MY_CONSTANT; // 42
@cebe
cebe / .xbindkeysrc
Created November 28, 2013 16:06
Swapping the PageUp,PageDown keys with Pos1,End on Lenovo keyboard. The Lenovo T530 has the pageup and pagedown keys placed directly over the arrow keys left and right. Navigation is quite unintuitive this way as I expect the Pos1 and End keys there to go to the start and end of the line. You'll need xdotool and xbindkeys: `sudo apt-get install …
// using the KP_* keys here to emulate behavior
// otherwise this will result in an endless loop
"xdotool key KP_Home"
Release+Prior
"xdotool key KP_End"
Release+Next
"xdotool key KP_Prior"
Release+Home
"xdotool key KP_Next"
Release+End
@cebe
cebe / ActiveRecordInterface.php
Created November 26, 2013 01:30
ActiveRecord Interface
<?php
/**
*
*
* @author Carsten Brandt <[email protected]>
*/
namespace yii\db;
@cebe
cebe / static.php
Last active December 28, 2015 21:49
static property overiding in php
<?php
class YiiBase
{
public static $app;
public static function test()
{
echo self::$app;
}
<?php
function fun($a = 'a', $b = 'b', $c = 'c')
{
echo $a . $b . $c;
}
fun($b = 'd');
// does output: dbc
@cebe
cebe / BehaviorA.php
Created October 25, 2013 13:55
trait event handling thinking...
<?php
trait BehaviorA
{
public function handleExampleEvent()
{
// do something
}
}
@cebe
cebe / main.cf
Last active December 26, 2015 07:49
example postfix config for sending root server replace #HOSTNAME# with your hostname and #DOMAIN# with your domain. example: hostname = tador.cebe.net domain = cebe.net Also make sure to replace [email protected] with your mail. I do not want to get your cron mails ;-)
# /etc/postfix/main.cf
## uncomment these when relaying via mail provider
## the host to relay via. The brackets mean "take the hostname itself, not its MX"
#relayhost = [mala.cebe.net]
## a fallback host to use if relayhost is not available
#smtp_fallback_relay= [hermes.bh-servers.net]
## uncommend these when you need smtp auth for mail provider
## put the following line in /etc/postfix/relay_password:
@cebe
cebe / EmailController.php
Created October 16, 2013 11:55
Autoloading namespaced model in yii 1.1
protected/controllers/EmailController.php
<?php
// no namespace needed here
class EmailController extends controller{
public function actionSend(){
$recipient = new \application\documents\email\Recipient();
}