Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world (or not, you can keep them private!)

What next?
1. Bookmark us with del.icio.us or Digg Us!
2. Subscribe to this site's RSS feed
3. Browse the site.
4. Post your own code snippets to the site!

Top Tags and Latest Posts

ruby
  Install postgres gem on Mac OS X 10.5 (Leopard)
  Suppress Warnings in Ruby
  Add missing empty directories in .svn
  ChatGPT Plugins development company

rails
  Subversion Configuration Script for Your Rails A..
  Install plugin on rails app
  Quantum AI review
   Ubuntu 7.10: bootstrap a Ruby on Rails stack

osx
  Install postgres gem on Mac OS X 10.5 (Leopard)
  Compile ClamAV from source on Mac OS X
  Gas Ertrag
  Run ClamAV from a system service agent account
  Bitcoin Bank

php
  Installs pecl memcache php5 extension on a Joyen..
  关于MYSQL的用法
  Test php mysql pdo_mysql


shell
  how to get process start time
  Compile ClamAV from source on Mac OS X
  rename many files at once
  Tesler trading

javascript
  xpath helper function
  jQuery namespaced event binding/unbinding
  jQuery and Rails' respond_to
  SpaceMan

mysql
  change mysql user password
  move column in mysql
  关于MYSQL的用法

bash
  Compile ClamAV from source on Mac OS X
  rename many files at once
  add apache to users group

mac
  Compile ClamAV from source on Mac OS X
  Run ClamAV from a system service agent account
  Creating & deleting system service agent account..

