GROUP BY clause groups rows by some value:
SELECT type, count(*) as c
FROM sys.objects
GROUP BY type
You can apply some function on each group (aggregate function) to calculate sum or count of the records in the group.
typecSQ3S72IT16PK1U5
HAVING clause removes groups that do not satisfy condition:
SELECT type, count(*) as c
FROM sys.objects
GROUP BY type
HAVING count(*) < 10
typecSQ3PK1U5
OFFSET FETCH clause is more advanced version of TOP. It enables you to skip N1 rows and take next N2 rows:
SELECT *
FROM sys.objects
ORDER BY object_id
OFFSET 50 ROWS FETCH NEXT 10 ROWS ONLY
You can use OFFSET without fetch to just skip first 50 rows:
SELECT *
FROM sys.objects
ORDER BY obj...
SELECT statement can be executed without FROM clause:
declare @var int = 17;
SELECT @var as c1, @var + 2 as c2, 'third' as c3
In this case, one row with values/results of expressions are returned.
This example shows a helper class that contains methods useful, when executing the queries for data. Every method here uses Java Generic's in order to be very flexible.
public <T> List<T> selectElements(AbstractDao<T, ?> dao) {
if (dao == null) {
return null;
}
...
Add the following dependencies to your application.
compile 'com.facebook.stetho:stetho:1.5.0'
compile 'com.facebook.stetho:stetho-okhttp3:1.5.0'
In your Application class' onCreate method, call the following.
Stetho.initializeWithDefaults(this);
When creating your Retrofit instance, crea...
This technique details how to ensure that your .apk has been signed with your developer certificate, and leverages the fact that the certificate remains consistent and that only you have access to it.
We can break this technique into 3 simple steps:
Find your developer certificate signature.
Em...
The following are some of the more common/useful shortcuts.
These are based on the default IntelliJ shortcut map. You can switch to other common IDE shortcut maps via File -> Settings -> Keymap -> <Choose Eclipse/Visual Studio/etc from Keymaps dropdown>
ActionShortcutFormat codeCTRL...
Enable Offline Work:
Click File -> Settings. Search for "gradle" and click in Offline work box.
Go to Compiler (in same settings dialog just below Gradle) and add --offline to Command-line Options text box.
Improve Gradle Performance
Add following two line of code in your gradle...
System Requirements
Microsoft® Windows® 8/7/Vista/2003 (32 or 64-bit).
Mac® OS X® 10.8.5 or higher, up to 10.9 (Mavericks)
GNOME or KDE desktop
Installation
Window
Download and install JDK (Java Development Kit) version 8
Download Android Studio
Launch Android Studio.exe then mention J...
Given the following XML document :
<?xml version="1.0" encoding="UTF-8"?>
<values>
<value>1</value>
<value>3</value>
<value>5</value>
</values>
We can produce an XML document describing the sum of the values wit...
We want to gather data created by multiple Workers.
First we create a Queue:
sink = Queue.new
Then 16 workers all generating a random number and pushing it into sink:
(1..16).to_a.map do
Thread.new do
sink << rand(1..100)
end
end.map(&:join)
And to get the data, conver...
We want to process data in parallel.
Let's populate source with some data:
source = Queue.new
data = (1..100)
data.each { |e| source << e }
Then create some workers to process data:
(1..16).to_a.map do
Thread.new do
until source.empty?
item = source.pop
sleep 0.5
...
We want to process data in parallel and push it down the line to be processed by other workers.
Since Workers both consume and produce data we have to create two queues:
first_input_source = Queue.new
first_output_sink = Queue.new
100.times { |i| first_input_source << i }
First wave of...
q = Queue.new
q << "any object including another queue"
# or
q.push :data
There is no high water mark, queues can infinitely grow.
#push never blocks
syncer = Queue.new
a = Thread.new do
syncer.pop
puts "this happens at end"
end
b = Thread.new do
puts "this happens first"
STDOUT.flush
syncer << :ok
end
[a, b].map(&:join)