Skip to content

Instantly share code, notes, and snippets.

@bonsi
bonsi / Git push deployment in 7 easy steps.md
Created October 26, 2015 10:16 — forked from thomasfr/Git push deployment in 7 easy steps.md
7 easy steps to automated git push deployments. With small and configurable bash only post-receive hook
@bonsi
bonsi / gist:28faa641acd6135d26dc
Created November 26, 2015 15:58 — forked from adamjimenez/gist:5917897
Generate thumbnails from video files using HTML5's video tag and canvas
<?php
//where you want your thumbnails to go
$thumbs_dir = 'uploads/thumbs/';
//this should be an array of video paths
$videos = array();
if( $_POST["name"] ){
// Grab the MIME type and the data with a regex for convenience
if (!preg_match('/data:([^;]*);base64,(.*)/', $_POST['data'], $matches)) {
@bonsi
bonsi / fail2ban.md
Created December 3, 2015 20:14 — forked from joecampo/fail2ban.md
fail2ban – stop HTTP(S) route abuse/brute forcing

If you're not familiar: What is fail2ban? fail2ban is an awesome linux service/monitor that scans log files (e.g. auth.log for SSH) for potentially malicious behavior. Once fail2ban is tripped it will ban users for a specified duration by adding rules to Iptables. If you're unfamiliar with fail2ban Chris Fidao has a wonderful (& free!) series about security including setting up fail2ban here.

Recently Laravel released a new feature in 5.1 to throttle authentication attempts by simply adding a trait to your authentication controller. The Laravel throttle trait uses the inputted username, and IP address to throttle attempts. I love seeing this added to a framework out of the box, but what about some of our other apps not built on Laravel? Like a WordPress login? Or even an open API etc.? Ultimately,

@bonsi
bonsi / virtualbox_vagrant_home.bat
Last active December 21, 2015 10:47 — forked from michaelklapper/virtualbox_vagrant_home.bat
Reconfigure VirtualBox and Vagrant home directory for Windows
REM # VirtualBox home directory.
"C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" setproperty machinefolder "X:\VirtualMachines\virtualboxImages"
REM # Vagrant home directory for downloadad boxes.
REM REG ADD HKCU\Environment /v VAGRANT_HOME /t REG_SZ /d "X:\VirtualMachines\VAGRANT_HOME"
REM - this will only set the env var for the current session. Use setx to persist it.
set VAGRANT_HOME=X:\VirtualMachines\VAGRANT_HOME
REM #########################################################################################
vagrant up
pause
@bonsi
bonsi / .bash_profile
Created January 5, 2016 10:05 — forked from JeffreyWay/.bash_profile
Prettier git logs
alias gl="git log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit"
@bonsi
bonsi / NewMessage.php
Created October 11, 2016 14:33 — forked from sebastiaanluca/NewMessage.php
Laravel + Redis + NodeJS + Socket.io pub/sub secure server and client supporting multiple rooms, channels, users, … Add `client.js` to your client app, run `node server.js`, and trigger the Laravel event any way you want to broadcast the data.
<?php
namespace App\Events;
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
use Illuminate\Queue\SerializesModels;
class NewMessage extends Event implements ShouldBroadcast
{
@bonsi
bonsi / ssl-config
Created November 14, 2016 13:26 — forked from ivanleoncz/ssl-config
Generates self-signed SSL certificates.
[ req ]
default_bits = 2048
distinguished_name = req_distinguished_name
attributes = req_attributes
prompt = no
[ req_distinguished_name ]
C = MX
ST = VE
L = XL
@bonsi
bonsi / private-fork.md
Created March 23, 2019 07:00 — forked from DavideMontersino/private-fork.md
How to fork to a private gitlab instance

Theory:

your git repository can have more than one remote server; In this case we want to have two:

  1. one for our private repository on gitlab (will be the default one, called origin)
  2. one to be connected to the source repo on github, to be able to pull new changes (will be called upstream)

How to make a private fork from github to gitlab

@bonsi
bonsi / install_font_adobe_source_code_pro.sh
Created January 12, 2020 19:39 — forked from enzinier/install_font_adobe_source_code_pro.sh
Install font Adobe Source Code Pro on Ubuntu 16.04 LTS
#!/bin/sh
# Userland mode (~$USER/), (~/).
# ~/.fonts is now deprecated and that
#FONT_HOME=~/.fonts
# ~/.local/share/fonts should be used instead
FONT_HOME=~/.local/share/fonts
echo "installing fonts at $PWD to $FONT_HOME"
mkdir -p "$FONT_HOME/adobe-fonts/source-code-pro"
@bonsi
bonsi / MSP_ATTITUDE.ino
Created January 24, 2020 08:26 — forked from Xorgon/MSP_ATTITUDE.ino
An Arduino sketch for getting attitude data from a flight controller using MSP.
#include <SoftwareSerial.h>
#define MSP_ATTITUDE 108
SoftwareSerial mspSerial(11, 12); // RX TX
void setup() {
mspSerial.begin(9600);
Serial.begin(9600);
}