Skip to content

Instantly share code, notes, and snippets.

View tenken's full-sized avatar

David Gurba tenken

View GitHub Profile
@tenken
tenken / wol.rb
Last active August 29, 2015 14:21 — forked from zunda/wol.rb
#!/usr/bin/ruby
# wol.rb: sends out a magic packet to wake up your PC
#
# Copyright (c) 2004 zunda <zunda at freeshell.org>
#
# This program is free software. You can re-distribute and/or
# modify this program under the same terms of ruby itself ---
# Ruby Distribution License or GNU General Public License.
#
@tenken
tenken / initial.sh
Created January 17, 2016 18:27
Setting up GitLab with Docker
# If you already have a webserver running you most likely won't be able to get GitLab
# woring on ports 80 and 443. Port 22 should work because we change the default SSH
# port on the host during server provisioning.
HTTP_PORT=8080
HTTPS_PORT=8443
SSH_PORT=22
# Install Docker (don't use Ubuntu's repositories, they're out of date).
wget -qO- https://get.docker.com/ | sudo sh
@tenken
tenken / certchain.sh
Created January 18, 2016 01:52 — forked from joshenders/certchain.sh
Simple Bash function to visualize PKI chain-of-trust for a given domain
function certchain() {
# Usage: certchain
# Display PKI chain-of-trust for a given domain
# GistID: https://gist.github.com/joshenders/cda916797665de69ebcd
if [[ "$#" -ne 1 ]]; then
echo "Usage: ${FUNCNAME} <ip|domain[:port]>"
return 1
fi
local host_port="$1"
@tenken
tenken / exec style aliases
Created February 7, 2016 16:56 — forked from hilbix/exec style aliases
`git exec` to exec command within GIT directory. `git top` to exec on submodule top level directory (somewhat).
git config --global alias.exec '!exec '
git config --global alias.top '!f() { GIT_TOP="${GIT_DIR%%/.git/modules/*}"; [ ".$GIT_TOP" != ".$GIT_DIR" ] && cd "$GIT_TOP"; exec "$@"; }; f'
# THIS IS PUBLIC DOMAIN.
#
# `git exec` executes something in the current GIT module's base directory. `git exec pwd` gives this base.
# Stolen from http://stackoverflow.com/questions/957928/is-there-a-way-to-get-the-git-root-directory-in-one-command/957978#comment9747528_957978
#
# `git top` is like `git exec`, but executes in the topmost GIT directory, even from within a GIT submodule.
@tenken
tenken / windows-1251-convert.sh
Created March 3, 2016 23:58 — forked from mustangostang/windows-1251-convert.sh
Convert windows-1251 to utf-8
#!/bin/zsh
for file in ./**/*.php
do
iconv -f windows-1251 -t UTF-8 "$file" > "${file%.php}-utf8.php"
rm $file
mv ${file%.php}-utf8.php $file
done
@tenken
tenken / convert.sh
Created March 8, 2016 22:20 — forked from akost/convert.sh
Bash script for recursive file convertion windows-1251 --> utf-8
#!/bin/bash
# Recursive file convertion windows-1251 --> utf-8
# Place this file in the root of your site, add execute permission and run
# Converts *.php, *.html, *.css, *.js files.
# To add file type by extension, e.g. *.cgi, add '-o -name "*.cgi"' to the find command
find ./ -name "*.php" -o -name "*.html" -o -name "*.css" -o -name "*.js" -type f |
while read file
do
@tenken
tenken / post-mortem-template.md
Created September 13, 2017 18:13 — forked from juliandunn/post-mortem-template.md
Post mortem template

INCIDENT DATE - INCIDENT TYPE

Meeting

Waiving meetings

In some cases the IC might determine that a PM meeting for the incident isn't needed. If the IC decides to waive the meeting please replace the Meeting section with a note indicating the meeting has been waived (example: Meeting waived: Paul Mooring)

@tenken
tenken / git-pushing-multiple.rst
Created February 13, 2018 23:32 — forked from rvl/git-pushing-multiple.rst
How to push to multiple git remotes at once. Useful if you keep mirrors of your repo.

Pushing to Multiple Git Repos

If a project has to have multiple git repos (e.g. Bitbucket and Github) then it's better that they remain in sync.

Usually this would involve pushing each branch to each repo in turn, but actually Git allows pushing to multiple repos in one go.

If in doubt about what git is doing when you run these commands, just

@tenken
tenken / wp-config.php
Created February 21, 2018 18:57 — forked from ryanjbonnell/wp-config.php
WordPress Config: Use X-Forwarded-For HTTP Header to Get Visitor's Real IP Address
// Use X-Forwarded-For HTTP Header to Get Visitor's Real IP Address
if ( isset( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) {
$http_x_headers = explode( ',', $_SERVER['HTTP_X_FORWARDED_FOR'] );
$_SERVER['REMOTE_ADDR'] = $http_x_headers[0];
}
@tenken
tenken / nginx_logs.py
Created March 2, 2018 22:20 — forked from SegFaultAX/nginx_logs.py
Parse nginx logs to sqlite3
#!/usr/bin/env python
# The MIT License (MIT)
# Copyright (c) 2016 Michael-Keith Bernard
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is