Skip to content

Instantly share code, notes, and snippets.

View calvinchengx's full-sized avatar
:octocat:
Focusing

Calvin Cheng calvinchengx

:octocat:
Focusing
View GitHub Profile
if [ -e /etc/sudoers.tmp -o "$(pidof visudo)" ]; then
echo $(pidof visudo)
echo "/etc/sudoers busy, try again later"
exit 1
fi
cp -p /etc/sudoers /etc/sudoers.bak
cp -p /etc/sudoers /etc/sudoers.tmp
line="%wheel ALL=(ALL) ALL"
import urlparse
from selenium import webdriver
from django.test import TestCase
from django.conf import settings
from django.core.urlresolvers import reverse
class BackendsTest(TestCase):
def setUp(self):
@calvinchengx
calvinchengx / gist:2641756
Created May 9, 2012 04:16
Why the weird warning?
calvin$ python setup.py register
/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution option: 'install_requires'
warnings.warn(msg)
running register
running check
@calvinchengx
calvinchengx / gist:2642480
Created May 9, 2012 06:39
Automated, programmatic creation of cherokee virtual server, reverse proxy with django cherrypy information sources
# User provides these input on an existing web interface, say for example on "www.od-eon.com/deploy":-
* project name
* project's domain name
* and his email address
# PHASE 1: MASTER SERVER SET-UP
# linode server kernel build `bootstrapping`
# base package installation in the new machine instance
# root user, web user and git user creation
@calvinchengx
calvinchengx / gist:2642826
Created May 9, 2012 08:02
systemd's cherokee.service
[Unit]
Description=Cherokee Lightweight Web Server
After=network.target
[Service]
Type=forking
PIDFile=/var/run/cherokee.pid
ExecStart=/usr/sbin/cherokee -d -C /etc/cherokee/cherokee.conf
[Install]
@calvinchengx
calvinchengx / gist:2642992
Created May 9, 2012 08:31
systemd's cherrypy-[project name].service
[Unit]
Description=Cherrypy
After=network.target
[Service]
ExecStart=/bin/su web -l -c "/bin/bash --login -c /var/www/[project name]/[project name]/cherrypy_server.sh"
[Install]
WantedBy=multi-user.target
@calvinchengx
calvinchengx / gist:2643069
Created May 9, 2012 08:46
systemd's cherrpy@.service
# An alternative approach which is more "systemd" native
cpserver@.service:
[Unit]
Description=cherrypy server on port %i
[Service]
WorkingDirectory=/...
// Use "appendChild" on the CDATA node we created.
$placemarkDescriptionNode = $dom->createElement('description');
$placemarkDescriptionCDATANode = $dom->createCDATASection(html_entity_decode($row['description']));
$placemarkDescriptionCDATANode = $placemarkDescriptionNode->appendChild($placemarkDescriptionCDATANode);
// So we create a wrapper node, called "description".
// Then we create a node that will contain your "CDATA" that's stored in a variable (I get it straight from my database).
@calvinchengx
calvinchengx / gist:2895247
Created June 8, 2012 11:58
systemd's postgresql.service
[Unit]
Description=PostgreSQL database server
[Service]
Type=forking
SyslogIdentifier=postgres
PIDFile=/var/lib/postgres/data/postmaster.pid
# initdb script takes care for symlinking $PGROOT to /var/lib/postgres
ExecStartPre=/usr/lib/systemd/scripts/postgresql-initdb
pacman -Syy --noconfirm
(echo n; echo Y) | pacman -S haveged
(echo n; echo Y) | pacman -S glibc --force
pacman -S pacman --noconfirm
haveged -w 1024
pacman-key --init
pacman-key --populate archlinux # Manual intervention required
pkill haveged
pacman -Rs haveged --noconfirm
pacman -S base-devel --noconfirm