Tutorial by Examples

You can also make a switch statement switch based on the class of the thing you're switching on. An example where this is useful is in prepareForSegue. I used to switch based on the segue identifier, but that's fragile. if you change your storyboard later and rename the segue identifier, it breaks ...
Parsing files into STL containers istream_iterators are very useful for reading sequences of numbers or other parsable data into STL containers without explicit loops in the code. Using explicit container size: std::vector<int> v(100); std::copy(std::istream_iterator<int>(ifs), std::...
a@coolbox:~/workspace$ express --ejs my-app a@coolbox:~/workspace$ cd my-app a@coolbox:~/workspace/my-app$ npm install a@coolbox:~/workspace/my-app$ npm start
""" usage: sub <command> commands: status - show status list - print list """ import sys def check(): print("status") return 0 if sys.argv[1:] == ['status']: sys.exit(check()) elif sys.argv[1:] == ['list']: ...
If a function returns a std::vector type, and it is exposed to Python directly like std::vector<float> secondMethod() { return std::vector<float>(); } BOOST_PYTHON_MODULE(CppProject) { boost::python::def("getEmptyVec", secondMethod); } then when the functions...
You can wait until the next frame. yield return null; // wait until sometime in the next frame You can have multiple of these calls in a row, to simply wait for as many frames as desired. //wait for a few frames yield return null; yield return null; Wait for approximately n seconds. It is ...
import argparse import sys def check(): print("status") return 0 parser = argparse.ArgumentParser(prog="sub", add_help=False) subparser = parser.add_subparsers(dest="cmd") subparser.add_parser('status', help='show status') subparser.add_parser('lis...
public class MyBubbleSort { public static void bubble_srt(int array[]) {//main logic int n = array.length; int k; for (int m = n; m >= 0; m--) { for (int i = 0; i < n - 1; i++) { k = i + 1; if (array[i] > arr...
Dynamically switch beetween multiple components using <component> element and pass data to v-bind:is attribute: Javascript: new Vue({ el: '#app', data: { currentPage: 'home' }, components: { home: { template: "<p>Home</p>" }, about...
Sometimes you want to keep the switched-out components in memory, to make that happen, you should use <keep-alive> element: Javascript: new Vue({ el: '#app', data: { currentPage: 'home', }, methods: { switchTo: function(page) { this.currentPage = page; ...
const http = require('http'); console.log('Starting server...'); var config = { port: 80, contentType: 'application/json; charset=utf-8' }; // JSON-API server on port 80 var server = http.createServer(); server.listen(config.port); server.on('error', (err) => { if (err.c...
const process = require('process'); const rl = require('readline').createInterface(process.stdin, process.stdout); rl.pause(); console.log('Something long is happening here...'); var cliConfig = { promptPrefix: ' > ' } /* Commands recognition BEGIN */ var commands = {...
Event stores details for players attempting to log in @EventHandler public void onPlayerLogin(PlayerLoginEvent e) { Player tryingToLogin = e.getPlayer(); //Disallowing a player login e.disallow(PlayerLoginEvent.Result.KICK_FULL , "The server is reserved and is full for you!&q...
Cache references to avoid the expensive calls especially in the update function. This can be done by caching these references on start if available or when available and checking for null/bool flat to avoid getting the reference again. Examples: Cache component references change void Update() {...
Avoid calling methods using strings that can accept methods. This approach will make use of reflection that can slow down your game especially when used in the update function. Examples: //Avoid StartCoroutine with method name this.StartCoroutine("SampleCoroutine"); //Ins...
Avoid empty unity methods. Apart from being bad programming style, there is a very small overhead involved in runtime scripting. Over many instances, this can build up and affect performance. void Update { } void FixedUpdate { }
Below is an example of an object pool that allows renting and returning of a given object type. To create the object pool a Func for the create function and an Action to destroy the object are required to give the user flexibility. On requesting an object when the pool is empty a new object will be ...
This is a bare minimum setup for MySQL servers using InnoDB tables. Using InnoDB, query cache is not required. Reclaim disk space when a table or database is DROPed. If you're using SSDs, flushing is a redundant operation (SDDs are not sequential). default_storage_engine = InnoDB query_cache_type ...
The default encryption aes-128-ecb uses Electronic Codebook (ECB) mode, which is insecure and should never be used. Instead, add the following to your configuration file: block_encryption_mode = aes-256-cbc
Using PowerShell executed from a SharePoint Web Server: $wacoll = get-spwebapplication foreach($wa in $wacoll){ if($wa.IsAdministrationWebApplication -eq $false){ foreach($site in $wa.Sites){ foreach($web in $site.AllWebs){ # your code here ...

Page 1015 of 1336