Skip to content

Instantly share code, notes, and snippets.

View prinsss's full-sized avatar
🐟
摸鱼中

prin prinsss

🐟
摸鱼中
View GitHub Profile
@prinsss
prinsss / gist:0e900c2e2fdd034aac5c
Created August 12, 2015 09:25
shadowsocks one-key install shell
#! /bin/bash
#==================================
# AUTHOR: printempw
# NOTE: I HAVEN'T WRITE ANY DEBUG CODE IN THIS SHELL,
# IF ANY ERROR RAISES,UMM,JUST LET IT GO
# SYSTEM REQUIRED: ONLY FOR UBUNTU
#==================================
clear
echo ""
@prinsss
prinsss / hitokoto.py
Created December 27, 2015 04:32
Python 一言爬虫
#!/usr/bin/env python
# -*- coding=utf-8 -*-
import sys
# Python version check
if (sys.version_info[0] < 3):
print("This script only works on Python 3+.")
exit(1)
import os, time
import urllib.request
#!/usr/bin/env python
# -*- coding=utf-8 -*-
art_dict = {}
def getArtLines(ascii):
lineNumberStart = (ascii - 64 - 1)*3 + 1
result = []
lines = ['┌─┐', '├─┤', '┴ ┴', '┬┐ ', '├┴┐', '┴─┘', '┌─┐', '│ ', '└─┘', '┬─┐', '│ │', '┴─┘', '┌─┐', '├┤ ', '└─┘', '┬─┐', '├┤ ', '┴ ', '┌─┐', '│ ┐', '└─┘', '┬ ┬', '├─┤', '┴ ┴', ' ┬ ', ' │ ', ' ┴ ', ' ┬ ', ' │ ', '└┘ ', '┐┌ ', '├┴┐', '┴ ┴', '┬ ', '│ ', '┴─┘', '┌┬┐', '│││', '┴ ┴', '┌┐┌', '│││', '┘└┘', '┌─┐', '│ │', '└─┘', '┬─┐', '├─┘', '┴ ', '┌─┐', '│ │', '└─┴', '┬─┐', '├┬┘', '┴└─', '┌─┐', '└─┐', '└─┘', '┌┬┐', ' │ ', ' ┴ ', '┐ ┌', '│ │', '└─┘', '┐ ┌', '└┐│', ' └┘', '┬ ┬', '│││', '└┴┘', '┬ ┬', '└┬┘', '┴ ┴', '┬ ┬', '└─┤', '└─┘', '┌─┐', '┌─┘', '└─┘']
for i in range(3):
<?php
/* MySQL 数据库名称 */
define('DB_NAME', 'wordpress');
/* MySQL 数据库用户名 */
define('DB_USER', 'root');
/* MySQL 数据库密码 */
define('DB_PASSWD', 'root');
@prinsss
prinsss / autoload.js
Last active August 5, 2016 00:03
Add page view counter for Ghost blog
/**
* Add to $(document).ready()
* Will auto load page view for each post on the page
*/
$('[id=post-view]').each(function(){
url = 'http://127.0.0.1/count.php?action=get&slug='+$(this).attr('data').slice(1,-1);
var span = $(this);
$.getJSON(url, function(data) {
span.html(data.count);
});
@prinsss
prinsss / convert.php
Last active February 1, 2016 16:30
Convert data of WP-PostViews to fit custom page counter of Ghost
<?php
/**
* @Author: printempw
* @Date: 2016-02-01 20:37:43
* @Last Modified by: prpr
* @Last Modified time: 2016-02-01 22:10:06
*
* Configure your database connection info here.
* $wp_conn for WordPress installation database,
* $ghost_conn for which you place `post_views` table in.
@prinsss
prinsss / count_universal.php
Last active September 15, 2018 14:38
Ghost page view counter, support both MySQL and SQLite.
<?php
/**
* @Author: printempw
* @Date: 2016-01-31 17:08:29
* @Last Modified by: prpr
* @Last Modified time: 2016-02-02 16:31:55
*
* Database type, `mysql` or `sqlite`
*/
define('DB_TYPE', 'mysql');
@prinsss
prinsss / autoloader.php
Last active March 18, 2016 10:12
Autoload PHP namespace
<?php
function __autoload($classname) {
$dir = dirname(__FILE__);
$include_dir = $dir.DIRECTORY_SEPARATOR."includes".DIRECTORY_SEPARATOR."classes".DIRECTORY_SEPARATOR;
$filename = $include_dir.str_replace('\\', DIRECTORY_SEPARATOR, $classname) . '.class.php';
require_once($filename);
}
@prinsss
prinsss / robbyrussell-makaizou-local.zsh-theme
Last active April 20, 2018 18:37
Modified Zsh theme, Robby Russell Makaizou. Added user@hostname prompt which is convenient for VPS management.
# For local shell, prompt is lik this
# ➜ blessing-skin-server git:(master)$
local ret_status="%(?:%{$fg_bold[green]%}➜ :%{$fg_bold[red]%}➜ %s)"
PROMPT='${ret_status}%{$fg_bold[green]%}%p %{$fg[cyan]%}%c %{$fg_bold[blue]%}$(git_prompt_info)%{$fg_bold[blue]%}%{$reset_color%}%{$fg_bold[blue]%}$ %{$reset_color%}'
ZSH_THEME_GIT_PROMPT_PREFIX="git:(%{$fg[red]%}"
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[blue]%}) %{$fg[yellow]%}✗ %{$reset_color%}"
ZSH_THEME_GIT_PROMPT_CLEAN="%{$fg[blue]%})"
@prinsss
prinsss / click-game.css
Last active November 3, 2016 05:02
Click the element to show a "+1" animation and change the content of the element to a new kaomoji. Just for fun :)
#kaomoji {
-moz-user-select: none;
-webkit-user-select: none;
-ms-user-select: none;
}
.info-rise {
z-index: 99999;
position: absolute;
padding: 0 4px;
border-radius: 1px;