Sam Rose's blog

Use Perl to find and replace

perl -pi -e "s/findtext/replacetext/g" *.txt

Deploy Drupal sites to remote server with GIT and Capistrano

Follow the instructions here for creating users on source server:

http://mattrude.com/2009/07/creating-a-secure-git-repository-server/

(ignore the rest of instructions on that blog post)

Capistrano set up will then be the same as http://socialsynergyweb.org/network/blog/building-capistrano-recipe-rail...

example:

Running git commands, etc

capfile would run http://en.wikipedia.org/wiki/Secure_copy command from destination to secure copy over db dump.

PHP code for Mediawiki Auth via API

adapted from: http://www.mwusers.com/forums/showthread.php?11287-Website-Login-with-AP...

<?php
$ch=curl_init();
$postfield = "lgname=$username&lgpassword=$password";
$url = "http://localhost/wiki/api.php?action=login"; //url to wiki's api
 
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, 1); 
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postfield);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
 
preg_match_all('/^Set-Cookie: (.*?)=(.*?);/m', curl_exec($ch), $m);
curl_close($ch);

undo apt-get or aptitude build-deps

sudo aptitude markauto $(apt-cache showsrc YOUR_APP_NAME | grep Build-Depends: | sed -e 's/Build-Depends:\|,\|([^)]*)//g')

Create login redirect in blocks Drupal 6.x

if(!$user->uid){
drupal_get_path_alias($_GET['q']).' ">Login</a></li>'; 
$my_string = "Login";
$my_path = 'http://example.com/user/login?destination='. drupal_get_path_alias($_GET['q']);

(it is better if path is NOT hardcoded in $my_path)

Recursively find and replace across files using sed

find ./* -type f -exec sed -i 's/oldstring/newstring/g' {} \;

Passenger Apache Settings example

<VirtualHost *:80>
 
  ServerName  domain.com
 
  DocumentRoot /home/path/to/railsapp/public
  Options +FollowSymLinks +ExecCGI
  RailsEnv development
 
</VirtualHost>

wagn action mailer settings

The following goes into wagn.rb file (not environment.rb)

ActionMailer::Base.delivery_method = :smtp
 
ActionMailer::Base.smtp_settings = {
:address => "localhost",
:port => "25",
:domain => "mydomain.org",
}

Install python-igraph Ubuntu 9.04 64 bit

Download python-igraph nightly from http://code.google.com/p/igraph/downloads/list

tar xfvz the tar.gz your download

First, make sure you added the following line to your /etc/apt/sources.list:

deb http://cneurocvs.rmki.kfki.hu /packages/binary/
deb-src http://cneurocvs.rmki.kfki.hu /packages/source/

Invoke apt-get update as root to update the package list, then fetch the source code and let Ubuntu build a package:

apt-get build-dep igraph && apt-get -b source igraph

Syndicate content (C01 _th3me_)