My experience on my daily works... helping others ease each other

Saturday, September 30, 2017

Developing Microservices Using Orleans by Microsoft



Image result for microservices architectureI am new to Microservices although it has been a while in software engineering world. Luckily Microsoft (am not marketing them) has done a pretty good job in explaining the detail.

Take a look if you guys which to understand in detail.

Microservices offer great benefits but also raise huge new challenges. Microservice architecture patterns are fundamental pillars when creating a microservice-based application. [more]

And as part of their initiative (and of course to boost their .NET platform), they too develop a framework to support the implementation of microservices. Have time to read here.

* note: all link is valid as of 1st October 2017


Share:

Tuesday, July 25, 2017

Replicate same question to different course in Moodle

How do I copy Moodle Quiz questions from one course to another?

In the Moodle section from which you would like to copy questions:
1. In the “Administration” block, click on “Export” in the “Question bank” menu.
2. Choose “Moodle XML format” and select the category you would like to copy from the “Export category” drop-down menu; click on the “Export questions to file” button.
3. Save the file to your desktop.
4. Go to the Moodle section to which you would like to copy the questions.
5. Click “Import” in the “Question bank” menu.
6. Choose “Moodle XML format,” and make sure the “Default” course level category is chosen for the “Import category” drop-down menu.
7. Click “Choose file…” to open the “File picker” window.
8. In the “File picker” window, click “Choose File” to browse and select your exported Moodle questions file, then click “Upload this file.”
9. Click “Import,” and you will see a preview of the imported questions.
10. Click “Continue” to proceed to the category containing the imported questions.
NOTE: At this point, you have only copied the quiz questions, and must still create a new quiz and load in the copied questions.

To add the copied questions into a new quiz:

1. Go to the home page of your Moodle course section and click “Turn editing on.”
2. Click the “Add an activity or resource” link in any section where you would like the link to your quiz to be displayed.
3. In the “Add an activity or resource” window, choose “Quiz” and click on the “Add” button.
4. Give your quiz a Name, Open and Close Dates, and set any other desired configurations.
5. Click on the “Save and display” button at the bottom of the page.
6. Click on the “Edit quiz” button; in the “Select a category” drop-down menu in the purple box on the right, select the (newly imported) question category.
7. Check the box to the left of the questions you would like to add to the quiz, or check the box at the top of the column to select all.
8. Click on the “Add to quiz” button.

The above content is copied directly from here:
https://delta.ncsu.edu/knowledgebase/how-do-i-copy-moodle-quiz-questions-from-one-course-to-another/
Share:

Thursday, July 20, 2017

Tableau - The user could not be added because you do not have access to the domain specified.

You may get the following error when you try to add new user. You have try may solutions as listed in Tableau:


Even you have file a case at Tableau Support and received respond from them. I received the following from Tableau Support:
Thank you for contacting Tableau Technical Support. My name is Henk, and I will be assisting with this case.

I have investigated the reported issue and I do have some steps below that should resolve the permissions issues on Tableau Server. We suggest consulting with your Active directory administrator to make sure the Tableau Server Run As User account has been granted permission to has access to query the Active Directory. If having the access capability, please follow the steps below re-entering the Run As User password and start Tableau Server.

• Try stopping TABLEAU Server, re-enter the Run As User password and start Tableau Server

1. Open Command Prompt and run as administrator, navigate to the “bin” folder located in the Tableau Server directory. For example if Tableau Server is installed in the default location, the directory will be: C:\Program Files\Tableau\Tableau Server\\bin 2. Type the following command to stop Tableau Server: tabadmin stop 3. From the start menu, type "Configure Tableau Server", and right click the program to open it as a Window Administrator.
4. Type the Run As user password and click "Ok" to save.
5. Type the following command to start Tableau Server: tabadmin start

Additional information on how to add Active Directory users can be found in the following links:

Add Users to a Site

I believe the above information will resolve this issue. If the information provided does not resolve the issue, please let me know by responding with the additional information requested below and a few details regarding why the solution above did not resolve the issue.

