Tuesday, April 29, 2014

Zen Coding plugin for NetBeans

Zen Coding plugin for NetBeans is an HTML editor extension allowing you to automate and to speed up the process of writing code using the syntax short (snippets) and keyboard shortcuts. It is extremely useful when you need to generate an HTML structure on the fly. ;)


screenshot


 


How to install Zen Coding plugin in netebeans


Download The Extension from github or click here


Open NetBeans IDE (6.9.1 or newer) and go to Tools > Plugins.


Untitled-1


 


Select tab Downloaded, click Add plugins… and search for downloaded nbm file


Untitled-2


Click Install button, follow instructions and restart NetBeans IDE


 


How to use Zen Coding plugin


Expand abbreviation


Fill a HTML/CSS code line with Zen syntax, then press CTRL+ALT+N, or click the toolbar button, or go to menu Edit > Zen Coding > Expand Zen code, or press Alt+Insert and choose Expand Zen Code.


Match Pair


Just press CTRL+ALT+M or go to menu Edit > Zen Coding > Match Pair.


Wrap with Abbreviation


Select something, press CTRL+ALT+W or go to menu Edit > Zen Coding > Wrap with Abbreviation, then insert a Zen code abbreviation in the input popup.


Merge Lines


Select multiple lines, then press CTRL+ALT+L or go to menu Edit > Zen Coding > Merge Lines.


Also available in the Edit > Zen Coding menu:


  • Remove Tag

  • Split/Join Tag

  • Toggle Comment

  • Go to Next / Previous Edit Point

  • Evaluate Math Expression

  • Increment / Decrement number by 1 / 10 / 0.1

These actions have not a default keyboard shortcut. You can edit NetBeans shortcuts in Tools > Options > KeymapHere is a guide.


 



Zen Coding plugin for NetBeans

Saturday, April 19, 2014

sitemap generator for Laravel 4

Installation


Add the following to your composer.json file :


"roumen/sitemap": "dev-master"

Then register this service provider with Laravel :


'Roumen\Sitemap\SitemapServiceProvider',

Publish configuration file. (OPTIONAL)


php artisan config:publish roumen/sitemap

 


Return dynamic sitemap


Dynamic sitemap means that everytime the URL http://domain.com/sitemap is called we gather all current URL’s and return then in XML or whatever else supported format.


For better optimization and for reducing the stress on the system we can cache that sitemap for a specified time period using this plugin also.


In order to return the sitemap we first have to define a route to handle our request /sitemap:


File: routes.php


Folder: app


You can add this directly to your `routes.php` file or you can place it somewhere else for better separation of code.


Route::get('sitemap', function()

// create new sitemap object
$sitemap = App::make("sitemap");

// set cache (key (string), duration in minutes
// (Carbon);

 


And that’s it! Now you have a sitemap for your application. Don’t forget, you still have to include all of yours URL’s in the above code using the same syntax.


 


 


 


Example: How to create dynamic sitemap


Route::get('sitemap', function()int), turn on/off (boolean))
// by default cache is disabled
$sitemap->setCache('laravel.sitemap', 3600);

// add item to the sitemap (url, date, priority, freq)
$sitemap->add(URL::to(), '2012-08-25T20:10:00+02:00', '1.0', 'daily');
$sitemap->add(URL::to('page'), '2012-08-26T12:30:00+02:00', '0.9', 'monthly');

// get all posts from db
$posts = DB::table('posts')->orderBy('created_at', 'desc')->get();

// add every post to the sitemap
foreach ($posts as $post)

$sitemap->add($post->slug, $post->modified, $post->priority, $post->freq);


// show your sitemap (options: 'xml' (default), 'html', 'txt', 'ror-rss', 'ror-rdf')
return $sitemap->render('xml');

);

 


Example: How to generate sitemap file


Route::get('mysitemap', function()

// create new sitemap object
$sitemap = App::make("sitemap");

// add items to the sitemap (url, date, priority, freq)
$sitemap->add(URL::to(), '2012-08-25T20:10:00+02:00', '1.0', 'daily');
$sitemap->add(URL::to('page'), '2012-08-26T12:30:00+02:00', '0.9', 'monthly');

// get all posts from db
$posts = DB::table('posts')->orderBy('created_at', 'desc')->get();

// add every post to the sitemap
foreach ($posts as $post)

$sitemap->add($post->slug, $post->modified, $post->priority, $post->freq);


// generate your sitemap (format, filename)
$sitemap->store('xml', 'mysitemap');
// this will generate file mysitemap.xml to your public folder

);

 


Download  sitemap generator for Laravel 4



sitemap generator for Laravel 4

Notification package for Laravel 4

