Tutorial by Examples: by

from struct import pack print(pack('I3c', 123, b'a', b'b', b'c')) # b'{\x00\x00\x00abc'
from struct import unpack print(unpack('I3c', b'{\x00\x00\x00abc')) # (123, b'a', b'b', b'c')
If you want the Value Types vs Reference Types in methods example to work properly, use the ref keyword in your method signature for the parameter you want to pass by reference, as well as when you call the method. public static void Main(string[] args) { ... DoubleNumber(ref number); ...
// Example of std::vector as an expanding dynamic size array. #include <algorithm> // std::sort #include <iostream> #include <vector> // std::vector using namespace std; int int_from( std::istream& in ) { int x = 0; in >> x; return x; } ...
To create a new Rails 5 API, open a terminal and run the following command: rails new app_name --api The following file structure will be created: create create README.rdoc create Rakefile create config.ru create .gitignore create Gemfile create app create app/as...
RVM is a great tool to manage your ruby versions and set up your working environment. Assuming you already have RVM installed, to get the latest version of ruby, which is needed for these examples, open a terminal and run: $ rvm get stable $ rvm install ruby --latest Check your ruby version by...
XML <Galaxy> <name>Milky Way</name> <CelestialObject name="Earth" type="planet"/> <CelestialObject name="Sun" type="star"/> </Galaxy> XPATH /Galaxy/*[contains(@name,'Ear')] or //*[contains(@name,'Ear...
XML <Galaxy> <name>Milky Way</name> <CelestialObject name="Earth" type="planet"/> <CelestialObject name="Sun" type="star"/> </Galaxy> XPATH /Galaxy/*[contains(lower-case(@name),'ear')] or //*[contain...
XML <Galaxy> <name>Milky Way</name> <CelestialObject name="Earth" type="planet"/> <CelestialObject name="Sun" type="star"/> </Galaxy> XPATH /Galaxy/*[starts-with(lower-case(@name),'ear')] or //*[star...
XML <Galaxy> <name>Milky Way</name> <CelestialObject name="Earth" type="planet"/> <CelestialObject name="Sun" type="star"/> </Galaxy> XPATH /Galaxy/*[ends-with(lower-case(@type),'tar')] or //*[ends-w...
Dim sites() As String = {"Stack Overflow", "Super User", "Ask Ubuntu", "Hardware Recommendations"} Dim query = From x In sites Select x.Length ' result = 14, 10, 10, 24 Query...
A HAVING clause filters the results of a GROUP BY expression. Note: The following examples are using the Library example database. Examples: Return all authors that wrote more than one book (live example). SELECT a.Id, a.Name, COUNT(*) BooksWritten FROM BooksAuthors ba INNER JOIN Aut...
We can use 1,2,3.. to determine the type of order: SELECT * FROM DEPT ORDER BY CASE DEPARTMENT WHEN 'MARKETING' THEN 1 WHEN 'SALES' THEN 2 WHEN 'RESEARCH' THEN 3 WHEN 'INNOVATION' THEN 4 ELSE 5 END, CITY IDREGIONCITYDEPARTMENTEMPLOYEES_N...
Corner radius for all 4 edges: UIBezierPath* rectanglePath = [UIBezierPath bezierPathWithRoundedRect: CGRectMake(x,y,width,height) cornerRadius: 11]; [UIColor.grayColor setFill]; [rectanglePath fill]; Corner radius for top-left edge: UIBezierPath* rectanglePath = [UIBezierPath bezierPat...
In C, all function parameters are passed by value, so modifying what is passed in callee functions won't affect caller functions' local variables. #include <stdio.h> void modify(int v) { printf("modify 1: %d\n", v); /* 0 is printed */ v = 42; printf("modify 2:...
Built in functions can subset rows with columns that meet conditions. df <- data.frame(item = c(1:10), price_Elasticity = c(-0.57667, 0.03205, -0.04904, 0.10342, 0.04029, 0.0742, 0.1669, 0.0313, 0.22204, 0.06158), total...
CREATE TABLE stack( id INT, username VARCHAR(30) NOT NULL, password VARCHAR(30) NOT NULL ); INSERT INTO stack (`id`, `username`, `password`) VALUES (1, 'Foo', 'hiddenGem'); INSERT INTO stack (`id`, `username`, `password`) VALUES (2, 'Baa', 'verySecret'); Query SELECT id FROM ...
The key in vectorizing R code, is to reduce or eliminate "by row operations" or method dispatching of R functions. That means that when approaching a problem that at first glance requires "by row operations", such as calculating the means of each row, one needs to ask themselves...
$ mkdir 20{09..11}-{01..12} Entering the ls command will show that the following directories were created: 2009-01 2009-04 2009-07 2009-10 2010-01 2010-04 2010-07 2010-10 2011-01 2011-04 2011-07 2011-10 2009-02 2009-05 2009-08 2009-11 2010-02 2010-05 2010-08 2010-11 2011-02 2011-05 2011-08 2011...
// Remember to initialize your client as described in the Remarks section Awareness.SnapshotApi.getPlaces(client) .setResultCallback(new ResultCallback<PlacesResult>() { @Override public void onResult(@NonNull PlacesResult placesResult) { List<PlaceLike...

Page 7 of 23