This file contains hidden or 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.mydomain.com | |
| DocumentRoot /var/www | |
| ProxyRequests Off | |
| ProxyPass /media ! | |
| ProxyPass /static ! | |
| ProxyPass / http://127.0.0.1:8000/ |
This file contains hidden or 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
| server { | |
| listen 80; | |
| server_name example.com; | |
| return 301 http://www.example.com$request_uri; | |
| } | |
| server { | |
| listen 80; | |
| server_name www.example.com; | |
| } |
This file contains hidden or 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 fn(pattrn, table, text, _range): | |
| x = 0 | |
| if _range[1] <= len(text): | |
| x = 1 | |
| for i in range(_range[0], _range[1]): | |
| if text[_range[1] - x] != pattrn[len(pattrn) - x]: | |
| _ch = text[_range[1] - x] | |
| r = [x for x in table if x[1] == _ch] | |
| _shift = len(pattrn) if not r else r[0][0] | |
| _shift = _range[1] + (_shift + 1 if _shift < 1 else _shift) |
This file contains hidden or 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 | |
| encoding = 'utf-8' | |
| reload(sys) | |
| sys.setdefaultencoding(encoding) |
This file contains hidden or 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
| UPDATE `table_name` SET `column_name` = REPLACE(`column_name` ,'á','á'); | |
| UPDATE `table_name` SET `column_name` = REPLACE(`column_name` ,'ä','ä'); | |
| UPDATE `table_name` SET `column_name` = REPLACE(`column_name` ,'é','é'); | |
| UPDATE `table_name` SET `column_name` = REPLACE(`column_name` ,'í©','é'); | |
| UPDATE `table_name` SET `column_name` = REPLACE(`column_name` ,'ó','ó'); | |
| UPDATE `table_name` SET `column_name` = REPLACE(`column_name` ,'íº','ú'); | |
| UPDATE `table_name` SET `column_name` = REPLACE(`column_name` ,'ú','ú'); | |
| UPDATE `table_name` SET `column_name` = REPLACE(`column_name` ,'ñ','ñ'); | |
| UPDATE `table_name` SET `column_name` = REPLACE(`column_name` ,'í‘','Ñ'); | |
| UPDATE `table_name` SET `column_name` = REPLACE(`column_name` ,'Ã','í'); |
This file contains hidden or 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
| UPDATE `table_name` SET `column_name` = REPLACE(`column_name` ,'\\u00c0','À'); | |
| UPDATE `table_name` SET `column_name` = REPLACE(`column_name` ,'\\u00c1','Á'); | |
| UPDATE `table_name` SET `column_name` = REPLACE(`column_name` ,'\\u00c2','Â'); | |
| UPDATE `table_name` SET `column_name` = REPLACE(`column_name` ,'\\u00c3','Ã'); | |
| UPDATE `table_name` SET `column_name` = REPLACE(`column_name` ,'\\u00c4','Ä'); | |
| UPDATE `table_name` SET `column_name` = REPLACE(`column_name` ,'\\u00c5','Å'); | |
| UPDATE `table_name` SET `column_name` = REPLACE(`column_name` ,'\\u00c6','Æ'); | |
| UPDATE `table_name` SET `column_name` = REPLACE(`column_name` ,'\\u00c7','Ç'); | |
| UPDATE `table_name` SET `column_name` = REPLACE(`column_name` ,'\\u00c8','È'); | |
| UPDATE `table_name` SET `column_name` = REPLACE(`column_name` ,'\\u00c9','É'); |
This file contains hidden or 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
| Stop the running EC2 instance | |
| Detach its /dev/sda1 volume (let's call it volume A) | |
| Start new t1.micro EC2 instance, using my new key pair | |
| Attach volume A to the new micro instance, as /dev/xvdf (or /dev/sdf) | |
| SSH to the new micro instance and mount volume A to /mnt/tmp | |
| Copy ~/.ssh/authorized_keys to /mnt/tmp/home/ubuntu/.ssh/authorized_keys | |
| Logout | |
| Terminate micro instance | |
| Detach volume A from it | |
| Attach volume A back to the main instance as /dev/sda1 |
This file contains hidden or 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
| font_size = 60 | |
| text = 'your text' | |
| rgb_color = (255,255,255) | |
| img = Image.open('your-image.jpg') | |
| draw = ImageDraw.Draw(img) | |
| font = ImageFont.truetype('your-font.ttf', font_size) | |
| w, h = draw.textsize(text, font) |
This file contains hidden or 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 validate_max_rows(obj): | |
| max_num = 5 | |
| model = obj.__class__ | |
| if (model.objects.count() == max_num and obj.id is None): | |
| raise ValidationError(u"oops! max num is %d" % max_num) | |
| class Model(models.Model): | |
| # Fields | |
| def clean(self): | |
| validate_max_rows(self) |
This file contains hidden or 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
| server { | |
| listen 443 ssl; | |
| server_name example.com www.example.com; | |
| ssl_protocols TLSv1 TLSv1.1 TLSv1.2; | |
| ssl_prefer_server_ciphers on; | |
| ssl_ciphers 'ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-DSS-AES128-GCM-SHA256:kEDH+AESGCM:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-DSS-AES128-SHA256:DHE-RSA-AES256-SHA256:DHE-DSS-AES256-SHA:DHE-RSA-AES256-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:AES:CAMELLIA:DES-CBC3-SHA:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!MD5:!PSK:!aECDH:!EDH-DSS-DES-CBC3-SHA:!EDH-RSA-DES-CBC3-SHA:!KRB5-DES-CBC3-SHA'; | |
| ssl_session_timeout 1d; | |
| ssl_session_cache shared:SSL:50m; |