1.            What issues are still occurring?
2.            Did the steps not resolve the issue?
3.            Is this an issue with all users or just a specific Active Directory user?

We may send a survey to confirm that the case has been fully resolved.

We appreciate any feedback on this issue as well as the general Tableau Technical Support experience.

Thank you for being a valued Tableau Software customer!

Please find your case summary below. To update this case via email, please reply to this message.

Sincerely,
Henk
Tech Support
Tableau Software


After try all the above, you still get the same result and thought of re-install your tableau server. Before you do that, let me give you another solutions:
1. Please make sure the username used to manage the tableau server (start, stop, restart) is register in the same domain as other user (in your Active Directory, LDAP server, or any authentication method used excluding local authentication)
2. If no. 1 ok, then ensure that the user has administrator privileges and has granted by your domain authenticator (in my case is Active Directory)
3. Open you Tableau Server Config (for Windows Start Menu > Tableau > Config Tableau Server).
4. In the window pop-up, make sure the username and password entered is the same username/password register in the Active Directory.
5. Restart your tableau server. Opps.. I recommended that you stop your tableau server first. :)

And it shall solve your problem.

p/s: it took me 2 days to figure out.

Share:

Friday, May 26, 2017

Kotlin + Netbeans IDE 8.2 - Don't use yet

I try the new language Kotlin with Netbeans 8.2.
http://plugins.netbeans.org/plugin/68590/kotlin

After download and install the plugin, it cause error on all projects currently on my list of projects and causing my netbeans to behave abnormally.

The error does not stop there. When I uninstall it, which you can't as it only appear in User Plugin and when you uninstall the plugin (just for the sake to remove kotlin), it causes many other problem.

So guys, use with extra careful ya.
Share:

Thursday, March 2, 2017

Get start with ionic framework

When I first developed apps using ionic, not many resources over the net will provide good explanation on it. I've found one and it is very easy to understand.

Here is the structure of ionic framework after it successfully execute ionic start command; for example 

ionic start myfirst blank --v2

>> ionic start [your_apps_name] [template] [ionic_framework_version]

the command will create a new folder (myfirst) and construct the following structures

├── hooks // custom cordova hooks to execute on specific commands 
├── platforms // iOS/Android specific builds will reside here 
├── plugins // where your cordova/ionic plugins will be installed 
├── resources // icon and splash screen 
├── scss // scss code, which will output to www/css/
 |── www // application - JS code and libs, CSS, images, etc. 
      |---------css //customs styles 
      |---------img //app images 
      |---------js //angular app and custom JS 
      |---------lib //third party libraries 
      |---------index.html //app master page 
├── bower.json // bower dependencies 
├── config.xml // cordova configuration 
├── gulpfile.js // gulp tasks 
├── ionic.project // ionic configuration 
├── package.json // node dependencies


Following are current potential templates that you can use:
  • tabs : a simple 3 tab layout
  • sidemenu: a layout with a swipable menu on the side
  • blank: a bare starter with a single page
  • super: starter project with over 14 ready to use page designs
  • tutorial: a guided starter project

Once it is completed, you will get to see the following message appear:
Downloading: https://github.com/driftyco/ionic2-app-base/archive/master.zip
Downloading: https://github.com/driftyco/ionic2-starter-                   sidemenu/archive/master.zip                                                
Installing npm packages (may take a minute or two)...                      
-                                                                          
♬ ♫ ♬ ♫  Your Ionic app is ready to go! ♬ ♫ ♬ ♫                          
                                                                           
Some helpful tips:                                                         
                                                                           
Run your app in the browser (great for initial development):               
  ionic serve                                                              
                                                                           
Run on a device or simulator:                                              
  ionic run ios[android,browser]                                           
                                                                           
Share your app with testers, and test on device easily with the Ionic View companion app:                                                             
  http://view.ionic.io                                                     

Yeah... now you test your apps. Just run ionic serve to view on your browser. It will pop-up your browser and automatically navigate to http://localhost:8100 ... else, you can open your browser and go to the address.

