Tutorial by Examples: bas

First we need a table to hold our data class CreateUsers < ActiveRecord::Migration def change create_table :users do |t| t.string :name t.string :password t.string :type # <- This makes it an STI t.timestamps end end end Then lets create some ...
This example will cover creating a custom error page for 404 Page Not Found and 500 Server Error. You can extend this code to capture any error code you need to. Web.Config If you are using IIS7 and above, ignore the <CustomError.. node and use <httpErrors... instead. Add in the following i...
Internally, Django uses the Python logging system. There is many way to configure the logging of a project. Here is a base: LOGGING = { 'version': 1, 'disable_existing_loggers': False, 'formatters': { 'default': { 'format': "[%(asctime)s] %(levelname)s [%(n...
You can use Try..Catch to rollback database operation by placing the rollback statement at the Catch Segment. Try 'Do the database operation... xCmd.CommandText = "INSERT into ...." xCmd.ExecuteNonQuery() objTrans.Commit() ...
Going to its roots, Logstash has the ability to parse and store syslog data. This example shows a basic configuration that gets you to that. input { file { path => [ "/var/log/syslog", "/var/log/auth.log" ] type => "syslog" } }...
Create a new database. $ wp db create Drop an existing database. $ wp db drop --yes Reset the current database. $ wp db reset --yes Execute a SQL query stored in a file. $ wp db query < debug.sql
To avoid unsightly #DIV/0 errors in a spreadsheet, a custom function can be used. /** * Divides n by d unless d is zero, in which case, it returns * the given symbol. * * @param {n} number The numerator * @param {d} number The divisor * @param {symbol} string The symbol to display...
First, complete the installation and setup to connect your app to Firebase. Then from anywhere in your class, you can write: // Write a message to the database FirebaseDatabase database = FirebaseDatabase.getInstance(); DatabaseReference myRef = database.getReference("message"); myRe...
In config.ini: [DEFAULT] debug = True name = Test password = password [FILES] path = /path/to/file In Python: from ConfigParser import ConfigParser config = ConfigParser() #Load configuration file config.read("config.ini") # Access the key "debug" in "DEF...
This is a jumbotron with a title, a content and a button. Code <div class="jumbotron"> <h1>Title text</h1> <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec tortor ipsum, convallis sit.</p> <p><a class="btn btn-default&...
//This example gets the response from iTunes { "rest": { "name": "rest", "connector": "rest", "debug": true, "options": { "useQuerystring": true, "timeout": 10000, "headers": { "accepts": "application/json", "content-type": "applicati...
There are a number of issues with Oracle. Here's how to resolve them. Assuming your procedure output parameter is ref cursor, you will get this exception. java.sql.SQLException: Invalid column type: 2012 So change Types.REF_CURSOR to OracleTypes.CURSOR in simpleJdbcCall.declareParameters() ...
Given the following custom Boolean type we want to wrap: typedef char MYBOOL; #define TRUE 1 #define FALSE 0 A simple approach might be to write the following typemaps in our SWIG interface: %typemap(in) MYBOOL %{ // $input is what we got passed from Python for this function argument $1...
If you do not only wish to display static objects, but have your UI respond to changes to correlating objects, you need to understand the basics of the INotifyPropertyChanged interface. Assuming we have our MainWindowdefined as <Window x:Class="Application.MainWindow" xmlns=&quot...
This example will go over the basic structure of a Cucumber feature file in Gherkin. Feature files use several keywords in the basic syntax. Lets look at the basic keywords: Feature: this keyword signifies that what follows is a basic description or name of the feature being tested or documented...
If a using-declaration occurs at class scope, it is only allowed to redeclare a member of a base class. For example, using std::cout is not allowed at class scope. Often, the name redeclared is one that would otherwise be hidden. For example, in the below code, d1.foo only refers to Derived1::foo(c...
public abstract class BaseActivity extends AppCompatActivity { private Map<Integer, PermissionCallback> permissionCallbackMap = new HashMap<>(); @Override protected void onStart() { super.onStart(); ... } @Override public void setConten...
import sys from PyQt4 import QtGui def window(): app = QtGui.QApplication(sys.argv) w = QtGui.QWidget() b = QtGui.QLabel(w) b.setText("<h1>Welcome to PyQt4 SO Documentation!</h1>") w.setGeometry(100,100,550,65) b.move(50,20) w.setWindowTitle(&quo...
A splash screen is just like any other activity, but it can handle all of your startup-needs in the background. Example: Manifest: <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="...
A function is defined by at least its return type and an unique name. void say_hello () { print ("Hello, world!\n"); } Then, to call it just use the name of the function followed by a parenthese. say_hello (); Functions can also have parameters between the parentheses, d...

Page 57 of 65