Skip to content

Instantly share code, notes, and snippets.

@jamesstout
jamesstout / process.py
Last active July 12, 2021 07:24
add tz param to https://github.com/mwaterfall/alfred-datetime-format-converter to get the time in your location. Some testing done.
# -*- coding: utf-8 -*-
import alfred
import calendar
import time
import math
from delorean import utcnow, parse, epoch
# global var to see if user
# has a time offset
@klb3713
klb3713 / web_test.py
Created July 25, 2013 06:07
用Python实现的Web服务器的压力测试脚本
# -*- coding: utf-8 -*-
__author__ = 'klb3713'
import threading, time, httplib
HOST = "127.0.0.1"; #主机地址 例如192.168.1.101
PORT = 8001 #端口
URI = "/api/huohuaId2Url" #相对地址,加参数防止缓存,否则可能会返回304
TOTAL = 0 #总数
SUCC = 0 #响应成功数
FAIL = 0 #响应失败数
@dodola
dodola / ACM学习计划
Created August 14, 2013 02:14
ACM学习计划
ACM大量习题题库
ACM大量习题题库
现在网上有许多题库,大多是可以在线评测,所以叫做Online Judge。除了USACO是为IOI准备外,其余几乎全部是大学的ACM竞赛题库。
USACO
http://ace.delos.com/usacogate
美国著名在线题库,专门为信息学竞赛选手准备
@sergiotapia
sergiotapia / images_dimensions.go
Last active February 13, 2024 17:40
Golang - Getting the dimensions of an image. jpg, jpeg, png
package main
import (
"fmt"
"image"
"os"
_ "image/jpeg"
_ "image/png"
)
@myusuf3
myusuf3 / delete_git_submodule.md
Created November 3, 2014 17:36
How effectively delete a git submodule.

To remove a submodule you need to:

  • Delete the relevant section from the .gitmodules file.
  • Stage the .gitmodules changes git add .gitmodules
  • Delete the relevant section from .git/config.
  • Run git rm --cached path_to_submodule (no trailing slash).
  • Run rm -rf .git/modules/path_to_submodule (no trailing slash).
  • Commit git commit -m "Removed submodule "
  • Delete the now untracked submodule files rm -rf path_to_submodule
@bliaxiong
bliaxiong / mysql_sqlx.go
Created December 31, 2014 06:25
Go mysql sqlx example
package main
import (
_ "github.com/go-sql-driver/mysql"
"github.com/jmoiron/sqlx"
"log"
)
type User struct {
Id int
# Hello, and welcome to makefile basics.
#
# You will learn why `make` is so great, and why, despite its "weird" syntax,
# it is actually a highly expressive, efficient, and powerful way to build
# programs.
#
# Once you're done here, go to
# http://www.gnu.org/software/make/manual/make.html
# to learn SOOOO much more.
@byrnedo
byrnedo / ComputeHmac256.go
Created September 12, 2016 07:32
Compute a hmac for a message in golang
func ComputeHmac256(message string, secret string) string {
key := []byte(secret)
h := hmac.New(sha256.New, key)
h.Write([]byte(message))
return base64.StdEncoding.EncodeToString(h.Sum(nil))
}
@toschneck
toschneck / install_docker_bash_completions.sh
Last active April 2, 2024 12:41
Install Docker and Docker-Compose bash completion
#!/usr/bin/env bash
set -e
echo "install docker bash completion"
curl -L https://raw.githubusercontent.com/docker/docker/v$(docker version --format '{{.Server.Version}}')/contrib/completion/bash/docker -o /etc/bash_completion.d/docker
echo "install docker-compose bash completion"
curl -L https://raw.githubusercontent.com/docker/compose/$(docker-compose version --short)/contrib/completion/bash/docker-compose -o /etc/bash_completion.d/docker-compose
echo ".... done!"
@atifazad
atifazad / sysquit_commands.md
Last active April 24, 2024 01:01
osascript commands to shutdown, restart, sleep and logout mac

Shut down without showing a confirmation dialog:

osascript -e 'tell app "System Events" to shut down'

Shut down after showing a confirmation dialog:

osascript -e 'tell app "loginwindow" to «event aevtrsdn»'