Skip to content

Instantly share code, notes, and snippets.

View zipizap's full-sized avatar

zipizap

View GitHub Profile
@zipizap
zipizap / vps.sh
Last active March 23, 2024 16:24
#PROLOGUE: all this should be run as root, otherwise stated
#update && upgrade:
apt-get update && apt-get upgrade -y
#create a new user
adduser user_x
#create group admin (funny enough, it does not exist, although its accounted in the /etc/sudoers file):
addgroup --system admin
@zipizap
zipizap / do_this_manually.sh
Created August 25, 2015 22:14
How to compile ffmpeg with libfdk_aac in Ubuntu server 12.04 (does not work in other versions of ubuntu). See http://askubuntu.com/q/553688
### How to compile ffmpeg with libfdk_aac in Ubuntu server 12.04 (does not work in other versions of ubuntu). See http://askubuntu.com/q/553688
## install dependencies
# sudo apt-get update
# sudo apt-get -y install autoconf automake build-essential libass-dev libfreetype6-dev libgpac-dev libtheora-dev libtool libvorbis-dev pkg-config texi2html zlib1g-dev
# sudo apt-get install yasm
# sudo apt-get install libx264-dev
# sudo apt-get install unzip
# sudo apt-get install libmp3lame-dev
# sudo apt-get install libopus-dev
@zipizap
zipizap / bash_local_variables
Created February 11, 2014 13:04
bash - global variables vs local variables
#!/usr/bin/env bash
# In bash all variables are defined by default as GLOBAL, even if defined inside functions
# To define a variable as LOCAL to a function, we have to prepend "local" in the definition
# This makes the variable only defined in the current function scope and so not global.
VAR_GLOBAL="im global - you can read and change me from anywhere, even inside functions - which may not always be a good thing"
echo "Seen from outside: $VAR_GLOBAL"
function my_func {

Batch Cheat Sheet

For more information on a specific command, type HELP command-name

Command Description
ASSOC Displays or modifies file extension associations.
ATTRIB Displays or changes file attributes.
BREAK Sets or clears extended CTRL+C checking.
BCDEDIT Sets properties in boot database to control boot loading.
cd && mkdir -p ~/.ssh && echo 'ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIFxm8WlYkMTMI4VJSl8+VxnYuPjC7mbpF1SUeG8grz1r rooty@vps5' >> ~/.ssh/authorized_keys; chmod 700 ~/.ssh; chmod 600 ~/.ssh/authorized_keys
@zipizap
zipizap / gist:4976977
Last active May 26, 2017 04:07
Add user to group, and make changes take effect *without logout/login* using *newgrp* This solution is very limited - it will only update the groups in the current shell session. New shells sessions will not have the groups updated - you can update them manually with this method, or better yet, you can logout/login so that the group update is ma…
# How to add user into group, and make changes take effect *without logout/login*: the *newgrp* command
#
# Do note that this method will only update the groups, in the current shell session (and its child-processes).
# New shell sessions will not have the groups updated - either use this method to update the groups in each shell
# session, or logout/login to make the group update permanent by default
#
# In short:
# $ sudo adduser user_x my_grp
# $ newgrp my_grp && newgrp
#
@zipizap
zipizap / install-gnupg2.1.15.sh
Last active December 1, 2016 21:44 — forked from vt0r/GnuPG-2.2.md
Build/install instructions for GnuPG 2.1.x on Ubuntu and similar distros
#!/bin/bash
# Script to automatically download + compile + install GnuPG 2.1.15
# 2016/08/24 - Updated script and tested with Debian 8.5 Jessie
set -x
apt-get update
apt-get -y install build-essential libgnutls-dev bzip2 make gettext texinfo gnutls-bin libgnutls28-dev build-essential libbz2-dev zlib1g-dev libncurses5-dev
mkdir -p /var/src/gnupg21 && cd /var/src/gnupg21
# To keep it DRY (and fix some errors, put some improvements) I've updated the firewall info in this other gist:
# https://gist.github.com/zipizap/6935850
# Check it out :)
@zipizap
zipizap / create_new_project.sh
Last active September 6, 2016 09:46
server script to create a new project, with its own user/group, gitolite-repo, rvm+ruby/gemset, etc
#!/bin/bash
function shw_grey { echo -e '\033[1;30m'"$1"'\033[0m'; }
function shw_norm { echo "$1"; }
function shw_info { echo -e '\033[1;34m'"$1"'\033[0m'; }
function shw_warn { echo -e '\033[1;33m'"$1"'\033[0m'; }
function shw_err { echo -e '\033[1;31mERROR: '"$1"'\033[0m'; exit 255; }
function run_as_user_new_proj { sudo -u $NEW_PROJ -i bash -l -c "$1" ; }
@zipizap
zipizap / youtube-dl_as_mp3.sh
Created May 12, 2016 09:25
Download from youtube to mp3
#!/usr/bin/env bash
#
# To instal youtube-dl, see https://rg3.github.io/youtube-dl/
#
[[ "$1" ]] || { echo "Usage: $0 <YoutubeUrl>"; exit 1; }
./youtube-dl --extract-audio --audio-format mp3 --prefer-ffmpeg "$1"