This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"crypto/sha256" | |
"encoding/hex" | |
"fmt" | |
"io" | |
"log" | |
"os" | |
"path/filepath" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func newHandler(w http.ResponseWriter, r *http.Request) { | |
if r.Method != http.MethodPost { | |
files := []string{ | |
templateDir + "/bootstrap.go.html", | |
templateDir + "/header.go.html", | |
templateDir + "/new.go.html", | |
templateDir + "/footer.go.html", | |
} | |
tmpl, err := template.ParseFiles(files...) | |
if err != nil { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import "fmt" | |
func inner(s []int) { | |
s[len(s)-1] = 999 | |
} | |
func inner2(s []int) { | |
s[0] = 9 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for r in *rpm ; do pkgname=$(rpm -q --queryformat "%{NAME}" -p ${r}); dnf -q repoquery --qf "%{name} %{reponame}" ${pkgname} ; done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
d1 = {'a': 1, 'b': 2, 'c': 3} | |
d2 = {'d': 4, 'e': 5, 'a': 6} | |
d1.update({k:v for (k,v) in d2.items() if k not in d1}) | |
d1 | |
# Out: {'a': 1, 'b': 2, 'c': 3, 'd': 4, 'e': 5} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import sys | |
import sqlite3 | |
if len(sys.argv) < 3: | |
print(f"Usage: {sys.argv[0]} <year_start> <year_end>") | |
sys.exit(1) | |
year_start = int(sys.argv[1]) | |
year_end = int(sys.argv[2]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for r in $(dnf repolist | egrep -v "^repo" | awk '{print $1}') ; do dnf repository-packages ${r} list > ${r}.txt ; done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import urllib.parse | |
import boto3 | |
import tempfile | |
from datetime import datetime | |
account_id = 'XXXXXXXXXX' | |
db_name = 'archive-db' | |
vault = 'archive-vault' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
печать = print | |
def пожалуйста(func): | |
def wrapper(): | |
func() | |
печать(', пожалуйста ', end='') | |
return wrapper |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Borrowed from here: https://stackoverflow.com/questions/18338585/how-to-get-the-instance-name-from-the-instance-in-aws | |
# This requires AWS CLI to be installed in the instance | |
INSTANCE_ID=`curl -s http://169.254.169.254/latest/meta-data/instance-id` | |
INSTANCE_NAME=`aws ec2 describe-tags --filters Name=resource-id,Values=$INSTANCE_ID --query Tags[].Value --output text` | |
export PS1="[\u@$INSTANCE_NAME \W]\\$ " |
NewerOlder