Skip to content

Instantly share code, notes, and snippets.

☁️
working on cebe.cloud

Carsten Brandt cebe

☁️
working on cebe.cloud
Block or report user

Report or block cebe

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@cebe
cebe / objectToArray.php
Created Jun 19, 2019
workaround for object to array cast in PHP <7.2.0
View objectToArray.php
<?php
// workaround for object to array cast in PHP <7.2.0
// https://wiki.php.net/rfc/convert_numeric_keys_in_object_array_casts
// https://3v4l.org/05SPE
private function objectToArray($object)
{
if (PHP_VERSION_ID < 70200) {
// work around PHP bug https://3v4l.org/05SPE
// https://wiki.php.net/rfc/convert_numeric_keys_in_object_array_casts
if (is_object($object)) {
@cebe
cebe / view.php
Created Jun 3, 2019
Bootstrap 3 responsive level indicator
View view.php
<!-- put this code directly after <body> tag, for non-Yii environment, skip the if() statement -->
<?php if (YII_DEBUG): ?>
<!-- bootstrap responsive level indicator, only shown in debug mode -->
<div style="position: fixed; top: 0; left: 0; background: white; border: solid 1px #ccc; width: 25px; height: 18px; text-align: center; font-size: 10px; font-weight: bold; opacity: 0.5; z-index: 10000;" title="bootstrap responsive level indicator">
<span class="visible-xs-inline">xs</span>
<span class="visible-sm-inline">sm</span>
<span class="visible-md-inline">md</span>
<span class="visible-lg-inline">lg</span>
</div>
<?php endif; ?>
View Mongodb Cache.php
// My code
<?php
$collection=\app\models\Notifications::getCollection()->name;
if ($this->beginCache('Notifghjgjhgication', ['dependency' => [
'class' => 'yii\caching\DbQueryDependency',
'query' => \app\models\Notifications::find()->where(["receiver_type" => "vendor", "receiver_id" => \Yii::$app->user->identity->_id, 'read_status' => FALSE]),
'method' => 'count',
]])) {?>
<li class="dropdown" id="Notification-list-container">
<?= Yii::$app->runAction('/notification/default/notificationlist') ?>
@cebe
cebe / abc.sls
Last active Nov 22, 2017 — forked from tom--/abc.sls
View abc.sls
a:
lorem.ipsum
x:
lorem.dolor
y:
lorem.sit
b:
@cebe
cebe / remote-git.sh
Created Oct 25, 2017
quick remote git repo
View remote-git.sh
# prepare server
ssh root@10.0.3.39
git init --bare /srv/testrepo.git
exit
# in local repo
git remote add testrepo root@10.0.3.39:/srv/testrepo.git
@cebe
cebe / neo4j.conf
Created Oct 5, 2017
Neo4j stalt state files
View neo4j.conf
#*****************************************************************
# Neo4j configuration
#
# For more details and a complete list of settings, please see
# https://neo4j.com/docs/operations-manual/current/reference/configuration-settings/
#*****************************************************************
# The name of the database to mount
#dbms.active_database=graph.db
@cebe
cebe / pdobug.php
Last active Aug 14, 2017
Reproducing a PHP PDO bug
View pdobug.php
<?php
$tableSql = <<<SQL
DROP TABLE IF EXISTS `typebug`;
CREATE TABLE `typebug` (
`int_col` integer NOT NULL,
`int_col2` integer DEFAULT '1',
`smallint_col` smallint(1) DEFAULT '1',
`char_col` char(100) NOT NULL,
`char_col2` varchar(100) DEFAULT 'something',
@cebe
cebe / basicauth.php
Created May 2, 2017
allow basic auth for users not logged in
View basicauth.php
<?php
class SomeController extends yii\web\Controller
{
/**
* @var array actions to authenticate via basicAuth if not logged in.
*/
public $basicAuthActions = [];
/**
View AR.php
<?php
use yii\behaviors\TimestampBehavior;
public function behaviors()
{
return [
'timestamp' => function() {
$b = new TimeStampBehavior();
$b->attributes = [
ActiveRecord::EVENT_BEFORE_INSERT => ['created_at', 'updated_at'],
@cebe
cebe / phpmailer.sh
Last active Dec 28, 2016
command for finding vulnerable files and line of code for https://isc.sans.edu/forums/diary/Critical+security+update+PHPMailer+5218+CVE201610033/21855/ finds also really old versions, e.g. 2.0.4.
View phpmailer.sh
#!/bin/bash
for file in $(find /var/www |grep class.phpmailer.php) ; do echo $file; grep -ni '%s["'\''], $this->Sender' $file ; done
You can’t perform that action at this time.