Tutorial by Examples: code

You will need to set your base URL in application/config/config.php If it is not set, then CodeIgniter will try to guess the protocol and path to your installation, but due to the security concerns the hostname will be set to $_SERVER['SERVER_ADDR'] if available, or localhost otherwise. The auto...
A source code file is a (generally) plain text file which is to processed by the compiler. A source code file may contain up to one main program and any number of modules and external subprograms. For example, a source code file may contain the following module mod1 end module mod1 module mod...
Simple one-liners may be specified as command line arguments to perl using the -e switch (think "execute"): perl -e'print "Hello, World!\n"' Due to Windows quoting rules you can't use single-quoted strings but have to use one of these variants: perl -e"print qq(Hello, W...
It is good practice to test the calling program's __name__ variable before executing your code. import sys def main(): # Your code starts here # Don't forget to provide a return code return 0 if __name__ == "__main__": sys.exit(main()) Using this pattern ens...
If you are just starting a new project, it's important to think about how you want to handle code signing. If you are new to code signing, check out the WWDC session that describes the fundamentals of code signing in Xcode. To properly code-sign your app, you have to have the following resources o...
It is possible to change Code Folding preference to suit your need. Thus code folding can be set enable/unable for specific constructs (ex: if block, for loop, Sections ...). To change folding preferences, go to Preferences -> Code Folding: Then you can choose which part of the code can be f...
Instead of linking to an external file, you can also include the JS code as-is in your HTML: <script> // JavaScript code </script>
Bytecode is the set of instructions used by the JVM. To illustrate this let's take this Hello World program. public static void main(String[] args){ System.out.println("Hello World"); } This is what it turns into when compiled into bytecode. public static main([Ljava/lang/String...
Placing date_default_timezone_set('Asia/Kolkata'); on config.php above base URL also works. PHP List of Supported Time Zones application/config.php <?php defined('BASEPATH') OR exit('No direct script access allowed'); date_default_timezone_set('Asia/Kolkata'); Another way I have found...
Edit your package.json to add the following script : { "scripts": { "lint": "eslint .;exit 0" } } Then run it using npm run lint We use exit 0 as a trick to gracefully terminate the script when linting fails, otherwise npm will use eslint return code an...
Most performance tips are very dependent of the current state of JS engines and are expected to be only relevant at a given time. The fundamental law of performance optimization is that you must first measure before trying to optimize, and measure again after a presumed optimization. To measure cod...
You can evaluate any valid C# code: int value = await CSharpScript.EvaluateAsync<int>("15 * 89 + 95"); var span = await CSharpScript.EvaluateAsync<TimeSpan>("new DateTime(2016,1,1) - DateTime.Now"); If type is not specified, the result is object: object value = ...
belongs_to :user belongs_to :authentication_provider serialize :params def self.create_from_omniauth(params, user, provider) token_expires_at = params['credentials']['expires_at'] ? Time.at(params['credentials']['expires_at']).to_datetime : nil create( user: user, ...
include OmniauthAttributesConcern has_many :user_authentications devise :omniauthable, :database_authenticatable, :registerable,:recoverable, :rememberable, :trackable def self.create_from_omniauth(params) self.send(params.provider,params) end
There are times when an include file has to generate different output from the preprocessor depending on whether the compiler is a C compiler or a C++ compiler due to language differences. For example a function or other external is defined in a C source file but is used in a C++ source file. Since...
First, here's what can happen when text/template is used for HTML. Note Harry's FirstName property). package main import ( "fmt" "html/template" "os" ) type Person struct { FirstName string LastName string Street string Cit...
PhpStorm offers default settings for code styling for a large amount of languages based on best practices and common standards. But you can customize the styling for each language on a per-project base within the PhpStorm Settings > Editor > Code Style. Schemes Schemes are collections of ...
Currently there is no one-click-button method to actually enforce any code style guidelines across a team but there are two methods to make sure a certain code style is applied to your product. Import PhpStorm Code Style Schemes The first and more easier solution is to set up a code style scheme o...
PhpStorm already ships with a lot of predefined language schemes that are based on common code style guidelines and standards like PSR-2. There is kind of a hidden feature in the code style settings pages where you can import these standards and set them as your current configuration. To do so simp...
The http_build_query() will create a query string from an array or object. These strings can be appended to a URL to create a GET request, or used in a POST request with, for example, cURL. $parameters = array( 'parameter1' => 'foo', 'parameter2' => 'bar', ); $queryString = http_b...

Page 6 of 21