Skip to content

Instantly share code, notes, and snippets.

View benyanke's full-sized avatar

Ben Yanke benyanke

View GitHub Profile
@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 / 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
<!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">
function htop() {
if [ "$1" == '' ] ; then
$(which htop)
else
clear
printf "\n\n\n\n"
printf "Connecting to $1"
printf "\n\n"
@benyanke
benyanke / munch.c
Created May 5, 2017 17:19
Memory allocation example
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <time.h>
// Wait [secs] seconds
void waitFor (unsigned int secs) {
unsigned int retTime = time(0) + secs; // Get finishing time.
while (time(0) < retTime); // Loop until it arrives.
}
#!/bin/bash
# Network Share Incremental Backup Script
# By Ben Yanke <ben@benyanke.com>
# Last modified May, 2017
#
# This script allows you to make backups of a network share, and to keep incremental backups, using
# rsync's incremental backup feature. Old copies are retained without extra storage, because unchanged files are
# hard linked to old snapshots instead of newly copied. By this method, only one copy of any given file is
# stored, but you also have multiple, complete, nonincremental backups on your backup server.
# Render all GABC files in current directory into PDF scores
function rendergabc() {
dir="`pwd`"
# Clean PDFs from folder
mkdir -p $dir/old >/dev/null 2>&1
rm $dir/old/* -f >/dev/null 2>&1
mv $dir/*.pdf $dir/old/ >/dev/null 2>&1
# -*- mode: ruby -*-
# vi: set ft=ruby :
##############
# Box Config #
##############
# Currently supporting Parallels and VirtualBox
@benyanke
benyanke / synology-key-fix.sh
Last active June 10, 2018 14:57
Fix ssh key login on synology
#!/bin/bash
homedir=$(eval echo ~$USER);
sudo chown $USER:users $homedir -R;
chmod 700 $homedir;
mkdir $homedir/.ssh;
touch $homedir/.ssh/authorized_keys;
chmod 700 $homedir/.ssh/;
chmod 600 $homedir/.ssh/authorized_keys;
@benyanke
benyanke / Vagrantfile
Last active July 24, 2017 14:24
Vagrant file exerpts showing hosts editing
##############
# Box Config #
##############
# Specify any plugins you want installed on every `vagrant up` run
# You need the hostsupdated plugin, but the others are useful too.
required_plugins = %w(vagrant-hostsupdater vagrant-vbguest vagrant-triggers)
plugins_to_install = required_plugins.select { |plugin| not Vagrant.has_plugin? plugin }