Tutorial by Examples: c

Most times when people have to reverse a string, they do it more or less like this: char[] a = s.ToCharArray(); System.Array.Reverse(a); string r = new string(a); However, what these people don't realize is that this is actually wrong. And I don't mean because of the missing NULL check. It ...
Creating backpressured data sources is the relatively easier task when dealing with backpressure in general because the library already offers static methods on Observable that handle backpressure for the developer. We can distinguish two kinds of factory methods: cold "generators" that ei...
Conceptually, integrate 3rd party REST APIs can be as simple as adding the http package and making a call to the external endpoint. meteor add http HTTP.get('http://foo.net/api/bar/');
Basic HTTP calls don't provide code-reusability, however. And they can get confused with all the other features you're trying to implement. For those reasons, it's common to implement an API wrapper. Foo = { identify: function(input){ return Http.get('http://foo.net/api/identify/' + input...
After creating an API wrapper, it's likely that you may want to create an Atmosphere package to redistribute it and share it between applications. The files of your package will probably look something like this. packages/foo-api-wrapper/package.js packages/foo-api-wrapper/readme.md packages/foo-...
At this point, you're still building your package, so you'll need to add the package to your application: meteor add myaccount:foo And eventually publish it to Atmosphere: meteor publish myaccount:foo
Now that we have all those pieces put together, you should now be able to make calls like the following from within your app: Foo.identify('John'); Foo.record_action_on_item('view', "HackerNews'); Obviously you'll want to adjust function names, arguments, urls, and the like, to create the ...
Uploading files can be easy or really complicated, depending on what you're wanting to do. In general, transfering a file itself isn't all that difficult. But there are lots of edge cases around attachments, binary files, and the like. And the real sticking point is horizontal scaling, and creating ...
To scale things, we have to stop using local storage on our server, and start using either a dedicated file storage service or implement a horizontal storage layer. The easiest way to get started with scalable file storage is to use a solution like Filepicker.io, which supports S3, Azure, Rackspace,...
However, if you're really serious about storage, and you want to store millions of images, you're going to need to leverage Mongo's GridFS infrastructure, and create yourself a storage layer. For that, you're going to need the excellent CollectionFS subsystem. Start by adding the necessary packages...
$ cat ip.txt address range substitution pattern sample Nth line $ sed -n '2p' ip.txt range $ sed '3d' ip.txt address range pattern sample Last line $ sed -n '$p' ip.txt sample
It's possible to send broadcast to BroadcastReceiver with adb. In this example we are sending broadcast with action com.test.app.ACTION and string extra in bundle 'foo'='bar': adb shell am broadcast -a action com.test.app.ACTION --es foo "bar" You can put any other supported type to b...
We can also use macros for making code easier to read and write. For example we can implement macros for implementing the foreach construct in C for some data structures like singly- and doubly-linked lists, queues, etc. Here is a small example. #include <stdio.h> #include <stdlib.h>...
def str = 'nice' assert "Groovy is $str" == 'Groovy is nice'
<style name="AppTheme" parent="Theme.AppCompat"> <item name="android:colorEdgeEffect">@color/my_color</item> </style>
5.0 The ripple animation is shown when user presses clickable views. You can use the same ripple color used by your app assigning the ?android:colorControlHighlight in your views. You can customize this color by changing the android:colorControlHighlight attribute in your theme: This effect colo...
The navigation bar (at the bottom of the screen) can be transparent. Here is the way to achieve it. <style name="AppTheme" parent="Theme.AppCompat"> <item name="android:windowTranslucentNavigation">true</item> </style> The Status Bar (t...
5.0 This attribute is used to change the navigation bar (one, that contain Back, Home Recent button). Usually it is black, however it's color can be changed. <style name="AppTheme" parent="Theme.AppCompat"> <item name="android:navigationBarColor">@col...
Given two types T and U, &T will coerce (implicitly convert) to &U if and only if T implements Deref<Target=U> This allows us to do things like this: fn foo(a: &[i32]) { // code } fn bar(s: &str) { // code } let v = vec![1, 2, 3]; foo(&v); // &Vec&l...
Microbenchmark is useful for estimating the time taking for otherwise fast procedures. For example, consider estimating the time taken to print hello world. system.time(print("hello world")) # [1] "hello world" # user system elapsed # 0 0 0 This i...

Page 250 of 826