You can use a TStringList to store Key-Value pairs. This can be useful if you want to store settings, for example. A settings consists of a Key (The Identifier of the setting) and the value.
Each Key-Value pair is stored in one line of the StringList in Key=Value format.
procedure Demo(const FileN...
The Caesar cipher is a classic encryption method. It works by shifting the characters by a certain amount. For example, if we choose a shift of 3, A will become D and E will become H.
The following text has been encrypted using a 23 shift.
THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG
QEB NRFZH YOL...
The ASCII way
This shifts the characters but doesn't care if the new character is not a letter. This is good if you want to use punctuation or special characters, but it won't necessarily give you letters only as an output. For example, "z" 3-shifts to "}".
def ceasar(text, shi...
To connect to a mongo database from node application we require mongoose.
Installing Mongoose
Go to the toot of your application and install mongoose by
npm install mongoose
Next we connect to the database.
var mongoose = require('mongoose');
//connect to the test database running on defau...
With Mongoose, everything is derived from a Schema. Lets create a schema.
var mongoose = require('mongoose');
var Schema = mongoose.Schema;
var AutoSchema = new Schema({
name : String,
countOf: Number,
});
// defining the document structure
// by default the collection...
For inserting a new document in the collection, we create a object of the schema.
var Auto = require('models/auto')
var autoObj = new Auto({
name: "NewName",
countOf: 10
});
We save it like the following
autoObj.save(function(err, insertedAuto) {
if (err) return cons...
Reading Data from the collection is very easy. Getting all data of the collection.
var Auto = require('models/auto')
Auto.find({}, function (err, autos) {
if (err) return console.error(err);
// will return a json array of all the documents in the collection
console.log(autos)...
For updating collections and documents we can use any of these methods:
Methods
update()
updateOne()
updateMany()
replaceOne()
Update()
The update() method modifies one or many documents (update parameters)
db.lights.update(
{ room: "Bedroom" },
{ status: "On&quo...
Deleting documents from a collection in mongoose is done in the following manner.
Auto.remove({_id:123}, function(err, result){
if (err) return console.error(err);
console.log(result); // this will specify the mongo default delete result.
});
To call a list of goals as if it were a conjunction of goals, combine the higher-order predicates call/1 and maplist/2:
?- Gs = [X = a, Y = b], maplist(call, Gs).
Gs = [a=a, b=b],
X = a,
Y = b.
The names of modules follow the filesystem's hierarchical structure. With the following file layout:
Foo/
├── Baz/
│ └── Quux.hs
└── Bar.hs
Foo.hs
Bar.hs
the module headers would look like this:
-- file Foo.hs
module Foo where
-- file Bar.hs
module Bar where
-- file Foo/Bar.hs
m...
systemd provides a modern implementation of cron. To execute a script periodical a service and a timer file ist needed.
The service and timer files should be placed in /etc/systemd/{system,user}.
The service file:
[Unit]
Description=my script or programm does the very best and this is the descri...
Detailed instructions on getting slick set up or installed.
http://kenwheeler.github.io/slick/
Slick Slider is easy to use and to customise. It provides good amount of customisation options including responsive options based on breakpoints.
To get started with slick, it is not that difficult. Jus...
C#
Visual Studio 2015 (latest update) - you can download the community version here for free: www.VisualStudio.com
Important: update all VS extensions to their latest versions
Tools->Extensions and Updates->Updates
Download the Bot Application template from here: Template Dow...
Below is an example of Gstreamer pipeline embedded in a simple gtk window. When run, a small window should appear like this:
import gi
gi.require_version('Gtk', '3.0')
gi.require_version('Gst', '1.0')
from gi.repository import Gtk, Gst
Gst.init(None)
Gst.init_check(None)
class GstWidg...
Below is a configuration file for log4j. Log4j2 can use the same syntax, but there are different appender classes:
log4j.rootLogger=INFO, FOO
## ConsoleAppender
log4j.appender.CA=org.apache.log4j.ConsoleAppender
log4j.appender.CA.layout=org.apache.log4j.PatternLayout
log4j.appender.CA.layout....
XML Example
The below configuration configures two appenders (log output). The first logs to standard system output (console) and the other logs to file. In this example, the location of the file can be set statically in configuration (appender file) or dynamically via maven filtering feature (<...
Recursive functions can get quite expensive. If they are pure functions (functions that always return the same value when called with the same arguments, and that neither depend on nor modify external state), they can be made considerably faster at the expense of memory by storing the values already...
There are different variable types for different purposes. In Visual Basic 6 the following variable types are available:
Array
Boolean
Byte
Currency
Date
Double
Integer
Long
Single
String
Variant
You declare a variable by using the Dim keyword:
Dim RandomNumber As Integer
If you ...