Tutorial by Examples: ast

NSDictionary can be enumerated using fast enumeration, just like other collection types: NSDictionary stockSymbolsDictionary = @{ @"AAPL": @"Apple", @"GOOGL": @"Alphabet", ...
If you are adding new rows and updating existing data. You need two additional parameters: --check-column : A column name that should be checked for newly appended and updated data. date, time, datetime and timestamp are suitable data types for this column. --last-value : The last value that su...
Utilizing .Net System.Security.Cryptography.HashAlgorithm namespace to generate the message hash code with the algorithms supported. $example="Nobody expects the Spanish Inquisition." #calculate $hash=[System.Security.Cryptography.HashAlgorithm]::Create("sha256").ComputeHas...
By default, Import-CSV imports all values as strings, so to get DateTime- and integer-objects, we need to cast or parse them. Using Foreach-Object: > $listOfRows = Import-Csv .\example.csv > $listOfRows | ForEach-Object { #Cast properties $_.DateTime = [datetime]$_.DateTime $...
Using a list object you can create a fully functional generic Stack with helper methods such as peeking and checking if the stack is Empty. Check out the official python docs for using list as Stack here. #define a stack class class Stack: def __init__(self): self.items = [] ...
A stream wrapper provides a handler for one or more specific schemes. The example below shows a simple stream wrapper that sends PATCH HTTP requests when the stream is closed. // register the FooWrapper class as a wrapper for foo:// URLs. stream_wrapper_register("foo", FooWrapper::class...
Drawing text in canvas with your font from assets. Typeface typeface = Typeface.createFromAsset(getAssets(), "fonts/SomeFont.ttf"); Paint textPaint = new Paint(); textPaint.setTypeface(typeface); canvas.drawText("Your text here", x, y, textPaint);
string is defined as alias string = immutable(char)[];: so need to use dup to make a mutable char array, before it can be reversed: import std.stdio; import std.string; int main() { string x = "Hello world!"; char[] x_rev = x.dup.reverse; writeln(x_rev); // !dlr...
Swift 2.3 let url = NSURL(string: "http://google.com/lastPath") let lastPath = url?.lastPathComponent Swift 3.0 let url = URL(string: "http://google.com/lastPath") let lastPath = url?.lastPathComponent
You may often find the need to get the auto incremented ID value for a row that you have just inserted into your database table. You can achieve this with the lastInsertId() method. // 1. Basic connection opening (for MySQL) $host = 'localhost'; $database = 'foo'; $user = 'root' $password = ''...
Calling the function string InvoiceHtml = myFunction.RenderPartialViewToString("PartialInvoiceCustomer", ToInvoice); // ToInvoice is a model, you can pass parameters if needed Function to generate HTML public static string RenderPartialViewToString(string viewName, object model) { ...
You might have realized that $emit is scoped to the component that is emitting the event. That's a problem when you want to communicate between components far from one another in the component tree. Note: In Vue1 you coud use $dispatch or $broadcast, but not in Vue2. The reason being that it doesn'...
Get last segment echo end($this->uri->segment_array()); //it will print others Get before last segment echo $this->uri->segment(count($this->uri->segment_array())-1); //it will print how-can-i-do-this More info: [http://stackoverflow.com/questions/9221164/code-igniter-get-b...
Create an HTML file (in this example libraries/turf.html) with the library you want to load: <script src="../../bower_components/turf/turf.min.js"></script> Import the HTML file (libraries/turf.html) in your component with the rest of your imports: <link rel...
If we are using method sendStickyBroadcast(intent) the corresponding intent is sticky, meaning the intent you are sending stays around after broadcast is complete. A StickyBroadcast as the name suggests is a mechanism to read the data from a broadcast, after the broadcast is complete. This can be ...
Swift let image = UIGraphicsGetImageFromCurrentImageContext() imageView.image = image //assuming imageView is a valid UIImageView object Objective-C UIImage *image = UIGraphicsGetImageFromCurrentImageContext(); imageView.image = image; //assuming imageView is a valid UIImageView object
First create a BroadcastReceiver class to handle the incoming Location updates: public class LocationReceiver extends BroadcastReceiver implements Constants { @Override public void onReceive(Context context, Intent intent) { if (LocationResult.hasResult(intent)) { ...
To view the first or last few records of a dataframe, you can use the methods head and tail To return the first n rows use DataFrame.head([n]) df.head(n) To return the last n rows use DataFrame.tail([n]) df.tail(n) Without the argument n, these functions return 5 rows. Note that the slice ...
It is possible to send a message or data to all avaible connections. This can be achieved by first initializing the server and then using the socket.io object to find all sockets and then emit as you normally would emit to a single socket var io = require('socket.io')(80) // 80 is the HTTP port io...
It is possible to emit a message or data to all users except the one making the request: var io = require('socket.io')(80); io.on('connection', function (socket) { socket.broadcast.emit('user connected'); });

Page 20 of 26