Skip to content

Instantly share code, notes, and snippets.

@pimpreneil
pimpreneil / README.md
Created September 16, 2022 13:24
Detect disk failures from HPE Smart Storage Administrator

Introduction

You don't want to pay for an iLO subscription but still want to be warned if one of your RAID drive was to fail, this script is made for you!

Prerequisites

  • Python 3
  • SSACLI (from Windows Server Service Pack)

Execution

python3 check-drives.py
@pimpreneil
pimpreneil / automate-wpml.php
Last active August 24, 2022 16:58
Small script to extract/import XLIFF from WPML with code for Wordpress translation
<?php
require_once('wp-load.php');
require_once('wp-content/plugins/sitepress-multilingual-cms/inc/wpml-private-actions-tm.php');
use WPML\TM\AutomaticTranslation\Actions\Actions;
define( 'WP_DEBUG', true );
error_reporting(E_ALL);
@pimpreneil
pimpreneil / fix-email-maildir-timestamps.sh
Last active September 5, 2020 18:44
Fix email maildir timestamps
#!/bin/bash
# Fix emails with bad timestamps in a maildir
# This script reads the date from the email header and set its UNIX timestamp and renames it with the proper date
# e.g. this:
# dec. 05 2017 1512499812.M908995P21566.ip-111-11-11-11,S=16331,W=16746:2,S
# becomes that (the email Date header is "Date: Tue, 22 Oct 2013 10:07:21 +0100"):
# oct. 22 2013 1382432841.M908995P21566.ip-111-11-11-11,S=16331,W=16746:2,S
cd "/var/mail/my@account.org/MyMailDir/cur";
@pimpreneil
pimpreneil / vlc-loop-screen.c
Last active August 23, 2016 10:10
VLC path to XScreen as Loop
#define _GNU_SOURCE
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <vlc/vlc.h>
#include <signal.h>
#include <dirent.h>
#include <string.h>
#include <X11/Xlib.h>
#include <glib.h>
@pimpreneil
pimpreneil / cert.sh
Created January 7, 2016 13:16
Create a certification authority and certify a self-signed certificate using openssl
# Create the CA key
openssl genrsa -out ca.key 4096
# Create the CA cert
openssl req -new -x509 -days 1826 -key ca.key -out ca.crt
# Create the certif key
openssl genrsa -out ia.key 4096
# Create the certification request
openssl req -new -key ia.key -out ia.csr
# Create the final certificate
openssl x509 -req -days 730 -in ia.csr -CA ca.crt -CAkey ca.key -set_serial 01 -out ia.crt
@pimpreneil
pimpreneil / ThinController.php
Last active January 7, 2016 11:26
Sexy routing (avoiding magical annotations)
<?php
class ThinController
{
public function editAction(Request $request, $_template)
{
$id = $request->attributes->get('id');
$form = $this->get('model.form_handler')->createForm($id);
return $this->render($_template, array('form' => $form));
@pimpreneil
pimpreneil / APNS command 3
Created January 30, 2014 09:31
Function to create an Apple APNS command 3 push payload
// token: An apple token
// message: The message to push
// id: The push message identifier
// expiry: Push expiration date
// priority: Priority (5 or 10)
public function createPayload($token, $message, $identifier, $expiry, $priority)
{
$body = json_encode(array('aps' => array('alert' => $message)), JSON_UNESCAPED_UNICODE);
$packedToken = pack("H*", $token);
@pimpreneil
pimpreneil / gist:4714483
Last active December 12, 2015 04:28
First working version of a semantic zoom with the full alphabet and disabled letters
// Sorts the groups.
function compareGroups(leftKey, rightKey) {
return leftKey.toString().charAt(0).charCodeAt(0) - rightKey.toString().charAt(0).charCodeAt(0);
}
// Returns the group key that an item belongs to.
function getGroupKey(dataItem) {
return dataItem.label.toString().charAt(0);
}