If you want to view in mobile, you may use mobile emulator or deploy on your mobile. Before that, do install mobile platform package first. To do that, run the following command:

                                                                       
ionic platform add ios  // to add ios platform into the package      
                                                                     
ionic platform add android //to add android platform into the package  
                                                                       

Finally, you are ready to run (on emulator or actual device).


                                                                           
ionic run android --prod --release //to run on emulator as production mode 
                                                                           
ionic build android --prod --release //to build as package for installation
                                                                           

For ios, it will require more steps and you can follow it https://ionicframework.com/docs/v2/intro/deploying/.

Lets dance... :)
Share:

Tuesday, February 28, 2017

PHP Randomize and Sort for multi-dimensional array

Learn to use rand() in php and sortation on multi-dimensional array via dice program.

Here is the code https://github.com/masteramuk/PHP-Rand-and-Sort
Share:

Directory Listener (java code) - finally on github

Hi guys.. it has been a while since I last wrote anything here.

Just wanna share with you my latest contribution to community. I've uploaded a simple directory listener code written in java. What it does?
1. Listen to any directory pass as parameter
2. Basically alert you through message prompt on any activity done.

It can be further extended for any process you wish.

Feel free to use the code. It can be downloaded at
https://github.com/masteramuk/Java-Directory-Watcher

Adios..

Share:

Tuesday, December 20, 2016

json_decode(file_get_contents("php://input") on https

When you try to run json_decode on https, it will throw errors due to null value. file_get_contents("php://input") will also return null.

Way to solve it and the most efficient are as follows

//get data from caller
$arrContextOptions=array(
 "ssl"=>array(
"verify_peer"=>false,
"verify_peer_name"=>false,
),
);  
$your_data_array= json_decode(file_get_contents("php://input",false, stream_context_create($arrContextOptions)),true);

The code actually make it don't care what protocol you are using and set it to false (means no verifications). It normally happen when you are using self-signed or non-standard SSL certificates.

It is the most efficient and the fastest solutions.. but not the most practical :)

The best is -> use standard approved certificates :)
Share:

Wednesday, November 23, 2016

Running SQL Server on Linux

It has gone viral and loved by many after Microsoft declared their engagement with Linux after series of interaction... and much awaited of the possible potential running few Microsoft product running on Linux.

While waiting, lets give a try on SQL Server running on Fedora through virtual machine powered by Docker

Paul W. Frields and Langdon White share their views and step for this.
  1. https://fedoramagazine.org/run-sql-server-v-next-public-preview-fedora/
  2. https://fedoramagazine.org/sql-server-fedora-docker-container/
Share:

Monday, November 14, 2016

Setting up JDK on Oracle Linux without downloading package

I was setting up my server when there is a need to have the JDK install and found the following guideline is useful for those that don't want to download the package, unzip and then install... just run to command.. Below is the guideline published @ http://stackoverflow.com/questions/5104817/how-to-install-java-sdk-on-centos

The following command will return a list of all packages directly related to Java. They will be in the format of java-.
$ yum search java | grep 'java-'
If there are no available packages, then you may need to download a new repository to search through. I suggest taking a look at Dag Wieers' repo. After downloading it, try the above command again.
You will see at least one version of Java packages available for download. Depending on when you read this, the lastest available version may be different.
java-1.7.0-openjdk.x86_64
The above package alone will only install JRE. To also install javac and JDK, the following command will do the trick:
$ yum install java-1.7.0-openjdk*
These packages will be installing (as well as their dependencies):
java-1.7.0-openjdk.x86_64
java-1.7.0-openjdk-accessibility.x86_64
java-1.7.0-openjdk-demo.x86_64
java-1.7.0-openjdk-devel.x86_64
java-1.7.0-openjdk-headless.x86_64
java-1.7.0-openjdk-javadoc.noarch
java-1.7.0-openjdk-src.x86_64
Share:

Sunday, November 13, 2016

ActiveDS.DLL is missing or corrupt

