Tutorial by Examples: e

Plot With Grid Lines import matplotlib.pyplot as plt # The Data x = [1, 2, 3, 4] y = [234, 124,368, 343] # Create the figure and axes objects fig, ax = plt.subplots(1, figsize=(8, 6)) fig.suptitle('Example Of Plot With Grid Lines') # Plot the data ax.plot(x,y) # Show the grid lin...
The easiest method to bypass cache is to change the URL. This is used as a best practice when the URL contains a version or a checksum of the resource, e.g. http://example.com/image.png?version=1 http://example.com/image.png?version=2 These two URLs will be cached separately, so even if …?versi...
This example displays a transaction for an image view with only two images.(can use more images as well one after the other for the first and second layer positions after each transaction as a loop) add a image array to res/values/arrays.xml <resources> <array name=&...
tree = log --oneline --decorate --source --pretty=format:'"%Cblue %h %Cgreen %ar %Cblue %an %C(yellow) %d %Creset %s"' --all --graph example * 40554ac 3 months ago Alexander Zolotov Merge pull request #95 from gmandnepr/external_plugins |\ | * e509f61 3 months ago Ievg...
It is common for an AsyncTask to require a reference to the Activity that called it. If the AsyncTask is an inner class of the Activity, then you can reference it and any member variables/methods directly. If, however, the AsyncTask is not an inner class of the Activity, you will need to pass an A...
If your team is following a rebase-based workflow, it may be a advantageous to setup git so that each newly created branch will perform a rebase operation, instead of a merge operation, during a git pull. To setup every new branch to automatically rebase, add the following to your .gitconfig or .gi...
Copy foo.txt from /path/to/source/ to /path/to/target/folder/ cp /path/to/source/foo.txt /path/to/target/folder/ Copy foo.txt from /path/to/source/ to /path/to/target/folder/ into a file called bar.txt cp /path/to/source/foo.txt /path/to/target/folder/bar.txt
copy folder foo into folder bar cp -r /path/to/foo /path/to/bar if folder bar exists before issuing the command, then foo and its content will be copied into the folder bar. However, if bar does not exist before issuing the command, then the folder bar will be created and the content of foo wil...
To change the URL of the repository you want your remote to point to, you can use the set-url option, like so: git remote set-url <remote_name> <remote_repository_url> Example: git remote set-url heroku https://git.heroku.com/fictional-remote-repository.git
Express is based on Connect, which is what provides the middleware functionality of Express. To understand what connect is, you can see that it provides the basic app structure that you use when you use express const connect = require('connect') const app = connect() app.listen(3000) This wi...
Middleware are attached to the app object, usually before listen is called. Example of a simple logging middleware: app.use(function (req, res, next) { console.log(`${req.method}: ${req.url}`) next() }) All this will do is log GET: /example if you where to GET localhost:3000/example. ...
If we would like to limit the access to our app, we could write a middleware for that too! This example only grants you access on thrusdays, but a real world example could, for example, be user authentication. A good place to put this would be after the logging middleware but before any content is s...
Use quasiquotes to create a Tree in a macro. object macro { def addCreationDate(): java.util.Date = macro impl.addCreationDate } object impl { def addCreationDate(c: Context)(): c.Expr[java.util.Date] = { import c.universe._ val date = q"new java.util.Date()" // this...
std::optional<float> divide(float a, float b) { if (b!=0.f) return a/b; return {}; } Here we return either the fraction a/b, but if it is not defined (would be infinity) we instead return the empty optional. A more complex case: template<class Range, class Pred> auto find_if...
void print_name( std::ostream& os, std::optional<std::string> const& name ) { std::cout "Name is: " << name.value_or("<name missing>") << '\n'; } value_or either returns the value stored in the optional, or the argument if there is nothing s...
If you have loaded a file into GHCi (e.g. using :l filename.hs) and you have changed the file in an editor outside of GHCi you must reload the file with :r or :reload in order to make use of the changes, hence you don't need to type again the filename. ghci> :r OK, modules loaded: Main. ghci...
Launch mode defines the behaviour of new or existing activity in the task. There are possible launch modes: standard singleTop singleTask singleInstance It should be defined in android manifest in <activity/> element as android:launchMode attribute. <activity android:launchM...
A string can be written to a file with an instance of the File class. file = File.new('tmp.txt', 'w') file.write("NaNaNaNa\n") file.write('Batman!\n') file.close The File class also offers a shorthand for the new and close operations with the open method. File.open('tmp.txt', 'w') ...
You can call an instance method using the . special form: (.trim " hello ") ;;=> "hello" You can call instance methods with arguments like this: (.substring "hello" 0 2) ;;=> "he"
You can call an instance field using the .- syntax: (def p (java.awt.Point. 0 1)) (.-x p) ;;=> 0 (.-y p) ;;=> 1

Page 479 of 1191