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 / Makefile
Last active January 25, 2023 09:49
How to run docker commands as your local user, not root
# This is a Makefile that implements helpers for a docker stack
#
# This example shows how to run a bash in a docker-compose container as your local user,
# so files are created owned by that user instead of root.
#
# For this to work, the user inside the container must have the same ID as the user outside.
# The name does not matter much but to avoid confusion it is helpful to make them have the same user name.
# You get a users ID by running the `id -u` command, and the users name is `whoami`.
#
# How it works:
<?php
// add a spinner to the upload button when it is clicked
$this->registerJs(<<<JS
$('#import-form').on('beforeSubmit', function() {
var button = $(this).find('#import-submit-button');
button.prop('disabled', true);
button.append(' <i class="fa fa-spinner fa-spin"></i>');
});
JS
@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 / PHP-Array.groovy
Created March 25, 2021 10:35
PHP Array exporter for PHPStorm
/*
* Based on IntelliJ PHPStorm JSON exporter.
*
* Available context bindings:
* COLUMNS List<DataColumn>
* ROWS Iterable<DataRow>
* OUT { append() }
* FORMATTER { format(row, col); formatValue(Object, col); getTypeName(Object, col); isStringLiteral(Object, col); }
* TRANSPOSED Boolean
* plus ALL_COLUMNS, TABLE, DIALECT
@cebe
cebe / snippet.php
Created March 19, 2012 20:39
yii: run console command inside webapplication action
<?php
// ...
$runner=new CConsoleCommandRunner();
$runner->commands=array(
'commandName' => array(
'class' => 'application.commands.myCommand',
),
);
ob_start();
@cebe
cebe / composer.lock
Last active April 10, 2020 15:29
composer.lock example
{
"_readme": [
"This file locks the dependencies of your project to a known state",
"Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically"
],
"hash": "8ca6b6b80bab36b5287b4292abee988f",
"packages": [
{
"name": "bower-asset/bootstrap",
@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 / main.php
Last active June 21, 2019 09:25
REST routing with Yii 2 UrlManager
<?php
return array(
/* ... */
'components' => array(
/* ... */
'urlManager' => array(
'enablePrettyUrl' => true,
'rules' => require(__DIR__ . '/routes.php'),
),
@cebe
cebe / objectToArray.php
Created June 19, 2019 08:36
workaround for object to array cast in PHP <7.2.0
<?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 June 3, 2019 15:48
Bootstrap 3 responsive level indicator
<!-- 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; ?>