I was updating my outlook when I got the message "ActiveDS.dll is missing" and my outlook keep on restarting. Reading many solutions through google search but it took me some time till I found the simplest solution at this site (which also listed many ways to solve the problem).

http://www.dllmissing.com/fix-missing-or-not-found-activeds.dll-errors-1886

but the most easier was -> just open your command prompt and run this command 'sfc /scannow' and it should do the rest.. and you will get to see the following process..


And is should be ok after that. Else, just follow the link and try all solutions there.
Share:

Sunday, September 18, 2016

Laravel Cheat Sheet

Artisanphp artisan --help OR -h
php artisan --quiet OR -q
php artisan --version OR -V
php artisan --no-interaction OR -n
php artisan --ansi
php artisan --no-ansi
php artisan --env
// -v|vv|vvv Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debugphp artisan --verbose
php artisan changes
php artisan clear-compiled
php artisan down
php artisan dump-autoload
php artisan env
php artisan help
php artisan list
php artisan migrate
php artisan optimize
php artisan routes
php artisan serve
php artisan tinker
php artisan up
php artisan workbench
php artisan asset:publish [--bench[="vendor/package"]] [--path[="..."]] [package]
php artisan auth:reminders
php artisan cache:clear
php artisan command:make name [--command[="..."]] [--path[="..."]] [--namespace[="..."]]
php artisan config:publish
php artisan controller:make [--bench="vendor/package"]
php artisan db:seed [--class[="..."]] [--database[="..."]]
php artisan key:generate
php artisan migrate [--bench="vendor/package"] [--database[="..."]] [--path[="..."]] [--package[="..."]] [--pretend] [--seed]
php artisan migrate:install [--database[="..."]]
php artisan migrate:make name [--bench="vendor/package"] [--create] [--package[="..."]] [--path[="..."]] [--table[="..."]]
php artisan migrate:refresh [--database[="..."]] [--seed]
php artisan migrate:reset [--database[="..."]] [--pretend]
php artisan migrate:rollback [--database[="..."]] [--pretend]
php artisan queue:listen [--queue[="..."]] [--delay[="..."]] [--memory[="..."]] [--timeout[="..."]] [connection]
php artisan queue:subscribe [--type[="..."]] queue url
php artisan queue:work [--queue[="..."]] [--delay[="..."]] [--memory[="..."]] [--sleep] [connection]
php artisan session:table
php artisan view:publish [--path[="..."]] package


Composercomposer create-project laravel/laravel folder_name
composer install
composer update
composer dump-autoload [--optimize]
composer self-update


RoutingRoute::get('foo', function(){});Route::get('foo', 'ControllerName@function');Route::controller('foo', 'FooController');

Triggering ErrorsApp::abort(404);App::missing(function($exception){});throw new NotFoundHttpException;

Route ParametersRoute::get('foo/{bar}', function($bar){});Route::get('foo/{bar?}', function($bar = 'bar'){});

HTTP VerbsRoute::any('foo', function(){});Route::post('foo', function(){});Route::put('foo', function(){});Route::patch('foo', function(){});Route::delete('foo', function(){});// RESTful actionsRoute::resource('foo', 'FooController');

Secure RoutesRoute::get('foo', array('https', function(){}));

Route ConstraintsRoute::get('foo/{bar}', function($bar){})
->
where('bar', '[0-9]+');Route::get('foo/{bar}/{baz}', function($bar, $baz){})
->
where(array('bar' => '[0-9]+', 'baz' => '[A-Za-z]'))

Filters// Declare an auth filterRoute::filter('auth', function(){});// Register a class as a filterRoute::filter('foo', 'FooFilter');// Routes in this group are guarded by the 'auth' filterRoute::get('foo', array('before' => 'auth', function(){}));Route::group(array('before' => 'auth'), function(){});// Pattern filterRoute::when('foo/*', 'foo');// HTTP verb patternRoute::when('foo/*', 'foo', array('post'));

Named RoutesRoute::currentRouteName();Route::get('foo/bar', array('as' => 'foobar', function(){}));

