Tutorial by Examples

Of course you can pass data to Sinatra routes, to accept data in your routes you can add route paremeters. You can then access a params hash: get '/hello/:name' do # matches "GET /hello/foo" and "GET /hello/bar" # params['name'] is 'foo' or 'bar' "Hello #{params['...
To create a user dev with password password123 MongoClient mongo = new MongoClient("localhost", 27017); MongoDatabase db = mongo.getDatabase("testDB"); Map<String, Object> commandArguments = new BasicDBObject(); commandArguments.put("createUser", "dev&qu...
To get data from testcollection collection in testdb database where name=dev import org.bson.Document; import com.mongodb.BasicDBObject; import com.mongodb.MongoClient; import com.mongodb.ServerAddress; import com.mongodb.client.MongoCollection; import com.mongodb.client.MongoCursor; import c...
This example adds a new parameter to MyTestFunction if $SomeUsefulNumber is greater than 5. function MyTestFunction { [CmdletBinding(DefaultParameterSetName='DefaultConfiguration')] Param ( [Parameter(Mandatory=$true)][int]$SomeUsefulNumber ) DynamicParam {...
File.Move In order to move a file from one location to another, one simple line of code can achieve this: File.Move(@"C:\TemporaryFile.txt", @"C:\TemporaryFiles\TemporaryFile.txt"); However, there are many things that could go wrong with this simple operation. For instance, wh...
3D touch has been introduced with iPhone 6s Plus. There are two behaviors added with this new interface layer: Peek and Pop. Peek and Pop in a nutshell Peek - Press hard Pop - Press really hard Checking for 3D support You should check if the device has a 3D touch support. You can do this by che...
Add the necessary dependencies to the project POM (mybatis, and mybatis-spring): <dependency> <groupId>org.mybatis</groupId> <artifactId>mybatis</artifactId> <version>x.x.x</version> </dependency> <dependency> <group...
The leader key could be used as a way to create a mapping with a key-binding that can be overridden by the end user. The leader is the \ key by default. In order to override it, the end-user would have to execute :let g:mapleader='somekey(s)' before defining the mapping. In a typical scenario, the...
A1:A4 have A,B,C,D. B1 have the following formula: =ARRAYFORMULA({A1:A4,ROW(A1:A4)}) Result ABC1AA12BB23CC34DD4
Substring returns the portion of string specified by the start and length parameters. var_dump(substr("Boo", 1)); // string(2) "oo" If there is a possibility of meeting multi-byte character strings, then it would be safer to use mb_substr. $cake = "cakeæøå"; var_d...
// Main frame class declaration class CMainFrame : public CMDIFrameWndEx { DECLARE_DYNAMIC(CMainFrame) protected: // declare our pane CDockablePane m_wndPane; // .... other class memebers public: CMainFrame(); protected: afx_msg int OnCreate(LPCREATEST...
wxPython Classic is a Python 2 build of the wxPython library. Generation of the python bindings require a large number of manual interventions and the documentation is simply the wxWidgets documentation which contains some annotations on wxPython mechanisms as such there is normally a delay of weeks...
If you want to setup quickly elasticsearch you can use the searchkick gem : gem 'searchkick' Add searchkick to models you want to search. class Product < ActiveRecord::Base searchkick end Add data to the search index. Product.reindex And to query, use: products = Product.search &...
The local configuration of sane is inside /etc/saned.d /etc/sane.d/dll.conf # /etc/sane.d/dll.conf - Configuration file for the SANE dynamic backend loader # # Backends can also be enabled by configuration snippets under # /etc/sane.d/dll.d directory -- packages providing backends should drop...
Identify the local scanner By using lsusb, identify the productId (1909 here) : pi:# lsusb pi:# Bus 001 Device 005: ID 04a9:1909 Canon, Inc. CanoScan LiDE 110 With that productId, grep the correct configuration file (it depends of your scanner model, for me it is genesys.conf) : pi:# grep 190...
The print elements of Bootstrap allow you to designate which items should be visible when printed and which should be hidden. To make something visible use either of the following depending on the element and how it should appear when printed: .visible-print-block .visible-print-inline .visible-...
If you want to make a change that you want to merge with master, the best way is to first create a topic branch git checkout -b foo make a single commit with your feature git commit -m "Made the thing X finally work" and push that branch to review via git push origin foo:refs/for/...
Because of how gerrit relies on change-ids, in order to resolve conflicts (pull changes to your topic branch) the best practice is to rebase topic branch onto master/other branch you want to push to. This way you preserve the change-id without having to ammend the merge commit. For example if you su...
As mentioned in the other example, you should use rebase instead of merge. But if you're working on a feature branch with your team then you'll run into the problem of pulling rewritten history. So the best way to work on a feature branch foo is to locally create tracking branch foo that you use onl...
Some times application must have panes that docked not to the main frame, but to the child frame. Usually it's MDI application. In MFC Feature pack such child frame is inherited from CMDIChildWndEx class and as main frame (inherited from CMDIFrameWndEx) have all required code for such docking. But ...

Page 913 of 1336