Skip to content

Instantly share code, notes, and snippets.

View cjsewell's full-sized avatar

Corey Sewell cjsewell

  • Jucy Group
  • New Zealand
View GitHub Profile
#!/bin/bash
set -e
RULE_NAMES=$(gcloud compute firewall-rules list --format json --project guru-cloud-hosting | jq ".[].name")
RULE_COUNT=1
COUNT=1
IPS=()
while read LINE; do
IPS+=("${LINE}")
@cjsewell
cjsewell / Mix.vb
Created February 6, 2020 01:42
Laravel mix utility module
Imports System.IO
Imports System.Web.Script.Serialization
Namespace Laravel
Public Module Mix
Private ReadOnly ManifestDirectory = "~/client"
Private ReadOnly Property ManifestFile As String
Get
Return HttpContext.Current.Server.MapPath($"{ManifestDirectory}/mix-manifest.json")
#!/bin/bash
HIGH=0.2;
LOG_FILE=/var/log/highload.log;
CURRENT_LOAD=$( uptime | awk -F'load average:' '{ print $2 }' | awk -F',' '{gsub(/[ \t]+/, "", $1); print $1}' );
IS_HIGH=$( echo "$CURRENT_LOAD >= $HIGH" | bc );
if [ $IS_HIGH -eq 1 ] ; then
top -b -n 1 2>&1 | while read line; do echo -e `/bin/date` "$line"; done >> $LOG_FILE
@cjsewell
cjsewell / CLI.bat
Created March 23, 2016 09:55
Handy dandy command line bits
REM Start a new conemu tab with cmd and UTF 7 Support
C:\Program Files\ConEmu\ConEmu64.exe -single -cmd cmd /k chcp 65001
@cjsewell
cjsewell / checkUncommitted.php
Last active November 18, 2015 03:34
Find Silverstripe modules which have uncommitted changes.
<?php
$gitDirs = array_merge(glob('*/.git', GLOB_ONLYDIR), glob('themes/*/.git', GLOB_ONLYDIR));
$origWorkingDir = getcwd();
foreach ($gitDirs as $dir) {
chdir(dirname($dir));
$getStatus = shell_exec("git status -s");
if ($getStatus) {
echo dirname($dir) . PHP_EOL;
}
@cjsewell
cjsewell / replacetranslations.sql
Created November 18, 2015 01:15
Replace locales of dataobjects in Silverstripe. Handy if you want to duplicate a site in a new language, but want to keep the old content as a starting point
// Returns list of tables which has a Locale column
SELECT DISTINCT TABLE_NAME
FROM INFORMATION_SCHEMA.COLUMNS
WHERE COLUMN_NAME IN ('Locale')
AND TABLE_SCHEMA='SS_mydatabase';
// Replace the locale en_NZ with en_US
UPDATE `ATableFromAbove` set `Locale` = "en_US" WHERE `Locale` = "en_NZ";
if Session("RCM123_BookingTypeID")="0" then
if Session("strAfterHoursBooking") = 1 then
HTML = HTML & "<tr><td colspan=2 class=text><p>Abholung außerhalb der Öffnungszeiten - Auf Anfrage</p><p>Vielen Dank für die Buchungsanfrage. Da die Abholung außerhalb unserer Öffnungszeiten statt findet, müssen wir vor der Bestätigung der Buchungsanfrage sicher stellen das wir alle persönlichen Daten erhalten haben.</p><p>Unsere Reservierung Team arbeit rund um die Uhr und wird in Kürze Kontakt aufnehmen um zu erklären wie die Abholung des Fahrzeuges funktioniert und um die.</p><p>Bei Rückfragen steht unser Team jederzeit gern zur Verfügung. Kontakt: <a href=""http://www.jucyrentals.de/Kundenbetreuung/default.aspx"">Kundenservice Team</a></p>"
else
HTML = HTML & "<tr><td colspan=2 class=text><p>Vielen Dank für die Buchung! Wir können es kaum erwarten dich in einer unserer Filialen persönlich kennen zu lernen! Bis dahin haben wir für die Vorbereitung einige wichtige Informationen. Falls es
@cjsewell
cjsewell / install.log
Created October 11, 2015 19:43
Project sections Revision 24 migrate output
$ rake redmine:plugins:migrate RAILS_ENV=production
rake aborted!
NoMethodError: undefined method `after_move' for #<Class:0x000000051b78a8>
/usr/local/rvm/gems/ruby-2.1.1/gems/activerecord-4.2.4/lib/active_record/dynamic_matchers.rb:26:in `method_missing'
/usr/share/redmine-3.1/plugins/project_section/lib/section_project_patch.rb:15:in `block in included'
/usr/share/redmine-3.1/plugins/project_section/lib/section_project_patch.rb:7:in `class_eval'
/usr/share/redmine-3.1/plugins/project_section/lib/section_project_patch.rb:7:in `included'
/usr/share/redmine-3.1/plugins/project_section/init.rb:24:in `include'
/usr/share/redmine-3.1/plugins/project_section/init.rb:24:in `block in <top (required)>'
/usr/local/rvm/gems/ruby-2.1.1/gems/activesupport-4.2.4/lib/active_support/callbacks.rb:446:in `instance_exec'
@cjsewell
cjsewell / ContainterPage.php
Last active October 4, 2015 17:32
SS Container Page Example
<?php
class ContainterPage extends Page {
static $db = array(
);
public function getCMSFields() {
$fields = new FieldList(
$rootTab = new TabSet("Root", $tabMain = new Tab('Main', LabelField::create("ContainerWarning", "Container page does not have any editable properties")
@cjsewell
cjsewell / ResetPermissions.bat
Last active September 22, 2015 03:40
Recursively reset NT permissions in Windows
cd "c:\problem folder" && takeown /a /r /d Y /f . && icacls . /T /Q /C /RESET