Skip to content

Instantly share code, notes, and snippets.

Avatar

Jens Riisom Schultz Ibmurai

  • Denmark
View GitHub Profile
@Ibmurai
Ibmurai / tv2e.fish
Created May 8, 2018
Fish function to convert a letter to a TV 2 team
View tv2e.fish
function tv2e
switch "$argv"
case 'a'
echo "playfe"
case 'b'
echo "is"
case 'c'
echo "cms"
case 'd'
echo "app"
@Ibmurai
Ibmurai / lol.sh
Created Feb 7, 2017
Is tvtid backend good?
View lol.sh
#!/bin/bash
if [ $(curl -s -H "Accept: application/json" https://tvtid-backend.tv2.dk/tvtid-app-backend/schedules/channels | grep "{},") ]; then
echo "It's bad!!"
else
echo "It's good!"
fi
@Ibmurai
Ibmurai / docker-clean.sh
Created Jan 19, 2017
Full docker cleanup - remove every image and container
View docker-clean.sh
#!/bin/bash
docker stop $(docker ps -aq --filter status=running)
docker rm $(docker ps -aq)
docker rmi $(docker images -q)
@Ibmurai
Ibmurai / docker-sweep.sh
Created Jan 19, 2017
Non destructive docker cleanup
View docker-sweep.sh
#!/bin/bash
docker rm $(docker ps -aq --filter status=exited)
docker rmi $(docker images -f "dangling=true" -q)
@Ibmurai
Ibmurai / fixstuff.php
Created Sep 27, 2012
Fix all calls to htmlentities and htmlspecialchars, if you want to do ISO-8859-1 on PHP 5.4 or just be prepared.
View fixstuff.php
#!/opt/local/bin/php
<?php
function getDirectoryList($dir, $skipExtensions = []) {
$dirList = $fileList = [];
if ($dfp = opendir($dir)) {
while (($entry = readdir($dfp)) !== false) {
$skip = false;
foreach ($skipExtensions as $extension) {
if (substr($entry, strlen($entry) - strlen($extension)) === $extension) {
@Ibmurai
Ibmurai / php-log-highlight.php
Created Apr 27, 2012
PHP apache error log highlighter
View php-log-highlight.php
#!/usr/bin/php
<?php
/**
* Usage: tail -f /var/log/apache2/error.log | php-log-highlight
*/
ini_set('display_errors', E_ALL & ~E_STRICT);
// Dependencies
require_once 'Console/Color.php';
@Ibmurai
Ibmurai / lol.php
Created Feb 20, 2012
php unnamed variable and silly stdClass casting
View lol.php
<?php
$lol = null;
$$lol->enabled = true;
var_dump($$lol);
var_dump($lol);
/* Output:
PHP Strict Standards: Creating default object from empty value in /Users/ibmurai/lol.php on line 4
@Ibmurai
Ibmurai / lol.js
Created Feb 6, 2012
A basic pattern for jQuery plugins
View lol.js
(function($) {
$.fn.lol = function() {
var scope = function($this) {
var f = {
/**
* The "constructor"
*/
init : function() {
console.log('init');
@Ibmurai
Ibmurai / PHP - finding escaped backslashes
Created Aug 19, 2011
PHP, regex and double quoted strings are fun...
View PHP - finding escaped backslashes
<?php
/* This handy script lets you locate escaped backslashes in the prettiest way. */
$input = $_POST['value'];
$matches = array();
if (preg_match("/\\\\/", $input, $matches)) {
var_dump($matches);
} else {
You can’t perform that action at this time.