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 merge_sort(lst): | |
""" | |
Performs in-place sorting using the merge sort algorithm | |
""" | |
if len(lst) > 1: | |
mid = len(lst) // 2 | |
left = lst[:mid] | |
right = lst[mid:] | |
merge_sort(left) |
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/bash | |
# Create a swap file with 8GB size | |
dd if=/dev/zero of=/swapfile bs=8192 count=1048576 | |
mkswap /swapfile | |
swapon /swapfile | |
# Add to /etc/fstab | |
# device target fs options dump pass | |
# /swapfile none swap sw 0 0 |
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
from twisted.application.service import Service | |
from twisted.protocols.basic import LineReceiver | |
from twisted.python import log | |
from twisted.internet.protocol import ClientCreator | |
from twisted.internet import reactor | |
class MyProtocol(LineReceiver): | |
def lineReceived(self, line): | |
# process bot command | |
log.msg("recv:", line) |
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
Install pypy | |
1. Go to sbo->python->pypy | |
2. Download pypy-1.9-linux64.tar.bz2 | |
3. Run pypy.Slackbuild | |
Install distribute | |
1. Go to sbo->python-distribute | |
2. Download distribute-0.6.30.tar.gz | |
3. Edit distribute.Slackbuild to: | |
- use pypy instead of python in running setup.py |
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
/*! | |
* Node.js script to encrypt and decrypt an arbitrary string using | |
* 128-bit AES method in CFB mode. | |
* | |
*/ | |
// A 16-byte key is required for a 128-bit encryption | |
var crypto = require('crypto'), | |
key = new Buffer('sixteen byte key'), | |
iv = crypto.randomBytes(16), |