Skip to content

Instantly share code, notes, and snippets.

View synsa's full-sized avatar

Steve Lang synsa

View GitHub Profile
@synsa
synsa / sshcmd.rb
Created January 26, 2022 05:28 — forked from gorsuch/sshcmd.rb
ruby remote ssh cmd example
require 'net/ssh'
server = 'mem.sysarcana.com'
user = 'root'
pass = 'password'
command = 'uptime'
Net::SSH.start(server, user, :password => pass) do |session|
stdout = ''
stderr = ''
@synsa
synsa / ssr_test.go
Created November 30, 2021 11:57 — forked from xeoncross/ssr_test.go
Example of using chromedp to prerender a create-react-app frontend using fake SSR via chrome headless
package main
import (
"context"
"io/ioutil"
"log"
"strings"
"testing"
"github.com/chromedp/cdproto/dom"
@synsa
synsa / main.go
Created November 11, 2021 02:56 — forked from marians/main.go
OAuth 2.0 authentication in a Golang CLI
package main
import (
"context"
"crypto/tls"
"fmt"
"log"
"net/http"
"net/url"
"time"
@synsa
synsa / gist:9b7cbefb66cbfbdaa6866646263c2bce
Created November 1, 2021 21:21 — forked from bububa/gist:2709741
mysql master-master
REFERENCE:
http://hzcsky.blog.51cto.com/1560073/479476
# $Id: mysql-replication 335 2005-10-13 19:46:20Z sbalukoff $
# To set up bi-directional mysql replication:
# For the purposes of this document, we have two servers which will in the
# end be filling a co-master type relationship. However, since when you set up
# this replication there will probably be one machine with all the data on it
# that needs to be brought into sync with the other machine, the machine
@synsa
synsa / sshfs-gcp-instance-osx.md
Created October 28, 2021 23:02 — forked from mollymerp/sshfs-gcp-instance-osx.md
How to mount a GCP compute instance filesystem locally using `sshfs` on MacOS

How to mount a GCP compute instance filesystem locally using sshfs

This guide assumes that:

  • you already have an instance set up on GCP that you want to mount locally
  • the GCP CLI (gcloud) is installed on your local machine
  • you have authenticated locally to your google account gcloud auth login
  1. make sure your gcloud config is correct for the instance you're trying to access:
@synsa
synsa / sendEmail.patch
Created October 14, 2021 02:05 — forked from wilkart/sendEmail.patch
sendEmail.pl 1.56 patched to use TLS 1.2
67,68c67,68
< "tls_client" => 0, ## If TLS is supported by the client (us)
< "tls_server" => 0, ## If TLS is supported by the remote SMTP server
---
> "tls_client" => 1, ## If TLS is supported by the client (us)
> "tls_server" => 1, ## If TLS is supported by the remote SMTP server
1906c1906
< if (! IO::Socket::SSL->start_SSL($SERVER, SSL_version => 'SSLv3')) {
---
> if (! IO::Socket::SSL->start_SSL($SERVER, SSL_version => 'TLSv1_2', SSL_verify_mode => 0 )) {
0spam.fusionzero.com
2.0.0.127.b.barracudacentral.org
3y.spam.mrs.kithrup.com
abuse.earthlink.net
abuse.org
abuse.rfc-ignorant.org
accept.the-carrot-and-the-stick.com
access.redhawk.org
all.rbl.kropka.net
all.s5h.net
@synsa
synsa / install_git_server.sh
Created June 27, 2021 07:35 — forked from peter279k/install_git_server.sh
Create own Git Server with Gitolite and Gitweb in Ubuntu (Gitolite + GitWeb)
#!/bin/bash
sudo apt-get update
sudo apt-get install git-core
sudo adduser \
--system \
--shell /bin/bash \
--gecos 'git version control' \
@synsa
synsa / Mysql slow query log quick parse
Created June 22, 2021 21:42 — forked from dcampano/Mysql slow query log quick parse
Parse a mysql slow query log and show how many times queries over a certain threshold happened
# Script used to quickly get a glance of how many queries since a certain time period were longer than X seconds
# Customize these 2 parameters
STARTDATE="120413" # 2 Digit Year, 2 Digit Month, 2 Digit Day
QUERYTIME=3.0
# Runs the commands and prints out Query_time lines
FIRST=`grep -n -m 1 "# Time: $STARTDATE" /var/log/mysql-slow.log | cut -d : -f 1`; TOTAL=`wc -l /var/log/mysql-slow.log | cut -d ' ' -f 1`; tail -n `echo "$TOTAL-$FIRST" | bc` /var/log/mysql-slow.log | grep Query_time | awk -v time="$QUERYTIME" '$3 > time {print; }'
require 'nokogiri'
require 'open-uri'
# Get a Nokogiri::HTML:Document for the page we're interested in...
doc = Nokogiri::HTML(open('http://www.google.com/search?q=tenderlove'))
# Do funky things with it using Nokogiri::XML::Node methods...
####