Tutorial by Examples

str := base64.StdEncoding.EncodeToString([]byte(`foo bar`)) fmt.Println(str) // Output: Zm9vIGJhcg== Playground
encoding := base64.StdEncoding data := []byte(`Zm9vIGJhcg==`) decoded := make([]byte, encoding.DecodedLen(len(data))) n, err := encoding.Decode(decoded, data) if err != nil { log.Fatal(err) } // Because we don't know the length of the data that is encoded // (only the max length), we n...
decoded, err := base64.StdEncoding.DecodeString(`biws`) if err != nil { log.Fatal(err) } fmt.Printf("%s", decoded) // Output: n,, Playground
Anything that needs to happen with data in an IndexedDB database happens in a transaction. There are a few things to note about transactions that are mentioned in the Remarks section at the bottom of this page. We'll use the database we set up in Opening a database. // Create a new readwrite (sinc...
Anything that needs to happen with data in an IndexedDB database happens in a transaction. There are a few things to note about transactions that are mentioned in the Remarks section at the bottom of this page. We'll use the database we set up in Opening a database. // Create a new transaction, we...
Create a new project dotnet new -l f# Restore any packages listed in project.json dotnet restore A project.lock.json file should be written out. Execute the program dotnet run The above will compile the code if required. The output of the default project created by dotnet new -l f# con...
Espresso by default has many matchers that help you find views that you need to do some checks or interactions with them. Most important ones can be found in the following cheat sheet: https://google.github.io/android-testing-support-library/docs/espresso/cheatsheet/ Some examples of matchers are...
Activity class takes care of creating a window for you in which you can place your UI with setContentView. There are three setContentView methods: setContentView(int layoutResID) - Set the activity content from a layout resource. setContentView(View view) - Set the activity content to an explic...
There are two Collections.sort() methods: One that takes a List<T> as a parameter where T must implement Comparable and override the compareTo() method that determines sort order. One that takes a List and a Comparator as the arguments, where the Comparator determines the sort order. ...
Instead of adding an observer with a selector, a block can be used: id testObserver = [[NSNotificationCenter defaultCenter] addObserverForName:@"TestNotification" object:nil ...
The 'Golden' method minimizes a unimodal function by narrowing the range in the extreme values import numpy as np from scipy.optimize import _minimize from scipy import special import matplotlib.pyplot as plt x = np.linspace(0, 10, 500) y = special.j0(x) optimize.minimize_scalar(special.j0,...
Brent's method is a more complex algorithm combination of other root-finding algorithms; however, the resulting graph isn't much different from the graph generated from the golden method. import numpy as np import scipy.optimize as opt from scipy import special import matplotlib.pyplot as plt ...
Think this could example could be better but you get the gist import numpy as np from scipy.optimize import _minimize from scipy import special import matplotlib.pyplot as plt from matplotlib import cm from numpy.random import randn x, y = np.mgrid[-2:2:100j, -2:2:100j] plt.pcolor(x, y, op...
Creating a Window with OpenGL context (extension loading through GLEW): #define GLEW_STATIC #include <GL/glew.h> #include <SDL2/SDL.h> int main(int argc, char* argv[]) { SDL_Init(SDL_INIT_VIDEO); /* Initialises Video Subsystem in SDL */ /* Setting up OpenGL version a...
Create User Model # Schema: User(token:string, auth_token:string) class User < ActiveRecord::Base has_secure_token has_secure_token :auth_token end Now when you create a new user a token and auth_token are automatically generated user = User.new user.save user.token # => "p...
Matlab allows some very trivial mistakes to go by silently, which might cause an error to be raised much later in the run - making debugging hard. If you assume something about your variables, validate it. function out1 = get_cell_value_at_index(scalar1,cell2) assert(isscalar(scalar1),'1st input ...
POSIX stands for "Portable Operating System Interface" and defines a set of standards to provide compatibility between different computing platforms. The current version of the standard is IEEE 1003.1 2016 and can be accessed from the OpenGroup POSIX specification. Previous versions incl...
$username = 'Hadibut'; $email = '[email protected]'; $variables = compact('username', 'email'); // $variables is now ['username' => 'Hadibut', 'email' => '[email protected]'] This method is often used in frameworks to pass an array of variables between two components.
The entries() method returns a new Array Iterator object that contains the key/value pairs for each index in the array. 6 var letters = ['a','b','c']; for(const[index,element] of letters.entries()){ console.log(index,element); } result 0 "a" 1 "b" 2 "c"...
Images, static data, sounds, etc. are resources in a Playground. If the Project Navigator is hidden, choose View > Navigators > Show Project Navigator (⌘1) There are several ways to add files Drag your resources to the Resources folder or Select the Resources folder and choose File &gt...

Page 607 of 1336