Tutorial by Examples: c

public class KnapsackProblem { private static int Knapsack(int w, int[] weight, int[] value, int n) { int i; int[,] k = new int[n + 1, w + 1]; for (i = 0; i <= n; i++) { int b; for (b = 0; b <= w; b++) { ...
You can COPY table and paste it into a file. postgres=# select * from my_table; c1 | c2 | c3 ----+----+---- 1 | 1 | 1 2 | 2 | 2 3 | 3 | 3 4 | 4 | 4 5 | 5 | (5 rows) postgres=# copy my_table to '/home/postgres/my_table.txt' using delimiters '|' with null as 'null_s...
Suppose, that we have three users : The Administrator of the database > admin The application with a full access for her data > read_write The read only access > read_only With below queries, you can set access privileges on objects created in the future in specified schema. ALTER ...
Schema changes: You will need to define a new field type in your solr schema file and then you can create fields of that type. Example schema snippet: <!-- Source: solr/example/.../conf/schema.xml --> <?xml version="1.0" encoding="UTF-8" ?> <schema name="a...
Let's get some theoretical knowledge before moving to the example. There are three important terms being used here Analyzers, Tokenizers, and Filters. To create such custom field you will need to create an analyzer with one tokenizer and one or more filters. As mentioned here, you can have only one ...
Creating a connection According to PEP 249, the connection to a database should be established using a connect() constructor, which returns a Connection object. The arguments for this constructor are database dependent. Refer to the database specific topics for the relevant arguments. import MyDBA...
You can parse XML from a string or from a XML file 1. From a string $xml_obj = simplexml_load_string($string); 2. From a file $xml_obj = simplexml_load_file('books.xml'); Example of parsing Considering the following XML: <?xml version="1.0" encoding="UTF-8"?> &l...
var x = 5; var str = "if (x == 5) {console.log('z is 42'); z = 42;} else z = 0; "; console.log("z is ", eval(str)); The use of eval is strongly discouraged. See the Remarks section for details.
import { NgModule, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'; import { CommonModule } from '@angular/common'; import { AboutComponent } from './about.component'; @NgModule({ imports: [ CommonModule ], declarations: [ AboutComponent ], exports: [ AboutComponent ], schemas...
import { Component } from '@angular/core'; @Component({ selector: 'myapp-about', template: `<my-webcomponent></my-webcomponent>` }) export class AboutComponent { }
Objective-C Create a new iOS project and add CoreSpotlight and MobileCoreServices framework to your project. Create the actual CSSearchableItem and associating the uniqueIdentifier, domainIdentifier and the attributeSet. Finally index the CSSearchableItem using [[CSSearchableIndex defaul...
When defining a new trait it is possible to enforce that types wishing to implement this trait verify a number of constraints or bounds. Taking an example from the standard library, the DerefMut trait requires that a type first implement its sibling Deref trait: pub trait DerefMut: Deref { fn...
import pygame file = 'some.mp3' pygame.init() pygame.mixer.init() pygame.mixer.music.load(file) pygame.mixer.music.play(-1) # If the loops is -1 then the music will repeat indefinitely.
import pygame import time pygame.mixer.init() pygame.display.init() screen = pygame.display.set_mode ( ( 420 , 240 ) ) playlist = list() playlist.append ( "music3.mp3" ) playlist.append ( "music2.mp3" ) playlist.append ( "music1.mp3" ) pygame.mixer.musi...
By default, PHP Curl supports GET and POST requests. It is possible to also send custom requests, such as DELETE, PUT or PATCH (or even non-standard methods) using the CURLOPT_CUSTOMREQUEST parameter. $method = 'DELETE'; // Create a DELETE request $ch = curl_init($url); curl_setopt($ch, CURLOPT...
Assuming a default server running on localhost with the default port, the command to connect to that Redis server would be: $redis = new Redis(); $redis->connect('127.0.0.1', 6379);
The Redis PHP module gives access to the same commands as the Redis CLI client so it is quite straightforward to use. The syntax is as follow: // Creates two new keys: $redis->set('mykey-1', 123); $redis->set('mykey-2', 'abcd'); // Gets one key (prints '123') var_dump($redis->get('m...
Preparing data: create table wf_example(i int, t text,ts timestamptz,b boolean); insert into wf_example select 1,'a','1970.01.01',true; insert into wf_example select 1,'a','1970.01.01',false; insert into wf_example select 1,'b','1970.01.01',false; insert into wf_example select 2,'b','1970.01.01...
The partition of an integer is a way of writing it as a sum of positive integers. For example, the partitions of the number 5 are: 5 4 + 1 3 + 2 2 + 2 + 1 2 + 1 + 1 + 1 1 + 1 + 1 + 1 + 1 Notice that changing the order of the summands will not create a different partition. The partition f...
public class IntegerPartition { public static int[,] Result = new int[100,100]; private static int Partition(int targetNumber, int largestNumber) { for (int i = 1; i <= targetNumber; i++) { for (int j = 1; j <= largestNumber; j++) ...

Page 613 of 826