Skip to content

Instantly share code, notes, and snippets.

View szepnapot's full-sized avatar

Peter Lodri szepnapot

View GitHub Profile
@szepnapot
szepnapot / archive_multi_into_flatzip
Created February 6, 2019 15:41
[create flat zip from multi dir] create a zip with multiple files without sub-folders #bash #unix #shortcut
zip myfiles d0
(cd f1; zip -u ../myfiles.zip d1)
(cd f2/f3; zip -u ../../myfiles.zip d4)
# example
# zip project3.zip -j a/*.hdl
# (cd b; zip -u ../project3.zip *.hdl)
# The parentheses create subshells, and the effect of the cd only lasts in the subshell,
# so you don't have to cd back to the original directory.
@szepnapot
szepnapot / setup_noisy.sh
Created February 2, 2019 15:12
Setup and tweak noisy.py
#!/usr/bin/env bash
set -o errexit
set -o pipefail
set -o nounset
git clone https://github.com/1tayH/noisy.git && cd noisy
readonly __dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
curl -sSL "http://s3.amazonaws.com/alexa-static/top-1m.csv.zip" | tar xvfz - -C ${__dir}
python - <<EOF
import json
import csv
@szepnapot
szepnapot / python.md
Last active February 1, 2019 11:16
python beauty

Call a function until a sentinel value

blocks = []
while True:
  block = f.read(32)
  if block == '':
    break
  blocks.append(block)
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <unistd.h>
#include <sys/personality.h>
#include <sys/utsname.h>
#define UNAME26 0x0020000
@szepnapot
szepnapot / ubuntu_docker_install.sh
Last active December 2, 2018 11:34
How To Install and Use Docker on Ubuntu 18.04
#!/bin/bash
# check for root first
if [ "$EUID" -ne 0 ]
then echo "Please run as root"
exit
fi
# update local packages
apt update
readonly CHAT_HOME=/opt/Rocket.Chat
readonly DOMAIN=[FILL-ME]
readonly WEBMASTER_MAIL=[FILL-ME]
# MongoDB
apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 2930ADAE8CAF5059EE73BB4B58712A2291FA4AD5
echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.6 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.6.list
# Node.js
apt-get update -yq && apt-get install -yq curl && curl -sL curl -sL https://deb.nodesource.com/setup_8.x | sudo bash -
# Install deps
apt-get install -yq build-essential mongodb-org nodejs graphicsmagick
@szepnapot
szepnapot / ubuntu_server_setup.sh
Created November 24, 2018 15:47
Basic setup for EC2 instance running Ubuntu 18.04LTS
# add PHP+Certbot repo
add-apt-repository ppa:certbot/certbot -y
apt-add-repository ppa:ondrej/php -y
# update + upgrade
DEBIAN_FRONTEND=noninteractive apt-get -yq update && apt-get -yq upgrade
# set time + locale
timedatectl set-timezone Europe/Budapest
locale-gen en_US en_US.UTF-8
update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8
# enable auto-update
@szepnapot
szepnapot / install_python37.sh
Created September 6, 2018 17:20
Install Python 3.7 with Black on Ubuntu 16.04
# Install requirements
apt-get install -y build-essential
apt-get install -y checkinstall
apt-get install -y libreadline-gplv2-dev
apt-get install -y libncursesw5-dev
apt-get install -y libssl-dev
apt-get install -y libsqlite3-dev
apt-get install -y tk-dev
apt-get install -y libgdbm-dev
apt-get install -y libc6-dev
@szepnapot
szepnapot / install-redis.sh
Created August 14, 2018 14:52 — forked from khelll/install-redis.sh
Installing Redis on Amazon Linux
#!/bin/bash
###############################################
# To use:
# chmod +x install-redis.sh
# ./install-redis.sh
###############################################
version=3.2.0
echo "*****************************************"
echo " 1. Prerequisites: Install updates, set time zones, install GCC and make"
@szepnapot
szepnapot / init.md
Last active March 25, 2018 16:32
Node + NPM installation guide