Skip to content

Instantly share code, notes, and snippets.

@zhasm
zhasm / rails_resources.md
Created May 7, 2014 03:19 — forked from jookyboi/rails_resources.md
Rails-related Gems and guides to accelerate your web project.

Gems

  • Bundler - Bundler maintains a consistent environment for ruby applications. It tracks an application's code and the rubygems it needs to run, so that an application will always have the exact gems (and versions) that it needs to run.
  • rabl - General ruby templating with json, bson, xml, plist and msgpack support
  • Thin - Very fast and lightweight Ruby web server
  • Unicorn - Unicorn is an HTTP server for Rack applications designed to only serve fast clients on low-latency, high-bandwidth connections and take advantage of features in Unix/Unix-like kernels.
  • SimpleCov - SimpleCov is a code coverage analysis tool for Ruby 1.9.
  • Zeus - Zeus preloads your Rails app so that your normal development tasks such as console, server, generate, and specs/tests take less than one second.
  • [factory_girl](h
@zhasm
zhasm / javascript_resources.md
Created May 7, 2014 03:19 — forked from jookyboi/javascript_resources.md
Here are a set of libraries, plugins and guides which may be useful to your Javascript coding.

Libraries

  • jQuery - The de-facto library for the modern age. It makes things like HTML document traversal and manipulation, event handling, animation, and Ajax much simpler with an easy-to-use API that works across a multitude of browsers.
  • Backbone - Backbone.js gives structure to web applications by providing models with key-value binding and custom events, collections with a rich API of enumerable functions, views with declarative event handling, and connects it all to your existing API over a RESTful JSON interface.
  • AngularJS - Conventions based MVC framework for HTML5 apps.
  • Underscore - Underscore is a utility-belt library for JavaScript that provides a lot of the functional programming support that you would expect in Prototype.js (or Ruby), but without extending any of the built-in JavaScript objects.
  • lawnchair - Key/value store adapter for indexdb, localStorage
@zhasm
zhasm / 0_reuse_code.js
Created May 7, 2014 03:18
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@zhasm
zhasm / getkey.py
Created March 18, 2014 06:15
get keypress without enter
def getkey():
"get key press without Enter"
import termios, sys, os
fd = sys.stdin.fileno()
old = termios.tcgetattr(fd)
new = termios.tcgetattr(fd)
new[3] = new[3] & ~TERMIOS.ICANON & ~TERMIOS.ECHO
new[6][TERMIOS.VMIN] = 1
@zhasm
zhasm / snippet.py
Last active October 4, 2016 07:36
python snippets
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
#author: rex
#blog: http://iregex.org
#
import re
from os.path import dirname as dirname
@zhasm
zhasm / my.sql
Last active August 29, 2015 13:56
brew install mysql
### mysql
A "/etc/my.cnf" from another install may interfere with a Homebrew-built
server starting up correctly.
To connect:
mysql -uroot
To have launchd start mysql at login:
ln -sfv /usr/local/opt/mysql/*.plist ~/Library/LaunchAgents
Then to load mysql now:
@zhasm
zhasm / new_mac.md
Last active December 9, 2016 00:46
New Mac Configration
@zhasm
zhasm / .user.el
Last active January 4, 2016 17:09
keyboard.shortcuts
;;; rex zone
;; show linum by default
(global-linum-mode t)
(setq linum-format " %03d ")
(setq display-time-day-and-date t)
(setq display-time-24hr-format t)
@zhasm
zhasm / ff.url.php
Created December 24, 2013 10:35
url regex.
const URL_REGEXP_PROTOCOL = '(?:(http|https):\/\/)';
const URL_REGEXP_USER = '(?:[^\/]+?(?::[^\/]+?)?@)?';
const URL_REGEXP_HOST = '(?:(?:(www\.)?(?:[\w\-]+\.)+(?:[a-z]{2,4}))|(?:(?:\d{1,3}\.){3}\d{1,3}))';
const URL_REGEXP_PORT = '(?::\d{1,5})';
const URL_REGEXP_QUERY = '(?:\/[\w\-\?\.\=\&\+\%\[\]\/#;@:~!]*)';
@zhasm
zhasm / curlicue
Created December 12, 2013 02:41
1,准备:将curlicue, curlicue-setup 保存到可识别的 bin 路径下,+x;将 msg 函数放到 ~/.bashrc 里,souce 一下; 2,初始化:执行 curlicue-setup ,按照提示操作; 3,发消息:msg NAME MESSAGE
#!/bin/sh
# Curlicue - an OAuth wrapper for curl
#
# Copyright © 2010 Decklin Foster <decklin@red-bean.com>
# Please see README for usage information and LICENSE for license.
# Because HTTP responses from the OAuth "dance" will be percent-encoded,
# and we want to round-trip this data, we require that credentials files
# are also percent-encoded. Therefore, no decoding is done here. $1 is