This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
def same_row(i,j): return (i/9 == j/9) | |
def same_col(i,j): return (i-j) % 9 == 0 | |
def same_block(i,j): return (i/27 == j/27 and i%9/3 == j%9/3) | |
class InconsistentPositionError(Exception): | |
pass | |
def still_consistent(a): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# INSTALLATION | |
# ------------ | |
# Put this script in the bin directory of your virtualenv and make it user executable: | |
# $ cp pip_upgrade_all.sh /path/to/your_virtualenv/bin/ | |
# $ chmod u+x /path/to/your_virtualenv/bin/pip_upgrade_all.sh | |
# USAGE | |
# ----- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# A script to resample your FLAC files *and* make sure they conform to the FLAC Subset | |
# specification so they will play in pretty much all hardware players - e.g. portable | |
# music players like those made by COWON - all this while minimizing file sizes. | |
# Requirements: | |
# - Bash 4 or newer (for the globstar) | |
# - sox | |
# - flac |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
## The contents of this file are subject to the Mozilla Public License | |
## Version 1.1 (the "License"); you may not use this file except in | |
## compliance with the License. You may obtain a copy of the License | |
## at http://www.mozilla.org/MPL/ | |
## | |
## Software distributed under the License is distributed on an "AS IS" | |
## basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See | |
## the License for the specific language governing rights and | |
## limitations under the License. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ sudo netstat -anp | grep beam | |
tcp 0 0 0.0.0.0:33793 0.0.0.0:* LISTEN 2157/beam | |
tcp 0 0 127.0.0.1:33813 127.0.0.1:4369 ESTABLISHED 2157/beam | |
tcp6 0 0 :::5672 :::* LISTEN 2157/beam |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<table cellspacing=0 cellpadding=0> | |
<tr><td bgcolor="#000000"> | |
</td></tr>olor="#ffffff" face="Arial,Helvetica">SSL/TLS Session Cache Status:</font></b> | |
<tr><td bgcolor="#ffffff"> | |
cache type: <b>SHMCB</b>, shared memory: <b>512000</b> bytes, current sessions: <b>5</b><br>subcaches: <b>32</b>, indexes per subcache: <b>133</b><br>time left on oldest entries' SSL sessions: avg: <b>160</b> seconds, (range: 40...280)<br>index usage: <b>0%</b>, cache usage: <b>0%</b><br>total sessions stored since starting: <b>1749</b><br>total sessions expired since starting: <b>1744</b><br>total (pre-expiry) sessions scrolled out of the cache: <b>0</b><br>total retrieves since starting: <b>456</b> hit, <b>104</b> miss<br>total removes since starting: <b>0</b> hit, <b>0</b> miss<br></td></tr> | |
</table> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<VirtualHost *:80> | |
ServerName www.my-site.com | |
RewriteEngine On | |
RewriteOptions inherit | |
# Hide the admin interface from the public internet. Make it only accessible from the company office | |
RewriteCond ${REMOTE_ADDR} !=153.64.172.11 | |
RewriteRule ^/admin(/.*)? - [L,R=404] | |
RewriteRule ^/(.*)$ http://172.20.11.13/$1 [L,P] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def add_employees(request): | |
# Some preparation... (skipped) | |
success_msg = '' | |
roles = get_roles() | |
if request.method == 'POST': | |
form = EmployeeForm(request.POST, roles=roles) | |
if form.is_valid(): | |
# add the employees... (details omitted) | |
success_msg = 'yay' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ set -x | |
++ ps1date | |
++ local d dow day date time col | |
++ printf -v d '%(%u_%Y-%m-%d_%a_%H:%M:%S %Z)T' -1 | |
++ dow=6 | |
++ d='2014-06-07_Sat_09:34:57 HKT' | |
++ date=2014-06-07 | |
++ d='Sat_09:34:57 HKT' | |
++ day=Sat | |
++ time='09:34:57 HKT' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
# pywin32 | |
from win32api import GetLastError | |
from win32event import CreateEvent, WaitForSingleObject | |
from win32file import ReadFile, WriteFile | |
from win32pipe import CreateNamedPipe, ConnectNamedPipe, DisconnectNamedPipe | |
from win32pipe import PIPE_ACCESS_DUPLEX, PIPE_READMODE_MESSAGE, PIPE_TYPE_MESSAGE, PIPE_UNLIMITED_INSTANCES, PIPE_WAIT | |
from winerror import ERROR_IO_PENDING, ERROR_PIPE_CONNECTED |
OlderNewer