Skip to content

Instantly share code, notes, and snippets.

@monkyz
monkyz / gist:3667658
Created September 7, 2012 16:41
apache user and group
ps aux | grep apache
www-data 4752 0.1 5.4 53368 27740 ? S 16:36 0:04 /usr/sbin/apache2 -k start
www-data 4756 0.0 5.1 52828 26416 ? S 16:36 0:01 /usr/sbin/apache2 -k start
www-data 4757 0.0 5.1 53020 26432 ? S 16:36 0:00 /usr/sbin/apache2 -k start
www-data 4762 0.0 1.6 35540 8340 ? S 16:36 0:00 /usr/sbin/apache2 -k start
www-data 5059 0.0 1.0 34392 5192 ? S 17:20 0:00 /usr/sbin/apache2 -k start
www-data 5071 0.0 4.9 52712 25384 ? S 17:21 0:00 /usr/sbin/apache2 -k start
myuser 5344 0.0 0.1 3372 756 pts/0 S+ 17:36 0:00 grep --color=auto apache
root 15076 0.0 1.6 34176 8608 ? Ss Aug20 1:12 /usr/sbin/apache2 -k start
@monkyz
monkyz / gist:3670077
Created September 7, 2012 21:59
drupal permissions script
#!/bin/bash
USER="user"
DOMAIN="DOMAIN"
#set the site here
SITE="/home/$USER/public_html/$DOMAIN"
# group is apache user (ex: www-data)
USER=$USER:www-data
@monkyz
monkyz / gist:3670552
Created September 7, 2012 23:06
drupal fix for permission issue
after chmod to 775 and reversing to 755, i had errors such as:
The selected file /tmp/file9kryvl could not be uploaded, because the destination sites/default/files/css/css_a5fe171ec6ef6dbf025f1b7fb1e4b78b.css is not properly configured.
The selected file /tmp/filePY11z6 could not be uploaded, because the destination sites/default/files/js/js_9eb6a4659c6cd03efedd85f2d3ae96b6.js is not properly configured.
The selected file /tmp/fileqtpqQR could not be uploaded, because the destination sites/default/files/js/js_064419d14a77f293c45395e1d45e50b8.js is not properly configured.
------------------------------------------------------------------------------------
fix:
chmod -R u+rwX,go+rX,go-w sites/default/files
@monkyz
monkyz / gist:3765052
Created September 22, 2012 03:48
function quicksort
Simple version
In simple pseudocode, the algorithm might be expressed as this:
function quicksort('array')
if length('array') ≤ 1
return 'array' // an array of zero or one elements is already sorted
select and remove a pivot value 'pivot' from 'array'
create empty lists 'less' and 'greater'
for each 'x' in 'array'
@monkyz
monkyz / qsort.js
Created September 22, 2012 04:20 — forked from guipn/qsort.js
Simple quicksort implementations
// The simplest implementation I can write.
function qsort(array) {
var lower, upper, pivot;
if (array.length <= 1) {
return array;
}
@monkyz
monkyz / gist:3791032
Created September 26, 2012 22:28
nginx + fast cgi vhost for drupal
server {
listen 80;
server_name subdomain.domain.com;
access_log /home/user/drupal/logs/access.log;
error_log /home/user/drupal/logs/error.log;
client_max_body_size 6M;
server {
server_name domain.tld;
root /var/www/drupal6; ## <-- Your only path reference.
location = /favicon.ico {
log_not_found off;
access_log off;
}
location = /robots.txt {
@monkyz
monkyz / gist:3798058
Created September 28, 2012 05:19
nginx vhost taken from chat
# Server configuration for example.com
server {
# Require HTTP authentication.
#auth_basic "Restricted";
#auth_basic_user_file /home/example/.htpasswd;
# Limit each user to 20 max connections.
limit_conn default 20;
@monkyz
monkyz / linux_ssh_bastion
Created October 7, 2012 20:48
Creating a transparent SSH tunnel through a bastion host
source article:
http://backdrift.org/transparent-proxy-with-ssh
Creating a transparent SSH tunnel through a bastion host using the ProxyCommand configuration parameter
Tags: linux, ssh, unix
Like most users out there (I think) my systems are usually configured to allow ssh connections from a small handfull of trusted hosts or a bastion host. This is decent security practice but is a total pain when you want to scp a file or grab the stdout of a command from a host outside the trusted area. Or perhaps you have a number of hosts on a private subnet and only one routable host to get in through. I was able to set up a method which allows for transparent access to a host while behind the scenes tunneling through a trusted bastion host involving some pretty minor adjustments to the .ssh/config file.
Here’s how it works: