Skip to content

Instantly share code, notes, and snippets.

View hien's full-sized avatar
🏠
Working from home

Hien Phan hien

🏠
Working from home
View GitHub Profile
apiVersion: autoscaling/v2beta1
kind: HorizontalPodAutoscaler
metadata:
name: my-hpa
namespace: sg-prod
annotations:
metric-config.object.istio-requests-total.prometheus/per-replica: "true"
metric-config.object.istio-requests-total.prometheus/query: |
sum(rate(istio_requests_total{reporter="destination", destination_workload="<deployment-name-here>"}[2m]))
spec:
@rothgar
rothgar / wtf.sh
Created November 29, 2017 05:19
Linux server debugging in 60 seconds
#!/bin/bash
# Taken from https://medium.com/netflix-techblog/linux-performance-analysis-in-60-000-milliseconds-accc10403c55
# initialize array
COMMANDS=('uptime')
# add systemctl command if it's installed
command -v systemctl >/dev/null && COMMANDS+=('systemctl list-units --state=failed')
# add more commands
COMMANDS+=('dmesg | tail'
'vmstat 1'
@ricjcosme
ricjcosme / gist:c6f4c72644cc9bf0e63db7acc54bf6fb
Created May 24, 2020 14:20
Resizing a filesystem using qemu-img and fdisk

Occasionally we will deploy a virtual instance into our KVM infrastructure and realize after the fact that we need more local disk space available. This is the process we use to expand the disk image. This process assumes the following:

  • You're using legacy disk partitions. The process for LVM is similar and I will describe that in another post.
  • The partition you need to resize is the last partition on the disk.

This process will work with either a qcow2 or raw disk image. For

@hnakamur
hnakamur / main.go
Last active October 11, 2022 04:18
Validate certificate key pair and hostname in Go
package main
import (
"crypto/tls"
"crypto/x509"
"flag"
"fmt"
"log"
"golang.org/x/net/idna"
@benjamincharity
benjamincharity / master.vim
Last active June 30, 2023 08:45 — forked from gmccreight/master.vim
Master Vim with this interactive tutorial.
" copy all this into a vim buffer, save it, then...
" source the file by typing :so %
" Now the vim buffer acts like a specialized application for mastering vim
" There are two queues, Study and Known. Depending how confident you feel
" about the item you are currently learning, you can move it down several
" positions, all the way to the end of the Study queue, or to the Known
" queue.
" type ,, (that's comma comma)
@msdzero
msdzero / chartjs_jquery_ajax_example.html
Created March 3, 2017 01:08
Chart.js example using Jquery Ajax to populate labels and data
<canvas id="myChart" width="400" height="100"></canvas>
<script src="/js/Chart.min.js"></script>
<script>
$(function () {
var ctx = document.getElementById("myChart").getContext("2d");
// examine example_data.json for expected response data
var json_url = "example_data.json";
// draw empty chart
@swyxio
swyxio / 1.md
Last active February 8, 2024 22:30
Learn In Public - 7 opinions for your tech career

2019 update: this essay has been updated on my personal site, together with a followup on how to get started

2020 update: I'm now writing a book with updated versions of all these essays and 35 other chapters!!!!

1. Learn in public

If there's a golden rule, it's this one, so I put it first. All the other rules are more or less elaborations of this rule #1.

You already know that you will never be done learning. But most people "learn in private", and lurk. They consume content without creating any themselves. Again, that's fine, but we're here to talk about being in the top quintile. What you do here is to have a habit of creating learning exhaust. Write blogs and tutorials and cheatsheets. Speak at meetups and conferences. Ask and answer things on Stackoverflow or Reddit. (Avoid the walled gardens like Slack and Discourse, they're not public). Make Youtube videos

@eddiewebb
eddiewebb / readme.md
Last active February 12, 2024 08:46
Hugo JS Searching with Fuse.js
Rank Type Prefix/Suffix Length
1 Prefix my+ 2
2 Suffix +online 6
3 Prefix the+ 3
4 Suffix +web 3
5 Suffix +media 5
6 Prefix web+ 3
7 Suffix +world 5
8 Suffix +net 3
9 Prefix go+ 2
@ryanfitz
ryanfitz / golang-nuts.go
Created December 2, 2012 22:45
two ways to call a function every 2 seconds
package main
import (
"fmt"
"time"
)
// Suggestions from golang-nuts
// http://play.golang.org/p/Ctg3_AQisl