Git 比较不同版本文件差异的常用命令格式:
git diff 查看尚未暂存的文件更新了哪些部分
git diff filename 查看尚未暂存的某个文件更新了哪些
git diff –cached 查看已经暂存起来的文件和上次提交的版本之间的差异
git diff –cached filename 查看已经暂存起来的某个文件和上次提交的版本之间的差异
# Y Combinator in Python | |
# See <http://d.hatena.ne.jp/nowokay/20090409#1239268405> | |
true = lambda x: lambda y: x | |
false = lambda x: lambda y: y | |
# `bool` to `true|false` | |
# | |
# >>> boolean(3 < 4)(2)(5) | |
# 2 |
import datetime | |
from django.conf import settings | |
from django.contrib.auth import logout | |
from django.contrib.auth.models import User | |
from django.contrib.sessions.models import Session | |
from django.http import HttpRequest | |
from django.utils.importlib import import_module | |
require 'gollum/frontend/app' | |
require 'digest/sha1' | |
class App < Precious::App | |
User = Struct.new(:name, :email, :password_hash, :can_write) | |
before { authenticate! } | |
before /^\/(edit|create|delete|livepreview|revert)/ do authorize_write! ; end | |
helpers do |
# -*- coding: utf-8 -*- | |
import Image | |
def resize_and_crop(img_path, modified_path, size, crop_type='top'): | |
""" | |
Resize and crop an image to fit the specified size. | |
args: | |
img_path: path for the image to resize. |
Git 比较不同版本文件差异的常用命令格式:
git diff 查看尚未暂存的文件更新了哪些部分
git diff filename 查看尚未暂存的某个文件更新了哪些
git diff –cached 查看已经暂存起来的文件和上次提交的版本之间的差异
git diff –cached filename 查看已经暂存起来的某个文件和上次提交的版本之间的差异
import fcntl | |
from contextlib import contextmanager | |
@contextmanager | |
def flocked(fd): | |
""" Locks FD before entering the context, always releasing the lock. """ | |
try: | |
fcntl.flock(fd, fcntl.LOCK_EX) | |
yield | |
finally: |
The plan is to create a pair of executables (ngrok
and ngrokd
) that are connected with a self-signed SSL cert. Since the client and server executables are paired, you won't be able to use any other ngrok
to connect to this ngrokd
, and vice versa.
Add two DNS records: one for the base domain and one for the wildcard domain. For example, if your base domain is domain.com
, you'll need a record for that and for *.domain.com
.
To install tcptraceroute on Debian/Ubuntu:
$ sudo apt-get install tcptraceroute
To install tcptraceroute on CentOS/REHL, first set up RepoForge on your system, and then:
$ sudo yum install tcptraceroute
def AbstractClassWithoutFieldsNamed(cls, *excl): | |
""" | |
Removes unwanted fields from abstract base classes. | |
Usage:: | |
>>> from oscar.apps.address.abstract_models import AbstractBillingAddress | |
>>> from koe.meta import AbstractClassWithoutFieldsNamed as without | |
>>> class BillingAddress(without(AbstractBillingAddress, 'phone_number')): | |
... pass |
// See: http://stackoverflow.com/questions/17218089/salt-and-hash-using-pbkdf2 | |
// See: https://crackstation.net/hashing-security.htm | |
'use strict'; | |
let Promise = require('bluebird'); | |
let crypto = require('crypto'); | |
function calcPassword(password) { | |
const RANDOM_BYTES = 64; |