Skip to content

Instantly share code, notes, and snippets.

@Demacr
Demacr / mount.sh
Created November 22, 2020 16:42
macos mount NTFS
sudo ntfs-3g -o uid=501 -o gid=20 /dev/disk4s1 ./NTFS -o local -o allow_other -o auto_xattr -o auto_cache

To convert a --bare repository to a non-bare:

  • Make a .git folder in the top-level of your repository.
  • Move the repository management things (HEAD branches config description hooks info objects refs etc.) into the .git you just created.
  • Run git config --local --bool core.bare false to convert the local git-repository to non-bare.
  • (via comment by Tamás Pap) After step #3 you will see that you are on branch master (or whichever your main branch is) and all your files are deleted and the deletion is staged. That's normal. Just manually checkout master, or do a git reset --hard, and you are done.
  • (to resolve issue reported by Royi) Edit .git/config file adding line fetch = +refs/heads/:refs/remotes/origin/ after url = <...> in [remote "origin"] section. Otherwise git fetch will not see origin/master and other origin's branches.
@Demacr
Demacr / cert_get.sh
Created October 7, 2020 06:59
Certificate generate
openssl req -x509 -newkey rsa:4096 -keyout key.pem -out cert.pem -days 365 -nodes -subj '/CN=somename'
@Demacr
Demacr / gist:d194d1dee4ba16f3aa241ba3a0048827
Created September 7, 2020 12:57
Merging indexes into one and deleting old
curl -XPOST 'localhost:9200/_reindex?pretty' -H 'Content-Type: application/json' -d'
{
"conflicts": "proceed",
"source": {
"index": "datas-*"
},
"dest": {
"index": "newdataindex",
"op_type": "create"
}

The view ClusterRole doesn’t actually have permissions for the Cluster level objects like Nodes and Persistent Volume Claims. So we’ll have to create a new RBAC config.

First, we’ll create a new dashboard-viewonly ClusterRole:

---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
  name: dashboard-viewonly
@Demacr
Demacr / checkudp.sh
Created July 31, 2020 14:01
Check UDP
$ nc -v -u -z -w 3 some.host 1234
Connection to some.host port 1234 [udp/*] succeeded!
@Demacr
Demacr / docker-compose.yml
Created July 31, 2020 12:03
Docker-compose memory limit
service:
someservice:
deploy:
resources:
limits:
cpus: '0.001'
memory: 50M
@Demacr
Demacr / ingress.yaml
Created July 29, 2020 12:30
K8S nginx ingress websocket
nginx.ingress.kubernetes.io/configuration-snippet: |
proxy_set_header Upgrade "websocket";
proxy_set_header Connection "Upgrade";
@Demacr
Demacr / nginx.conf
Created July 22, 2020 17:28
Rabbitmq nginx %2F workaround
location ~* /rabbitmq/api/ {
if ($request_uri ~* "/rabbitmq/(.*)") {
proxy_pass http://localhost:15672/$1;
}
@Demacr
Demacr / docker-compose.yml
Created June 28, 2020 20:09
Traefik 1.7 basic auth
version: '3'
services:
myservice:
image: myimage
labels:
- "traefik.frontend.rule=Host:mydomain.com"
- ...
- "traefik.frontend.auth.basic.users=<USER-PASSWORD-OUTPUT>"