Skip to content

Instantly share code, notes, and snippets.

View tiernano's full-sized avatar

Tiernan OToole tiernano

View GitHub Profile
@tiernano
tiernano / gist:8581643
Created January 23, 2014 16:25
MikroTik Router VPN Stuff
/interface l2tp-client add name="vpn" max-mtu=1460 max-mru=1460 mrru=disabled connect-to=servername user="username" password="password" profile=default-encryption add-default-route=no dial-on-demand=no allow=pap,chap,mschap1,mschap2
/interface l2tp-client enable [/interface l2tp-client find name ="vpn"]
/ip firewall mangle add chain=prerouting action=mark-routing new-routing-mark=vpn passthrough=yes src-address=networkaddress/24 dst-address=!networkaddress/24
/ip route add dst-address=0.0.0.0/0 gateway=vpn gateway-status=vpn distance=1 scope=30 target-scope=10 routing-mark=vpn
/ip firewall nat add chain=srcnat action=masquerade out-interface=vpn
18 ;;; 7/0 goes to WAN1
chain=prerouting action=mark-connection new-connection-mark=WAN1_conn passthrough=yes
dst-address-type=!local in-interface=LAN1 connection-mark=no-mark
per-connection-classifier=both-addresses-and-ports:7/0
19 ;;; 7/1 goes to WAN2
chain=prerouting action=mark-connection new-connection-mark=WAN2_conn passthrough=yes
dst-address-type=!local in-interface=LAN1 connection-mark=no-mark
per-connection-classifier=both-addresses-and-ports:7/1
@tiernano
tiernano / gist:8217968
Created January 2, 2014 11:35
mikrotik script for sending from a particular address list to a particular WAN link
9 ;;; WAN1 address list -> WAN1
chain=prerouting action=mark-routing new-routing-mark=to_WAN1 passthrough=no
dst-address=!192.168.0.0/16 dst-address-list=WAN1
10 ;;; WAN2 address list -> WAN2
chain=prerouting action=mark-routing new-routing-mark=to_WAN2 passthrough=no
dst-address=!192.168.0.0/16 dst-address-list=WAN2
11 ;;; WAN3 address list -> WAN3
chain=prerouting action=mark-routing new-routing-mark=to_WAN3 passthrough=no
<?php
// Local server settings
// Local Database
define('DB_NAME', 'client');
define('DB_USER', 'root');
define('DB_PASSWORD', 'root');
define('DB_HOST', 'localhost');
// Overwrites the database to save keep edeting the DB
@tiernano
tiernano / gist:4655956
Created January 28, 2013 14:33
config required for Loggly NLog Target: https://github.com/tiernano/LogglyNLoggerTarget/
<?xml version="1.0" encoding="utf-8" ?>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<extensions>
<add assembly="LogglyTarget"/>
</extensions>
<targets>
<target name="Loggly" xsi:type="Loggly" URL="<EnterYourLogglyURLHere>" bufferNumber="5" shouldBuffer="true"/>
</targets>
@tiernano
tiernano / post-receive
Created January 16, 2013 06:56
post-receive hook for GIT to generate site using Jekyll and then push to NFSN using RSYNC. dont forget the / at the end of public_www or a new directory will be created in your public folder... if you want the contents uploaded to the public folder, include the /!
GIT_REPO=$HOME/repositories/<sitename>.git
TMP_GIT_CLONE=$HOME/tmp/<sitename>
PUBLIC_WWW=/var/wwwsites/<sitename>/
git clone $GIT_REPO $TMP_GIT_CLONE
cd $TMP_GIT_CLONE && jekyll --no-auto $TMP_GIT_CLONE $PUBLIC_WWW
cd ~ && rm -rf $TMP_GIT_CLONE
rsync -avz -e ssh $PUBLIC_WWW <NFSNUSERNAME>@ssh.phx.nearlyfreespeech.net:/home/public/
@tiernano
tiernano / gist:4344701
Created December 20, 2012 11:08
IPv6 Firewall rules for a MikroTik router to allow outgoing connections, but block incoming, unless they are responses...
/ipv6 firewall filter
add action=accept chain=input comment="Allow established connections" connection-state=established disabled=no
add action=accept chain=input comment="Allow related connections" connection-state=related disabled=no
add action=accept chain=input comment="Allow limited ICMP" disabled=no limit=50/5s,5 protocol=icmpv6
add action=accept chain=input comment="Allow UDP" disabled=no protocol=udp
add action=drop chain=input comment="" disabled=no
add action=accept chain=forward comment="Allow any to internet" disabled=no out-interface=sit1
add action=accept chain=forward comment="Allow established connections" connection-state=established disabled=no
add action=accept chain=forward comment="Allow related connections" connection-state=related disabled=no
add action=drop chain=forward comment="" disabled=no
@tiernano
tiernano / gist:4267157
Created December 12, 2012 11:40
take a compressed protobuf file (local), uncompress and then deserialize
using (FileStream fs = new FileStream(location, FileMode.Open))
{
using (GZipStream gz = new GZipStream(fs, CompressionMode.Decompress))
{
var result = Serializer.Deserialize<objectType>(gz);
//work with result here...
}
}
@tiernano
tiernano / gist:4267147
Created December 12, 2012 11:38
convert the object (obj) into a serialized protobuf object, compress and then write to tmpFile
using (MemoryStream serialized = new MemoryStream())
{
Serializer.Serialize(serialized, obj);
byte[] data = serialized.ToArray();
using (FileStream fs = new FileStream(tmpFile, FileMode.Create))
{
using (GZipStream zip = new GZipStream(fs, CompressionMode.Compress))
{
zip.Write(data, 0, data.Length);
}
@tiernano
tiernano / disableVNC.sh
Created November 29, 2012 16:23
Disable VNC on OSX though Command Line
sudo /System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contents/Resources/kickstart -deactivate -configure -access -off