Coder Social home page Coder Social logo

howcani-data's Introduction

Hi to all visitors of my GitHub profile

I'm a passionated and experienced developer from Munich, Germany.

  • 🔭 I work with Kubernetes, Docker, Node.js, React.js, Next.js, Go and now also Rust
  • In my current project I use Svelte.js, to learn new things.

howcani-data's People

Contributors

janbaer avatar

Watchers

 avatar  avatar

howcani-data's Issues

How can I configure the tabwidth in VIM in which param means what"

tabstop

The width of a hard tabstop measured in "spaces" -- effectively the (maximum) width of an actual tab character.

shiftwidth

The size of an "indent". It's also measured in spaces, so if your code base indents with tab characters then you want shiftwidth to equal the number of tab characters times tabstop. This is also used by things like the =, > and < commands.

softtabstop

Setting this to a non-zero value other than tabstop will make the tab key (in insert mode) insert a combination of spaces (and possibly tabs) to simulate tab stops at this width.

expandtab

Enabling this will make the tab key (in insert mode) insert spaces instead of tab characters. This also affects the behavior of the retab command.

smarttab

Enabling this will make the tab key (in insert mode) insert spaces or tabs to go to the next indent of the next tabstop when the cursor is at the beginning of a line (ie: the only preceding characters are whitespace).

To configure this setting for a specific fileype you've to enter the following line in your .vimrc

autocmd expandtab BufNewFile,BufRead *.py setlocal tabstop=4 shiftwidth=4 softtabstop=4

or shorthand for vim modeline:

vim :set ts=4 sw=4 sts=4 et :

How to disable System Integrity Protection ‘csrutil’

Disabling Apple’s new System Integrity Protection ‘csrutil’, also called “rootless”, introduced with Mac OS X 10.11 El Capitan is easily down by booting into recovery mode and executing the command ‘csrutil disable’ in terminal.

How can I connect to a shell in a alpine based image

The alpine image is a very small image, it has only a size of 5 MB. Unfortunately there's no bash inside available. But of course there is a shell. You can reach it with

docker run -i -t --name=alpine alpine /bin/sh

or just exec into a running image with

docker exec -it container_name /bin/sh

How can I encrypt my github token with the travis client

  1. Install travis client or better pull a docker image
docker pull caktux/travis-cli
docker tag caktux/travis-cli travis-cli

see also

  1. Run the travis client with the following command
docker run --rm travis-cli encrypt -r howcani-project/howcani-project.github.io GH_TOKEN={YOUR_PERSONAL_GITHUB_ACCESS_TOKEN} | pbcopy

How can I undo a commit or rollback a merge

To undo the last commit you've to enter

git reset --hard HEAD~1

To undo a complete merge that contains more than one commit you've to find the id of your last commit before the merge and then enter

git reset --hard COMMIT_HASH

  • hard - you'll lose all your changes from the commit
  • soft - (will undo the commit but leave the changes in the working directory)
  • merge - switch instead of --hard, it doesn't touch uncommitted changes

But attention, this way you can only do for commit you haven't pushed before. When you want to undo a commit you pushed to the origin you've to use revert

git revert -m 1 commit_hash

See chapter 4 in the git book

How can I set bookmarks in VIM and navigate back to it

To set a bookmark that is valid for the current page press m and then a lowercase letter. You can use the same letter on different pages. But you have to have activated this page to navigate to the set bookmark.
To set a bookmark that is valid between all pages press a uppercase letter.

To navigate back to the bookmark press ' (jumps to the beginning of the line) or ` (jumps back to the exact position) and then the letter again.

see also

How can I change the last commit messages

The last commit message you can change with

git commit --amend

When you want to show more than one commit message, for example the latest 3 or one of this, you have to enter

git rebase -i HEAD~3

But you should only do this with commits that you've not pushed to any remote server!!!

How can I change the permissions for a file without knowing the octal number

You have to write it in the following syntax: chmod u=rwx,g=rx,o=r {filenname}

See also

But the calculation of the numbers is really easy:

  • 0 = no access
  • 4 = read access
  • 2 = write access
  • 1 = execution rights

The first number is for the owner, the second number is for the group, and the third number is for all other users.
So to calculate the numbers for each you just have to add the rights (4+2+1=7) and then concatenate the number. So in case that you can do everything, the group members can only read and all other users have no access the number is 740.

http://www.onlineconversion.com/html_chmod_calculator.htm

More info: https://www.pluralsight.com/blog/it-ops/linux-file-permissions

How can I remove a docker image or a container

To remove a docker image you have to enter the following command

docker rmi {id}

To delete all docker images enter

docker rmi $(docker images -a -q)

To delete all docker images that are not tagged enter

