Skip to content

Instantly share code, notes, and snippets.

View mrtrkmn's full-sized avatar
☁️
working

Ahmet Türkmen mrtrkmn

☁️
working
View GitHub Profile
@mrtrkmn
mrtrkmn / add-key..
Created May 27, 2022 18:53
Add GPG key when there is an error on { apt update } command
#!/bin/bash
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys $1
@mrtrkmn
mrtrkmn / turn-off-built-in-display.md
Created May 27, 2022 12:45
off built-in display when external displays are connected
$ xrandr  # take the name of display that you would like to turn off
$ xrandr --output <display-name> --off
@mrtrkmn
mrtrkmn / screen-set.sh
Created May 27, 2022 12:37
how to set only one screen - ubuntu
#!/bin/bash
NR_OF_MONITORS=$(xrandr -d :0 -q | grep ' connected' | wc -l)
if [ $NR_OF_MONITORS = "2" ]; then
xrandr --output DFP1 --primary
fi
# refer to https://askubuntu.com/questions/88858/how-to-only-have-one-display
@mrtrkmn
mrtrkmn / git-cherry-pick.md
Created May 25, 2022 20:47
cherrypick: select and move some commits from one repo to another

git cherry-pick is generally used to get specific commit from one branch to another. It can also be used to move commits from one repository to another repository. It can be done in following ways:

$ git remote add newrepo <new-repository-link> 
$ git fetch newrepo
$ git cherry-pick <commit-sha>
@mrtrkmn
mrtrkmn / const-address-go.md
Last active May 22, 2022 11:48
How to get address of const variable in go ?

taken from: https://stackoverflow.com/questions/35146286/find-address-of-constant-in-go

In short: you can't.

The error message says:

cannot take the address of k There are limitations on the operand of the address operator &. Spec: Address operators:

For an operand x of type T, the address operation &x generates a pointer of type *T to x. The operand must be addressable, that is, either a variable, pointer indirection, or slice indexing operation; or a field selector of an addressable struct operand; or an array indexing operation of an addressable array. As an exception to the addressability requirement, x may also be a (possibly parenthesized) composite literal. If the evaluation of x would cause a run-time panic, then the evaluation of &x does too.

@mrtrkmn
mrtrkmn / set-dock-bar.sh
Created April 27, 2022 16:33
Set Linux - Ubuntu dock bar to center
#!/bin/bash
gsettings set org.gnome.shell.extensions.dash-to-dock extend-height false
gsettings set org.gnome.shell.extensions.dash-to-dock dock-position BOTTOM
gsettings set org.gnome.shell.extensions.dash-to-dock transparency-mode FIXED
gsettings set org.gnome.shell.extensions.dash-to-dock dash-max-icon-size 32
gsettings set org.gnome.shell.extensions.dash-to-dock unity-backlit-items true
package main
import (
"context"
"fmt"
"log"
"net/http"
"time"
"github.com/caddyserver/certmagic"
@mrtrkmn
mrtrkmn / dec.sh
Created February 15, 2022 23:26
decrypt files- for netsec course exercises
#!/bin/bash
files=(*.gpg)
# declare -p files
i=0
while read p; do
printf 'Decrypting: %s with passphrase %s\n' "${files[$i]}" "$p"
gpg --pinentry-mode=loopback --passphrase "$p" "${files[$i]}" 2>/dev/null >test
((i=i+1))
package client
type Tar struct {
c *Client
}
// exec executes an ExecFunc using 'tar' command.
func (tr *Tar) exec(args ...string) ([]byte, error) {
return tr.c.exec("tar", args...)
package client
type YoutubeDL struct {
c *Client
}
// exec executes an ExecFunc using 'youtube-dl'.
func (ytdl *YoutubeDL) exec(args ...string) ([]byte, error) {
return ytdl.c.exec("youtube-dl", args...)