Route Prefixing// This route group will carry the prefix 'foo'Route::group(array('prefix' => 'foo'), function(){})

Sub-Domain Routing// {sub} will be passed to the closureRoute::group(array('domain' => '{sub}.example.com'), function(){});URLsURL::full();URL::current();URL::previous();URL::to('foo/bar', $parameters, $secure);URL::action('FooController@method', $parameters, $absolute);URL::route('foo', $parameters, $absolute);URL::secure('foo/bar', $parameters);URL::asset('css/foo.css', $secure);URL::secureAsset('css/foo.css');URL::isValidUrl('http://example.com');URL::getRequest();URL::setRequest($request);URL::getGenerator();URL::setGenerator($generator);

EventsEvent::fire('foo.bar', array($bar));Event::listen('foo.bar', function($bar){});Event::listen('foo.*', function($bar){});Event::listen('foo.bar', 'FooHandler', 10);Event::listen('foo.bar', 'BarHandler', 5);Event::listen('foor.bar', function($event){ return false; });Event::queue('foo', array($bar));Event::flusher('foo', function($bar){});Event::flush('foo');Event::subscribe(new FooEventHandler);

DB$results = DB::select('select * from users where id = ?', array('value'));DB::insert('insert into users (id, name) values (?, ?)', array(1, 'Dayle'));DB::update('update users set votes = 100 where name = ?', array('John'));DB::delete('delete from users');DB::statement('drop table users');DB::listen(function($sql, $bindings, $time){ code_here() });DB::transaction(function(){ code_here() });

EloquentModel::create(array('key' => 'value'));Model::destroy(1);Model::all();Model::find(1);// Trigger an exceptionModel::findOrFail(1);Model::where('foo', '=', 'bar')->get();Model::where('foo', '=', 'bar')->first();// ExceptionModel::where('foo', '=', 'bar')->firstOrFail();Model::where('foo', '=', 'bar')->count();Model::where('foo', '=', 'bar')->delete();Model::whereRaw('foo = bar and cars = 2', array(20))->get();Model::on('connection-name')->find(1);Model::with('relation')->get();Model::all()->take(10);Model::all()->skip(10);

Soft DeleteModel::withTrashed()->where('cars', 2)->get();Model::withTrashed()->where('cars', 2)->restore();Model::where('cars', 2)->forceDelete();Model::onlyTrashed()->where('cars', 2)->get();

EventsModel::creating(function($model){});Model::created(function($model){});Model::updating(function($model){});Model::updated(function($model){});Model::saving(function($model){});Model::saved(function($model){});Model::deleting(function($model){});Model::deleted(function($model){});Model::observe(new FooObserver);

MailMail::send('email.view', $data, function($message){});Mail::send(array('html.view', 'text.view'), $data, $callback);Mail::queue('email.view', $data, function($message){});Mail::queueOn('queue-name', 'email.view', $data, $callback);Mail::later(5, 'email.view', $data, function($message){});// Write all email to logs instead of sendingMail::pretend();

QueuesQueue::push('SendMail', array('message' => $message));Queue::push('SendEmail@send', array('message' => $message));Queue::push(function($job) use $id {});
php artisan queue:listen
php artisan queue:listen connection
php artisan queue:listen --timeout=60
php artisan queue:work


LocalizationApp::setLocale('en');Lang::get('messages.welcome');Lang::get('messages.welcome', array('foo' => 'Bar'));Lang::has('messages.welcome');Lang::choice('messages.apples', 10);

FilesFile::exists('path');File::get('path');File::getRemote('path');File::getRequire('path');File::requireOnce('path');File::put('path', 'contents');File::append('path', 'data');File::delete('path');File::move('path', 'target');File::copy('path', 'target');File::extension('path');File::type('path');File::size('path');File::lastModified('path');File::isDirectory('directory');File::isWritable('path');File::isFile('file');// Find path names matching a given pattern.File::glob($patterns, $flag);// Get an array of all files in a directory.File::files('directory');// Get all of the files from the given directory (recursive).File::allFiles('directory');// Get all of the directories within a given directory.File::directories('directory');File::makeDirectory('path', $mode = 0777, $recursive = false);File::copyDirectory('directory', 'destination', $options = null);File::deleteDirectory('directory', $preserve = false);File::cleanDirectory('directory');

