Skip to content

Instantly share code, notes, and snippets.

View Rudis1261's full-sized avatar

Rudi Strydom Rudis1261

View GitHub Profile
@Rudis1261
Rudis1261 / PHP.sublime-settings
Last active August 29, 2015 14:03
Sublime Preference
{
"word_separators": "./\\()\"'-:,.;<>~!@#%^&*|+=[]{}`~?"
}
@Rudis1261
Rudis1261 / convert_to_720p.sh
Created July 12, 2014 16:26
A quick video conversion script, $1 is the input Video and $2 the output video name.
#!/usr/bin/sh
#ffmpeg -i $1 -vf scale=-1:480 -b:v 500k -maxrate 500k -crf 23 -c:a mp3 -strict -2 -b:a 128k $2
#ffmpeg -i $1 -codec:v libx264 -profile: high -preset slow -b:v 500k -maxrate 500k -bufsize 1000k -vf scale=-1:480 -threads 0 -codec:a mp3 -b:a 128k $2
#ffmpeg -i $1 -codec:v libx264 -profile:v main -preset slow -b:v 400k -maxrate 400k -bufsize 800k -vf scale=-1:480 -threads 4 -codec:a mp3 -b:a 128k $2
ffmpeg -i $1 -codec:v libx264 -profile:v main -preset slow -b:v 1500k -maxrate 1500k -bufsize 2000k -vf scale=-1:720 -threads 4 -codec:a mp3 -b:a 96k $2
@Rudis1261
Rudis1261 / ga_events.js
Last active May 11, 2016 21:41
GA Universal dataLayer event Tracking
<script type="text/javascript">
/*eslint-env browser*/
/*global ga*/
(function(e) {
'use strict';
function ucfirst(string) {
@Rudis1261
Rudis1261 / ga_url_tracking_via_gtm.js
Last active August 29, 2015 14:16
This is to be able to inspect the url query string and send the details to Google Analytics through Google Tag Manager
<script type="text/javascript">
/*eslint-env browser*/
/*global ga*/
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
@Rudis1261
Rudis1261 / install-sublime-text.sh
Last active August 29, 2015 14:17
An adaptation of the sublime text 3 installer found here http://www.simonewebdesign.it/install-sublime-text-3-on-fedora-20/
#!/bin/sh
# Sublime Text 3 install with Package Control
# http://simonewebdesign.it/blog/install-sublime-text-3-on-fedora-20/
curl -o ~/st3.tar.bz2 $1
if tar -xf ~/st3.tar.bz2 --directory=$HOME; then
sudo mv ~/sublime_text_3/ /opt/
sudo ln -s /opt/sublime_text_3/sublime_text /bin/sublime
fi
@Rudis1261
Rudis1261 / center_crop.sh
Created March 25, 2015 06:57
Center Cropping images with ImageMagick
echo "Creating thumbnail of ${1}, to ${2}"
echo "Dimensions: ${3}px X ${4}px"
convert $1 -format png -strip -resize $3'x'$4'^' -gravity center -crop $3x$4'+0+0' $2
@Rudis1261
Rudis1261 / test.go
Last active August 29, 2015 14:19
Go Lang Testing Number Divisibilities
package main
import "fmt"
func main() {
for i := 1; i < 100; i++ {
if i %2 == 0 && i %3 == 0 && i %4 == 0 {
fmt.Println(i)
}
}
}
@Rudis1261
Rudis1261 / delete_all_contacts.php
Created May 15, 2015 11:28
Shell Script to Delete all Magento Contacts
<?php
// Delete all users from the database
// Can only be run from the command line
if (! isset($_SERVER['argv'][0])) {
header("HTTP/1.1 403 Unauthorized");
die("Access Denied");
}
// Otherwise make sure the user confirmed
@Rudis1261
Rudis1261 / migrate.sh
Created June 26, 2015 09:03
Migrating Data from one drive to another
tar --numeric-owner --one-file-system \
--exclude='proc' \
--exclude='dev' \
--exclude='sys' \
--exclude='x/*' -cBpf - * | ( cd /x && tar -xBpf - )
@Rudis1261
Rudis1261 / test.php
Created July 15, 2015 14:57
Just creating a quick test to ensure that a float gets converted to the correct INT value expected by SnapScan
<?php
$amount = (!empty($_GET['amount'])) ? $_GET['amount'] : 50;
$amount = $amount * 100;
$amount = (int)$amount;
$merchant = (!empty($_GET['merchant'])) ? $_GET['merchant'] : 'snapTest';
header("location:https://pos.snapscan.io/qr/{$merchant}?amount={$amount}&id=TestingTheAccount&strict=true");