A simple notification management package for Laravel 4 framework .


  • Notification containers

  • Notification collections

  • Notification messages

  • Formats for notifications

  • Flashable notifications

  • Method chaining

  • Message aliasing

  • Message positioning

Installation


Just place require new package for your laravel installation via composer.json


"edvinaskrucas/notification": "2.*"

 


Then hit composer update


Registering to use it with laravel


Add following lines to app/config/app.php


ServiceProvider array


'Krucas\Notification\NotificationServiceProvider'

 


Alias array


'Notification' => 'Krucas\Notification\Facades\Notification'

 


Now you are able to use it with Laravel4.


Publishing config file


If you want to edit default config file, just publish it to your app folder.


php artisan config:publish edvinaskrucas/notification

 


Usage


Default usage


Adding message to default container.


Notification::success('Success message');
Notification::error('Error message');
Notification::info('Info message');
Notification::warning('Warning message');

 


Containers


Containers allows you to set up different containers for different placeholders.


You can pass closure to modify containers, simply use this syntax showed below


Notification::container('myContainer', function($container)

$container->info('Test info message');
$container->error('Error');
);

 


Also you can access container like this


Notification::container('myContainer')->info('Info message');

 


Method chaining


Notification::container('myContainer')->info('Info message')->error('Error message');

 


If you want to use default container just use null as container name. Name will be taken from config file.


Notification::container()->info('Info message');

 


Instant notifications (shown in same request)


Library supports not only flash messages, if you want to show notifications in same request just use


Notification::successInstant('Instant success message');

 


Custom single message format


Want a custom format for single message? No problem


Notification::success('Success message', 'Custom format :message');

 


Add multiple messages


If you want to add multiple notifications you can pass notication message as array


Notification::success(array(
'Message one',
array('Message two with its format', 'My format: :message')
array('message' => 'ok', 'format' => ':message', 'alias' => 'okMsg', 'position' => 5)
));

 


Also you can still pass second param (format), to format messages, but you can format individual messages as shown above.


Add message as object


You can add messages as objects


Notification::success(
Notification::message('Sample text')
);

 


When adding message as object you can add additional params to message


Notification::success(
Notification::message('Sample text')->format(':message')
);

 


Accessing first notification from container


You can access and show just first notification in container


 Notification::container('myContainer')->get('success')->first() 

 


Accessing first notification from all types


 Notification::container('myContainer')->all()->first() 

 


Displaying notifications


To display all notifications in a default container you need to add just one line to your view file


 Notification::showAll() 

 


When using showAll() you may want to group your messages by type, it can be done like this


 Notification::group('info', 'success', 'error', 'warning')->showAll() 

 


This will group all your messages in group and output it, also you can use just one, two or three groups.


Manipulating group output on the fly


Notification::addToGrouping('success')->removeFromGrouping('error');

 


Display notifications by type in default container, you can pass custom format


 Notification::showError() 
Notification::showInfo()
Notification::showWarning()
Notification::showSuccess(':message')

 


Displaying notifications in a specific container with custom format.


 Notification::container('myContainer')->showInfo(':message') 

 


Message aliasing


You can add message with an alias, then if you want to override that message just add new one with same alias. It works in a same type scope.


Notification::success(Notification::message('ok')->alias('okMsg'));

// We need to override first success message, just alias it with same alias name.
Notification::success(Notification::message('ok2')->alias('okMsg'));

 


With aliasing you can override message type too


Notification::info(Notification::message('info')->alias('loginMsg'));

// Overrides info message with error message
Notification::error(Notification::message('error')->alias('loginMsg'));

 


Getting aliased message instance.


Notification::getAliased('loginMsg');

 


Method getAliased($alias) is available in all scopes (Notification, NotificationBag and Collection), if no message will be found with given alias, null will be returned.


Message positioning


There is ability to add message to certain position. It works in same type scope.


