Skip to content

Instantly share code, notes, and snippets.

@eegrok
eegrok / iptables-forward.info
Created May 6, 2011 00:18
forward traffic with iptables
# from http://www.debuntu.org/how-to-redirecting-network-traffic-a-new-ip-using-iptables
# enable ip forwarding until reboot
echo 1 > /proc/sys/net/ipv4/ip_forward
# enable ip forwarding after reboot
# edit /etc/sysctl.conf
# uncomment line: #net.ipv4.ip_forward=1
@eegrok
eegrok / mac-keycodes
Last active January 26, 2025 17:30
Mac virtual keycodes
from: http://www.meandmark.com/keycodes.html
with some additions from people in the comments, thanks :)
Virtual Keycodes for the Mac QWERTY Layout
Keycodes are in hexadecimal. A blank entry means either there is no key assigned to that keycode or I was unable to find the assigned key.
Keycode Key
0x00 A
0x01 S
0x02 D
@eegrok
eegrok / no-ssh-password-mac.txt
Created June 23, 2011 21:48
disable password ssh authentication on mac os
make sure the following lines are set in /etc/sshd_config (or /etc/ssh/sshd_config on ubuntu)
(they all exist already, but are commented, some may have a value of yes)
PasswordAuthentication no
ChallengeResponseAuthentication no
UsePAM no
then restart the ssh server (uncheck / recheck 'Remote Login' in the 'System Preferences' -> 'Sharing' panel)
@eegrok
eegrok / remote-desktop-login-too-many.txt
Created March 5, 2012 19:56
How to login with RDP if you have too many connections to the server -- remote desktop
#execute the following from the command prompt
mstsc /v:<ip-address> /admin
you can kick other people off by running (on the remote box)
query session
then
logoff <sessionid> /server /v
@eegrok
eegrok / gist:9ccfcf060aab1e065651d0e2f70fd46c
Created February 23, 2023 21:39
Example of how to tell when a TabView changes which tab is selected, or when the same tab is tapped when it is already selected.
//
// ContentView.swift
// TestTabs
//
// Created by Kem Mason on 24/02/23.
//
import SwiftUI
enum TopNavTag: Hashable {
@eegrok
eegrok / postfix-modify-header
Created May 13, 2011 22:54
Modify the to: header in postfix
# so recently I had an issue where I wanted to send email sent to a local user root (from logwatch, e.g.) to a different email address
# simple enough -- just add a ~root/.forward file, with the contents root-handler-testing@gmail.com
# all the email gets sent there...
# but the email shows up with a to: header of root@my-example-machine.com
# what I really want is the to: header to be root-handler-testing@gmail.com
# so I can filter emails, etc... below is how to do that.
#uncomment the following line in /etc/postfix/main.cf
#header_checks = regexp:/etc/postfix/header_checks
@eegrok
eegrok / vpn-setup.txt
Created May 4, 2011 22:26
set up VPN from scratch
#partially from:
#http://openvpn.net/index.php/open-source/documentation/miscellaneous/78-static-key-mini-howto.html
# in this I refer to the server and the client -- really the only difference here is that the 'server'
# needs to have a publicly accessible IP, and be configured to allow UDP port 1194 to connect inbound
iptables -A INPUT -s <put-client-public-ip-address-here> -p udp -m udp --dport 1194 -j ACCEPT
# other than that, they can communicate both ways, assuming the client firewall is configured to allow it
# (to firewall the client to prevent all server connections, see below)
# don't forget to save your iptables configurations after making them -- https://gist.github.com/958060
#on server, make sure openvpn is installed (on ubuntu it's simply: aptitude install openvpn)
# to install on rhel5, follow this: https://gist.github.com/957868
@eegrok
eegrok / gist:79d29a705e0c600460f0c4a1c2170835
Last active September 13, 2020 23:22
one liners for tcp socket connection test in ruby
# client
ip_addr = 'server_addr'; require 'socket'; loop { begin; sock = TCPSocket.new(ip_addr, 2000); while (str = sock.readline) do puts str; end; rescue EOFError; sleep 1; next; rescue Errno::ECONNREFUSED; puts "FAIL"; end; sleep 1; }
# server
require 'socket'; server = TCPServer.new 2000; loop { Thread.start(server.accept) do |client| client.puts "Hello !"; client.puts "Time is #{Time.now}"; client.close; puts "Handled request at #{Time.now}"; end; }
@eegrok
eegrok / Gemfile
Created March 29, 2012 00:31 — forked from vangberg/README
Deploying a Sinatra app with database to Heroku
source 'http://rubygems.org'
gem 'rack'
gem 'sinatra'
gem 'dm-core'
gem 'haml'
gem 'dm-postgres-adapter'
gem 'dm-migrations'
gem 'pg'
@eegrok
eegrok / git-patch-example.sh
Created February 28, 2013 22:52
save patch / apply it using git
#this will save off a single commits patch, so you can apply it
# if you leave off from --stdout to the right, it'll create a patchfile in the current directory with a name
# that includes the comment from the commit
git format-patch -1 095e61f --stdout > /tmp/patchname.patch
# this will check the patch to see if any conflicts will arise when applying it
git apply --check /tmp/patchname.patch
# this will apply the patch
git apply /tmp/patchname.patch