Skip to content

Instantly share code, notes, and snippets.

@TakayoshiMiyamoto
TakayoshiMiyamoto / gist:70988f326c6989ef0862
Created February 16, 2016 14:51
PHPUnit Exception: Serialization of Closure is not allowed
# --no-globals-backup: Do not backup and restore $GLOBALS for each test.
# Options link: https://phpunit.de/manual/current/en/textui.html#textui.clioptions
$ phpunit --no-globals-backup test_script.php
@TakayoshiMiyamoto
TakayoshiMiyamoto / validators.py
Last active February 11, 2016 12:05
Python email, password validators
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import re
def validate_str_len_max(length):
def decorator(func):
def wrapper(*args, **kwargs):
if len(args[0]) <= length:
@TakayoshiMiyamoto
TakayoshiMiyamoto / aes_crypto.py
Created February 2, 2016 17:37
Python Multi-byte aes crypto
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import base64
from Crypto import Random
from Crypto.Cipher import AES
# Block size
BS = 32
@TakayoshiMiyamoto
TakayoshiMiyamoto / settings.sh
Last active December 30, 2021 06:31
Vagrant, Ubuntu14.04, uWSGI, Nginx, Python3.5, Flask, MariaDB first settings.
# Versions:
# Vagrant: 1.8.1
# Ubuntu: 14.04
# uWSGI: 2.0.12
# Nginx: 1.8.1
# Python: 2.7.6, 3.5.1
# Flask: 0.10.1
# MariaDB: 5.5.46
# My computer: MacOSⅩ 10.10.5 (Yosemite)
# VM: VirtualBox 5.0.14
@TakayoshiMiyamoto
TakayoshiMiyamoto / NSURLRequest+SelfSignedCertificate.h
Created December 30, 2015 09:53
NSURLConnection/CFURLConnection HTTP load failed (kCFStreamErrorDomainSSL, -9813)
#import <Foundation/Foundation.h>
@interface NSURLRequest (SelfSignedCertificate)
#ifdef DEBUG
+ (BOOL)allowsAnyHTTPSCertificateForHost:(NSString *)host;
#endif
@end
@TakayoshiMiyamoto
TakayoshiMiyamoto / gist:e7664e536763976b2d2c
Created December 30, 2015 08:18
CakePHP: Table table_name for model TableModelName was not found in datasource default
rm app/tmp/cache/models/*