############################################ # SEO links # index.php?q=neki-link # postaje index/neki-link ############################################ <IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-s RewriteRule ^(.*)$ index.php?q=$1 [QSA,NC,L] RewriteCond %{REQUEST_FILENAME} -d RewriteRule ^(.*)$ index.php [QSA,NC,L] RewriteCond %{REQUEST_FILENAME} -s RewriteRule ^(.*)$ index.php [QSA,NC,L] </IfModule>


#cron php /home/{user}/helpletter/cron.php


# CLEARFIX // Clearfix // Source: // // For modern browsers // 1. The space content is one way to avoid an Opera bug when the // contenteditable attribute is included anywhere else in the document. // Otherwise it causes space to appear at the top and bottom of elements // that are clearfixed. // 2. The use of `table` rather than `block` is only necessary if using // `:before` to contain the top-margins of child elements. clearfix:before, .clearfix:after { content: " "; display: table; } .clearfix:after { clear: both; } /* * For IE 6/7 only * Include this rule to trigger hasLayout and contain floats. */ .clearfix { *zoom: 1; } # PREVENT TEXT SELECT -webkit-touch-callout: none; -webkit-user-select: none; -khtml-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none;


@mixin theme($name, $color) { $primary: $color; $secondary: lighten(adjust-hue($color, 20), 10%); .#{$name} { .element { color: $primary; } .other-element { background: $secondary; } } }


The taxonomy module uses the default_nodes_main variable to decide how many to show per page (this happens around line 55 of in case you're interested). Usually you would implement a custom module and provide a form to override that variable for your users. But you don't have to do that, if you just want to set the variable once and be done with it use one of the following methods instead: Use Drush (drush vset default_nodes_main 20) Add a PHP snippet somewhere that will be run in your site (you only need to do it once) variable_set('default_nodes_main', 20); Use the Devel variable editor # hook_menu() function hook_menu() { $items['example'] = array( 'title' => 'Example Page', 'page callback' => 'example_page', 'access arguments' => array('access content'), 'type' => MENU_SUGGESTED_ITEM, ); $items['example/feed'] = array( 'title' => 'Example RSS feed', 'page callback' => 'example_feed', 'access arguments' => array('access content'), 'type' => MENU_CALLBACK, ); return $items; } drupal_add_css(drupal_get_path('module', 'custom') . '/css/custom.css', array('group' => CSS_DEFAULT, 'every_page' => TRUE));


# path auto transliteration - je za hrvatska slova drush dl pathauto, transliteration drush dl drupal-8 drush dl drupal --drupal-project-rename=helpium-web bez pswd-a drush si --db-url=mysql://root:@localhost/helpium-web a ako je pswd pass drush si --db-url=mysql://root:pass@localhost/helpium sudo chgrp -R www-data sites/default/files/ sudo chmod -R g+w sites/default/files/ drush 10 drush dl drupal --drupal-project-rename=metasys-drupal cd metasys-drupal cp sites/default/default.settings.php sites/default/settings.php chmod -R o+w sites/defaultwww drush si --db-url=mysql://root:@localhost/metasys_drupal #!/bin/bash if [ $(id -u) != 0 ]; then printf "This script must be run as root.\n" exit 1 fi drupal_path=${1%/} drupal_user=${2} httpd_group="${3:-www-data}" # Help menu print_help() { cat <<-HELP This script is used to fix permissions of a Drupal installation you need to provide the following arguments: 1) Path to your Drupal installation. 2) Username of the user that you want to give files/directories ownership. 3) HTTPD group name (defaults to www-data for Apache). Usage: (sudo) bash ${0##*/} --drupal_path=PATH --drupal_user=USER --httpd_group=GROUP Example: (sudo) bash ${0##*/} --drupal_path=/usr/local/apache2/htdocs --drupal_user=john --httpd_group=www-data HELP exit 0 } # Parse Command Line Arguments while [ $# -gt 0 ]; do case "$1" in --drupal_path=*) drupal_path="${1#*=}" ;; --drupal_user=*) drupal_user="${1#*=}" ;; --httpd_group=*) httpd_group="${1#*=}" ;; --help) print_help;; *) printf "Invalid argument, run --help for valid arguments.\n"; exit 1 esac shift done if [ -z "${drupal_path}" ] || [ ! -d "${drupal_path}/sites" ] || [ ! -f "${drupal_path}/core/modules/system/system.module" ] && [ ! -f "${drupal_path}/modules/system/system.module" ]; then printf "Please provide a valid Drupal path.\n" print_help exit 1 fi if [ -z "${drupal_user}" ] || [ $(id -un ${drupal_user} 2> /dev/null) != "${drupal_user}" ]; then printf "Please provide a valid user.\n" print_help exit 1 fi cd $drupal_path printf "Changing ownership of all contents of "${drupal_path}":\n user => "${drupal_user}" \t group => "${httpd_group}"\n" chown -R ${drupal_user}:${httpd_group} . printf "Changing permissions of all directories inside "${drupal_path}" to "rwxr-x---"...\n" find . -type d -exec chmod u=rwx,g=rx,o= '{}' \; printf "Changing permissions of all files inside "${drupal_path}" to "rw-r-----"...\n" find . -type f -exec chmod u=rw,g=r,o= '{}' \; printf "Changing permissions of "files" directories in "${drupal_path}/sites" to "rwxrwx---"...\n" cd sites find . -type d -name files -exec chmod ug=rwx,o= '{}' \; printf "Changing permissions of all files inside all "files" directories in "${drupal_path}/sites" to "rw-rw----"...\n" printf "Changing permissions of all directories inside all "files" directories in "${drupal_path}/sites" to "rwxrwx---"...\n" for x in ./*/files; do find ${x} -type d -exec chmod ug=rwx,o= '{}' \; find ${x} -type f -exec chmod ug=rw,o= '{}' \; done echo "Done settings proper permissions on files and directories"


/** * Implements hook_block_info(). */ function example_block_info() { $blocks['ad_banner1'] = array( 'info' => t('Ad Banner 1'), ); $blocks['ad_banner2'] = array( 'info' => t('Ad Banner 2'), ); return $blocks; } /** * Implements hook_block_view(). */ function example_block_view($delta = '') { $block = array(); switch ($delta) { case 'ad_banner1': $block['content'] = 'shtuffenins'; break; case 'ad_banner2': $block['content'] = 'shtuffenins2'; break; } return $block; }


$menu = menu_get_object(); if (isset($menu->type) && $menu->type == 'events') { // Sad kreiram bredcrumb za events Početna->Skupovi->Trenutni_node $bcmb = array( l('Početna', '<front>'), l('Skupovi', 'skupovi'), l( $menu->title, 'node/' . $menu->nid), ); drupal_set_breadcrumb($bcmb);

Directory permisions

Navigate to /sites/default chown -R :www-data files chmod g+ws files Navigate to /sites/default/files find . -type d -exec chmod g+ws {} \; find . -type f -exec chmod 664 {} \;


# submit $form['submit'] = array('#type' => 'submit', '#value' => t('Import')); # textfield $form['title'] = array( '#type' => 'textfield', '#title' => t('Subject'), '#default_value' => $node->title, '#size' => 60, '#maxlength' => 128, '#required' => TRUE, ); # select $form['selected'] = array( '#type' => 'select', '#title' => t('Selected'), '#options' => array( 0 => t('No'), 1 => t('Yes'), ), '#default_value' => $category['selected'], '#description' => t('Set this to <em>Yes</em> if you would like this category to be selected by default.'), ); # checkbox $form['copy'] = array( '#type' => 'checkbox', '#title' => t('Send me a copy.'), ); # checkboxes $form['high_school']['tests_taken'] = array( '#type' => 'checkboxes', '#options' => drupal_map_assoc(array(t('SAT'), t('ACT'))), '#title' => t('What standardized tests did you take?'), ... ), # textarea $form['keywords'] = array( '#title' => t('Keywords'), '#type' => 'textarea', '#description' => t('The comment will be unpublished if it contains any of the phrases above. Use a case-sensitive, comma-separated list of phrases. Example: funny, bungee jumping, "Company, Inc."'), '#default_value' => isset( $context['keywords']) ? drupal_implode_tags($context['keywords']) : '', ); $form['vid'] = array('#type' => 'value', '#value' => $node->vid);


function module_name_form() { $form = array(); $form['city'] = array( '#title' => t('City'), '#type' => 'textfield', '#autocomplete_path' => 'example/autocomplete', ); $form['submit'] = array( '#type' => 'submit', '#value' => 'Save', ); return $form; } function module_name_menu() { $items['example/autocomplete'] = array( 'page callback' => '_module_name_autocomplete', 'access arguments' => array('access example autocomplete'), 'type' => MENU_CALLBACK ); return $items; } function _module_name_autocomplete($string) { $matches = array(); // Some fantasy DB table which holds cities $query = db_select('cities', 'c'); // Select rows that match the string $return = $query ->fields('c', array('city')) ->condition('', '%' . db_like($string) . '%', 'LIKE') ->range(0, 10) ->execute(); // add matches to $matches foreach ($return as $row) { $matches[$row->city] = check_plain($row->city); } // return for JS drupal_json_output($matches); }


// Retrieve all records into an indexed array of stdClass objects. $result->fetchAll(); // Retrieve all records into an associative array keyed by the field in the result specified. $result->fetchAllAssoc($field); // Retrieve a 2-column result set as an associative array of field 1 => field 2. $result->fetchAllKeyed(); // You can also specify which two fields to use by specifying the column numbers for each field $result->fetchAllKeyed(0,2); // would be field 0 => field 2 $result->fetchAllKeyed(1,0); // would be field 1 => field 0 // If you need an array where keys and values contain the same field (e.g. for creating a 'checkboxes' form element), the following is a perfectly valid method: $result->fetchAllKeyed(0,0); // would be field 0 => field 0, e.g. [article] => [article] // Retrieve a 1-column result set as one single array. $result->fetchCol(); // Column number can be specified otherwise defaults to first column $result->fetchCol($column_index); $query = db_select('node', 'n') ->condition('type', 'article') ->fields('n'); $query = $query->extend('PagerDefault')->limit(2); $result = $query->execute(); while($record = $result->fetchAssoc()) { print_r($record); } $output .= theme('pager', array('tags' => array()));


<div contenteditable="true">Hello world! <span style="color: blue;">This</span> is HTML5 Boilerplate.</div>


/* = put selected divs to equal height according to highest -----------------------------------------------------------------------*/ $.fn.eqHeight = function() { var heighest = 0; this.each(function(){ if($(this).height() > heighest){ heighest = $(this).height(); } }); this.each(function(){ $(this).height(heighest); }); } /* = receives array, removes duplicates and returns new array -----------------------------------------------------------------------*/ function group(items){ var grouped = []; var j = 0; for(var i = 0; i < items.length; i++){ if($.inArray(items[i], grouped) === -1){ grouped[j] = items[i]; j++; } } return grouped; }




<?php ?> <?php foreach($array as $key=>$arr): ?> //count <?php endforeach; ?> # Dir to Array function dirToArray($dir) { $contents = array(); # Foreach node in $dir foreach (scandir($dir) as $node) { # Skip link to current and parent folder if ($node == '.') continue; if ($node == '..') continue; # Check if it's a node or a folder if (is_dir($dir . DIRECTORY_SEPARATOR . $node)) { # Add directory recursively, be sure to pass a valid path # to the function, not just the folder's name $contents[$node] = dirToArray($dir . DIRECTORY_SEPARATOR . $node); } else { # Add node, the keys will be updated automatically $contents[] = $node; } } # done return $contents; } # Function similar to in_array() but it recursively searches a multi-depth array. # NIJE TESTIRANO function deep_in_array($value, $array, $case_insensitive = false) { foreach($array as $item) { if (is_array($item)) { $output = deep_in_array($value, $item, $case_insensitive); } else { $output = ($case_insensitive) ? strtolower($item)==$value : $item==$value; } if ($output) { return $output; } } return false; } # NIJE TESTIRANO # Matches all strings with brackets: $text = '[This] is a [test] string, [eat] my [shorts].'; preg_match_all("/\[.*?\]/", $text, $matches); var_dump($matches[0]); # If You want strings without brackets: $text = '[This] is a [test] string, [eat] my [shorts].'; preg_match_all("/\[(.*?)\]/", $text, $matches); var_dump($matches[1]); // remove the extension from a filename. $withoutExt = pre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', 'ŭ', 'Ů', 'ů', 'Ű', 'ű', 'Ų', 'ų', 'Ŵ', 'ŵ', 'Ŷ', 'ŷ', 'Ÿ', 'Ź', 'ź', 'Ż', 'ż', 'Ž', 'ž', 'ſ', 'ƒ', 'Ơ', 'ơ', 'Ư', 'ư', 'Ǎ', 'ǎ', 'Ǐ', 'ǐ', 'Ǒ', 'ǒ', 'Ǔ', 'ǔ', 'Ǖ', 'ǖ', 'Ǘ', 'ǘ', 'Ǚ', 'ǚ', 'Ǜ', 'ǜ', 'Ǻ', 'ǻ', 'Ǽ', 'ǽ', 'Ǿ', 'ǿ'); $b = array('A', 'A', 'A', 'A', 'A', 'A', 'AE', 'C', 'E', 'E', 'E', 'E', 'I', 'I', 'I', 'I', 'D', 'N', 'O', 'O', 'O', 'O', 'O', 'O', 'U', 'U', 'U', 'U', 'Y', 's', 'a', 'a', 'a', 'a', 'a', 'a', 'ae', 'c', 'e', 'e', 'e', 'e', 'i', 'i', 'i', 'i', 'n', 'o', 'o', 'o', 'o', 'o', 'o', 'u', 'u', 'u', 'u', 'y', 'y', 'A', 'a', 'A', 'a', 'A', 'a', 'C', 'c', 'C', 'c', 'C', 'c', 'C', 'c', 'D', 'd', 'D', 'd', 'E', 'e', 'E', 'e', 'E', 'e', 'E', 'e', 'E', 'e', 'G', 'g', 'G', 'g', 'G', 'g', 'G', 'g', 'H', 'h', 'H', 'h', 'I', 'i', 'I', 'i', 'I', 'i', 'I', 'i', 'I', 'i', 'IJ', 'ij', 'J', 'j', 'K', 'k', 'L', 'l', 'L', 'l', 'L', 'l', 'L', 'l', 'l', 'l', 'N', 'n', 'N', 'n', 'N', 'n', 'n', 'O', 'o', 'O', 'o', 'O', 'o', 'OE', 'oe', 'R', 'r', 'R', 'r', 'R', 'r', 'S', 's', 'S', 's', 'S', 's', 'S', 's', 'T', 't', 'T', 't', 'T', 't', 'U', 'u', 'U', 'u', 'U', 'u', 'U', 'u', 'U', 'u', 'U', 'u', 'W', 'w', 'Y', 'y', 'Y', 'Z', 'z', 'Z', 'z', 'Z', 'z', 's', 'f', 'O', 'o', 'U', 'u', 'A', 'a', 'I', 'i', 'O', 'o', 'U', 'u', 'U', 'u', 'U', 'u', 'U', 'u', 'U', 'u', 'A', 'a', 'AE', 'ae', 'O', 'o'); $stripped = str_replace($a, $b, $str); return strtolower(preg_replace(array('/[^a-zA-Z0-9 -]/', '/[ -]+/', '/^-|-$/'), array('', '-', ''), $stripped)); } }



move composer into a bin directory you control: sudo mv composer.phar /usr/local/bin/composer # scp download scp root@{ip_adresa}:/{full path}/file.php local_file.php # scp upload scp local_file.php root@{ip_adresa}:/{full path}/file.php # scp upload folder & files scp -r {loacal-folder-name} root@{ip_adresa}:{full path} Miro: miro is really a great tool for downloading videos from various sites including youtube. You just need to run one command on terminal. sudo apt-get install miro One can know more about it from link: 2. youtube-dl: youtube-dl is a small command-line program to download videos from YouTube, Vimeo and a few more sites. It is included in the Ubuntu repositories, so you may install it by typing: sudo apt-get install youtube-dl Now,get the URL of the video. Then simply execute the command - youtube-dl"URL_of_the_video" youtube-dl supports downloading videos through a proxy, by setting the http_proxy environment variable to the proxy URL, as in http://proxy_machine_name:port/. 3. vimeo-dl: vimeo-dl is a stand-alone command-line program to download videos from Vimeo. It is not included in the Ubuntu repositories, therefore you must download and save the script somewhere and make it executable by typing: chmod 775 <script> 4. ClipGrab : ClipGrab is a free software for downloading and converting online videos from many sites like YouTube or Vimeo. ClipGrab can download from the following sites: YouTube, Clipfish, Collegehumor, Dailymotion, MyVideo, MySpass, Sevenload, Tudou, Vimeo. To Install ClipGrab,run these commands on your terminal. sudo add-apt-repository ppa:clipgrab-team/ppa sudo apt-get update sudo apt-get install clipgrab4. Add-ons/Plugins for Mozilla Firefox / Google Chrome 5. Flash Video Downloader it’s a great plugin for Mozilla Firefox. You can download the video in appropriate format (mp4, flv, 3gp, webm etc), for the devices you want – you can also use the converter for more options. As the name suggest, it’s not just for youtube, you can download videos from a number of video sharing sites including Facebook, Metacafe etc. # mogrify za slike convert -thumbnail x180 *.pdf[0] prilog.jpg mogrify -resize 256x256 *.jpg # renema sav space sa - u folderu rename 's/ /-/g' * rename files - mice space s - for f in *\ *; do mv "$f" "${f// /-}"; done lowercase: 'y/A-Z/a-z/' *

Auto back up

Open cmd in actual folder

Wouldn’t it be useful to open the terminal in the current directory from the GNOME file browser of Ubuntu? The following package gives an option to open the terminal from the right click menu in the nautilus file browser. Install the package nautilus-open-terminal from the Synaptic package manager or by using the command [bash]sudo apt-get install nautilus-open-terminal[/bash] You may need to restart nautilus for the change to appear. [bash] killall nautilus && nautilus[/bash] source:

convert images

convert somefile.png somefile.pnm # PNG to PNM potrace somefile.pnm -s -o somefile.svg