Skip to content

Instantly share code, notes, and snippets.

View adamtester's full-sized avatar
💻
Coding

Adam Tester adamtester

💻
Coding
View GitHub Profile
const fs = require('fs');
const readline = require('readline');
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout
});
// Load the participants and questions from the files.
fs.readFile('participants.txt', 'utf8', (err, participantsData) => {
if (err) {
@adamtester
adamtester / regex
Last active December 6, 2018 13:58
AWS CodeBuild - Github - Only build master and PRs
^(master|pr\/[0-9]+)$
@adamtester
adamtester / SqlServerConnector.php
Created June 1, 2018 13:20
Force SQL Server connection using odbc instead of dblib in laravel
/**
* Create a DSN string from a configuration.
*
* @param array $config
* @return string
*/
protected function getDsn(array $config)
{
// First we will create the basic DSN setup as well as the port if it is in
@adamtester
adamtester / Carbon.php
Created May 29, 2018 11:42
Fix Carbon for SQL Server when using Laravel
/**
* Create a Carbon instance from a specific format.
*
* @param string $format
* @param string $time
* @param \DateTimeZone|string|null $tz
*
* @throws \InvalidArgumentException
*
* @return static
@adamtester
adamtester / update_env.sh
Created March 6, 2018 14:13
Update .env ENV variable with git hash on deploy
sed -i "s/RELEASE=.*/RELEASE=$(git log --pretty="%h" -n1 HEAD)/" .env
@adamtester
adamtester / app.module.ts
Created September 1, 2017 13:53
Angular 4 Hash URL on local, HTML5Mode on production
import { NgModule } from '@angular/core';
...
import { environment } from '../environments/environment';
@NgModule({
...
providers: [{
provide: LocationStrategy,
useClass: environment.production ? PathLocationStrategy : HashLocationStrategy,
}],
@adamtester
adamtester / script.sh
Created April 15, 2016 09:37
Bypassing the memory check on a VMware ESXi 6
# Modified version of
# http://dtucker.co.uk/hack/bypassing-the-memory-check-on-a-vmware-esxi-5.html
# Boot the system from USB Stick / CD with ESXi installer on it.
# Once the installer welcome screen shows up, press ALT+F1
# Login as "root", no password.
cd /usr/lib/vmware/weasel/util
mv upgrade_precheck.pyc upgrade_precheck.pyc.old
cp upgrade_precheck.py upgrade_precheck.py.old
chmod 666 upgrade_precheck.py.old
@adamtester
adamtester / wkhtmltopdf.sh
Last active April 12, 2019 16:58
Install wkhtmltopdf on Ubuntu 14.04+
wget http://download.gna.org/wkhtmltopdf/0.12/0.12.2.1/wkhtmltox-0.12.2.1_linux-trusty-amd64.deb
sudo apt-get update
sudo apt-get install wkhtmltox
sudo apt-get -f install
sudo dpkg -i wkhtmltox-0.12.2.1_linux-trusty-amd64.deb
wkhtmltopdf -V
rm wkhtmltox-0.12.2.1_linux-trusty-amd64.deb
@adamtester
adamtester / GetLevel
Created July 20, 2015 09:44
Code for the levelling system for Vevvu Platform
function getLevels($cEXP) {
for($i = 1; ($i * $i + 2) * $i <= $cEXP; $i++);
return $i;
}
@adamtester
adamtester / Slug.php
Created July 6, 2015 13:36
Laravel unique slug generator
<?php namespace App\Libraries;
use DB;
class Slug {
// Create a unique slug
static function make($name, $table = null, $column = null)
{
$valid = false;