Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / mysql-import-individual-table
Created November 22, 2014 05:23
extract individual tables from database dump, for import -- mysql
touch /tmp/empty
ack "Table structure" /path/to/database_backup.sql /tmp/empty
it spits out something like this:
...
56160:-- Table structure for table `sub_human`
56195:-- Table structure for table `fool`
56385:-- Table structure for table `fool_games`
56465:-- Table structure for table `fool_games_old`
56657:-- Table structure for table `fool_games_texts`
@eegrok
eegrok / cltools.sh
Last active August 29, 2015 14:05 — forked from jellybeansoup/cltools.sh
install command line tools on osx / other libraries as well
#!/bin/sh
##
# Install autoconf, automake, libtool and pkg-config smoothly on Mac OS X.
# Newer versions of these libraries may be available and may work better on OS X
#
# This script is originally from http://jsdelfino.blogspot.com.au/2012/08/autoconf-and-automake-on-mac-os-x.html
#
export build=~/src # or wherever you'd like to build
@eegrok
eegrok / curl-ca-cert-import.txt
Created April 16, 2014 01:04
curl SSL3_GET_SERVER_CERTIFICATE error fix
# I recently got the following error while using curl:
# curl: (60) SSL certificate problem, verify that the CA cert is OK. Details:
# error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed
openssl s_client -connect www.whateverserver.com:443 |tee logfile
# then QUIT <RETURN>
# copy from BEGIN CERTIFICATE to END CERTIFICATE into /tmp/certstuff.pem
openssl x509 -inform PEM -in /tmp/certstuff.pem -text -out certdata
cat certdata
# in there, I saw this line:
@eegrok
eegrok / locate.updatedb.comment
Created April 8, 2014 23:40
locate.updatedb on osx as root instead of nobody user -- indexes home directory files
# comment out this region to index as root according to:
# http://apple.stackexchange.com/questions/84532/how-can-i-search-my-entire-drive-for-a-file-without-getting-recursively-stuck-in/84556#84556
# if [ "$(id -u)" = "0" ]; then
# rc=0
# export FCODES=`mktemp -t updatedb`
# chown nobody $FCODES
# tmpdb=`su -fm nobody -c "$0"` || rc=1
# if [ $rc = 0 ]; then
# install -m 0444 -o nobody -g wheel $FCODES /var/db/locate.database
# fi
#instructions for ubuntu 12.04
sudo apt-get -y update
sudo apt-get install git emacs curl build-essential zlib1g-dev libssl-dev libreadline6-dev libyaml-dev libmysql-ruby libmysqlclient-dev
cd /tmp
#install ruby -- from: http://stackoverflow.com/questions/16222738/how-to-install-ruby-2-0-0-correctly-on-ubuntu-12-04
wget http://cache.ruby-lang.org/pub/ruby/2.0/ruby-2.0.0-p353.tar.gz
tar -xvzf ruby-2.0.0-p353.tar.gz
cd ruby-2.0.0-p353/
./configure --prefix=/usr/local

general settings

  • turn off key clicks: Progrm + backslash

remap - any platform (press they key you want it to be first, then the key you will press to get that)

  • Tab --> Caps Lock
  • Esc --> Tab
  • Back Space --> Ctrl (left)
  • Delete --> Alt (left)
  • Down Arrow --> ]}
  • [{ --> Down Arrow
@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
@eegrok
eegrok / toggle-mic-mute.applescript
Last active December 13, 2015 21:49
applescript to toggle mute / notify via growl
tell application "System Events"
set isRunning to (count of (every process whose bundle identifier is "com.Growl.GrowlHelperApp")) > 0
end tell
if isRunning then
tell application id "com.Growl.GrowlHelperApp"
-- Make a list of all the notification types
-- that this script will ever send:
set the allNotificationsList to ¬
{"Microphone Muted", "Mic Live"}