Tutorial by Examples: basic

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. ...
# 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...
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"); ...
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')
class Car { public position: number = 0; protected speed: number = 42; move() { this.position += this.speed; } } class SelfDrivingCar extends Car { move() { // start moving around :-) super.move(); super.move(); } } ...
A Bootstrap carousel is a Bootstrap component that creates a slideshow which cycles through elements within the carousel. Here is a basic HTML usage example: <div id="carousel-example-generic" class="carousel slide" data-ride="carousel"> <!-- Indicators --...
Carousel components can be instantiated via jQuery with the function $('.carousel').carousel(options), where $('.carousel') is a top-level reference to the specific carousel and options is a Javascript object specifying the carousel's default attributes. The options object allows for multiple prope...
The arc4random_uniform() function is the simplest way to get high-quality random integers. As per the manual: arc4random_uniform(upper_bound) will return a uniformly distributed random number less than upper_bound. arc4random_uniform() is recommended over constructions like ''arc4random() % uppe...
From MSDN: An enumeration type (also named an enumeration or an enum) provides an efficient way to define a set of named integral constants that may be assigned to a variable. Essentially, an enum is a type that only allows a set of finite options, and each option corresponds to a number. By d...
Once connected you can publish messages by calling the ISubscriber.Publish method: // grab an instance of an ISubscriber var subscriber = connection.GetSubscriber(); // publish a message to the 'chat' channel subscriber.Publish("chat", "This is a message") Consumers can ...
package { import flash.display.Sprite; import flash.display.StageAlign; import flash.display.StageScaleMode; import flash.events.Event; public class Main extends Sprite { //Document Class Main Constructor public function Main() { ...
Backbone requires Underscore and (optionally) jQuery - for DOM manipulation (using Backbone.View) and RESTful persistence. The quickest way to get up and running with Backbone is to create an index.html file with simple script tags in the HTML <head>: <html> <head> ...
Event Emitters are built into Node, and are for pub-sub, a pattern where a publisher will emit events, which subscribers can listen and react to. In Node jargon, publishers are called Event Emitters, and they emit events, while subscribers are called listeners, and they react to the events. // Requ...
A VectorDrawable should consist of at least one <path> tag defining a shape <vector xmlns:android="http://schemas.android.com/apk/res/android" android:width="24dp" android:height="24dp" android:viewportWidth="24.0" android:viewpor...

Page 8 of 43