Tutorial by Examples: c

The following example creates a canvas with 2 points and 1 line in between. You will be able to move the point and the line around. from kivy.app import App from kivy.graphics import Ellipse, Line from kivy.uix.boxlayout import BoxLayout class CustomLayout(BoxLayout): def __init__(se...
When defining a function, use {param1, param2, …} to specify named parameters: void enableFlags({bool bold, bool hidden}) { // ... } When calling a function, you can specify named parameters using paramName: value enableFlags(bold: true, hidden: false);
A linked list is a linear collection of data elements, called nodes, which are linked to other node(s) by means of a "pointer." Below is a singly linked list with a head reference. ┌─────────┬─────────┐ ┌─────────┬─────────┐ HEAD ──▶│ data │"pointer"│──▶...
In many Excel applications, the VBA code takes actions directed at the workbook in which it's contained. You save that workbook with a ".xlsm" extension and the VBA macros only focus on the worksheets and data within. However, there are often times when you need to combine or merge data fr...
It's a VBA Best Practice to always specify which workbook your VBA code refers. If this specification is omitted, then VBA assumes the code is directed at the currently active workbook (ActiveWorkbook). '--- the currently active workbook (and worksheet) is implied Range("A1").value = 3.1...
The "factory default" number of worksheets created in a new Excel workbook is generally set to three. Your VBA code can explicitly set the number of worksheets in a new workbook. '--- save the current Excel global setting With Application Dim oldSheetsCount As Integer oldSheets...
Mac OSX Using Homebrew: brew install haskell-stack
To create a project called helloworld run: stack new helloworld simple This will create a directory called helloworld with the files necessary for a Stack project.
File structure A simple project has the following files included in it: ➜ helloworld ls LICENSE Setup.hs helloworld.cabal src stack.yaml In the folder src there is a file named Main.hs. This is the "starting point" of the helloworld project. By default...
Stackage is a repository for Haskell packages. We can add these packages to a stack project. Adding lens to a project. In a stack project, there is a file called stack.yaml. In stack.yaml there is a segment that looks like: resolver: lts-6.8 Stackage keeps a list of packages for every revision...
When the GADTs extension is enabled, besides regular data declarations, you can also declare generalized algebraic datatypes as follows: data DataType a where Constr1 :: Int -> a -> Foo a -> DataType a Constr2 :: Show a => a -> DataType a Constr3 :: DataType Int A G...
Example uses of $(document).ready(): Attaching event handlers Attach jQuery event handlers $(document).ready(function() { $("button").click(function() { // Code for the click function }); }); Run jQuery code after the page structure is created jQuery(function($) ...
Step 1: Install the SDK You can install the SDK manually or via CocoaPods. The latter option is highly recommended. Put these lines in Podfile: target 'MyApp' do use_frameworks! pod 'FBSDKCoreKit' pod 'FBSDKLoginKit' pod 'FBSDKShareKit' end Run pod install in the terminal and op...
When building a webserver with Express it's often required to serve a combination of dynamic content and static files. For example, you may have index.html and script.js which are static files kept in the file system. It is common to use folder named 'public' to have static files. In this case th...
a basic example for http client: write the follwing code in http_client.js file: var http = require('http'); var options = { hostname: '127.0.0.1', port: 80, path: '/', method: 'GET' }; var req = http.request(options, function(res) { console.log('STATUS: ' + res.statusCode)...
This program copies a file using readable and a writable stream with the pipe() function provided by the stream class // require the file system module var fs = require('fs'); /* Create readable stream to file in current directory named 'node.txt' Use utf8 encoding Read the data...
Multiple database cursors can be published from the same publication method by returning an array of cursors. The "children" cursors will be treated as joins and will not be reactive. Meteor.publish('USER_THREAD', function(postId) { let userId = this.userId; let comments = Comm...
Production deployments will vary in many ways, but a standard convention when deploying in production is to define an environment variable called NODE_ENV and set its value to "production". Runtime flags Any code running in your application (including external modules) can check the valu...
Example. It will be replacing the word email to a name in a text file index.txt with simple RegExp replace(/email/gim, 'name') var fs = require('fs'); fs.readFile('index.txt', 'utf-8', function(err, data) { if (err) throw err; var newValue = data.replace(/email/gim, 'name'); ...
app.js const readline = require('readline'); const fs = require('fs'); var file = 'path.to.file'; var linesCount = 0; var rl = readline.createInterface({ input: fs.createReadStream(file), output: process.stdout, terminal: false }); rl.on('line', function (line) { linesCo...

Page 235 of 826