InputInput::get('key');// Default if the key is missingInput::get('key', 'default');Input::has('key');Input::all();// Only retrieve 'foo' and 'bar' when getting inputInput::only('foo', 'bar');// Disregard 'foo' when getting inputInput::except('foo');

Session Input (flash)// Flash input to the sessionInput::flash();Input::flashOnly('foo', 'bar');Input::flashExcept('foo', 'baz');Input::old('key','default_value');

Files// Use a file that's been uploadedInput::file('filename');// Determine if a file was uploadedInput::hasFile('filename');// Access file propertiesInput::file('name')->getRealPath();Input::file('name')->getClientOriginalName();Input::file('name')->getSize();Input::file('name')->getMimeType();// Move an uploaded fileInput::file('name')->move($destinationPath);// Move an uploaded fileInput::file('name')->move($destinationPath, $fileName);

CacheCache::put('key', 'value', $minutes);Cache::add('key', 'value', $minutes);Cache::forever('key', 'value');Cache::remember('key', $minutes, function(){ return 'value' });Cache::rememberForever('key', function(){ return 'value' });Cache::forget('key');Cache::has('key');Cache::get('key');Cache::get('key', 'default');Cache::get('key', function(){ return 'default'; });Cache::increment('key');Cache::increment('key', $amount);Cache::decrement('key');Cache::decrement('key', $amount);Cache::section('group')->put('key', $value);Cache::section('group')->get('key');Cache::section('group')->flush();

CookiesCookie::get('key');// Create a cookie that lasts for everCookie::forever('key', 'value');// Send a cookie with a response$response = Response::make('Hello World');
$response->withCookie(Cookie::make('name', 'value', $minutes));


SessionsSession::get('key');Session::get('key', 'default');Session::get('key', function(){ return 'default'; });Session::put('key', 'value');Session::all();Session::has('key');Session::forget('key');Session::flush();Session::regenerate();Session::flash('key', 'value');Session::reflash();Session::keep(array('key1', 'key2'));

RequestsRequest::path();Request::is('foo/*');Request::url();Request::segment(1);Request::header('Content-Type');Request::server('PATH_INFO');Request::ajax();Request::secure();

Responsesreturn Response::make($contents);return Response::make($contents, 200);return Response::json(array('key' => 'value'));return Response::json(array('key' => 'value'))
->
setCallback(Input::get('callback'));return Response::download($filepath);return Response::download($filepath, $filename, $headers);// Create a response and modify a header value$response = Response::make($contents, 200);
$response->header('Content-Type', 'application/json');
return $response;// Attach a cookie to a responsereturn Response::make($content)
->withCookie(Cookie::make('key', 'value'));


Redirectsreturn Redirect::to('foo/bar');return Redirect::to('foo/bar')->with('key', 'value');return Redirect::to('foo/bar')->withInput(Input::get());return Redirect::to('foo/bar')->withInput(Input::except('password'));return Redirect::to('foo/bar')->withErrors($validator);return Redirect::back();return Redirect::route('foobar');return Redirect::route('foobar', array('value'));return Redirect::route('foobar', array('key' => 'value'));return Redirect::action('FooController@index');return Redirect::action('FooController@baz', array('value'));return Redirect::action('FooController@baz', array('key' => 'value'));// If intended redirect is not defined, defaults to foo/bar.return Redirect::intended('foo/bar');

IoCApp::bind('foo', function($app){ return new Foo; });App::make('foo');// If this class exists, it's returnedApp::make('FooBar');App::singleton('foo', function(){ return new Foo; });App::instance('foo', new Foo);App::bind('FooRepositoryInterface', 'BarRepository');App::register('FooServiceProvider');// Listen for object resolutionApp::resolving(function($object){});

