Skip to content

Instantly share code, notes, and snippets.

Avatar

Zeyi (Rice) Fan fanzeyi

View GitHub Profile
@felixrabe
felixrabe / string-utils.coffee
Last active Jun 25, 2018
CoffeeScript: String.startsWith() and String.endsWith()
View string-utils.coffee
# http://stackoverflow.com/a/646643
String::startsWith ?= (s) -> @slice(0, s.length) == s
String::endsWith ?= (s) -> s == '' or @slice(-s.length) == s
@danielrw7
danielrw7 / replify
Last active Jun 10, 2019
replify - Create a REPL for any command
View replify
#!/bin/sh
command="${*}"
printf "Initialized REPL for `%s`\n" "$command"
printf "%s> " "$command"
read -r input
while [ "$input" != "" ];
do
eval "$command $input"
printf "%s> " "$command"
@thedod
thedod / README
Created Mar 6, 2011
Webpy CSRF protection (request for comments)
View README
A simple trick against CSRF for web.py (webpy.org)
* At the GET() template, you add a hidden field called csrf_token with value "$csrf_token()"
* The POST() should have the @csrf_protected decorator
That's it.
Request for comments:
* Is this secure? Can you see any holes?
* Is there anything in [or for] web.py that does this? Am I reinvevting the wheel here?
@gudbergur
gudbergur / README.markdown
Created Feb 19, 2012
Bootstrap's Typeahead plugin extended (allowing for AJAX functionality) among other things
View README.markdown

This is a fork of Bootstrap Typeahead that adds minimal but powerful extensions.

For example, process typeahead list asynchronously and return objects

  # This example does an AJAX lookup and is in CoffeeScript
  $('.typeahead').typeahead(
    # source can be a function
    source: (typeahead, query) ->
      # this function receives the typeahead object and the query string
View bundle.vim
" VIM配置文件
" 设置语言及编码
source $VIMRUNTIME/delmenu.vim
source $VIMRUNTIME/menu.vim
set enc=utf-8
" set fencs=utf-8,ucs-bom,gbk,gb18030,shift-jis,gb2312,cp936
" 常规设置
set nocompatible " 关闭vi兼容模式
View did-you-know-re.py
from sre_parse import Pattern, SubPattern, parse as sre_parse
from sre_compile import compile as sre_compile
from sre_constants import BRANCH, SUBPATTERN
class Scanner(object):
def __init__(self, tokens, flags=0):
subpatterns = []
pat = Pattern()
@chuangbo
chuangbo / README.md
Last active Jun 3, 2020
Python dynamic DNSPod DNS Script
View README.md

替换上你的 API Token,域名ID,记录ID等参数,就可以运行了。 会在后台一直运行,每隔30秒检查一遍IP,如果修改了就更新IP。

获取 API Token 的方式

获得 domain_id 可以用 curl

curl -k https://dnsapi.cn/Domain.List -d "login_token=TOKEN"`
@sontek
sontek / snowjob.py
Created Dec 22, 2011
Make your terminal snow with python
View snowjob.py
#!/usr/bin/env python
import os
import random
import time
import platform
snowflakes = {}
try:
# Windows Support
@jirutka
jirutka / rules-both.iptables
Created Sep 18, 2012
Basic iptables template for ordinary servers (both IPv4 and IPv6)
View rules-both.iptables
###############################################################################
# The MIT License
#
# Copyright 2012-2014 Jakub Jirutka <jakub@jirutka.cz>.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
@mdo
mdo / 00-intro.md
Last active Aug 10, 2020
Instructions for how to affix an Ikea Gerton table top to the Ikea Bekant sit-stand desk frame.
View 00-intro.md

Ikea Bekant standing desk with Gerton table top

You can’t perform that action at this time.