Tutorial by Examples

If you have a virtualenv and CherryPy is already installed in it, create a file hello.py: #!/usr/bin/env python # -*- coding: UTF-8 -*- import cherrypy class HelloWorld(object): @cherrypy.expose def index(self): return 'Hello World!' @cherrypy.expose def greet(...
This example consists of three parts: server.py - CherryPy application that can receive and save a file. webpage.html - Example how to upload a file to server.py from a webpage. cli.py - Example how to upload a file to server.py from a command line tool. Bonus - upload.txt - file that you will...
If class A is in relationship with class B and class B has property with the same name and type as the primary key of A, then EF automatically assumes that property is foreign key. public class Department { public int DepartmentId { set; get; } public string Name { set; get; } publi...
As we all are aware that PHP writes session data into a file at server side. When a request is made to php script which starts the session via session_start(), PHP locks this session file resulting to block/wait other incoming requests for same session_id to complete, because of which the other requ...
WPF does not support displaying anything other than an image as a splash screen out-of-the-box, so we'll need to create a Window which will serve as a splash screen. We're assuming that we've already created a project containing MainWindow class, which is to be the application main window. First of...
WPF does not support displaying anything other than an image as a splash screen out-of-the-box, so we'll need to create a Window which will serve as a splash screen. We're assuming that we've already created a project containing MainWindow class, which is to be the application main window. First of...
Parameters Nullable type hint was added in PHP 7.1 using the ? operator before the type hint. function f(?string $a) {} function g(string $a) {} f(null); // valid g(null); // TypeError: Argument 1 passed to g() must be of the type string, null given Before PHP 7.1, if a parameter has a typ...
# app/channels/application_cable/connection.rb module ApplicationCable class Connection < ActionCable::Connection::Base identified_by :current_user def connect self.current_user = find_verified_user logger.add_tags 'ActionCable', current_user.id # Can replace...
One day I had a conversation with a friend of mine who uses Laravel PHP framework in his job. When I told him that Django has its own all-included HTML CRUD system, for interacting with the database, called Django admin, his eyes popped off! He told me: "It took me months to build an Admin inte...
Create the source file for your new Client Script Create a new JavaScript file using your favorite editor or IDE Add the following source code to your file (original source here) /** * A simple "Hello, World!" example of a Client Script. Uses the `pageInit` * event to wr...
Create the source file for your new Client Script Create a new JavaScript file using your favorite editor or IDE Add the following source code to your file (original source here) define([], function () { /** * A simple "Hello, World!" example of a Client Script. U...
Add the following code in you main program. var cpuprofile = flag.String("cpuprofile", "", "write cpu profile `file`") var memprofile = flag.String("memprofile", "", "write memory profile to `file`") func main() { flag.Parse() ...
var memprofile = flag.String("memprofile", "", "write memory profile to `file`") func main() { flag.Parse() if *memprofile != "" { f, err := os.Create(*memprofile) if err != nil { log.Fatal("could not create mem...
// Sets the CPU profiling rate to hz samples per second // If hz <= 0, SetCPUProfileRate turns off profiling runtime.SetCPUProfileRate(hz) // Controls the fraction of goroutine blocking events that are reported in the blocking profile // Rate = 1 includes every blocking event in the profil...
Open a new Query Window with current connection (Ctrl + N) Toggle between opened tabs (Ctrl + Tab) Show/Hide Results pane (Ctrl + R) Execute highlighted query (Ctrl + E) Make selected text uppercase or lowercase (Ctrl + Shift + U, Ctrl + Shift + L) Intellisense list member and complete word (...
Lazy loading modules helps us decrease the startup time. With lazy loading our application does not need to load everything at once, it only needs to load what the user expects to see when the app first loads. Modules that are lazily loaded will only be loaded when the user navigates to their routes...
An example on how to compose the reader, writer, and state monad using monad transformers. The source code can be found in this repository We want to implement a counter, that increments its value by a given constant. We start by defining some types, and functions: newtype Counter = MkCounter {...
As an example you want to disable pagination in your default index action and get all results in index. How can you do that? It's simple. You should override the index action in your controller like this: public function actions() { $actions = parent::actions(); unset($actions['index'])...
Create training instances from .arff file private static Instances getDataFromFile(String path) throws Exception{ DataSource source = new DataSource(path); Instances data = source.getDataSet(); if (data.classIndex() == -1){ data.setClassIndex(data.numAttributes()...
The sqlite3 module was written by Gerhard Häring. To use the module, you must first create a Connection object that represents the database. Here the data will be stored in the example.db file: import sqlite3 conn = sqlite3.connect('example.db') You can also supply the special name :memory: to ...

Page 1020 of 1336