Skip to content

Instantly share code, notes, and snippets.

@Zauberfisch
Zauberfisch / conky-inxi.conf
Created May 18, 2017 20:38
easy script to display system stats using inxi and conky
conky.config = {
alignment = 'bottom_left',
background = true,
color2 = '588078',
cpu_avg_samples = 2,
default_color = '80FFF9',
double_buffer = true,
font = 'Droid Sans Mono:size=12',
draw_shades = false,
gap_x = 25,
@Zauberfisch
Zauberfisch / audio-switch.sh
Created October 12, 2016 03:44
shell script to switch pulseaudio output device
#!/bin/sh
# based on a script from a now deleted askubuntu answer on this question http://askubuntu.com/questions/71863/how-to-change-pulseaudio-sink-with-pacmd-set-default-sink-during-playback
# the script linked in the answer is still available at https://github.com/mpapis/home_dotfiles/blob/master/bin/mypa though
# dependencies: pulseaudio pacmd awk xargs grep volumeicon
# optional dependencies: zenity (for gui switch)
# this script assumes you are using volumeicon as a tray icon and will restart it on switch
# if you do not use volumeicon you should remove the 2 lines in switch_sink()
@Zauberfisch
Zauberfisch / i3-disable-focus-wrapping.md
Last active March 18, 2024 04:08
i3 Window Manager - disable focus wrapping / cycling

i3 Window Manager - disable focus wrapping / cycling

Switching window focus ($mod+Up / $mod+Right / $mod+Down / $mod+Left) in i3 cycles through all windows on a workspace, meaning when you hit one edge of the screen, it will start again on the other side.

I was looking for a way to disable that, but was unable to find a way to change this via configuration. Therefore I have created the following script.

Place i3-focus-nowrap.sh somewhere within your path (eg /usr/local/bin) or use an absolute reference in the keybindings below. And replace the keybindings in your .i3 config (eg ~/.i3/config)

@Zauberfisch
Zauberfisch / PhoneNumberField.php
Created July 22, 2015 20:10
Custom SilverStripe PhoneNumberField
<?php
/*
class MyDataObject extends DataObject {
private static $db = [
'FoobarCountryCode' => 'Varchar',
'FoobarAreaCode' => 'Varchar',
'FoobarPhoneNumber' => 'Varchar',
'FoobarExtension' => 'Varchar',
];
@Zauberfisch
Zauberfisch / BaseValidator.php
Last active August 29, 2015 14:13
Better SilverStripe Form Validator
<?php
/**
* @author zauberfisch
*/
class BaseValidator extends Validator {
protected $validateFields, $requireFields;
/**
* @param bool|string[]|\FormField[]|\FieldList $validateFields
ErrorDocument 404 /assets/error-404.html
ErrorDocument 500 /assets/error-500.html
<Files *.ss>
Order deny,allow
Deny from all
Allow from 127.0.0.1
</Files>
<Files web.config>
@Zauberfisch
Zauberfisch / A_SilverStripe_SkyScrapers_Example.md
Last active August 29, 2015 14:02
SilverStripe SkyScrapers Example

SilverStripe SkyScrapers Example

simple example of DataObjects
managed with ModelAdmin
filterable in the frontend

@Zauberfisch
Zauberfisch / OrderableManyManyGridField.php
Created March 10, 2014 06:34
SilverStripe 3.x GridField with Orderable/Sortable ManyMany List
<?php
class Page extends SiteTree {
private static $many_many = array(
'RelatedPages' => 'Page',
);
// be careful to name the many_many_extraField something that does not conflict with existing DB fields.
// eg: 'Sort' already exists on class SiteTree, so using that will get you into trouble.
private static $many_many_extraFields = array(
'RelatedPages' => array(
@Zauberfisch
Zauberfisch / DataObjectAsPage.php
Last active January 15, 2020 07:16
SilverStripe 3.x DataObject as Page with URLSegment
<?php
/**
* @author Zauberfisch
* @method ManyManyList Products()
*/
class ProductCategoryPage extends Page {
private static $many_many = array(
'Products' => 'Product',
);
@Zauberfisch
Zauberfisch / TranslatableControllerExtension.php
Last active December 23, 2015 13:41
SilverStripe Translatable defaults snippets
<?php
// file: mysite/code/TranslatableControllerExtension.php
class TranslatableControllerExtension extends Extension {
/**
* save the current controller to ensure we have access to it,
* this is necessary because Security crates a fake Page_Controller to render templates
* @var Controller
*/
protected static $actual_current_controller;