Skip to content

Instantly share code, notes, and snippets.

Peter Mescalchin magnetikonline

Block or report user

Report or block magnetikonline

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@magnetikonline
magnetikonline / nginx.conf
Last active Aug 29, 2015
SilverStripe improved Nginx configuration built upon http://doc.silverstripe.org/framework/en/installation/nginx.
View nginx.conf
location / {
try_files $uri /framework/main.php?url=$uri&$query_string;
}
error_page 404 /assets/error-404.html;
error_page 500 /assets/error-500.html;
location ^~ /assets/ {
sendfile on;
try_files $uri =404;
@magnetikonline
magnetikonline / README.md
Last active Aug 29, 2015
Install Windows 7 ISO to USB key.
View README.md

Install Windows 7 ISO to USB key

Plug in USB key and get device name:

$ df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda1             110G   34G   71G  33% /
udev                  7.9G  4.0K  7.9G   1% /dev
tmpfs                 1.6G  1.5M  1.6G   1% /run
@magnetikonline
magnetikonline / README.md
Last active Aug 29, 2015
PHP array addition examples.
View README.md

PHP array addition

Example script

<?php
$first = [
	'one' => 'first',
	'two' => 'first',
	'three' => 'first'
];
@magnetikonline
magnetikonline / README.md
Last active Aug 29, 2015
XBMC update library paths.
View README.md

XBMC update library paths

Taken from XBMC Wiki.

Video library

SQL

UPDATE art SET url = REPLACE(url,'nfs://192.168.0.2/','nfs://nas/');
UPDATE episode SET c18 = REPLACE(c18,'nfs://192.168.0.2/','nfs://nas/');
UPDATE movie SET c22 = REPLACE(c22,'nfs://192.168.0.2/','nfs://nas/');
@magnetikonline
magnetikonline / README.md
Last active Aug 29, 2015
AWS s3curl.pl example.
View README.md

AWS s3curl.pl example usage

Perl wrapper script for curl from Amazon to GET/PUT items to/from S3 buckets, adding the required headers to the curl command line.

Download: http://aws.amazon.com/code/128

Listing a bucket

$ chmod u+x s3curl.pl
$ ./s3curl.pl \
	--id [AWS_KEY] \
@magnetikonline
magnetikonline / run.sh
Last active Aug 29, 2015
Testing jpegtran (libjpeg-turbo) vs. mozjpeg compression abilities on a set of source JPEGs.
View run.sh
#!/bin/bash
rm turbo/*
rm mozjpeg/*
cd orig/
echo libjpeg-turbo
find . -name "*.jpg" -exec jpegtran -optimize -copy none -outfile "{}.tmp" "{}" \; -exec mv "{}.tmp" "../turbo/{}" \;
echo Done
@magnetikonline
magnetikonline / README.md
Last active Aug 29, 2015
AWS summary of EC2 storage types.
View README.md

AWS summary of EC2 storage types

For my own sanity, as I always seem to struggle with this.

Elastic block store (EBS)

  • Can be attached to any EC2 instance in the same availability zone.
  • Recommended for long term persistence.
  • Can attach multiple EBS volumes to a single EC2 instance.
  • Survives reboot, stop/start and terminate (but only if not the root EBS volume).

Instance storage (ephemeral)

@magnetikonline
magnetikonline / README.md
Created Sep 29, 2014
Extract unique HTTP request lines from access.log.
View README.md

Extract unique HTTP request lines from access.log

$ cat access.log \
	| grep "] \"GET /wp-content/themes/" \
	| awk '{print $7}' \
	| sort -u
@magnetikonline
magnetikonline / addoneday.sh
Created Oct 8, 2014
Add one day to file modification time on a collection of files in bash.
View addoneday.sh
#!/bin/bash
find . -type f -exec touch -r "{}" -d '+1 day' "{}" \;
@magnetikonline
magnetikonline / clone.sh
Created Oct 21, 2014
Git shallow clone repository and any sub-modules within.
View clone.sh
#!/bin/bash
git clone --depth 1 \
-qb $BRANCH_NAME \
$REPOSITORY_URL $TARGET_CLONE_DIR
cd $TARGET_CLONE_DIR
git submodule update -q --init --depth 1
You can’t perform that action at this time.