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')

send digest messages

  1. function send_digest_messages($op){
  2.  
  3.  
  4.  
  5. switch($op) {
  6.  
  7. case 'hourly':
  8. $status_query = db_query('SELECT * FROM {noti}');
  9. while($status_result = db_fetch_array($status_query)){
  10.  
  11. $status[] = $status_result;
  12.  
  13.  
  14. }
  15. dsm($status);
  16.  
  17.  
  18. foreach($status as $key => $setting_uid){
  19. dsm($setting_uid);
  20. if($setting_uid['status'] == "1"){
  21. dsm($setting_uid['']);
  22. $email = user_load(array('uid' => $setting_uid['uid']))->mail;
  23. //get everything from noti_groups table that equals 1 (hourly)
  24. dsm($digest_arrays);
  25. $send_interval_query = db_query('SE

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",
}

Syndicate content (C01 _th3me_)