Skip to content

Instantly share code, notes, and snippets.

View normoes's full-sized avatar
💭
working

Norman Schenck normoes

💭
working
View GitHub Profile

hidden files

create an archive using tar (including hidden files)

taken from Digitesters

Normally:

tar czf backup.tar.gz /backup/*

This way all files are tarred except the hidden files.

@normoes
normoes / bit shifts.md
Last active March 14, 2018 08:44
remember me: shifting bits

shifting bits

n << 1 == n * 2
n << 2 == n * 4
n << 3 == n * 8
n &gt;&gt; 1 == n / 2
@normoes
normoes / binary_math.md
Last active March 14, 2018 09:07
remember me: binary math

binary math

source

2's complement

101 -> 010 + 1 = 011
11010 -> 00101 + 1 = 00110

binary subtraction

@normoes
normoes / permissions_from_root.md
Created August 23, 2018 12:55
get folder permissions starting from root directory
  $ namei -om ~/tmp/newnew/
  f: /home/user/tmp/newnew/
  drwxr-xr-x root   root   /
  drwxr-xr-x root   root   home
  drwxr-xr-x user user user
  drwxrwxr-x user user tmp
  drwxrwxr-x user user newnew
@normoes
normoes / git_ssh_agent_ssh_add.md
Last active August 28, 2018 06:20
add ssh key on the fly when pulling form git

ssh-agent bash -c ' ssh-add ~/git_key/id_rsa; cd ~/some_git_repo; git pull'

@normoes
normoes / docker_interactive_terminal.md
Last active September 4, 2018 09:33
interactive terminal in docker and docker-compose

docker cli

  -it

docker-compose

  stdin_open: true
  tty: true
@normoes
normoes / create_django_SECRE_KEY.md
Created October 7, 2018 11:28
Create Django SECRET_KEY
    >>> import secrets
    >>> import string
    >>> print(''.join(secrets.choice(string.digits + string.ascii_letters + string.punctuation) for i in range(100)))

    *:}~{MH)D&e}SGYRcAO~Q}PFD@:bN$6\d2&A7VB.ge2<zGda5J#)(p>>_H5l*Z>Q9R+!lZ&yn-th2^0ZUf|tkQS8zQu&5+THw&}C
@normoes
normoes / docker_logfile_to_stdout.md
Created October 10, 2018 10:25
forward request and error logs to docker log collector

Like done in the official nginx docker image:

# forward request and error logs to docker log collector
RUN ln -sf /dev/stdout /var/log/nginx/access.log \
	&& ln -sf /dev/stderr /var/log/nginx/error.log
@normoes
normoes / strace_in_docker_container.md
Created October 12, 2018 06:18
strace within a docker container

Run the container with:

--cap-add sys_admin --cap-add sys_ptrace 

Within the container:

apt-get strace
@normoes
normoes / stdout_stderr.md
Last active October 12, 2018 07:46
redirection of stdout and stderr

source

Redirect stdout to one file and stderr to another file:

command > out 2>error

Redirect stderr to stdout (&1), and then redirect stdout to a file:

command &gt;out 2&gt;&amp;1