Skip to content

Instantly share code, notes, and snippets.

View stalmok's full-sized avatar

Kestutis Stalmok stalmok

  • Vancouver, Canada
View GitHub Profile
@stalmok
stalmok / clean-svn
Created April 24, 2012 10:32
Unix CL: Remove all .svn folders in a directory tree
find . -name ".svn" -type d -exec rm -rf {} \;
@stalmok
stalmok / platform_check
Created June 21, 2012 05:32
JavaScript: test if Mac or PC
if (navigator.userAgent.indexOf('Mac OS X') != -1) {
$("body").addClass("mac");
} else {
$("body").addClass("pc");
}
@stalmok
stalmok / readlink
Created July 9, 2012 18:19
Unix CL: Find Out Real Path Of File
@stalmok
stalmok / prevent-text-breakouts.css
Created August 14, 2012 05:38
CSS: Prevent Long URL’s From Breaking Out of Container
.prevent-text-breakouts {
-ms-word-break: break-all;
word-break: break-all;
word-break: break-word;
-webkit-hyphens: auto;
-moz-hyphens: auto;
hyphens: auto;
}
@stalmok
stalmok / drop-tables
Created August 16, 2012 07:00
Unix CL: drop all MySQL tables
// NOT SECURE
mysqldump -u username --no-data dbname | grep ^DROP | mysql -u username
// SECURE
mysqldump -u username -p --no-data dbname | grep ^DROP > drop.sql
mysql -u username -p dbname < drop.sql
@stalmok
stalmok / unix-search-in-file
Created October 12, 2012 11:15
Unix CL: search in files
find . -name "*" -exec grep -l "somestring" {} \;
@stalmok
stalmok / mysql-import
Created October 29, 2012 12:20
MySQL: Import Datafile
mysql -u username -p -h localhost DATA-BASE-NAME < data.sql
@stalmok
stalmok / clear_cache.php
Created November 8, 2012 22:09
Drupal: clear cache
menu_rebuild();
drupal_flush_all_caches();
die();
@stalmok
stalmok / sql-replace-string
Created November 12, 2012 09:38
MySQL: replace string and update
// replace string and update
update [table_name] set [field_name] = replace([field_name],'[string_to_find]','[string_to_replace]');
@stalmok
stalmok / restrict-access
Created December 5, 2012 15:03
Restrict user access to content in folders using PHP and Apache
/**
* Original post: http://www.thebigblob.com/how-to-restrict-user-access-to-content-in-folders-using-php-and-apache-htaccess-files/
*/
# The .htaccess file
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_URI} ^\/(path\/to\/some\/folder|dummy)\/.*$
RewriteRule !^((.*.php)|(.*\/))$ authorize.php