Skip to content

Instantly share code, notes, and snippets.

class ApplicationController < ActionController::Base
before_filter :protect
protect_from_forgery
def protect
@ips = ['127.0.0.1', '116.155.117.121']
if not @ips.include? request.remote_ip
# Check for your subnet stuff here, for example
# if not request.remote_ip.include?('127.0,0')
render :text => "You are unauthorized"
@dannymcc
dannymcc / mainpractice-wireshark
Created November 14, 2011 08:44
Main Practice (Wireshark)
No. Time Source Destination Protocol Length Info
1 0.000000 192.168.1.45 192.168.3.1 TCP 62 41636 > printer [SYN] Seq=0 Win=8192 Len=0 MSS=1460 SACK_PERM=1
Frame 1: 62 bytes on wire (496 bits), 62 bytes captured (496 bits)
Ethernet II, Src: WistronI_1d:5d:05 (f0:de:f1:1d:5d:05), Dst: Draytek_78:9a:f8 (00:50:7f:78:9a:f8)
Internet Protocol Version 4, Src: 192.168.1.45 (192.168.1.45), Dst: 192.168.3.1 (192.168.3.1)
Transmission Control Protocol, Src Port: 41636 (41636), Dst Port: printer (515), Seq: 0, Len: 0
No. Time Source Destination Protocol Length Info
2 0.144101 192.168.1.45 192.168.1.255 NBNS 92 Name query NB ISATAP<00>
@dannymcc
dannymcc / auto_cleanup
Created December 26, 2012 15:56
Automatic cleanup script for Windows XP
@echo off
ECHO*****************************************************************************************
ECHO Please close all running programs, and plug into A/C power if you are on a laptop.
ECHO This will take a LONG time to complete.
ECHO *****************************************************************************************
REM This batch will set Check Disk to run after reboot, run Disk Cleanup, delete temp files,
REM run Disk Defragmenter, delete this file, and reboot the machine, starting Check Disk
REM Check Disk
REM ================

Keybase proof

I hereby claim:

  • I am dannymcc on github.
  • I am dmcc (https://keybase.io/dmcc) on keybase.
  • I have a public key ASCaikJT8WxLbn8dslsCM8oQeuKNx52qdB7JxGyqMHCWkQo

To claim this, I am signing this object:

@dannymcc
dannymcc / install_ruby_rpi.sh
Created March 14, 2017 16:06 — forked from blacktm/install_ruby_rpi.sh
A Bash script to install Ruby 2.4 on the Raspberry Pi (Raspbian)
#!/bin/bash
# --------------------------------------------------------------------------------------------
# Installs Ruby 2.4 using rbenv/ruby-build on the Raspberry Pi (Raspbian)
#
# Run from the web:
# bash <(curl -s https://gist.githubusercontent.com/blacktm/8302741/raw/install_ruby_rpi.sh)
# --------------------------------------------------------------------------------------------
# Welcome message
@dannymcc
dannymcc / diary.sh
Created May 1, 2020 23:04
Basic bash diary
#!/bin/bash
if [ "$1" == "new" ]; then
FILENAME=$(date +"%d.%m.%Y")
vim $FILENAME &&
mcrypt -u $FILENAME
else
if [ $# -eq 1 ]; then
PTEXT=$(cat $1 | mcrypt -d) &&
echo $PTEXT | vim -R -
else
@dannymcc
dannymcc / config
Created May 1, 2020 21:28 — forked from jetpks/config
.irssi/config
servers = (
{
address = "irc.mikezauner.com";
chatnet = "zl4u";
port = "6697";
autoconnect = "yes";
use_ssl = "yes";
},
{
address = "irc.freenode.net";
@dannymcc
dannymcc / raspberry-pi-vpn-router.md
Created December 13, 2019 20:25 — forked from superjamie/raspberry-pi-vpn-router.md
Raspberry Pi VPN Router

Raspberry Pi VPN Router

This is a quick-and-dirty guide to setting up a Raspberry Pi as a "router on a stick" to PrivateInternetAccess VPN.

Requirements

Install Raspbian Jessie (2016-05-27-raspbian-jessie.img) to your Pi's sdcard.

Use the Raspberry Pi Configuration tool or sudo raspi-config to:

@dannymcc
dannymcc / install_network_printer
Created December 26, 2012 15:44
This script, in it's current state, automates the process of creating a local IP port and installing the print driver. It runs locally on the machine that's installing the printer. First, it checks if the client machine is running XP. If not, it assume Windows 7. There's a set of commands for XP, and a set of commands for Windows 7. The commands…
@echo off
echo **YOU MUST BE AN ADMINISTRATOR ON THIS MACHINE FOR THE SCRIPT TO WORK PROPERLY**
echo THIS SCRIPT WORKS FOR WINDOWS XP AND WINDOWS 7
REM This determines if you're running XP or Windows 7
ver | find "XP" > nul
if %errorlevel% == 1 goto :win7
break
REM This runs if XP is found. The Windows 7 commands are at the bottom of this script
echo IDENTIFIED WINDOWS XP
echo Checking if printer "[PRINTER NAME HERE]" already exists

Keybase proof

I hereby claim:

  • I am dannymcc on github.
  • I am dmcc365 (https://keybase.io/dmcc365) on keybase.
  • I have a public key ASBFhEsSciBVUf4WX1WOQwRGJOr016jI-iPaFRJAFk6rQwo

To claim this, I am signing this object: