Tutorial by Examples: f

Passing Variable in URL as a method's parameter return $this->redirect([ 'controller' => 'users', 'action' => 'profile', $id ]); Url should be looks like this http://your_app_url/users/profile/{id} in UsersController.php file in profile() method class UsersController e...
Set default layout for entire application. i.e, created layout file in /src/Template/Layout/admin.ctp class AppsController extends Controller { public function beforeFilter(Event $event) { parent::beforeFilter($event); $this->viewBuilder()->layout('admin'); // For Ver...
This will load a JSON file from disk and convert it to the given type. public static <T> T getFile(String fileName, Class<T> type) throws FileNotFoundException { Gson gson = new GsonBuilder() .create(); FileReader json = new FileReader(fileName); return gson....
First of all you need to add the GsonConverterFactory to your build.gradle file compile 'com.squareup.retrofit2:converter-gson:2.1.0' Then, you have to add the converter factory when creating the Retrofit Service: Gson gson = new GsonBuilder().create(); new Retrofit.Builder() .baseUrl...
It's possible to compare lists and other sequences lexicographically using comparison operators. Both operands must be of the same type. [1, 10, 100] < [2, 10, 100] # True, because 1 < 2 [1, 10, 100] < [1, 10, 100] # False, because the lists are equal [1, 10, 100] <= [1, 10, 100] #...
.NET Core app should be published using dotnet publish FROM microsoft/dotnet:latest COPY bin/Debug/netcoreapp1.0/publish/ /root/ EXPOSE 5000 ENTRYPOINT dotnet /root/sampleapp.dll
There are a number of predefined global variables that you can set in the front matter of a page or post. VariableDescriptionlayoutIf set, this specifies the layout file to use. Use the layout file name without the file extension. Layout files must be placed in the _layouts directory.permalinkIf y...
If you want to retrieve the details of a user's Facebook profile, you need to set permissions for the same: loginButton = (LoginButton)findViewById(R.id.login_button); loginButton.setReadPermissions(Arrays.asList("email", "user_about_me")); You can keep adding more permiss...
Once you first add the Facebook login/signup, the button looks something like: Most of the times, it doesn't match with the design-specs of your app. And here's how you can customize it: <FrameLayout android:layout_below="@+id/no_network_bar" android:id="@+id/FrameLay...
You have to setup the prerequisites. Add the Facebook activity to the AndroidManifest.xml file: <activity android:name="com.facebook.FacebookActivity" android:configChanges= "keyboard|keyboardHidden|screenLayout|screenSize|orientation" android:theme=&...
Facebook SDK 4.0 onwards, this is how we logout: com.facebook.login.LoginManager.getInstance().logOut(); For versions before 4.0, the logging out is gone by explicitly clearing the access token: Session session = Session.getActiveSession(); session.closeAndClearTokenInformation();
If you want your application to support a plug-in system, for example to load plug-ins from assemblies located in plugins folder: interface IPlugin { string PluginDescription { get; } void DoWork(); } This class would be located in a separate dll class HelloPlugin : IPlugin { ...
Structure: Try 'Your program will try to run the code in this block. 'If any exceptions are thrown, the code in the Catch Block will be executed, 'without executing the lines after the one which caused the exception. Catch ex As System.IO.IOException 'If an exception occurs w...
Add a init.gradle to your user gradle folder. The init.gradle is recognized on every project. Unix: ~/.gradle/init.gradle These are also alternative locations where init script can be placed and loaded automatically:- Any *.gradle file in USER_HOME/.gradle/init.d Any *.gradle file in t...
To list all available schemes for the project in your current directory xcodebuild -list Optionally you can pass a path to a project or workspace file xcodebuild -list -workspace ./MyApp.xcworkspace xcodebuild -list -project ./MyApp.xcodeproj Example output Information about project "...
Thanks to this great post If we want to mimic the Sitecore UI behavior and execute the command which will change the workflow state, we need to use WorkflowProvider to get an instance of the workflow assigned to the given item and call Execute method with a chosen command ID. This will fire all the...
using System; public class Program { public static void Main() { var date = new DateTime(2016,12,31); Console.WriteLine(date.ToString()); //Outputs: 12/31/2016 12:00:00 AM Console.WriteLine(date.ToShortDateString()); //Out...
To get Array from any object, use Kernel#Array. The following is an example: Array('something') #=> ["something"] Array([2, 1, 5]) #=> [2, 1, 5] Array(1) #=> [1] Array(2..4) #=> [2, 3, 4] Array([]) #=> [] Array(nil) #=> [] For...
std::ifstream src("source_filename", std::ios::binary); std::ofstream dst("dest_filename", std::ios::binary); dst << src.rdbuf(); C++17 With C++17 the standard way to copy a file is including the <filesystem> header and using copy_file: std::fileystem::copy...
Sometimes you may want to have local changes in a file you don't want to commit or publish. Ideally local settings should be concentrated in a separate file that can be placed into .gitignore, but sometimes as a short-term solution it can be helpful to have something local in a checked-in file. You...

Page 189 of 457