Skip to content

Instantly share code, notes, and snippets.

View tranch's full-sized avatar
Focusing

Tranch tranch

Focusing
View GitHub Profile
@tranch
tranch / docstring.vim
Last active February 28, 2018 03:24 — forked from vpetro/gist:1204166
add docstring for python function in vim
function! WriteParams()
python << endpython
import re
import vim
# get the function definition line
line = vim.eval("getline(line('.'))")
# get the number of spaces to add to the start of the line
num_spaces = 4 + len(line) - len(line.lstrip())
# get the line number wher to do the insertion
<?php
class GridView extends \kartik\grid\GridView {
const TYPE_NONE = 'none';
public $toolbar = [];
public $bordered = false;
public $export = false;
public $layout = "{items}\n{pager}\n{pageSize}\n{summary}";
public $summaryOptions = [
@tranch
tranch / vimrc.vim
Last active March 26, 2018 15:51
My VIM Profile
set t_Co=256
set laststatus=2
set tabstop=8 softtabstop=0 expandtab shiftwidth=4 wmw=0 smarttab smartindent nu
set listchars=tab:▸\ ,eol:¬ list
if has('gui_running')
colorscheme molokai
set background=dark
set guifont=Inconsolata-g\ for\ Powerline:h12
set guioptions-=r
https://press.one/p/address/v?s=4c8d6cec6dc360ad73cc18d9f893cf2a1816f3ab527be0f98fe6f8338087075a14a252d2f99089a3107df842673123bbd99aaca8a30db94357a2105aeed4df7d0&h=bf59b4c015605a9e8a08952d52c0fca3e78e67463d74e13887c3eac6ebc3ea4a&a=96303b762d3860e21afc7cefd7e1ff79176f5cb2&f=P1&v=2
import socket
import struct
import time
# datetime.date(1970, 1, 1) - datetime.date(1900, 1, 1)
NTP_DELTA = 2208988800
NTP_SERVER = '0.cn.pool.ntp.org'
def get_ntp_time():
data = bytearray(48)
@tranch
tranch / ntp.py
Last active November 28, 2018 12:43
NTP time update for micropython
import socket
import ustruct
import time
from machine import RTC
# datetime.date(2000, 1, 1) - datetime.date(1900, 1, 1)
NTP_DELTA = 3155673600
NTP_SERVER = '0.cn.pool.ntp.org'
def get_ntp_time():
@tranch
tranch / ideolog-monolog.md
Last active July 30, 2019 05:53 — forked from mysiar/ideolog-monolog.md
Monolog template for Ideolog
  • Message pattern: ^\[(.*)\] (.+?)\.([A-Z]+): (.*)
  • Message start pattern: ^\[
  • Time format: yyyy-MM-dd HH:mm:ss
  • Time capture group: 1
  • Severity capture group: 3
  • Category capture group: 2
package com.honey;
import java.util.concurrent.*;
/**
* Hello world!
*/
public class App {
public static void main(String[] args) {
@tranch
tranch / INSTALL.sh
Last active November 4, 2020 15:06
V2ray config
#!/bin/bash
mkdir /usr/local/{etc,share}/v2ray
cp ./*.json /usr/local/etc/v2ray
cp ./v2{ctl,ray} /usr/local/bin
cp ./*.dat /usr/local/share/v2ray
@tranch
tranch / .bash_prompt.sh
Last active January 19, 2021 15:10
bash prompt
if infocmp xterm-256color >/dev/null 2>&1; then
export TERM=xterm-256color
fi
if tput setaf 1 &> /dev/null; then
tput sgr0
if [[ $(tput colors) -ge 256 ]] 2>/dev/null; then
MAGENTA=$(tput setaf 9)
ORANGE=$(tput setaf 172)
GREEN=$(tput setaf 190)