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 / file.php
Last active April 21, 2016 08:35
<?php
$query = Schedule::find();
$query->andWhere(['type' => 4]);
$models = $query->all();
var_dump($models);
@cebe
cebe / .gitignore
Last active April 21, 2022 14:34
CGAL fails to read OFF file generated by Minkowsky Sum https://github.com/CGAL/cgal/issues/978
/bug
/*.o
@cebe
cebe / mirror.php
Created February 10, 2016 18:45
Script for fetching all google code download files for migration.
<?php
function downloadfiles($url)
{
$json = file_get_contents($url);
if (!$json) {
return false;
}
//print_r(json_decode($json));
$data = json_decode($json);
@cebe
cebe / bug.c
Created December 6, 2015 03:09
Compile it with: clang -o utox -g -Wall -Wshadow -std=gnu99 ./bug.c `pkg-config --libs --cflags libv4lconvert` -fsanitize=address
static int utox_v4l_fd = -1;
#include <stdlib.h>
#include <stdio.h>
#include <stdint.h>
#include <string.h>
#include <ctype.h>
#include <fcntl.h>
@cebe
cebe / bug.cpp
Created November 21, 2015 16:25
CGAL bug report, compile with g++ -o bug bug.cpp -lCGAL
#include <CGAL/Simple_cartesian.h>
#include <CGAL/Polyhedron_3.h>
#include <iostream>
#include <string>
typedef CGAL::Simple_cartesian<double> Kernel;
typedef Kernel::Point_3 Point_3;
typedef Kernel::Vector_3 Vector_3;
typedef Kernel::Plane_3 Plane_3;
@cebe
cebe / suto.php
Created August 27, 2015 16:11
Yii 1.1 login as someone else
public function actionSuto()
{
$identity = UserIdentity::unauthenticatedById($_GET['id']);
if ($identity) {
Yii::app()->user->login($identity, 0);
}
$this->redirect(array('/site/index'));
}
@cebe
cebe / 123456789_my_extension_migration.php
Last active January 4, 2017 15:33
include yii2 extension migration into the application migration chain
<?php
// require the extension migration file
require(__DIR__ . '/../vendor/path/to/extension/migration/yymmsshhiiss_extension_migration.php');
// or if you want to use alias
//require(Yii::getAlias('@vendor/path/to/extension/migration/yymmsshhiiss_extension_migration.php'));
class yymmsshhiiss_my_extension_migration extends yymmsshhiiss_extension_migration
{
// no implementation needed
@cebe
cebe / going_crazy.php
Last active August 29, 2015 14:20
Magic explained for: http://3v4l.org/jNb0R
<?php
// assign the value foo to a variable named x
$x = "foo";
// assign the value bar to a variable named "x", the name includes the " ;)
${'"x"'} = "bar";
// assign the value of a variable, whos name you determine from the content
// of the HEREDOC, which is "x" (the name includes the "), to the variable named doc
$doc = "${<<<'HERE'
"x"
@cebe
cebe / getset.php
Created April 22, 2015 09:00
yii getter/setter
<?php
class MyClass extends \yii\base\Component
{
private $_value;
public function getValue()
{
if ($this->_value === null) {
$this->_value = /* your sql query here */;
@cebe
cebe / web.php
Created March 28, 2015 20:08
gii config
<?php
// ...
$config['modules']['gii'] = [
'class' => 'yii\gii\Module',
'allowedIPs' => ['127.0.0.1', '::1', '192.168.0.*', '192.168.178.20'] // adjust this to your needs
];