Tutorial by Examples: code

Download and install Code::Blocks here. If you're on Windows, be careful to select a file for which the name contains mingw, the other files don't install any compiler. Open Code::Blocks and click on "Create a new project": Select "Console application" and click &...
using MongoDB.Bson; using System; using System.Diagnostics; using System.IO; namespace python_csharp { class Program { static void Main(string[] args) { // full path to .py file string pyScriptPath = "...../sum.py"; ...
user.model.js var mongoose = require('mongoose') const UserSchema = new mongoose.Schema({ name: String }) const User = mongoose.model('User', UserSchema) module.exports = User; user.routes.js var express = require('express'); var router = express.Router(); var UserController...
Spaghetti code means a code snippet that uses many, and often confusing structures. Such as GOTOs, exceptions and inconsistent code. Examples and Solutions Example A @echo off set /a counter=0 :Loop set /a counter=%counter% + 1 echo %counter% if %counter% equ 10 goto :exit goto :Loop ...
The Rule An e-commerce have a shipping rule based on zipcodes. All shipping to California is eligible to free shipping. All other west cost are US$ 10.00 and The rest of USA is US$ 20.00 How to apply technique We all know there are lots of zipcodes by state, and we are not going to use them all. ...
LibGDX is designed in a way that you can write the same code and deploy it on several different platforms. Yet, there are times when you want to get access to platform specific code. For an instance, if you have leaderboards and achievements in your game, you may want to use platform-specific tools ...
Add a new Swift file to your Xcode project. Name it as you please and you should get an alert box asking if you would like to create a bridging header. Note: If you don’t receive a prompt to add a bridging header, you probably declined this message once before and you will have to add the header m...
#!bin/bash $ string='Question%20-%20%22how%20do%20I%20decode%20a%20percent%20encoded%20string%3F%22%0AAnswer%20%20%20-%20Use%20printf%20%3A)' $ printf '%b\n' "${string//%/\\x}" # the result Question - "how do I decode a percent encoded string?" Answer - Use printf ...
Open3.popen3 or Open3.capture3: Open3 actually just uses Ruby's spawn command, but gives you a much better API. Open3.popen3 Popen3 runs in a sub-process and returns stdin, stdout, stderr and wait_thr. require 'open3' stdin, stdout, stderr, wait_thr = Open3.popen3("sleep 5s && ls&q...
Exec: exec 'echo "hello world"' or exec ('echo "hello world"') The System Command: system 'echo "hello world"' Will output "hello world" in the command window. or system ('echo "hello world"') The system command can return a true if ...
Sometimes you'll need to execute synchronous code from within an asynchronous task. To do this, simply schedule a synchronous task from within the asynchronous block. Bukkit.getScheduler().runTaskTimerAsynchronously(VoidFlame.getPlugin(), () -> { Bukkit.getScheduler().runTask(VoidFlame.ge...
#include "cuda_runtime.h" #include "device_launch_parameters.h" #include "cuda.h" #include <device_functions.h> #include <cuda_runtime_api.h> #include<stdio.h> #include <cmath> #include<stdlib.h> #include<iostream> #include...

Page 21 of 21