Tutorial by Examples: ad

Here is a basic setting of the Header to change to a new page when a button is clicked. if(isset($_REQUEST['action'])) { switch($_REQUEST['action']) { //Setting the Header based on which button is clicked case 'getState': header("Location: http://NewPageForSta...
If you want to add all the JARs in directory to the classpath, you can do this concisely using classpath wildcard syntax; for example: someFolder/* This tells the JVM to add all JAR and ZIP files in the someFolder directory to the classpath. This syntax can be used in a -cp argument, a CLASSPA...
CSS div { height: 200px; width: 200px; background: url(http://lorempixel.com/200/200/nature/1); mask-image: linear-gradient(to right, white, transparent); } HTML <div></div> In the above example there is an element with an image as its background. The mask that is a...
The following code has undefined behavior: char buffer[6] = "hello"; char *ptr1 = buffer - 1; /* undefined behavior */ char *ptr2 = buffer + 5; /* OK, pointing to the '\0' inside the array */ char *ptr3 = buffer + 6; /* OK, pointing to just beyond */ char *ptr4 = buffer + 7; /* un...
for /r command can be used to recursively visit all the directories in a directory tree and perform a command. @echo off rem start at the top of the tree to visit and loop though each directory for /r %%a in (.) do ( rem enter the directory pushd %%a echo In directory: cd rem leave...
If you know the format of the string you are converting (parsing) you should use DateTime.ParseExact Dim dateString As String = "12.07.2003" Dim dateFormat As String = "dd.MM.yyyy" Dim dateValue As Date dateValue = DateTime.ParseExact(dateString, dateFormat, Globalization.C...
Simply use the .ToString overload of a DateTime object to get the format you require: Dim dateValue As DateTime = New DateTime(2001, 03, 06) Dim dateString As String = dateValue.ToString("yyyy-MM-dd") '2001-03-06
$ git show # equivalent to 'git show HEAD' 'HEAD' names the commit on which you based the changes in the working tree, and is usually the symbolic name for the current branch. Many (but not all) commands that take revision parameter defaults to 'HEAD' if it is missing.
Reading file using a BufferedInputStream generally faster than FileInputStream because it maintains an internal buffer to store bytes read from the underlying input stream. import java.io.BufferedInputStream; import java.io.FileInputStream; import java.io.IOException; public class FileReadin...
Each Java Thread has an interrupt flag, which is initially false. Interrupting a thread, is essentially nothing more than setting that flag to true. The code running on that thread can check the flag on occasion and act upon it. The code can also ignore it completely. But why would each Thread have...
Drag a gesture recognizer from the object library onto your view. Control drag from the gesture in the Document Outline to your View Controller code in order to make an Outlet and an Action. Notes This example comes from this fuller sample project demonstrating gesture recognizers.
The current release version of Jetty is 9.4. Support is still provided for Jetty 9.2 and 9.3, and maintenance releases are provided for Jetty 7 and Jetty 8 when needed. The most up-to-date distributions can be found on the Jetty Downloads page. It is worth noting that current releases of Jetty requ...
/** * Load a class by from a ClassNode * * @param cn * ClassNode to load * @return */ public static Class<?> load(ClassNode cn) { ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_FRAMES); return new ClassDefiner(ClassLoader.getSystemClassLoader()).get(cn....
PHP provides support for the HTTP PUT method used by some clients to store files on a server. PUT requests are much simpler than a file upload using POST requests and they look something like this: PUT /path/filename.html HTTP/1.1 Into your PHP code you would then do something like this: <?p...
Python programs can read from unix pipelines. Here is a simple example how to read from stdin: import sys for line in sys.stdin: print(line) Be aware that sys.stdin is a stream. It means that the for-loop will only terminate when the stream has ended. You can now pipe the output of anot...
This example describes how to create a SurfaceView with a dedicated drawing thread. This implementation also handles edge cases such as manufacture specific issues as well as starting/stopping the thread to save cpu time. import android.content.Context; import android.graphics.Canvas; import and...
We'll use the popular eslint-config-airbnb as a starter as well as Meteor specific rules using eslint-import-resolver-meteor. We also need to install babel-parser to lint Meteor enabled ES7 features such as async/await. cd my-project npm install --save-dev eslint-config-airbnb eslint-plugin-impor...
Syntax - $this->load->model('model_name'); Practice - $this->load->model('home_model'); If you would like your model assigned to a different object name you can specify it via the second parameter of the loading method: Syntax - $this->load->model('model_name', 'foobar'); ...
To copy a data.frame as a data.table, use as.data.table or data.table: DF = data.frame(x = letters[1:5], y = 1:5, z = (1:5) > 3) DT <- as.data.table(DF) # or DT <- data.table(DF) This is rarely necessary. One exception is when using built-in datasets like mtcars, which must be copi...
AlertDialog is a subclass of Dialog that can display one, two or three buttons. If you only want to display a String in this dialog box, use the setMessage() method. The AlertDialog from android.app package displays differently on different Android OS Versions. The Android V7 Appcompat library pro...

Page 42 of 114