Latest 100 public snipts »
jrguitar21's
snipts
showing 1-20 of 44 snipts
-
∞ Htaccess Private Files (svn, cvs, sql, etc)
# Drupal's way of denying access to delicate server files <FilesMatch "\.(engine|inc|info|install|make|module|profile|test|po|sh|.*sql|theme|tpl(\.php)?|xtmpl|svn-base)$|^(code-style\.pl|Entries.*|Repository|Root|Tag|Template|all-wcprops|entries|format)$"> Order allow,deny </FilesMatch>
-
∞ free binaural beats
# A little snippet to download a bunch of free binaural beats # to your hard drive. cd ~/Downloads && curl -O http://mayhem-chaos.net/stuff/xspf-download-0.1.0.py && chmod 755 xspf-download-0.1.0.py && ./xspf-download-0.1.0.py http://healingbeats.com/beats.xspf & # After the downloads finish, simply # 1) open Finder # 2) Navigate to Downloads folder, # 3) Drag the folder 'beats' over the itunes icon in your Dock. # 4) delete the xspf-download-0.1.0.py file from Downloads folder.
-
∞ svn ignore passwords
# on production servers its often a good idea not to store svn passwords. # heres a one-liner to do just that: echo "store-passwords=no" >> ~/.subversion/servers && rm -f ~/.subversion/auth/svn.simple/*
-
∞ drupal_get_machinename
<?php /** * Most machine names are generated as-you-type via Javascript helpers on the * client side. This helper function automates server-side conversions from * regular text strings into valid Drupal machine names. * * Machine names must contain only lowercase alpha-numerics and underscores. * Non-alphanumeric characters are converted to underscores, and sequential * underscore characters are trimmed to a single character. * * Additionally, if the transliteration module is enabled, then it will be * used to first convert non-ascii Unicode characters to standard Roman ASCII * characters on a best-effort basis, and replacing all unknown characters * with underscores. * * @param $text * A string of characters to be converted. * * @return * A string containing the valid Drupal machine name for the specified text. * Returns the empty string if invalid input was provided. * * @see * See the transliteration module in the drupal contrib repository for more * information on non-ascii character transliterations. */ function drupal_get_machinename($text) { // Cache machine name conversions locally for performance boost. static $texts; // If the input string is not valid, return an empty string. if (empty($text) || !is_string($text)) { return ''; } // Setup the local static variable cache if it doesnt exist. if (!is_array($texts)) { $texts = array(); } // Save the machine name conversion to the static cache if it doesnt exist. if (!isset($texts[$text])) { $out = $text; if (module_exists('transliteration')) { $out = transliteration_get($out, '_'); } $out = strtolower($out); $out = preg_replace('/[^a-z0-9]/', '_', $out); $out = preg_replace('/_+/', '_', $out); $texts[$text] = $out; } return $texts[$text]; }
-
∞ grep find
# grep find excluding .svn directories # from http://wordaligned.org/articles/ignoring-svn-directories alias gf='find . -path "*/.svn" -prune -o -type f -print0 | xargs -0 grep -I -n'
-
∞ find exclude .svn
# exclude .svn folders with find find . -name "myfile*.*" \( -not -iname "*.svn*" \)
-
∞ uncompress css stylesheet
# quick one-liner to uncompress a stylesheet that has been # compressed down to one line. This will add the newlines back. perl -pi -e "s/\}/\}\n/g" *.css
-
∞ drupal files folder svn externals
# go to working copy cd ~/public_html/sites/default/ # take a backup tar zcvf files.tar.gz --exclude=.svn files # move drupal files folder out of trunk, and replace with externals, to keep trunk lightweight. svn mv http://svn/project/trunk/sites/default/files http://svn/project/assets/files -m "moved files folder out of trunk to assets" # delete files on working copy svn up # setup the external reference svn propset svn:externals 'files http://svn/project/assets/files' . # fetch external file svn up
-
∞ prevent dot underscore mac os x tar
# prevent tar from creating those blasted # dot-underscore (aka ._) alias 'Apple Double' files. # put this in your .bashrc file. export COPYFILE_DISABLE=true
-
∞ php clean folder listing
<?php // a clean replacement for default apache file listing // this version only shows subfolders, not files $path = dirname(__FILE__); $folder = @opendir($path) or die("Unable to open $path"); $host = $_SERVER['SERVER_NAME']; echo "<h2>Folder listing for $host</h2>"; echo '<ul>'; while ($file = readdir($folder)) { if ($file != '.' && $file != '..' && is_dir($path . $file)) { echo "<li><a href='$file'>$file</a></li>"; } } echo '</ul>'; closedir($folder);
-
∞ install Drush from CVS HEAD on any unix server
## ## Installs Drush (the Drupal Shell command line utility) from CVS HEAD ## on any UNIX machine, such that all users that have /usr/local/bin in ## their $PATH can use Drush (granted they have access to a Drupal install). ## ## cd /usr/local/src cvs -z6 -d:pserver:anonymous:anonymous@cvs.drupal.org:/cvs/drupal-contrib checkout -d drush-HEAD contributions/modules/drush/ curl -O http://download.pear.php.net/package/Console_Table-1.1.3.tgz tar zxvf Console_Table-1.1.3.tgz cp Console_Table-1.1.3/Table.php drush-HEAD/includes/table.inc ln -s /usr/local/src/drush-HEAD/drush /usr/local/bin/drush ## ## now any user that has /usr/local/bin in their $PATH can use Drush. ## ## ## ... later on, to keep drush up to date, run the following: #cd /usr/local/src/drush-HEAD #cvs update -dPA
-
∞ create ssh RSA id
# Create an SSH id and public key pair (RSA) on your laptop/local machine mkdir ~/.ssh chmod 700 ~/.ssh ssh-keygen -q -f ~/.ssh/id_rsa -t rsa ## Enter passphrase (empty for no passphrase): … ## Enter same passphrase again: … # protect your SSH keys chmod go-w ~/ chmod 700 ~/.ssh chmod go-rwx ~/.ssh/* # Send your public id to the server. # @see http://snipt.net/jrguitar21/passwordless-rsa-ssh-1-liner/
-
∞ install svn on shared host
#Install subversion on a shared host curl -O http://subversion.tigris.org/downloads/subversion-1.6.9.tar.gz curl -O http://subversion.tigris.org/downloads/subversion-deps-1.6.9.tar.gz curl -O http://www.openssl.org/source/openssl-0.9.8l.tar.gz tar zxvf openssl-0.9.8l.tar.gz tar zxvf subversion-1.6.9.tar.gz tar zxvf subversion-deps-1.6.9.tar.gz cd openssl-0.9.8l/ ./config shared --prefix=$HOME/installs && make clean && make && make install cd ../ export CFLAGS="-O2 -g -I$HOME/installs/include" export LDFLAGS="-L$HOME/installs/lib" export CPP="gcc -E -I$HOME/installs/include" cd subversion-1.6.9/neon/ ./configure --with-ssl=openssl --prefix=$HOME/installs cd ../ ./configure --with-ssl --prefix=$HOME/installs --with-neon=$HOME/installs/bin/neon-config make clean && make && make install echo 'store-plaintext-passwords=no' >> ~/.subversion/servers
-
∞ remove .svn folders
find . -name ".svn" -type d -exec rm -rf {} \;
-
∞ detect linux distro
#!/bin/sh # Detects which OS and if it is Linux then it will detect # which Linux Distribution. OS=`uname -s` REV=`uname -r` MACH=`uname -m` GetVersionFromFile() { VERSION=`cat $1 | tr "\n" ' ' | sed s/.*VERSION.*=\ // ` } if [ "${OS}" = "SunOS" ] ; then OS=Solaris ARCH=`uname -p` OSSTR="${OS} ${REV}(${ARCH} `uname -v`)" elif [ "${OS}" = "AIX" ] ; then OSSTR="${OS} `oslevel` (`oslevel -r`)" elif [ "${OS}" = "Linux" ] ; then KERNEL=`uname -r` if [ -f /etc/redhat-release ] ; then DIST='RedHat' PSUEDONAME=`cat /etc/redhat-release | sed s/.*\(// | sed s/\)//` REV=`cat /etc/redhat-release | sed s/.*release\ // | sed s/\ .*//` elif [ -f /etc/SUSE-release ] ; then DIST=`cat /etc/SUSE-release | tr "\n" ' '| sed s/VERSION.*//` REV=`cat /etc/SUSE-release | tr "\n" ' ' | sed s/.*=\ //` elif [ -f /etc/mandrake-release ] ; then DIST='Mandrake' PSUEDONAME=`cat /etc/mandrake-release | sed s/.*\(// | sed s/\)//` REV=`cat /etc/mandrake-release | sed s/.*release\ // | sed s/\ .*//` elif [ -f /etc/debian_version ] ; then DIST="Debian `cat /etc/debian_version`" REV="" fi if [ -f /etc/UnitedLinux-release ] ; then DIST="${DIST}[`cat /etc/UnitedLinux-release | tr "\n" ' ' | sed s/VERSION.*//`]" fi OSSTR="${OS} ${DIST} ${REV}(${PSUEDONAME} ${KERNEL} ${MACH})" fi echo ${OSSTR}
-
∞ outdated drupal module with svn
## In a nutshell, how to update a module from Drupal contrib, ## on a production site that is under revision control (subversion). # If you turn on a module (that just happens to already be # present in the list on admin/build/modules), then you MUST # 1) go to the update status page # 2) find out if the module you just turned on is up to date # 3) if it is, fine (your done! stop here), # 4) if there are updates... then go to the drupal.org site first # to see if there are any "gotchas" for the upgrade. As you'll # be turning the module on for the first time on a new site, # then you shouldnt have to worry too much. # 5) To run the updates: login via ssh ssh username@server.com # 6) go to the right folder and execute drush update cd domains/example.com/public_html/sites/all/modules drush --uri=example.com update modulename # 7) confirm that the update was successful on the site # 8) then check in the code svn commit -u username -m "updated modulename to the latest version"
-
∞ apache configure htaccess defaults
# # AccessFileName: The name of the file to look for in each directory # for additional configuration directives. See also the AllowOverride # directive. # AccessFileName .htaccess # # The following lines prevent .htaccess and .htpasswd files from being # viewed by Web clients. # <Files ~ "^\.ht"> Order allow,deny Deny from all </Files>
-
∞ protect svn/cvs in apache conf
# Protect revision controlled web projects. This version is # for Apache's global configuration (conf) file. Protection # can also be done if you dont have access to Apache conf, # in any directorie's .htaccess file, in which case, Apache # conf must aleady be configured to use htaccess. <DirectoryMatch "^/.*/(\.svn|CVS)/"> Order deny,allow Deny from all </DirectoryMatch>
-
∞ svn bash shortcuts
alias .s='svn stat' alias .c='svn ci -m' alias .u='svn up' alias .a='svn stat | grep "^\?" | awk "{print \$2}" | xargs svn add' alias .d='svn stat | grep "^\!" | awk "{print \$2}" | xargs svn delete'
-
∞ divide and conquer svn repo
# The following structure exists: # # originalrepository/ # project_name/ # trunk/ # branches/ # tags/ # # I want to move it to its *own* repository and give the following structure: # # newrepositoryname/ # trunk/ # branches/ # tags/ # export LOCAL='file:/' export SVN_DIR='/home/bluespark/svn' export SVN_OLD_REPO='originalrepository' export SVN_PROJ='project_name' export SVN_REPO='newrepositoryname' cd $SVN_DIR ## Create dumps mkdir $SVN_DIR/dumps svnadmin dump $SVN_OLD_REPO > dumps/$SVN_OLD_REPO.dump ## Filter the specific project_name out of the dump svndumpfilter include $SVN_PROJ \ --drop-empty-revs \ --preserve-revprops \ --renumber-revs \ < dumps/$SVN_OLD_REPO.dump \ > dumps/$SVN_PROJ.dump ## Create the new repository... ## NOTE: You may need to do this step in the cpanel!! ## Here is how to do it on the comand line: # svnadmin create $SVN_DIR/$SVN_REPO ## Load the new repository with the contents of the ## filtered dump file. svnadmin load $SVN_REPO < dumps/$SVN_PROJ.dump ## Move the contens of the project_name to the repo root. svn mv $LOCAL/$SVN_DIR/$SVN_REPO/$SVN_PROJ/branches \ $LOCAL/$SVN_DIR/$SVN_REPO/$SVN_PROJ/tags \ $LOCAL/$SVN_DIR/$SVN_REPO/$SVN_PROJ/trunk \ $LOCAL/$SVN_DIR/$SVN_REPO/ \ -m "moved $SVN_PROJ contents to root" ## Delete the old (empty) project directory. ## Note: you need to make sure the directory ## is really empty before deleting! svn del $SVN_DIR/$SVN_REPO/$SVN_PROJ -m "removed old project directory"