docker rmi -f $(docker images | grep "<none>" | awk "{print \$3}")

To delete all docker containers enter

docker rm $(docker ps -a -q)

How can I uninstall JAVA from my MacOS system

Uninstall Oracle Java using the Terminal

Note: To uninstall Java, you must have Administrator privileges and execute the remove command either as root or by using the sudo.
Remove one directory and one file (a symlink), as follows:

  • Click on the Finder icon located in your dock
  • Click on the Utilities folder
  • Double-click on the Terminal icon
  • In the Terminal window Copy and Paste the command below:
sudo rm -fr /Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin 
sudo rm -fr /Library/PreferencePanes/JavaControlPanel.prefpane

This tip is from here

How can I hash a string with Node.js

You can use the builtin crypto module for that.

const crypto = require('crypto');

function hashPassword(password, salt, algorithm='sha256'){
    let hash = crypto.createHmac(algorithm, salt); 
    hash.update(password);
    let value = hash.digest('hex');

    return {
        salt: salt,
        passwordHash: value
    };
}

See also this article

How can I show a progress in the terminal for node base command line apps

There're some nice modules on npmjs.org available, but for the most you've to know the total number of items. When you don't know it, the module can't calculate the percentage value.
In such cases you could show a dot to just show that something was happened. But console.log doesn't help you in this cases, since it always adds a new line break at the end.

Instead of that you could do what console.log is also doing, using the stdout stream, but without the newline at the end.

process.stdout.write('.');

How can I find out which process has opened a specific file

For this you can use lsof. On MacOS you have to install it with brew before.

lsof {complete path and filename}

Shows you all informations you need to now. To find out which files are opened by a specific process you just have to enter lsof -p {processed}

How can I build a Go executable in a Docker container that can be executed on MacOS or Windows

To build an executable for another platform than the current platform (Docker is running on a Linux OS) you've to set the GOOS environment variable. So you can build executable binaries for MacOS (darwin) and Windows platforms.

GOOS=darwin GOARCH=amd64 go build
GOOS=windows GOARCH=386 go build
GOOS=linux GOARCH=amd64 go build

To find out which platform you've to define for your current system, you can install the node module go-platform. This return the current os and cpu-architecture.

How can I start or stop a service on Linux system

When the System is a new Linux distribution you can use systemctl (which comes from systemd), on older systems you've to use the service command.

with list you can list all running services, with status you can get the status, and with start and stop you can control it. see also

On MacOS you've to use launchctl see also

How can I ignore a line or a code block from the eslint checks

To ignore a line just append the following comment:

console.log('Using Development Mode: ', process.env.NODE_ENV, isDevelopment); // eslint-disable-line no-console

To ignore a code block you have to enter two comments

/*eslint-disable */
Some code that should not be verified by eslint
/*eslint-enable */

How can I make a Python script executable

You have to enter the following shebang in the first line

#!/usr/bin/python3

After that you've to make your script executable with chmod +x youmagicscript.py

Now you can enter your script in your terminal shell.

How can I clean my docker images and containers

To get rid of unused containers and images you can execute the following commands:

# remove stopped + exited containers, I skip Exit 0 as I have old scripts using data containers.
docker rm -v $(docker ps -a | grep "Exit [1-255]" | awk '{ print $1 }')  
# remove untagged images
docker rmi $(docker images | grep none | awk '{ print $3}')
# remove unused volumes
docker volume rm $(docker volume ls -q )
# `shotgun` remove unused networks
docker network rm $(docker network ls | grep "_default")

On MacOS the Docker client stores everything in virtual disk image file and this file can grow to an enormous size. Actually the file will now shrinked by the Docker client after deleting some Docker images. There're two ways to handle that. The first is to stop the Docker client and then delete the Docker.qcow2 file which is stored in ~/Library/Containers/com.docker.docker/Data/com.docker.driver.amd64-linux. But ATTENTION, you'll lose all you containers and images with that!

The second way is to try to shrink it manually by executing the following script, after stopping the Docker client

mv Docker.qcow2 Docker.qcow2_backup
qemu-img convert -O qcow2 Docker.qcow2_backup Docker.qcow2

See also Reclaim disk space from a sparse image file (qcow2/ vmdk)

How can I restore a deleted commit

With git reflog you can see all changes you made in the repository.

Now you can enter the commit you want to restore. After that you're in a detached state. So you've to create a new branch from this state with git branch restore-commit. This branch should now contain the missing files.

How can I replace a html element with another element tag in VIM

When you've installed the vim-surround plugin it's easy. You just to set the focus within the tag and then enter

In this case the complete element will be replaced, even the attributes.
When you only change for example from a span to a div, but leave the attributes.
You've to enter the same but without the > at the end

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.