// This will add message at 5th position
Notification::info(Notification::message('info')->position(5));
Notification::info(Notification::message('info2')->position(1);

 


Retrieving messages at certain position


Notification::getAtPosition(5);

 


Above example will return message at fifth position in a default container.


Aliasing with a position


You can alias message and add it to a certain position. It works in same type scope.


Notification::info(Notification::message('info')->alias('infoMsg')->position(4));
// If we want to override and set other position
Notification::info(Notification::message('info2')->alias('infoMsg')->position(1));

 


Clearing messages


You can clear all messages or by type.


Notification::clearError();
Notification::clearWarning();
Notification::clearSuccess();
Notification::clearInfo();
Notification::clearAll();

 


Add message and display it instantly in a view file


Want to add message in a view file and display it? Its very simple:


 Notification::container('myInstant')
->infoInstant('Instant message added in a view and displayed!')

 


You can also add multiple messages


 Notification::container('myInstant')
->infoInstant('Instant message added in a view and displayed!')
->errorInstant('Error...')

 Download Notification package for Laravel4



Notification package for Laravel 4

Saturday, April 12, 2014

how to hide/remove wordpress toolbar

with this method you can Easily hide/remove the front end Toolbar for logged in users.


Simple way to hide this bar is seen in the image below:


hide-admin-bar


 


 


Visable only for admin In your functions.php just write this code 


if ( !current_user_can('administrator') ) 
show_admin_bar( false );

with this just admin user can see toolbar but normal user cant see.


 


if you want for all use this 


show_admin_bar(false);

 


hide it for all users who can’t edit posts


add_action('set_current_user', 'tutorialworld_hide_admin_bar');
function csstricks_hide_admin_bar()
if (current_user_can('edit_posts'))
show_admin_bar(false);


 



how to hide/remove wordpress toolbar

User management system for codeigniter

User management system for codeigniter is a set of controllers, models and libraries for dealing with user registration, profiles and management in codeigniter.


Files and folders


application\config email.php contains settings for sending emails user_manager.php contains settings for the user manager


application\controllers main.php testing controller user_manager_controller.php user manager main controller


application\helpers um_helper.php helpers for user manager


application\hooks um_hook.php hook for reporting user activity to the database


application\language\english user_manager_lang.php localization


application\libraries user_manager.php User manager library


application\models um_users_model.php model


application\views\user_manager views edit_profile_form.php login_form.php profile.php register_form.php reset_form.php reset_pass_form.php um_msg.php


dps stores user uploaded profile pictures


pics stores user uploaded pictures (feature in development)


Installation


  1. Copy the content of each folder to your CI root folder.

  2. Go to autoload.php and make sure these settings are set. $autoload['libraries'] = array(‘database’,'form_validation’,'user_manager’,'session’); $autoload['helper'] = array(‘url’); $autoload['config'] = array(‘user_manager’); $autoload['language'] = array(‘user_manager’); $autoload['model'] = array(‘um_users_model’);

  3. User sessions are saved using the session library so you must set an encryption key. On config.php set $config['encryption_key'] = ‘some random stuff’;

  4. For security set $config['global_xss_filtering'] = true; on config.php

  5. Set up your database settings properly on database.php. The default dbprefix is ‘tbl_’ you may open the database.sql with a text editor and replace ‘tbl_’ with your own. Import the database.sql on to your database.

  6. Setup email settings on email.php to receive activation emails.

  7. On the routes.php add these lines $route['register'] = ‘user_manager_controller/register’; $route['activate'] = ‘user_manager_controller/activate’; $route['login'] = ‘user_manager_controller/login’; $route['logout'] = ‘user_manager_controller/logout’; $route['profile'] = ‘user_manager_controller/show_profile’; $route['editprofile'] = ‘user_manager_controller/edit_profile’; $route['resetpass'] = ‘user_manager_controller/reset_pass’; $route['reset'] = ‘user_manager_controller/reset’;

  8. To see if everything is working on routes.php set $route['default_controller'] = “main”; and load the site.

  9. If you’re installing in a subdirectory make sure you’ve changed the .htaccess file.


Adding your own registration fields


To add your own registration form fields:


1. Add the required columns to your database.

2. Add the new fields to the forms in view folder.


3. Open the user_manager_controller.php and edit the register() function and the edit_profile() function as needed.


4. Edit the $config['um_register_rules'] and $config['um_profile_rules'] in config/user_manager.php to reflect the new columns.


Email settings


Email sending method and other settings are in config/email.php. More email settings are on config/user_manager.php.


User status reporting


User manager can save the logged in user data to a table. The data is saved to the ‘tbl_loggedin_users’ table by default and can be accessed later.


1. To enable this feature you must enable hooks globally. On config.php make sure $config['enable_hooks'] = true; is set.


2. Put these lines on to the hooks.php /* hook for managing the logged in users table this maybe resource intensive if the site has too much traffic */ $hook['post_controller'] = array( ‘class’ => ‘Um_hook’, ‘function’ => ‘update_user_status’, ‘filename’ => ‘um_hook.php’, ‘filepath’ => ‘hooks’, ‘params’ => array() );


Logins older than a certain amount of time will be deleted from this table upon calling the hook. By default this is set to 15 minutes and can be changed at $config['um_login_timeout']=900; in config/user_manager.php.


Helper


User manager has a helper file called um_helper.php. This contains certain helpers that might be useful for re-populating data on forms.


Localization


User manager views can be localized to any language. Edit the application\language\english\user_manager_lang.php file to change the default strings or create your own language file.



Download User management system for codeigniter



User management system for codeigniter