Skip to content

Instantly share code, notes, and snippets.

View benyanke's full-sized avatar

Ben Yanke benyanke

View GitHub Profile
function htop() {
if [ "$1" == '' ] ; then
$(which htop)
else
clear
printf "\n\n\n\n"
printf "Connecting to $1"
printf "\n\n"
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>The HTML5 Herald</title>
<meta name="description" content="The HTML5 Herald">
<meta name="author" content="SitePoint">
@benyanke
benyanke / Documentation.md
Created April 5, 2017 19:11 — forked from KartikTalwar/Documentation.md
Rsync over SSH - (40MB/s over 1GB NICs)

The fastest remote directory rsync over ssh archival I can muster (40MB/s over 1gb NICs)

This creates an archive that does the following:

rsync (Everyone seems to like -z, but it is much slower for me)

  • a: archive mode - rescursive, preserves owner, preserves permissions, preserves modification times, preserves group, copies symlinks as symlinks, preserves device files.
  • H: preserves hard-links
  • A: preserves ACLs
@benyanke
benyanke / post-receive
Created March 29, 2017 18:25 — forked from anthumchris/post-receive
Git Push to Deploy — Instantly deploy your local Git repository to your remote web server
#/bin/bash
# This script will push your local repository's latest commit to a remote repository on your server.
# It's useful for quickly pushing your local changes to deployment servers (Dev, Stage, Prod/Live, etc.)
#
# This file should be placed in your remote server's project's git hooks folder and named .git/hooks/post-receive.
# Security reminder: Your web server should not allow access to the /.git folder URL
#
# Ensure that this script is executable:
# $ chmod +x .git/hooks/post-receive
@benyanke
benyanke / client.py
Created March 16, 2017 05:15 — forked from yoavram/client.py
Example of uploading binary files programmatically in python, including both client and server code. Client implemented with the requests library and the server is implemented with the flask library.
import requests
#http://docs.python-requests.org/en/latest/user/quickstart/#post-a-multipart-encoded-file
url = "http://localhost:5000/"
fin = open('simple_table.pdf', 'rb')
files = {'file': fin}
try:
r = requests.post(url, files=files)
print r.text
@benyanke
benyanke / README.md
Created February 16, 2017 03:53 — forked from oodavid/README.md
Deploy your site with git

Deploy your site with git

This gist assumes:

  • you have a local git repo
  • with an online remote repository (github / bitbucket etc)
  • and a cloud server (Rackspace cloud / Amazon EC2 etc)
    • your (PHP) scripts are served from /var/www/html/
    • your webpages are executed by apache
  • apache's home directory is /var/www/
@benyanke
benyanke / setupLbryServer.sh
Created November 14, 2016 23:51
LBRY Server Setup - Setup script to install LBRY on a headless debian or ubuntu server
#!/bin/bash
#################################
# Written by Ben Yanke
# https://github.com/benyanke
#
# This script sets up the lbry daemon
# for use on a headless server.
#
# Currently tested on Ubuntu Server 16.04.1 LTS
@benyanke
benyanke / BASH: Reminder to 'git pull'
Last active April 28, 2022 12:34
BASH: Reminder to 'git pull'. This function hooks into CD to remind you to 'git pull' when entering a repository directory. It will only alert you every X seconds.
cd() {
# Seconds between alerts: raise this
# number if you want to get fewer alerts
# Default: 10 min
alertDelay=600
# Alert text: this is displayed when you
# CD into a git repo
alertText="\n##################################################\n This is a git repo. Don't forget to 'git pull'\n##################################################\n"
# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples
# If not running interactively, don't do anything
case $- in
*i*) ;;
*) return;;
esac
@benyanke
benyanke / ip_in_range.php
Created July 11, 2016 14:25 — forked from tott/ip_in_range.php
php check if IP is in given network range
/**
* Check if a given ip is in a network
* @param string $ip IP to check in IPV4 format eg. 127.0.0.1
* @param string $range IP/CIDR netmask eg. 127.0.0.0/24, also 127.0.0.1 is accepted and /32 assumed
* @return boolean true if the ip is in this range / false if not.
*/
function ip_in_range( $ip, $range ) {
if ( strpos( $range, '/' ) == false ) {
$range .= '/32';
}