Skip to content

Instantly share code, notes, and snippets.

View jyap808's full-sized avatar

Julian Y jyap808

View GitHub Profile
@jyap808
jyap808 / Nginx Virtual Host Log Format.md
Created April 13, 2014 05:03
Nginx Virtual Host Log Format
$ diff -u /etc/nginx/nginx.conf{.ORIG,}
--- /etc/nginx/nginx.conf.ORIG  2014-04-13 04:15:51.907316500 +0000
+++ /etc/nginx/nginx.conf       2014-04-13 05:02:22.807316500 +0000
@@ -30,7 +30,9 @@
        # Logging Settings
        ##
 
-       access_log /var/log/nginx/access.log;
+ log_format vhosts '$host $remote_addr - $remote_user [$time_local] "$request" $status $body_bytes_sent "$http_referer" "$http_user_agent"';
@jyap808
jyap808 / gist:8700714
Last active November 25, 2022 22:42
Rsync - via SSH with no password, utilizing SSH ForceCommand in the authorized_keys file to limit the commands that can be run with that SSH key

To make rsync both secure and automated (i.e : non-interactive), you can use SSH as the transport and set up a key pair. This is what will be discussed in this post, along with a few improvements.

Basic rsync + ssh

Let’s first ensure that rsync works correctly over ssh :

spaghetti% rsync -avz -e ssh --delete Documents prodigy:/tmp

Password:

@jyap808
jyap808 / gist:8703450
Created January 30, 2014 06:13
Resume another user's screen session

The problem: Being root you would like to resume another user's screen session. Let the user be A.

You 'become' him by

su A -

or

sudo su - A
@jyap808
jyap808 / Upgrade Yarn dependencies (and update package.json).md
Last active July 11, 2022 22:12
Upgrade Yarn dependencies (and update package.json)
jq '.dependencies | keys | .[]' package.json | xargs yarn add
jq '.devDependencies | keys | .[]' package.json | xargs yarn add --dev

FROM: yarnpkg/yarn#3266 (comment)

Install Yarn for every NVM install

Create a text file at $NVM_DIR/default-packages, usually it is located at ~/.nvm/default-packages, with a list of npm packages to be installed. The content may looks like the following:

@jyap808
jyap808 / create_boot_usb_osx.md
Created February 19, 2014 00:04
Create a bootable USB stick on OS X

##Create a bootable USB stick on OS X

Convert the .iso file to .img using hdiutil

Note: OS X tends to put the .dmg ending on the output file automatically.

$ hdiutil convert -format UDRW -o target.img source.iso
Reading Master Boot Record (MBR : 0)…
Reading Ubuntu 13.10 i386                (Apple_ISO : 1)…
@jyap808
jyap808 / encrypt_decrypt_gpg_armor.go
Created January 4, 2014 01:12
Symmetrically encrypting a string into ASCII armored GPG format and then Decrypting it in Golang
package main
import (
"bytes"
"code.google.com/p/go.crypto/openpgp"
"code.google.com/p/go.crypto/openpgp/armor"
"fmt"
"io/ioutil"
"log"
)
@jyap808
jyap808 / public_key_encrypt_gpg_base64.go
Last active May 21, 2021 16:39
Public key encrypting a string into GPG format and outputting it in base64 encoding
package main
import (
"bytes"
"code.google.com/p/go.crypto/openpgp"
"encoding/base64"
"fmt"
"io/ioutil"
"log"
)
@jyap808
jyap808 / useful.md
Created December 17, 2020 09:50
Useful random notes

Undo Git changes (also pushed Git changes)

In the server, move the cursor back to the last known good commit:

git push -f origin <last_known_good_commit>:<branch_name>

Locally, do the same:

git reset --hard 
@jyap808
jyap808 / decrypt_gpg_armor.go
Created January 4, 2014 01:05
Decrypting an ASCII armored GPG encrypted string in Golang
package main
import (
"bytes"
"code.google.com/p/go.crypto/openpgp"
"code.google.com/p/go.crypto/openpgp/armor"
"fmt"
"io/ioutil"
"log"
)
@jyap808
jyap808 / decrypt_gpg_armor_using_passphrase_private_key.go
Created January 8, 2014 01:14
Decrypting an ASCII armored GPG encrypted string using a passphrase protected private key in ASCII armor format
package main
import (
"bytes"
"code.google.com/p/go.crypto/openpgp"
"code.google.com/p/go.crypto/openpgp/armor"
"fmt"
"io/ioutil"
"log"
)