Skip to content

Instantly share code, notes, and snippets.

@nl5887
nl5887 / transfer.fish
Last active July 30, 2024 09:21
Bash and zsh alias for transfer.sh. Transfers files and directories to transfer.sh.
function transfer
if test (count $argv) -eq 0
echo "No arguments specified. Usage:\necho transfer /tmp/test.md\ncat /tmp/test.md | transfer test.md"
return 1
end
## get temporarily filename, output is written to this file show progress can be showed
set tmpfile ( mktemp -t transferXXX )
## upload stdin or file
@nl5887
nl5887 / gist:87d92199550be6160884
Created December 19, 2014 23:25
Workaround for unable to convert "\xCA" issue
sh-3.2# export LC_CTYPE="utf-8"
sh-3.2# gem install nokogiri -v '1.6.5'
Building native extensions. This could take a while...
Successfully installed nokogiri-1.6.5
Parsing documentation for nokogiri-1.6.5
unable to convert "\xCA" from ASCII-8BIT to UTF-8 for lib/nokogiri/nokogiri.bundle, skipping
1 gem installed
-----
This will skip the generation of docs, and suppress the error:
sh-3.2# vim ~/.gemrc
@nl5887
nl5887 / gist:17686b63d8260912f94b
Last active August 29, 2015 14:11
Workaround for Vagrant NOKOGIRI installation error on OSX
❯❯❯ vagrant plugin install vagrant-vmware-fusion ⏎
Installing the 'vagrant-vmware-fusion' plugin. This can take a few minutes...
Bundler, the underlying system Vagrant uses to install plugins,
reported an error. The error is shown below. These errors are usually
caused by misconfigured plugin installations or transient network
issues. The error from Bundler is:
An error occurred while installing nokogiri (1.6.5), and Bundler cannot continue.
Make sure that `gem install nokogiri -v '1.6.5'` succeeds before bundling.
@nl5887
nl5887 / gist:2063706d815607805dd9
Last active February 26, 2018 10:45
Gin-gonic middleware to prevent x-forwarded-for spoofing.
func ipInMasks(ip net.IP, masks []interface{}) bool {
for _, proxy := range masks {
var mask *net.IPNet
var err error
switch t := proxy.(type) {
case string:
if _, mask, err = net.ParseCIDR(t); err != nil {
panic(err)
}
@nl5887
nl5887 / gist:8aaee404c6bef30d23eb
Last active October 10, 2017 11:09
Extreme simple (golang) webserver to serve static files. Easy for testing.
package main
import (
"flag"
"fmt"
"net/http"
)
func main() {
path := flag.String("path", ".", "path to static files")
@nl5887
nl5887 / vpn.pf.rules
Created January 24, 2015 14:33
OSX Rules to block all (incoming and outgoing) access except the traffic routed through (open)vpn.
# Options
set block-policy drop
set fingerprints "/etc/pf.os"
set ruleset-optimization basic
set skip on lo0
# Normalization
# Scrub incoming packets
scrub in all no-df
@nl5887
nl5887 / cleanup.sh
Created January 29, 2015 10:11
Remove all bak files 7 days or older.
#!/bin/sh
find /mnt/ -name '*.bak' -mtime +7 | xargs rm -f
@nl5887
nl5887 / gist:5bc08d589830545b044e
Created February 16, 2015 15:12
Cleanup lxc containers
lxc-ls |grep -v u1|xargs -I % lxc-destroy --name % | true
@nl5887
nl5887 / ApplicationProxy.cs
Created February 22, 2015 11:34
Compile and run dynamic .NET code in sandbox
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
namespace dutchcoders.Sandbox
{
public class ApplicationProxy : MarshalByRefObject
{
@nl5887
nl5887 / gist:bd8153f4288badcd02d7
Created March 6, 2015 16:16
SANS Suspicious domains by Country Fri 6 Mar 2015
https://isc.sans.edu/feeds/suspiciousdomains_Low.txt
56
6 Argentina
35 Australia
1 Austria
6 Belarus
1 Belgium
16 Brazil
92 British Virgin Islands