Skip to content

Instantly share code, notes, and snippets.

Avatar

Kestutis Stalmokas stalmok

  • Vancouver, Canada
View GitHub Profile
@stalmok
stalmok / clean-svn
Created Apr 24, 2012
Unix CL: Remove all .svn folders in a directory tree
View clean-svn
find . -name ".svn" -type d -exec rm -rf {} \;
@stalmok
stalmok / platform_check
Created Jun 21, 2012
JavaScript: test if Mac or PC
View platform_check
if (navigator.userAgent.indexOf('Mac OS X') != -1) {
$("body").addClass("mac");
} else {
$("body").addClass("pc");
}
@stalmok
stalmok / readlink
Created Jul 9, 2012
Unix CL: Find Out Real Path Of File
View readlink
@stalmok
stalmok / prevent-text-breakouts.css
Created Aug 14, 2012
CSS: Prevent Long URL’s From Breaking Out of Container
View prevent-text-breakouts.css
.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 Aug 16, 2012
Unix CL: drop all MySQL tables
View drop-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 Oct 12, 2012
Unix CL: search in files
View unix-search-in-file
find . -name "*" -exec grep -l "somestring" {} \;
@stalmok
stalmok / mysql-import
Created Oct 29, 2012
MySQL: Import Datafile
View mysql-import
mysql -u username -p -h localhost DATA-BASE-NAME < data.sql
@stalmok
stalmok / clear_cache.php
Created Nov 8, 2012
Drupal: clear cache
View clear_cache.php
menu_rebuild();
drupal_flush_all_caches();
die();
@stalmok
stalmok / sql-replace-string
Created Nov 12, 2012
MySQL: replace string and update
View sql-replace-string
// replace string and update
update [table_name] set [field_name] = replace([field_name],'[string_to_find]','[string_to_replace]');
@stalmok
stalmok / restrict-access
Created Dec 5, 2012
Restrict user access to content in folders using PHP and Apache
View restrict-access
/**
* 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
You can’t perform that action at this time.