A complete list of RxJS 5 operators with easy to understand explanations and runnable examples.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Copyright (c) 2016, Tiernan Cridland | |
| * | |
| * Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby | |
| * granted, provided that the above copyright notice and this permission notice appear in all copies. | |
| * | |
| * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL | |
| * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, | |
| * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER | |
| * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?xml version="1.0" encoding="UTF-8"?> | |
| <persistence xmlns="http://java.sun.com/xml/ns/persistence" | |
| xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
| xsi:schemaLocation="http://java.sun.com/xml/ns/persistence | |
| http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd" | |
| version="1.0"> | |
| <!-- derby --> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public static class Flatten { | |
| public static T[] Flat<T>(T[,] toFlat) | |
| { | |
| int width = toFlat.GetLength(0); | |
| int height = toFlat.GetLength(1); | |
| int size = width * height; | |
| T[] result = new T[size]; | |
| for (int i=0;i<size; i++) | |
| { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import java.io.IOException; | |
| import java.io.UnsupportedEncodingException; | |
| import java.net.HttpURLConnection; | |
| import java.security.MessageDigest; | |
| import java.security.NoSuchAlgorithmException; | |
| import java.util.HashMap; | |
| import com.google.common.base.CharMatcher; | |
| import com.google.common.base.Joiner; | |
| import com.google.common.base.Splitter; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import android.Manifest; | |
| import android.content.pm.PackageManager; | |
| import android.database.Cursor; | |
| import android.os.Build; | |
| import android.os.Bundle; | |
| import android.provider.ContactsContract; | |
| import android.support.annotation.NonNull; | |
| import android.support.annotation.Nullable; | |
| import android.support.design.widget.Snackbar; | |
| import android.support.v4.app.LoaderManager; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * parse a chunked csv file and give the result per row back if it is finished | |
| * @param withHeader | |
| * @param delimiter | |
| * @param quotes | |
| * @returns {(chunk:string, callback:(result:(Array<string>|Object))=>void)=>void} | |
| */ | |
| function parseCSV(withHeader: boolean, delimiter: string = ';', quotes: string = '"') { | |
| let tmpString = ''; | |
| let headerCells: Array<string> = null; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import android.os.Handler; | |
| import android.os.Message; | |
| import android.support.v4.content.Loader; | |
| import com.android.volley.NoConnectionError; | |
| import com.android.volley.Response; | |
| import com.android.volley.RetryPolicy; | |
| import com.android.volley.TimeoutError; | |
| import com.android.volley.VolleyError; | |
| import com.android.volley.toolbox.JsonRequest; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -- Reference: http://stackoverflow.com/questions/418898/sqlite-upsert-not-insert-or-replace | |
| -- Approach #1: Select original values before insertion. | |
| -- demo table 'emplyee' | |
| CREATE TABLE employee ( | |
| id INTEGER PRIMARY KEY, | |
| role TEXT, | |
| name TEXT); | |
| -- This will update 2 of the columns. When ID=1 exists, the NAME will be unaffected. When ID=1 does not exist, the name will be default (NULL). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const sumMethod = (a, b) => a + b; | |
| const transpose = m => m[0].map((x, i) => m.map(x => x[i])); | |
| /** | |
| * Softmax for one or two dimensional arrays | |
| */ | |
| export const softmax = (arr: [number | [number]]) => { | |
| if (arr.every(item => Array.isArray(item))) { | |
| return transpose(transpose(arr).map(item => softmax(<[number]>item))); | |
| } else { | |
| const sumRow = arr.map(value => Math.exp(<number>value)).reduce(sumMethod); |
NewerOlder