Tutorial by Examples: code

(input) output = 0 for cycleStart from 0 to length(array) - 2 item = array[cycleStart] pos = cycleStart for i from cycleStart + 1 to length(array) - 1 if array[i] < item: pos += 1 if pos == cycleStart: continue while item == array[pos]: ...
Constraints: Input (an array to be sorted) Number of element in input (n) Keys in the range of 0..k-1 (k) Count (an array of number) Pseudocode: for x in input: count[key(x)] += 1 total = 0 for i in range(k): oldCount = count[i] count[i] = total total += oldCount for...
In this example, we trying to create a gui with only through code rather than using any ui file. Its a very basic example you need to extend based on your need." from PyQt4 import QtCore, QtGui import maya.OpenMayaUI as mui import sip class Ui_MainWindow(QtGui.QMainWindow): def __ini...
/** * Runs user-specified code when the given javascript object is garbage collected */ template<class CALLBACK_FUNCTION> void global_set_weak(v8::Isolate * isolate, const v8::Local<v8::Object> & javascript_object, CALLBACK_FUNCTION function) { struct SetWeakCallbackData{...
This will be a relatively comprehensive tutorial of how to write a command line tool to print the weather from the zip code provided to the command line tool. The first step is to write the program in ruby to do this action. Let's start by writing a method weather(zip_code) (This method requires the...
First, you need to install pry-byebug gem. Run this command: $ gem install pry-byebug Add this line at the top of your .rb file: require 'pry-byebug' Then insert this line wherever you want a breakpoint: binding.pry A hello.rb example: require 'pry-byebug' def hello_world puts &qu...
PS> $LastExitCode PS> $? PS> $Error[0] These are built-in PowerShell variables that provide additional information about the most recent error. $LastExitCode is the final exit code of the last native application that was executed. $? and $Error[0] is the last error record that was gene...
Applications running in non-development environments often require database updates. After using the Add-Migration command to create your database patches there's the need to run the updates on other environments, and then the test environment as well. Challenges commonly faced are: no Visual S...
You can also use Laravel Artisan commands from your routes or controllers. To run a command using PHP code: Artisan::call('command-name'); For example, Artisan::call('db:seed');
We can use the unit type as a function argument to define functions that we don't want executed until later. This is often useful in asynchronous background tasks, when the main thread may want trigger some predefined functionality of the background thread, like maybe moving it to a new file, or if...
In normal mode: gg go to top = then G
This is just a small hack for those who use self-defined functions often. Type "fun" RStudio IDE and hit TAB. The result will be a skeleton of a new function. name <- function(variables) { } One can easily define their own snippet template, i.e. like the one below ...
To set the timezone in Codeigniter by extending date helper is an alternative way. For doing that need to follow the following two step activity. Extend date helper with the following function: if ( ! function_exists('now')) { /** * Get "now" time * * Returns tim...
Autodoc needs to imports your modules to work. You can include your code path in your conf.py file. For instance: import os sys.path.insert(0, os.path.abspath('../src'))
var pipeline = {}; // (...) adding things in pipeline for(var key in pipeline) { fs.stat(pipeline[key].path, function(err, stats) { if (err) { // clear that one delete pipeline[key]; return; } // (...) pipeline[key].count++; }); } The problem i...
In case you have json with an ISO date string like this JSON.stringify({date: new Date()}) // -> "{"date":"2016-12-12T13:24:34.470Z"}" You can map it to elm Date type: import Html exposing (text) import Json.Decode as JD import Date payload = ""&...
It is a bad practice to block on async calls as it can cause deadlocks in environments that have a synchronization context. The best practice is to use async/await "all the way down." For example, the following Windows Forms code causes a deadlock: private async Task<bool> TryThis()...
function doGet(e){ var serveFile = e.parameter.servefile; var id = e.parameter.id; if(serveFile) { return downloadFile(id); // and Hyde } return HtmlService.createHtmlOutputFromFile('form.html'); // Jekyll } function fetchFromGoogleDrive() { // Jekyll va...
From Xcode menu open: Product > Scheme > Edit Scheme. On your Environment Variables set OS_ACTIVITY_MODE = disable

Page 15 of 21