/*
* This example show some ways of using std::function to call
* a) C-like function
* b) class-member function
* c) operator()
* d) lambda function
*
* Function call can be made:
* a) with right arguments
* b) argumens with different order, types and count
*/
#include <...
Some programs need so store arguments for future calling of some function.
This example shows how to call any function with arguments stored in std::tuple
#include <iostream>
#include <functional>
#include <tuple>
#include <iostream>
// simple function to be called
d...
The ConstainsKey method is the way to know if a key already exists in the Dictionary.
This come in handy for data reduction. In the sample below, each time we encountner a new word, we add it as a key in the dictionary, else we increment the counter for this specific word.
Dim dic As IDictionary(...
public class PancakeSort
{
private static void SortPancake(int[] input, int n)
{
for (var bottom = n - 1; bottom > 0; bottom--)
{
var index = bottom;
var maxIndex = input[bottom];
int i;
for (i = bottom - 1; i >= ...
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...
@echo off
setlocal
set /p "_myvar=what is your name?"
echo HELLO!>file.txt
echo %_myvar%!>>file.txt
echo done!
pause
type file.txt
endlocal
exit
Now file.txt looks like:
HELLO!
John Smith!
(assuming you typed John Smith as your name.)
Now your batch file's consol...
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...
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...
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 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 (<...
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 ...