Skip to content

Instantly share code, notes, and snippets.

#! /bin/bash
chartName=$1
shift 1
for img in $(helm show chart $chartName $@ | yq .annotations.images | yq '.[].image'); do
docker pull $img
docker save -o "$(echo $img | sed 's#docker.io/##g' | sed 's#:#-#g' | sed 's#/#-#g').tar" $img
done
package main
import (
"bufio"
"bytes"
"context"
"fmt"
"os"
"time"
package main_
import (
"context"
"net/http"
"os"
"github.com/golang/protobuf/ptypes"
"github.com/golang/protobuf/ptypes/any"
gpb "github.com/golang/protobuf/ptypes/wrappers"
@PeerXu
PeerXu / main.py
Created June 30, 2017 10:50
pulsar teller-receiver framework
#! /usr/bin/env python3
import pulsar
@pulsar.command(ack=False)
async def _tell(request, data):
await request.actor.app.receive_data(request.actor, data)
(Pdb) print(buf.decode('gbk'))
A篹rsion="1.0" encoding="GBK"?>
<datas>
<infocode>1</infocode>
<msg/>
<datarow>2</datarow>
<page>0</page>
<pagesize>0</pagesize>
<pagecount>1</pagecount>
import numpy as np
class Unit(object):
def __init__(self):
pass
def invoke(self, q):
raise NotImplementedError()
@PeerXu
PeerXu / demo.go
Created August 18, 2016 01:35
let http.Response.Body become re-readable
import (
"bytes"
"io"
"io/ioutil"
"net/http"
)
func ReadAndAssignResponseBody(res *http.Response) (io.Reader, error) {
buf, err := ioutil.ReadAll(res.Body)
if err != nil {
package main
import (
"bytes"
"fmt"
"go/ast"
"go/parser"
"go/token"
"io/ioutil"
"log"
@PeerXu
PeerXu / dictSim.py
Last active August 27, 2015 16:10
Dice Game Simulator
import random
from itertools import groupby
class Dice(object):
NUMBERS = [1, 2, 3, 4, 5, 6]
def __init__(self, result):
self.result = result
def __eq__(self, obj):
@PeerXu
PeerXu / ns.c
Last active August 29, 2015 14:23
CVE-2015-1328 create namespace
#define _GNU_SOURCE
#include <sys/types.h>
#include <sys/wait.h>
#include <stdio.h>
#include <sched.h>
#include <signal.h>
#include <unistd.h>
#define STACK_SIZE (1024*1024)
static char container_stack[STACK_SIZE];