SecurityPasswordsHash::make('secretpassword');Hash::check('secretpassword', $hashedPassword);Hash::needsRehash($hashedPassword);

Auth// Check if the user is logged inAuth::check();Auth::user();Auth::attempt(array('email' => $email, 'password' => $password));// Remember user loginAuth::attempt($credentials, true);// Log in for a single requestAuth::once($credentials);Auth::login(User::find(1));Auth::loginUsingId(1);Auth::logout();Auth::validate($credentials);Auth::basic('username');Auth::onceBasic();Password::remind($credentials, function($message, $user){});

EncryptionCrypt::encrypt('secretstring');Crypt::decrypt($encryptedString);Crypt::setMode('ctr');Crypt::setCipher($cipher);

ValidationValidator::make(
array('key' => 'Foo'),
array('key' => 'required|in:Foo')
);
Validator::extend('foo', function($attribute, $value, $params){});Validator::extend('foo', 'FooValidator@validate');Validator::resolver(function($translator, $data, $rules, $msgs)
{
return new FooValidator($translator, $data, $rules, $msgs);
});

Validation Rulesaccepted
active_url
after:YYYY-MM-DD
before:YYYY-MM-DD
alpha
alpha_dash
alpha_num
between:1,10
confirmed
date
date_format:YYYY-MM-DD
different:fieldname
email
exists:table,column
image
in:foo,bar,baz
not_in:foo,bar,baz
integer
numeric
ip
max:value
min:value
mimes:jpeg,png
regex:[0-9]
required
required_if:field,value
required_with:foo,bar,baz
required_without:foo,bar,baz
same:field
size:value
unique:table,column,except,idColumn
url


ViewsView::make('path/to/view');View::make('foo/bar')->with('key', 'value');View::make('foo/bar', array('key' => 'value'));View::exists('foo/bar');// Share a value across all viewsView::share('key', 'value');// Nesting viewsView::make('foo/bar')->nest('name', 'foo/baz', $data);// Register a view composerView::composer('viewname', function($view){});//Register multiple views to a composerView::composer(array('view1', 'view2'), function($view){});// Register a composer classView::composer('viewname', 'FooComposer');View::creator('viewname', function($view){});

Blade Templates@extends('layout.name')
@section('name')
// Begin a section@stop // End a section@show // End a section and then show it@yield('name') // Show a section name in a template@include('view.name')
@include('view.name', array('key' => 'value'));
@lang('messages.name')
@choice('messages.name', 1);
@if
@else
@elseif
@endif
@unless
@endunless
@for
@endfor
@foreach
@endforeach
@while
@endwhile
{{ $var }}
// Echo content{{{ $var }}} // Echo escaped content{{-- Blade Comment --}}

FormsForm::open(array('url' => 'foo/bar', 'method' => 'PUT'));Form::open(array('route' => 'foo.bar'));Form::open(array('route' => array('foo.bar', $parameter)));Form::open(array('action' => 'FooController@method'));Form::open(array('action' => array('FooController@method', $parameter)));Form::open(array('url' => 'foo/bar', 'files' => true));Form::token();Form::model($foo, array('route' => array('foo.bar', $foo->bar)));Form::close;

Form ElementsForm::label('id', 'Description');Form::label('id', 'Description', array('class' => 'foo'));Form::text('name');Form::text('name', $value);Form::textarea('name');Form::textarea('name', $value);Form::textarea('name', $value, array('class' => 'name'));Form::hidden('foo', $value);Form::password('password');Form::email('name', $value, array());Form::file('name', array());Form::checkbox('name', 'value');Form::radio('name', 'value');Form::select('name', array('key' => 'value'));Form::select('name', array('key' => 'value'), 'key');Form::submit('Submit!');


Form MacrosForm::macro('fooField', function()
{
return ''; });Form::fooField();

