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
@piscisaureus
piscisaureus / pr.md
Created August 13, 2012 16:12
Checkout github pull requests locally

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = [email protected]:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:

@crisu83
crisu83 / ModelGroupForm.php
Last active December 12, 2015 06:38
Yii form model that allows for using multiple models in the same form.
<?php
/**
* Class ModelGroupForm
*
* Note! Attributes must be defined as "modelName.attributeName", e.g. "user.name" in forms.
*/
class ModelGroupForm extends CFormModel {
/**
* @var CModel[] $models the model instances (name=>config).
@crisu83
crisu83 / ConfigBuilder.php
Last active December 13, 2015 23:09
Helper for building Yii application configurations.
<?php
/**
* ConfigBuilder class file.
* @author Christoffer Niska <[email protected]>
* @copyright Copyright &copy; Christoffer Niska 2013-
* @license http://www.opensource.org/licenses/bsd-license.php New BSD License
*/
/**
* Helper for building application configurations.
@karmi
karmi / .gitignore
Last active August 24, 2020 09:25
Elasticat makes Elasticsearch JSON responses pretty • http://git.io/elasticat
.DS_Store
tmp/
@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 / json.php
Created June 14, 2013 22:24
This is how json_encode() treats arrays...
<?php
$a = new StdClass();
$a->prop = 2;
$a->str = "hallo";
$a->arr = array(1,2,3);
echo json_encode($a); // {"prop":2,"str":"hallo","arr":[1,2,3]}
echo json_encode((array)$a); // {"prop":2,"str":"hallo","arr":[1,2,3]}
echo json_encode(array(1,2,3)); // [1,2,3]
@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
@renoirb
renoirb / files-ssl.cnf
Last active March 3, 2025 01:02
Creating on a server MySQL configuration. Using those three
[client]
ssl
ssl-ca=/etc/mysql/ca-cert.pem
ssl-cert=/etc/mysql/client-cert.pem
ssl-key=/etc/mysql/client-key.pem
[mysqld]
ssl
ssl-cipher=DHE-RSA-AES256-SHA
ssl-ca=/etc/mysql/ca-cert.pem
@kimus
kimus / ufw.md
Created March 2, 2014 22:46
NAT and FORWARD with Ubuntu’s ufw firewall

UFW

I use Ubuntu’s Uncomplicated firewall because it is available on Ubuntu and it's very simple.

Install UFW

if ufw is not installed by default be sure to install it first.

@igorw
igorw / turel.clj
Last active August 29, 2015 13:57
(ns turel.core
(:refer-clojure :exclude [==])
(:use clojure.core.logic))
(defn not-membero
[x l]
(conde [(emptyo l)]
[(fresh [head tail]
(conso head tail l)
(!= head x)