Tutorial by Examples: bas

Sometimes you need rewrite history with a rebase, but git push complains about doing so because you rewrote history. This can be solved with a git push --force, but consider git push --force-with-lease, indicating that you want the push to fail if the local remote-tracking branch differs from the b...
This code example creates a TCP client, sends "Hello World" over the socket connection, and then writes the server response to the console before closing the connection. // Declare Variables string host = "stackoverflow.com"; int port = 9999; int timeout = 5000; // Create ...
In Python 3 and higher, print is a function rather than a keyword. print('hello world!') # out: hello world! foo = 1 bar = 'bar' baz = 3.14 print(foo) # out: 1 print(bar) # out: bar print(baz) # out: 3.14 You can also pass a number of parameters to print: print(foo, bar, b...
The function map() from the package maps provides a simple starting point for creating maps with R. A basic world map can be drawn as follows: require(maps) map() The color of the outline can be changed by setting the color parameter, col, to either the character name or hex value of a color...
A basic plot is created by calling plot(). Here we use the built-in cars data frame that contains the speed of cars and the distances taken to stop in the 1920s. (To find out more about the dataset, use help(cars)). plot(x = cars$speed, y = cars$dist, pch = 1, col = 1, main = "Distance ...
docopt turns command-line argument parsing on its head. Instead of parsing the arguments, you just write the usage string for your program, and docopt parses the usage string and uses it to extract the command line arguments. """ Usage: script_name.py [-a] [-b] <path> ...
Django manger is an interface through which the django model queries the database. The objects field used in most django queries is actually the default manager created for us by django (this is only created if we don't define custom managers). Why would we define a custom manager/queryset? To avo...
Perform a basic GET request and prints the contents of a site (HTML). package main import ( "fmt" "io/ioutil" "net/http" ) func main() { resp, err := http.Get("https://example.com/") if err != nil { panic(err) } ...
LINQ is largely beneficial for querying collections (or arrays). For example, given the following sample data: var classroom = new Classroom { new Student { Name = "Alice", Grade = 97, HasSnack = true }, new Student { Name = "Bob", Grade = 82, HasSnack = false }, ...
This is how to create a basic method that logs 'Hello World" to the console: - (void)hello { NSLog(@"Hello World"); } The - at the beginning denotes this method as an instance method. The (void) denotes the return type. This method doesn't return anything, so you enter void. ...
Since Git 1.7.12 it is possible to rebase down to the root commit. The root commit is the first commit ever made in a repository, and normally cannot be edited. Use the following command: git rebase -i --root
Private inheritance is useful when it is required to restrict the public interface of the class: class A { public: int move(); int turn(); }; class B : private A { public: using A::turn; }; B b; b.move(); // compile error b.turn(); // OK This approach efficiently pr...
# app/channels/appearance_channel.rb class NotificationsChannel < ApplicationCable::Channel def subscribed stream_from "notifications" end def unsubscribed end def notify(data) ActionCable.server.broadcast "notifications", { title: 'New things!', ...
app/assets/javascripts/channels/notifications.coffee App.notifications = App.cable.subscriptions.create "NotificationsChannel", connected: -> # Called when the subscription is ready for use on the server $(document).on "change", "input", (e)=> ...
{ "name": "my-project", "version": "0.0.1", "description": "This is a project.", "author": "Someone <[email protected]>", "contributors": [{ "name": "Som...
<?php namespace models; use yii\db\ActiveRecord; use yii\behaviors\TimestampBehavior; class Post extends ActiveRecord { public static function tableName() { return 'post'; } public function rules() { ...
Use the speakUtterance: method of AVSpeechSynthesizer to convert text to speech. You need to pass an AVSpeechUtterance object to this method, which contains the text that you want to be spoken. Objective C AVSpeechSynthesizer *speaker = [[AVSpeechSynthesizer alloc] init]; AVSpeechUtterance *speec...
public static void Main() { var xml = new XmlDocument(); var root = xml.CreateElement("element"); // Creates an attribute, so the element will now be "<element attribute='value' />" root.SetAttribute("attribute", "value"); ...
In this example database for a library, we have Authors, Books and BooksAuthors tables. Live example: SQL fiddle Authors and Books are known as base tables, since they contain column definition and data for the actual entities in the relational model. BooksAuthors is known as the relationship tabl...
raw_data = {'first_name': ['John', 'Jane', 'Jim'], 'last_name': ['Doe', 'Smith', 'Jones'], 'department': ['Accounting', 'Sales', 'Engineering'],} df = pd.DataFrame(raw_data,columns=raw_data.keys()) df.to_csv('data_file.csv')

Page 10 of 65