Skip to content

Instantly share code, notes, and snippets.

View sakti's full-sized avatar
🦀

Sakti Dwi Cahyono sakti

🦀
View GitHub Profile
#!/usr/bin/env python
"download random text file from gutenberg project into current directory; `pip install Gutenberg` first"
import random
from gutenberg.acquire import load_etext
from gutenberg.cleanup import strip_headers
list_generated_random = []
def get_unique_random(lower, upper):
choice = random.randrange(lower, upper)
Hi :)
blog: www.saktidwicahyono.name
email: 54krpl@gmail.com
`gorm:"<annotation>;<annotation>"`
size:255
AUTO_INCREMENT
- // ignore this field
many2many:user_languages;
index
unique_index
type:varchar(100)
not null

Client-side SSL

For excessively paranoid client authentication.

Using self-signed certificate.

Create a Certificate Authority root (which represents this server)

Organization & Common Name: Some human identifier for this server CA.

openssl genrsa -des3 -out ca.key 4096
openssl req -new -x509 -days 365 -key ca.key -out ca.crt

Sublime Text 2 – Useful Shortcuts (PC)

Loosely ordered with the commands I use most towards the top. Sublime also offer full documentation.

Editing

Ctrl+C copy current line (if no selection)
Ctrl+X cut current line (if no selection)
Ctrl+⇧+K delete line
Ctrl+↩ insert line after
# list
buah = ['duku', 'jeruk', 'semangka']
# dictionaries
duku = {'warna': 'krem', 'berat': 10, 'rasa': 'asem'}
jeruk = {'warna': 'hijau', 'berat': 30, 'rasa': 'kecut'}
semangka = {'warna': 'kuning', 'berat': 90, 'rasa': 'manis'}
for item in buah:
#!/usr/bin/python
#based on the ideas from http://synack.me/blog/implementing-http-live-streaming
# Run this script and then launch the following pipeline:
# gst-launch videotestsrc pattern=ball ! video/x-raw-rgb, framerate=15/1, width=640, height=480 ! jpegenc ! multipartmux boundary=spionisto ! tcpclientsink port=9999
from Queue import Queue
from threading import Thread
from socket import socket
from select import select
from wsgiref.simple_server import WSGIServer, make_server, WSGIRequestHandler
#!/usr/bin/python
#based on the ideas from http://synack.me/blog/implementing-http-live-streaming
# Run this script and then launch the following pipeline:
# gst-launch videotestsrc pattern=ball ! video/x-raw-rgb, framerate=15/1, width=640, height=480 ! jpegenc ! multipartmux boundary=spionisto ! tcpclientsink port=9999
from Queue import Queue
from threading import Thread
from socket import socket
from select import select
from wsgiref.simple_server import WSGIServer, make_server, WSGIRequestHandler