Skip to content

Instantly share code, notes, and snippets.

View tuupola's full-sized avatar

Mika Tuupola tuupola

View GitHub Profile
@tuupola
tuupola / httpd-vhosts.conf
Created November 4, 2011 15:40
Automatic virtual hosts
<VirtualHost *:80>
ServerAdmin webmaster@localhost
VirtualDocumentRoot "/Users/tuupola/Code/www/%0/htdocs"
ServerName dev.subdomains
ServerAlias dev.*
LogFormat "%V %h %l %u %t \"%r\" %s %b" vcommon
ErrorLog "/Users/tuupola/Code/www/logs/vhosts-error_log"
CustomLog "/Users/tuupola/Code/www/logs/vhosts-access_log" vcommon
</VirtualHost>
<pre><div class="edit" id="unique_id">Editable text</div>
<a href="#" class="edit_trigger">Edit me!!</a></pre>
$(".edit").editable("http://www.example.com/save.php", {
event : "edit"
});
/* Find and trigger "edit" event on correct Jeditable instance. */
$(".edit_trigger").bind("click", function() {
<div class="edit" id="unique_id">Editable text</div>
<a href="#" class="edit_trigger">Edit me!!</a></pre>
@tuupola
tuupola / chmodgw.sh
Created March 8, 2012 12:05
Update webserver permissions
#!/usr/bin/bash
for vhost in `ls /www`; do
if [ -d /www/$vhost/htdocs ]; then
/usr/local/bin/find /www/$vhost/htdocs -print0 | /usr/local/bin/xargs -0 chmod g+w
fi
if [ -d /www/$vhost/include ]; then
/usr/local/bin/find /www/$vhost/include -print0 | /usr/local/bin/xargs -0 chmod g+w
fi
done
@tuupola
tuupola / gist:3872711
Created October 11, 2012 14:25
Average Apache memory usage
ps aux | grep httpd | grep -v pts | awk '{ tot += $6; procs += 1; print $2,$6,$11 } END { print "TOTAL:",tot,"/",procs,"=",tot/procs }'
@tuupola
tuupola / gist:3877855
Created October 12, 2012 07:53
Fix for. Centos screen No more PTYs. Sorry could not find PTY.
sudo mount -t devpts /dev/ptmx /dev/pts
@tuupola
tuupola / invite.js
Created November 7, 2012 13:39
Facebook share and message
$("#invite").bind("click", function(event) {
var invitation = {
method: "send",
name: "Lorem ipsum dolor sit amet",
link: "http://www.example.com/",
picture: "http://placekitten.com/95/95",
//to: next_uid,
description: "Typi non habent claritatem insitam; est usus legentis in iis qui facit eorum claritatem."
};
@tuupola
tuupola / .htaccess
Created December 12, 2012 10:34
Force https in .htaccess
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
@tuupola
tuupola / links.html
Last active December 21, 2015 20:59
Example on how to do Google Event tracking.
@tuupola
tuupola / index.php
Created April 18, 2015 14:03
Sample JWT workflow with HTTP Basic Auth
<?php
use \Slim\Middleware\JwtAuthentication;
use \Slim\Middleware\JwtAuthentication\RequestPathRule;
use \Slim\Middleware\HttpBasicAuthentication;
/* Setup Slim */
$app = new \Slim\Slim();
$app->add(new JwtAuthentication([