Skip to content

Instantly share code, notes, and snippets.

View leafsummer's full-sized avatar
🎯
Focusing

LeafSummer leafsummer

🎯
Focusing
View GitHub Profile
@leafsummer
leafsummer / commit_message.md
Created August 5, 2022 03:56
Semantic Commit Messages

Semantic Commit Messages

See how a minor change to your commit message style can make you a better programmer.

Format: <type>(<scope>): <subject>

<scope> is optional

Example

@leafsummer
leafsummer / make_zero_seed.md
Last active May 17, 2022 11:54
zeronet auto make seed

Become a Seeder: If you have a spare node (like a Raspberry PI with external HDD), you can setup a ZeroNet node here, which can automatically download and seen each new site published here.

Script to download new sites:


ZERO_DIR=~/ZeroNet-master
ZERO_HOST=127.0.0.1
Organization name: leexij@gmail.com
Serial Key: eNrzzU/OLi0odswsqslJTa3IzHJIz03MzNFLzs+tMTQyNrcwsTQyAIEa5xpDAIFxDy8k
@leafsummer
leafsummer / rest_client.py
Last active September 19, 2021 21:48
My share snippets
from restclient import GET, POST
import simplejson as json
import logging
import socket
logger = logging.getLogger('rs.utils.restclient')
class ConnectAPI(object):
'''
all the way of connection web and api server
@leafsummer
leafsummer / simple_proxy.py
Last active September 19, 2021 21:48
a proxy class example
def _default_cls_attr(name, type_, cls_value):
# Proxy uses properties to forward the standard
# class attributes __module__, __name__ and __doc__ to the real
# object, but these needs to be a string when accessed from
# the Proxy class directly. This is a hack to make that work.
# -- See Issue #1087.
def __new__(cls, getter):
instance = type_.__new__(cls, cls_value)
instance.__getter = getter
@leafsummer
leafsummer / _redis.py
Last active September 19, 2021 21:48
custom redis tools
#!/usr/bin/env python
import redis
from ncelery import conf
class RedisClient(object):
"""
Singleton pattern
http://stackoverflow.com/questions/42558/python-and-the-singleton-pattern
@leafsummer
leafsummer / _redis.py
Created August 11, 2015 11:24
A simple until tool of the redis
#!/usr/bin/env python
import redis
from ncelery import conf
class RedisClient(redis.StrictRedis):
"""
Singleton pattern
http://stackoverflow.com/questions/42558/python-and-the-singleton-pattern
@leafsummer
leafsummer / singleton.py
Created April 5, 2016 02:21
singleton pattern redis
class RedisClient(redis.StrictRedis):
"""
Singleton pattern
http://stackoverflow.com/questions/42558/python-and-the-singleton-pattern
"""
_instance = {}
def __init__(self, server):
@leafsummer
leafsummer / string_to_array.sh
Created July 8, 2016 02:24
cut string by semicolon to arrary in bash
#!/bin/bash
str="item1;item2;item3"
array=($(echo $str|tr ',' ' '|tr -s ' ')) #bash的方法
echo ${array[1]}
#item2
for s in ${arry[@]}; do echo "$s"; done
#item1 item2 item3
#or use this method
OLD_IFS="$IFS"
@leafsummer
leafsummer / network_service.sh
Created November 22, 2016 09:14
network service shell
#! /bin/bash
#
# network Bring up/down networking
#
# chkconfig: 2345 10 90
# description: Activates/Deactivates all network interfaces configured to \
# start at boot time.
#
### BEGIN INIT INFO
# Provides: $network