Skip to content

Instantly share code, notes, and snippets.

View autosquid's full-sized avatar

mightu autosquid

  • HangZhou, ZheJiang, China.
View GitHub Profile
@autosquid
autosquid / mini-web-proxy
Created January 24, 2023 05:17
A mini web proxy to accelerate github access.
# Author: Jay
# Date: 2023-01-24
# Description: A mini web proxy to accelerate github access.
# Usage: python3 mini_web_proxy.py
# Note: You need to set up a http/https proxy first
import http.client
import http.server
import logging
import socketserver
@autosquid
autosquid / Install NVIDIA Driver and CUDA.md
Created April 15, 2018 16:26 — forked from wangruohui/Install NVIDIA Driver and CUDA.md
Install NVIDIA Driver and CUDA on Ubuntu / CentOS / Fedora Linux OS
if [ "$#" != 1 ];then
echo "param error."
exit 0
fi
ACCOUNT=""
PASSWORD=""
DOMAIN=""
SUBDOMAIN=""
RECORD_LINE=""
@autosquid
autosquid / retain_pythonpath_virtualenv.zsh
Created March 19, 2018 06:22
retain pythonpath when virtualenv activate
# This file must be used with "source bin/activate" *from bash*
# you cannot run it directly
deactivate () {
unset -f pydoc >/dev/null 2>&1
# reset old environment variables
# ! [ -z ${VAR+_} ] returns true if VAR is declared at all
if ! [ -z "${_OLD_PYTHONPATH+_}" ] ; then
PYTHONPATH="$_OLD_PYTHONPATH"
@autosquid
autosquid / google-once
Created March 16, 2018 15:47
once yasnippet conforming to google style
#name : #ifndef XXX; #define XXX; #endif
# key: once
# --
#ifndef ${1: `(upcase (subst-char-in-string ?. ?_ (subst-char-in-string ?/ ?_ (file-relative-name buffer-file-name (projectile-project-root)))))`_}
#define $1
$0
#endif // $1
@autosquid
autosquid / remove-gaurd.el
Created March 16, 2018 15:46
remove cpp header guard (once)
(defun remove-line()
(delete-region
(progn (forward-visible-line 0) (point))
(progn (forward-visible-line 1) (point))))
(defun remove-guard()
(interactive)
(progn
(goto-char (point-min))
(search-forward-regexp "^#ifndef")

trick

if you create a new wget child process "wget http://foo.bar", but redirect child stdin and stdout to the same pipe, wget will give you something like this

  0K .......... .......... .......... .......... ..........  0%  105K 2h1m
 50K .......... .......... .......... .......... ..........  0%  158K 1h41m
100K .......... .......... .......... .......... ..........  0%  302K 81m58s
@autosquid
autosquid / git_submodules.md
Created May 12, 2017 07:52 — forked from gitaarik/git_submodules.md
Git Submodules basic explanation

Git Submodules basic explanation

Why submodules?

In Git you can add a submodule to a repository. This is basically a repository embedded in your main repository. This can be very useful. A couple of advantages of using submodules:

  • You can separate the code into different repositories.
@autosquid
autosquid / variousconf.cmake
Created May 9, 2017 06:39
A Cmake Template
function(PROTOBUF_GENERATE_PYTHON SRCS)
if(NOT ARGN)
message(SEND_ERROR "Error: PROTOBUF_GENERATE_PYTHON() called without any proto files")
return()
endif()
if(PROTOBUF_GENERATE_CPP_APPEND_PATH)
# Create an include path for each file specified
foreach(FIL ${ARGN})
get_filename_component(ABS_FIL ${FIL} ABSOLUTE)
@autosquid
autosquid / open chrome tab in safari.scpt
Created May 3, 2017 06:18
open current chrome tab in safari
tell application "Google Chrome"
set theURL to URL of active tab of window 1
end tell
tell application "Safari"
open location theURL
activate
end tell