Skip to content

Instantly share code, notes, and snippets.

View sdvcrx's full-sized avatar
🎯
Focusing

sdvcrx sdvcrx

🎯
Focusing
View GitHub Profile
{{ $repo := .Get "repo" }}
{{ $detail := getJSON "https://api.github.com/repos/" $repo }}
<article class="shortcode-card">
<a href="https://github.com/{{ $repo }}" target="_blank" rel="noopener">
<header>
<img alt="{{ $repo }}" src="https://opengraph.githubassets.com/1/{{ $repo }}" />
</header>
<div class="shortcode-card-content">
<h2>{{ .Get "repo" }}</h2>
{{ with $detail }}
@sdvcrx
sdvcrx / migrate.py
Last active December 28, 2021 02:54
Sync dockerhub images to ghcr.io or other registry
"""
Sync dockerhub images to ghcr.io or other registry
Usage:
1. create tag list file `tags.txt` that syncing to ghcr.io
```
git tag > tags.txt
Vue.js 14 hrs 16 mins ███████████▎░░░░░░░░░ 53.9%
JavaScript 6 hrs 38 mins █████▎░░░░░░░░░░░░░░░ 25.1%
Other 2 hrs 35 mins ██░░░░░░░░░░░░░░░░░░░ 9.8%
Go 1 hr 42 mins █▎░░░░░░░░░░░░░░░░░░░ 6.4%
Git 41 mins ▌░░░░░░░░░░░░░░░░░░░░ 2.6%
@sdvcrx
sdvcrx / login.py
Created January 16, 2014 02:48
baidu login
#!/usr/bin/env python2
#!coding=utf-8
from time import time
import json
import logging
import re
import os
from urllib import urlencode
import urllib2

fmt

%T: print type of variable

Slice

Usage

Create a slice:

@sdvcrx
sdvcrx / archlinux-cleanup-pkg.go
Created January 30, 2017 09:56
Cleanup cached pkg files on Archlinux
package main
import (
"fmt"
"io/ioutil"
"log"
"os"
"regexp"
"sort"
)
@sdvcrx
sdvcrx / cvim.css
Last active February 29, 2016 13:50
cvim
#cVim-link-container, .cVim-link-hint, #cVim-command-bar, #cVim-command-bar-mode, #cVim-command-bar-input, #cVim-command-bar-search-results, .cVim-completion-item, .cVim-completion-item .cVim-full, .cVim-completion-item .cVim-left, .cVim-completion-item .cVim-right, #cVim-hud, #cVim-status-bar {
font-family: Helvetica, Helvetica Neue, Neue, sans-serif, monospace, Arial;
font-size: 12pt !important;
-webkit-font-smoothing: antialiased !important;
}
#cVim-link-container {
position: absolute;
pointer-events: none;
width: 100%; left: 0;
@sdvcrx
sdvcrx / aria2.sh
Created January 19, 2014 13:02
start script for popobox
#!/bin/sh
NAME=aria2c
prefix="/usr"
DAEMON=${prefix}/bin/${NAME}
DAEMON_OPTS="-D"
test -x $DAEMON || exit 0
if [ -z "$1" ] ; then
@sdvcrx
sdvcrx / argparser.py
Created December 27, 2013 14:33
arg parser
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("square", type=int,
help="display a square of a given number")
parser.add_argument("-v", "--verbosity", action="count", default=0,
help="increase output verbosity")
args = parser.parse_args()
answer = args.square**2
if args.verbosity >= 2:
print "the square of {} equals {}".format(args.square, answer)
@sdvcrx
sdvcrx / uniqify_list.py
Created December 26, 2013 08:29
去除list中相同项的最快的方法
def uniqify_list(seq):
seen = Set()
return [x for x in seq if x not in seen and not seen.add(x)]