warning: ignoring broken ref refs/remotes/origin/HEAD
➜ ✗ g symbolic-ref refs/remotes/origin/HEAD refs/remotes/origin/develop
➜ ✗ g fetch --prune
➜ ✗ g gc
warning: ignoring broken ref refs/remotes/origin/HEAD
➜ ✗ g symbolic-ref refs/remotes/origin/HEAD refs/remotes/origin/develop
➜ ✗ g fetch --prune
➜ ✗ g gc
import contextlib | |
import OpenSSL.crypto | |
import os | |
import requests | |
import ssl | |
import tempfile | |
@contextlib.contextmanager | |
def pfx_to_pem(pfx_path, pfx_password): | |
''' Decrypts the .pfx file to be used with requests. ''' |
<!doctype html> | |
<html lang=en> | |
<head> | |
<meta charset=utf-8> | |
<title>Copy To Clipboard Example</title> | |
</head> | |
<body> | |
<input id="txtToCopy" type="text"> | |
<button id="btnCopy">Copy!</button> |
Using grep (well, pcregrep) to display the labels of reference style links in a Markdown document:
$ pcregrep --only-matching=1 \ # Only display the match from group 1
"\[.*?\](\[.*?\])" \ # Find [text][label] reference style links
/path/to/document.md | \ # Path to the markdown document
sort # Optionally sort the output
I had the regexp working in grep but couldn't capture just the group I was interested in. This Stack Overflow answer suggested pcregrep
.
Below are the Big O performance of common functions of different Java Collections. | |
List | Add | Remove | Get | Contains | Next | Data Structure | |
---------------------|------|--------|------|----------|------|--------------- | |
ArrayList | O(1) | O(n) | O(1) | O(n) | O(1) | Array | |
LinkedList | O(1) | O(1) | O(n) | O(n) | O(1) | Linked List | |
CopyOnWriteArrayList | O(n) | O(n) | O(1) | O(n) | O(1) | Array |
chmod cheat sheet | |
PERMISSION COMMAND | |
U G W | |
_____________________________________ | |
|rwx rwx rwx chmod 777 <filename> | | |
|_____________________________________| | |
|rwx rwx r-x chmod 775 <filename> | | |
|_____________________________________| |
#!/bin/bash | |
LOCAL_BRANCH=$1 | |
REMOTE_BRANCH="${2:-origin}/$1" | |
if [ x"$(git rev-parse $LOCAL_BRANCH)" != x"$(git rev-parse $REMOTE_BRANCH)" ] | |
then | |
echo "$LOCAL_BRANCH is not in sync with $REMOTE_BRANCH. You may want to rebase or push first." | |
fi |
# create container with key authentication | |
sudo lxc-create -t ubuntu -n test -- -S /root/.ssh/id_rsa.pub | |
sudo lxc-start -n test -d | |
sudo lxc-wait -n test -s RUNNING | |
# enable passwordless sudo for ubuntu user | |
chroot /var/lib/lxc/test/rootfs sh -c "echo 'ubuntu ALL=NOPASSWD:ALL' > /etc/sudoers.d/ubuntu; chmod 440 /etc/sudoers.d/ubuntu" | |
# now you can run commands in container, example: install avahi-daemon | |
ssh `cat /var/lib/misc/dnsmasq.leases | grep --word-regexp test | awk '{print $3}'` -l ubuntu -o "StrictHostKeyChecking no" sudo apt-get install -y avahi-daemon |
Every so often I have to restore my gpg keys and I'm never sure how best to do it. So, I've spent some time playing around with the various ways to export/import (backup/restore) keys.
cp ~/.gnupg/pubring.gpg /path/to/backups/
cp ~/.gnupg/secring.gpg /path/to/backups/
cp ~/.gnupg/trustdb.gpg /path/to/backups/