Skip to content

Instantly share code, notes, and snippets.

@jpswade
jpswade / gist:5014891
Created February 22, 2013 16:57
Shuffle with associative keys
<?php
function ashuffle (&$array) {
$shuffle = $array;
shuffle($shuffle);
return $array = array_combine(array_keys($array), $shuffle);
}
?>
<?php
function ashuffle (&$array) {
$shuffle = $array;
shuffle($shuffle);
return $array = array_combine(array_keys($array), $shuffle);
}
?>
@jpswade
jpswade / setup_dev.bat
Last active January 14, 2016 13:57
Setup Windows Development Environment
::setup - Setup Windows Development Environment
ECHO *** install chocolatey
@powershell -NoProfile -ExecutionPolicy unrestricted -Command "iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'))" && SET PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin
ECHO *** install Google Chrome
choco install GoogleChrome -y
ECHO *** install Firefox
choco install firefox -y
pause
::EOF
::install_dotnetfx40.bat - installs dotNetFx40_Full_x86_x64.exe
::based on install_ooo.bat by @jpswade
@ECHO OFF
:SETTINGS
SET INSTALLNAME=Microsoft .NET Framework
SET SOURCEDIR=%CD%
SET INSTALLURL=http://www.microsoft.com/en-gb/download/details.aspx?id=17718
SET INSTALLEXE=dotNetFx40_Full_x86_x64.exe
:START
@jpswade
jpswade / fix_au.bat
Created January 19, 2016 12:11
Fixes for Windows AutoUpdates
@ECHO off
ECHO Fixes for Windows AutoUpdates
ECHO @see http://support.microsoft.com/kb/971058
ECHO By @jpswade
PAUSE
ECHO Updating the time...
W32TM /config /update /syncfromflags:manual /manualpeerlist:"time-b.nist.gov,0x8"
ECHO Stopping the services...
#fix_apache
#http://lists.bitfolk.com/lurker/message/20140907.170406.4b9ef2e5.en.html
echo start>>httpd.log
echo ps -C httpd -FH>>httpd.log
ps -C httpd -FH>>httpd.log
echo ps -eo pmem,pcpu,vsize,pid,cmd | sort -k 1 -nr>>httpd.log
ps -eo pmem,pcpu,vsize,pid,cmd | sort -k 1 -nr>>httpd.log
#cat /etc/httpd/conf/httpd.conf | grep LoadModule
cp /etc/httpd/conf/httpd.conf /etc/httpd/conf/httpd.conf.bak
sed -i 's|^LoadModule|#LoadModule|g' /etc/httpd/conf/httpd.conf
@jpswade
jpswade / xphpunit
Last active February 23, 2016 13:15 — forked from rolfvreijdenberger/phpunit-xdebug
xphpunit (/usr/local/bin/xphpunit)
#!/bin/bash
#curl -O https://gist.githubusercontent.com/jpswade/d82392d62bd25b43c6ce/raw/59a7e9c990ba9979f0967de049aea23f76e2bb2d/xphpunit /usr/local/bin/phpunitx && chmod 755 /usr/local/bin/phpunitx
# a wrapper around phpunit with xdebug enabled for eclipse
# make sure the debug session is started in the debug client (eclipse, netbeans, choose one of the settings below)
# see component diagram on https://en.wikipedia.org/wiki/Xdebug
# export XDEBUG_CONFIG="idekey=ECLIPSE_DBGP"
export XDEBUG_CONFIG="idekey=netbeans-xdebug"
phpunit --colors $@
@jpswade
jpswade / install_thunderbird.bat
Created February 25, 2016 14:10
Installs Mozilla Thunderbird
::install_thunderbird.bat - Installs Mozilla Thunderbird
@ECHO OFF
SETLOCAL EnableDelayedExpansion
:SETTINGS
SET INSTALLVER=17.0.11esr
SET INSTALLEXE=Thunderbird Setup %INSTALLVER%.exe
SET INSTALLURL=http://download.cdn.mozilla.net/pub/mozilla.org/thunderbird/releases/%INSTALLVER%/win32/en-GB/Thunderbird Setup %INSTALLVER%.exe
SET INSTALLDIR=%PROGRAMFILES%\Mozilla Thunderbird
SET INSTALLTBE=%INSTALLDIR%\thunderbird.exe
@jpswade
jpswade / setup_test.bat
Last active February 25, 2016 15:00
Setup Windows Testing Environment
::setup_test.bat - Setup Windows Testing Environment
@ECHO OFF
:SETTINGS
SET SETUPNAME=Setup Windows Testing Environment
:START
TITLE %SETUPNAME% Installer
ECHO *** %SETUPNAME% Installer
ECHO.
:ADMINCHECK
@jpswade
jpswade / vzubc.pl
Last active February 26, 2016 19:09
Human readable user beancounters
#!/usr/bin/perl
###############################################################################
# vzubc.pl - Human readable user beancounters
#
# This script reads /proc/user_beancounters on OpenVz HNs and VEs and displays
# the values in human-readable format (megabytes/kilobytes).
#
# The script can be distributed freely for everybody who finds it usable.
#
# Based on a script by Christian Anton