Skip to content

Instantly share code, notes, and snippets.

View Fity's full-sized avatar
🎯
Focusing

Fity Yang Fity

🎯
Focusing
View GitHub Profile
@Fity
Fity / README.md
Created August 13, 2014 02:37 — forked from lbolla/README.md

Asynchronous programming with Tornado

Asynchronous programming can be tricky for beginners, therefore I think it's useful to iron some basic concepts to avoid common pitfalls.

For an explanation about generic asynchronous programming, I recommend you one of the [many][2] [resources][3] [online][4].

I will focus on solely on asynchronous programming in [Tornado][1]. From Tornado's homepage:

#!/bin/zsh
# with bugs, can not use $$, it is the current pid, use $PPID instead
function Usage() {
cat<<EOF
change the parameter orders of the last command and execute again
eg:
for commmand 'ls -l -a -h'
chargs 3 1 2
#!/usr/bin/env python
# -*- coding:utf-8 -*-
'''Change the order of the last command and excute again
Not completed, canceled.
@Author [email protected]
'''
import logging
import os
import subprocess

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@Fity
Fity / tmux.md
Last active August 29, 2015 14:25 — forked from andreyvit/tmux.md

tmux cheat sheet

(C-x means ctrl+x, M-x means alt+x)

Prefix key

The default prefix is C-b. If you (or your muscle memory) prefer C-a, you need to add this to ~/.tmux.conf:

remap prefix to Control + a

@Fity
Fity / buttondown.css
Created October 30, 2015 05:45 — forked from ryangray/buttondown.css
A clean, minimal CSS stylesheet for Markdown, Pandoc and MultiMarkdown HTML output.
/*
Buttondown
A Markdown/MultiMarkdown/Pandoc HTML output CSS stylesheet
Author: Ryan Gray
Date: 15 Feb 2011
Revised: 21 Feb 2012
General style is clean, with minimal re-definition of the defaults or
overrides of user font settings. The body text and header styles are
left alone except title, author and date classes are centered. A Pandoc TOC
@Fity
Fity / github-pandoc.css
Created October 30, 2015 05:46 — forked from dashed/github-pandoc.css
GitHub-like CSS for pandoc standalone HTML files (perfect for HTML5 output). Based on Marked.app's GitHub CSS. Added normalize.css (v2.1.3) in the prior to GitHub css.
/*! normalize.css v2.1.3 | MIT License | git.io/normalize */
/* ==========================================================================
HTML5 display definitions
========================================================================== */
/**
* Correct `block` display not defined in IE 8/9.
*/
@Fity
Fity / ssh-agent-start.fish
Last active December 10, 2016 08:41
Start ssh-agent gracefully. Modified from the wide spreaded script.
#this script can never fail
#Usage: put this line into your config.fish
# source $HOME/.config/fish/ssh_agent_start.fish && start_agent
setenv SSH_ENV $HOME/.ssh/environment
function __setup_env
if [ -f $SSH_ENV ]
. $SSH_ENV > /dev/null
@Fity
Fity / indexable_json_column.py
Created June 6, 2017 06:05
Indexable JSON Column for SQLAlchemy
class JsonEncodedDict(sqlalchemy.TypeDecorator):
"""Enables JSON storage by encoding and decoding on the fly."""
impl = sqlalchemy.VARCHAR
def process_bind_param(self, value, dialect):
if value is not None:
value = json.dumps(value)
return value
def process_result_value(self, value, dialect):
@Fity
Fity / flipboard.js
Created May 13, 2018 09:22
flipboard challenge solution.
var s = ''
var result = ''
var step = async (x, y, last) => {
const response = await fetch(`/step?s=${s}&amp;x=${x}&amp;y=${y}`)
const json = await response.json()
const adjacent = json.adjacent.filter(
item => JSON.stringify(item) !== JSON.stringify(last)
)
if (json.end) {