linux
  activate root in ubuntu after install
  running scheduled programs in linux
  Rename files by reordering existing data (regula..

lighttpd
  Tomcat connector for lighttpd:
  Lighttpd redirect www to no www
  lighttpd launchd script for Leopard

ssh
  ssh-copy-id for automated pubkey append
  ssh remote systems
  Local SOCKS Proxy for Safari

Top Tags Alphabetically

accelerator (12)
actionscript (18)
administration (32)
ajax (25)
apache (35)
applescript (15)
backup (12)
bash (63)
cli (23)
css (44)
delphi (21)
dns (15)
dom (17)
effect (12)
email (19)
expressionengine (25)
fastcgi (14)
flash (17)
freebsd (12)
html (41)
image (23)
java (15)
javascript (104)
js (11)
lighttpd (46)
linux (53)
mac (56)
mysql (64)
osx (110)
perl (19)
php (110)
prototype (15)
python (21)
rails (125)
recipe (16)
regex (26)
ruby (130)
rubyonrails (19)
shell (106)
sql (32)
ssh (45)
subversion (24)
svn (35)
sysadmin (14)
terminal (27)
textdrive (15)
textpattern (17)
tiger (11)
ubuntu (13)
unix (44)

« Newer Snippets
Older Snippets »
997 total  XML / RSS feed 

Remove sudo password request when deploying

Change the sudoers list by adding a NOPASSWD: [Cmnd_Alias] line.

In terminal: visudo

# Cmnd alias specification
Cmnd_Alias HTTPD = /usr/local/sbin/apachectl, /etc/init.d/apache2

# User privilege specification
[user] ALL = NOPASSWD: HTTPD

change mysql user password

From terminal (square brackets denote your input, do not actually include the brackets):

mysqladmin -u [user] -h localhost -p password '[new_password]'

move column in mysql

// description of your code here

ALTER TABLE TableName MODIFY ColumnName ColumnType NULL/NOT NULL AFTER OtherColumnName;

Install postgres gem on Mac OS X 10.5 (Leopard)

When upgrading or installing recent versions of the postgres ruby gem on Leopard the following error appears

        ===========   WARNING   ===========

                You are building this extension on OS X without setting the
                ARCHFLAGS environment variable, and PostgreSQL does not appear
                to have been built as a universal binary. If you are seeing this
                message, that means that the build will probably fail.

                Try setting the environment variable ARCHFLAGS
                to '-arch i386' before building.

                For example:
                (in bash) $ export ARCHFLAGS='-arch i386'
                (in tcsh) $ setenv ARCHFLAGS '-arch i386'

                Then try building again.

                ===================================


The trick is to set the ARCHFLAGS variable inside the sudo command using env.

sudo env ARCHFLAGS="-arch i386" gem install postgres

Installs pecl memcache php5 extension on a Joyent Accelerator

//

#!/bin/sh
# Installs pecl memcache php5 extension on a Joyent Accelerator
#
# $Id$

VERSION=2.2.3
TEMPDIR=`/usr/bin/mktemp`

cd ${TEMPDIR}
/usr/sfw/bin/wget http://pecl.php.net/get/memcache-${VERSION}.tgz
/opt/local/bin/tar -zxvf memcache-${VERSION}.tgz
cd memcache-${VERSION}
/opt/local/bin/phpize
./configure
/usr/bin/make
/usr/bin/make install
/opt/local/bin/gsed -i"" "s/;extension=memcache.so/extension=memcache.so/" /opt/local/etc/php.ini

Nginx configure options for Accel w/FLV support

Build nginx on an Accelerator with support for flash video. Assumes you have PCRE and OpenSSL built as per the wiki/forum. Keep everything tidy in /opt/local/nginx.

./configure --prefix=/opt/local/nginx --with-http_ssl_module --with-openssl=../openssl-0.9.8e --with-cc-opt="-m64 -I/usr/local/include -I/usr/local/ssl/include" --with-ld-opt="-L/lib/64 -L/usr/sfw/lib/64 -R/usr/sfw/lib/64 -R/lib/64 -L/usr/local/ssl/lib -m64 -L/usr/local/lib -R/usr/local/lib" --with-http_flv_module

Suppress Warnings in Ruby

#!/usr/bin/env ruby

# Kernel#with_warnings_suppressed - Supresses warnings in a given block.
# Require this file to use it or run it directly to perform a self-test.
#
# Note: The test probably won't work on Windows (haven't tried it, but
#       IO.popen likely uses fork)
# 
# Author:: Rob Pitt
# Copyright:: Copyright (c) 2008 Rob Pitt
# License:: Free to use and modify so long as credit to previous author(s) is left in place.
#

module Kernel
  # Suppresses warnings within a given block.
  def with_warnings_suppressed
    saved_verbosity = $-v
    $-v = nil
    yield
  ensure
    $-v = saved_verbosity
  end
end

#--
# Kernel#with_warnings_suppressed self-test.
if $0 == __FILE__
  # Go here for reference on rspec: http://rspec.info/examples.html
  require 'rubygems'
  require 'spec'
  
  def warning_generator
    IO.popen( '-' ) do |io|
      if io # parent          
        return io.read
      else #child
        $stderr.reopen( $stdout )
        Object.const_set( 'MONKEY', 1 )
        Object.const_set( 'MONKEY', 2 )
      end
    end
  end
  
  describe Kernel do

    it "should supress warnings" do
      with_warnings_suppressed do 
        warning_generator
      end.should == ""
    end
    
    it "should restore the previous verbosity state when it's finished" do
      with_warnings_suppressed do 
        warning_generator
      end.should == ""
      warning_generator.should match( /warning: already initialized constant MONKEY/ )
    end
    
  end
    
end
#++

VERY GOOD!

// 这是什么来的?

// 我很好..

关于百度的用法

// description of your code here

//百度中国,中国是一个伟大的国家 

Infrant Widget Patch to add support for BitTorrent Add-on

// This requires the BitTorrent add-on from RAIDiator 4.00c1-p2.
// This adds the following functionality to the widget:
// Adds a button on the back of widget to connect to bittorrent admin interface on port 8080.
// Adds drag-and-drop support to allow multiple torrents to be added from local filesystem.

curl http://www.infrant.com/beta/raidar/RAIDar.wdgt -o RAIDar.wdgt.zip
curl -O http://speedbinge.com/code/RAIDar_bt.patch
unzip RAIDar.wdgt.zip
patch -p0 < RAIDar_bt.patch
open RAIDar.wdgt
« Newer Snippets
Older Snippets »
997 total  XML / RSS feed