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
| function rrmdir($dir) { | |
| if (is_dir($dir)) { | |
| $objects = scandir($dir); | |
| foreach ($objects as $object) { | |
| if ($object != "." && $object != "..") { | |
| if (filetype($dir."/".$object) == "dir") rrmdir($dir."/".$object); else unlink($dir."/".$object); | |
| } | |
| } | |
| reset($objects); | |
| rmdir($dir); |
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
| class Array | |
| def ^(that) | |
| self + that - (self & that) | |
| end | |
| end |
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
| #include <stdio.h> | |
| #include <stdlib.h> | |
| typedef struct { | |
| int i; | |
| } student; | |
| int main() | |
| { | |
| student *s = malloc(sizeof(student)); |
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
| >>> a = range(10000) | |
| >>> def b(): | |
| ... return len(set(a)) == 1 | |
| ... | |
| >>> def c(): | |
| ... return all(x == a[0] for x in a) | |
| ... | |
| >>> timeit.timeit(b, number=1000) | |
| 0.4336268901824951 | |
| >>> timeit.timeit(c, number=1000) |
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
| from multiprocessing import Pool | |
| from time import sleep | |
| from sys import exit | |
| def slowly_square(i): | |
| sleep(1) | |
| return i*i | |
| def go(): | |
| pool = Pool(8) |
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
| #!/usr/bin/env python | |
| # http://jtushman.github.io/blog/2014/01/14/python-%7C-multiprocessing-and-interrupts/ | |
| from multiprocessing import Process | |
| from multiprocessing.managers import SyncManager | |
| import time | |
| import signal | |
| def mgr_init(): | |
| signal.signal(signal.SIGINT, signal.SIG_IGN) |
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
| ntpdate time.stdtime.gov.tw |
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
| # Zenburn colours scheme for Xfce Terminal. Copy and paste the following in ${HOME}/.config/Terminal/terminalrc: | |
| ColorBackground=#404040 | |
| ColorForeground=#F6F3E8 | |
| ColorPalette1=#3f3f3f3f3f3f | |
| ColorPalette2=#e8e893939393 | |
| ColorPalette3=#9e9ecece9e9e | |
| ColorPalette4=#f0f0dfdfafaf | |
| ColorPalette5=#8c8cd0d0d3d3 | |
| ColorPalette6=#c0c0bebed1d1 |
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
| if [ -f /etc/bashrc ]; then | |
| . /etc/bashrc | |
| fi | |
| if [ -f /etc/bash_completion ]; then | |
| . /etc/bash_completion | |
| fi | |
| xhost +local:root > /dev/null 2>&1 |
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
| Preferred package installation list for CentOS: | |
| Usage: | |
| $ sudo yum install -y $(curl https://gist.githubusercontent.com/jlhg/9365775/raw/yum-pkg) |