Skip to content

Instantly share code, notes, and snippets.

View d-amend's full-sized avatar

David Amend d-amend

  • Universität Siegen
  • Siegen
View GitHub Profile
@d-amend
d-amend / yamaha_rx-V677_http_control.md
Last active February 18, 2022 12:28
Controlling Yamaha Receiver RX-V677 via http

Controlling Yamaha RX-V677 via HTTP

Execute Commands via curl

curl --request POST \ --url http://receiver-ip/YamahaRemoteControl/ctrl \ --header 'Content-Type: Content-Type text/xml; charset="utf-8"' \ --data '<YAMAHA_AV cmd="PUT"><Main_Zone><Sound_Video><Tone><Bass><Val>0</Val><Exp>1</Exp><Unit>dB</Unit></Bass></Tone></Sound_Video></Main_Zone></YAMAHA_AV>'

*BSD/Darwin (macOS):
LC_ALL=C sed -i '' '/porn/d' $HISTFILE
Linux (GNU sed):
LC_ALL=C sed -i '/porn/d' $HISTFILE
This will remove all lines matching "porn" from your $HISTFILE.
With setopt HIST_IGNORE_SPACE, you can prepend the above command with a space character to prevent it from being written to $HISTFILE.
@d-amend
d-amend / Content-Security-Policy Header for nginx hosted Wordpress
Created January 9, 2022 14:55
Base for Content-Security-Policy Header for nginx hosted Wordpress. Needs hostname adjustments to use
add_header Content-Security-Policy "default-src 'none'; base-uri 'self'; media-src 'self'; img-src 'self' https://s.w.org https://wordpress.org https://ps.w.org data:; font-src 'self' data:; object-src 'none'; script-src 'self' 'unsafe-inline' 'unsafe-eval' ; style-src 'self' 'unsafe-inline'; connect-src 'self' wss://*.selfhostname.org; form-action 'self'; frame-ancestors 'self' *.validhosttoembedthissite.org; frame-src 'self' ; upgrade-insecure-requests;" always;
@d-amend
d-amend / make-doc
Last active May 19, 2021 11:34 — forked from publicarray/make-doc
Make a FreeBSD Handbook docset for Dash
#!/bin/bash
# thank you publicarray for the main work - this script is just a minor adaption
set -e
if ! command -v dashing >/dev/null 2>&1; then
if command -v go >/dev/null; then
brew install dashing
else
echo "Missing go. Install golang first 'brew install golang'"
@d-amend
d-amend / Batch-convert of files via ffmpeg
Created July 3, 2015 09:52
Batch-convert of files via ffmpeg
for f in *.m4a; do ffmpeg -i "$f" -b:a 256K -map a "${f%.m4a}.mp3"; done
@d-amend
d-amend / gist:37d20b423a3133b403c3
Created June 2, 2014 09:15
Animate alpha of an array of views step by step
/**
* The alpha is changed step by step in order of array
* @param duration the duration of the animations for each view
*/
- (void)animateAlphaForViews:(NSArray *)views to:(CGFloat)alpha duration:(CGFloat)duration
{
if (views.count > 0) {
UIView *view = views.firstObject;
NSMutableArray *newViews = [views mutableCopy];
@d-amend
d-amend / writeBundleVersionToSettingsBundle
Created September 5, 2013 09:29
Writes the CFBundleShortVersionString from the currently used Info.plist and the build number, generated from the git commit count to the Root.plist in a Settings.bundle
# Get the commit count
GIT_COMMIT_COUNT=`git rev-list --all | wc -l | tr -d ' '`
#copy template to settingsbundle
bundleVersion=$(/usr/libexec/PlistBuddy -c "Print CFBundleShortVersionString" "${PROJECT_DIR}/${INFOPLIST_FILE}")
#update Root.plist in settingsbundle with current version and build number
/usr/libexec/PlistBuddy -c "Set :PreferenceSpecifiers:0:DefaultValue $bundleVersion (build $GIT_COMMIT_COUNT)" "${PROJECT_DIR}"/Settings.bundle/Root.plist
@d-amend
d-amend / DAMCustomSuperViewController
Created June 12, 2013 08:18
Enforce calling super in Objective C superclasses (generates warning)
#import <UIKit/UIKit.h>
@interface DAMCustomViewController : UIViewController
//Enforce calling super
- (void)viewWillAppear:(BOOL)animated __attribute__((objc_requires_super));
- (void)viewDidAppear:(BOOL)animated __attribute__((objc_requires_super));
- (void)viewWillDisappear:(BOOL)animated __attribute__((objc_requires_super));
- (void)viewDidDisappear:(BOOL)animated __attribute__((objc_requires_super));
- (void)viewDidLoad __attribute__((objc_requires_super));
@d-amend
d-amend / gist:4206103
Created December 4, 2012 16:51
Selecting UITableViewCells in grouped UITableViews with custom color or view
#import <QuartzCore/QuartzCore.h>
@implementation CustomTableViewController
-(void)setSelectionViewForCell:(UITableViewCell*)cell withRoundedRectCorners:(UIRectCorner)rectCorners
{
CGRect cellRect = CGRectMake(0, 0, cell.bounds.size.width-18, cell.bounds.size.height);
UIView *view = [[UIView alloc] initWithFrame:cellRect];
if (rectCorners != 0) { //we need rounded corners, beginning or end of a tableViewSection