Skip to content

Instantly share code, notes, and snippets.

View Caffe1neAdd1ct's full-sized avatar
:octocat:
Crafting something new..

Kevin Andrews Caffe1neAdd1ct

:octocat:
Crafting something new..
View GitHub Profile
@Caffe1neAdd1ct
Caffe1neAdd1ct / raidopt.sh
Created October 6, 2017 09:29
Optimise software raid resync linux
#!/bin/bash
### EDIT THESE LINES ONLY
RAID_NAME="md0"
# devices seperated by spaces i.e. "a b c d..." between "(" and ")"
RAID_DRIVES=(b c)
# this should be changed to match above line
blockdev --setra 16384 /dev/sd[bc]
SPEED_MIN=50000
SPEED_MAX=200000
### DO NOT EDIT THE LINES BELOW
@Caffe1neAdd1ct
Caffe1neAdd1ct / reset_table_autoincrement.sql
Created October 2, 2017 13:20
Postgress reset all table increments
CREATE OR REPLACE FUNCTION setval_max
(
schema_name name,
table_name name DEFAULT NULL::name,
raise_notice boolean DEFAULT false
)
RETURNS void AS
$BODY$
-- Sets all the sequences in the schema "schema_name" to the max(id) of every table (or a specific table, if name is supplied)
@Caffe1neAdd1ct
Caffe1neAdd1ct / dehumanize.php
Last active October 2, 2017 12:47
Convert Human Readable Sizes to Bytes
<?php
function parseSize($size)
{
$unit = preg_replace('/[^bkmgtpezy]/i', '', $size); // Remove the non-unit characters from the size.
$size = preg_replace('/[^0-9\.]/', '', $size); // Remove the non-numeric characters from the size.
if ($unit) {
// Find the position of the unit in the ordered string which is the power of magnitude to multiply a kilobyte by.
return $bytesSize = $size * pow(1024, stripos('bkmgtpezy', $unit[0]));
}
@Caffe1neAdd1ct
Caffe1neAdd1ct / dehumanize.py
Last active October 3, 2017 15:44
Convert Human Readable Sizes to Bytes
def parse_size_to_bytes(size):
"""
Convert Human Readable Sizes to Bytes
https://gist.github.com/Caffe1neAdd1ct/2b8f1a51c39e471119663c93f24d33fe
:param size: String representing size in a human readable format
:return:
"""
units = 'bkmgtpezy'
unit_index = -1
@Caffe1neAdd1ct
Caffe1neAdd1ct / domain.com.conf
Last active July 21, 2017 18:37
Example VirtualHost 80
<VirtualHost *:80>
ServerName domain.tld
ServerAdmin [email protected]
DocumentRoot "/var/www/html/domain.tld/"
<Directory "/var/www/html/domain.tld/">
Options +Indexes +FollowSymLinks +MultiViews
AllowOverride All

Keybase proof

I hereby claim:

  • I am caffe1neadd1ct on github.
  • I am kjandrews (https://keybase.io/kjandrews) on keybase.
  • I have a public key ASBi_zg2m4D4mGNz9f-S63C40dEnZx2X5ITMFidPtxFuWgo

To claim this, I am signing this object:

@Caffe1neAdd1ct
Caffe1neAdd1ct / _ide_helper.php
Created May 9, 2017 16:40 — forked from barryvdh/_ide_helper.php
Laravel IDE Helper for Netbeans / PhpStorm / Sublime Text 2 CodeIntel, generated using https://github.com/barryvdh/laravel-ide-helper
<?php
/**
* A helper file for Laravel 5, to provide autocomplete information to your IDE
* Generated for Laravel 5.4.11 on 2017-02-14.
*
* @author Barry vd. Heuvel <[email protected]>
* @see https://github.com/barryvdh/laravel-ide-helper
*/
namespace {
exit("This file should not be included, only analyzed by your IDE");
@Caffe1neAdd1ct
Caffe1neAdd1ct / build.xml
Last active January 3, 2017 15:54
Cake 1.3 Phing Build Script with Composer
<?xml version="1.0" encoding="UTF-8"?>
<project name="my-project-name" default="bundle" basedir="." description="Build file for my-project-name.">
<property name="export.dir" value="build/export" />
<autoloader autoloaderpath="vendor/autoload.php"/>
<fileset dir="app/tmp/" id="tmp">
<include name="**" />
<exclude name="**/.gitkeep" />
<exclude name=".gitkeep" />
@Caffe1neAdd1ct
Caffe1neAdd1ct / FlashBootstrap.php
Last active November 23, 2016 20:05
Phalcon flash messages with Bootstrap 3 integration
<?php
namespace Ext;
/**
* Extension to Phalcon Framework to implement Bootstrap 3 dismissable messages.
* Pass mappings of phalcon to bootstrap classes to construct
* @link https://docs.phalconphp.com/uk/latest/reference/flash.html Phalcon flash docs
* @author Kevin Andrews <[email protected]>
*/
@Caffe1neAdd1ct
Caffe1neAdd1ct / upgrade.sh
Created September 5, 2016 11:55
Upgrading PHP from 5.3 to 5.4 on Sentora CentOS 6
sudo su root -l
yum install centos-release-scl
yum install php54.x86_64 php54-build.x86_64 php54-php.x86_64 php54-php-bcmath.x86_64 php54-php-cli.x86_64 php54-php-common.x86_64 php54-php-dba.x86_64 php54-php-devel.x86_64 php54-php-enchant.x86_64 php54-php-fpm.x86_64 php54-php-gd.x86_64 php54-php-imap.x86_64 php54-php-intl.x86_64 php54-php-ldap.x86_64 php54-php-mbstring.x86_64 php54-php-mysqlnd.x86_64 php54-php-odbc.x86_64 php54-php-pdo.x86_64 php54-php-pear.noarch php54-php-pecl-apc.x86_64 php54-php-pecl-zendopcache.x86_64 php54-php-pgsql.x86_64 php54-php-process.x86_64 php54-php-pspell.x86_64 php54-php-recode.x86_64 php54-php-snmp.x86_64 php54-php-soap.x86_64 php54-php-tidy.x86_64 php54-php-xml.x86_64 php54-php-xmlrpc.x86_64
echo "source /opt/rh/php54/enable" >> /etc/bashrc
source /opt/rh/php54/enable
## Install suhosin
wget -nv -O suhosin.zip https://github.com/stefanesser/suhosin/archive/0.9.37.1.zip
unzip -q suhosin.zip