HTML BuilderHTML::macro('name', function(){});HTML::entities($value);HTML::decode($value);HTML::script($url, $attributes);HTML::style($url, $attributes);HTML::link($url, 'title', $attributes, $secure);HTML::secureLink($url, 'title', $attributes);HTML::linkAsset($url, 'title', $attributes, $secure);HTML::linkSecureAsset($url, 'title', $attributes);HTML::linkRoute($name, 'title', $parameters, $attributes);HTML::linkAction($action, 'title', $parameters, $attributes);HTML::mailto($email, 'title', $attributes);HTML::email($email);HTML::ol($list, $attributes);HTML::ul($list, $attributes);HTML::listing($type, $list, $attributes);HTML::listingElement($key, $type, $value);HTML::nestedListing($key, $type, $value);HTML::attributes($attributes);HTML::attributeElement($key, $value);HTML::obfuscate($value);

Strings// Transliterate a UTF-8 value to ASCIIStr::ascii($value)Str::camel($value)Str::contains($haystack, $needle)Str::endsWith($haystack, $needles)// Cap a string with a single instance of a given value.Str::finish($value, $cap)Str::is($pattern, $value)Str::length($value)Str::limit($value, $limit = 100, $end = '...')Str::lower($value)Str::words($value, $words = 100, $end = '...')Str::plural($value, $count = 2)// Generate a more truly "random" alpha-numeric string.Str::random($length = 16)// Generate a "random" alpha-numeric string.Str::quickRandom($length = 16)Str::upper($value)Str::title($value)Str::singular($value)Str::slug($title, $separator = '-')Str::snake($value, $delimiter = '_')Str::startsWith($haystack, $needles)// Convert a value to studly caps case.Str::studly($value)Str::macro($name, $macro)

HelpersArraysarray_add($array, 'key', 'value');
array_build($array,
function(){});
array_divide($array);
array_dot($array);
array_except($array, array('key'));
array_fetch($array, 'key');
array_first($array,
function($key, $value){}, $default);// Strips keys from the arrayarray_flatten($array);
array_forget($array, 'foo');
// Dot notationarray_forget($array, 'foo.bar');
array_get($array, 'foo', 'default');
array_get($array, 'foo.bar', 'default');
array_only($array, array('key'));
// Return array of key => valuesarray_pluck($array, 'key');// Return and remove 'key' from arrayarray_pull($array, 'key');
array_set($array, 'key', 'value');
// Dot notationarray_set($array, 'key.subkey', 'value');
array_sort($array,
function(){});// First element of an arrayhead($array);// Last element of an arraylast($array);

Pathsapp_path();
public_path();
// App root pathbase_path();
storage_path();


Stringscamel_case($value);
class_basename($class);
// Escape a stringe('');
starts_with('Foo bar.', 'Foo');
ends_with('Foo bar.', 'bar.');
snake_case('fooBar');
str_contains('Hello foo bar.', 'foo');
// Result: foo/bar/str_finish('foo/bar', '/');
str_is('foo*', 'foobar');
str_plural('car');
str_random(25);
str_singular('cars');
// Result: FooBarstudly_case('foo_bar');
trans('foo.bar');
trans_choice('foo.bar', $count);


URLs and Linksaction('FooController@method', $parameters);
link_to('foo/bar', $title, $attributes, $secure);
link_to_asset('img/foo.jpg', $title, $attributes, $secure);
link_to_route('route.name', $title, $parameters, $attributes);
link_to_action('FooController@method', $title, $params, $attrs);
// HTML Linkasset('img/photo.jpg', $title, $attributes);// HTTPS linksecure_asset('img/photo.jpg', $title, $attributes);
secure_url('path', $parameters);
route($route, $parameters, $absolute = true);
url('path', $parameters = array(), $secure = null);


Miscellaneouscsrf_token();
dd($value);
value(
function(){ return 'bar'; });
with(new Foo)->chainedMethod();


Google Docs Document Source :https://docs.google.com/document/d/1NeCLL4fOgAmm4pYHIcBeWgCSCem5pqnGcwD_j4sNZyc/edit?usp=sharing  
Share:

About Me

Somewhere, Selangor, Malaysia
An IT by profession, a beginner in photography

Labels

Blog Archive

Blogger templates