2.1.3
1. Preview Different Devices
There is a preview panel at the right of the android studio. In thispanel there is a button with device name with which you are previewing the UI of your app like this .
Click on small dropdown indicator of this and a floating panel will appear with all the pr...
In Emacs, basic search tool (I-Search) allows you to search after or before the location of your cursor.
To search for sometext after the location of your cursor (search-forward) hit C-s sometext. If you want to go to the next occurence of sometext, just press C-s again (and so on for the ne...
Set mark in cursor location:
C-space or C-@
Kill region (Cut):
C-w
Copy region to kill ring:
M-w or Esc-w
Yank (Paste) most recently killed:
C-y
Yank (Paste) next last killed:
M-y or Esc-y
Kill
killis the command used by Emacs for the deletion of ...
Use the task dependencies. Depending on how your modules are set up, it may be either ./gradlew dependencies or to see the dependencies of module app use ./gradlew :app:dependencies
The example following build.gradle file
dependencies {
compile 'com.android.support:design:23.2.1'
compile...
Using the System.String.Replace method, you can replace part of a string with another string.
string s = "Hello World";
s = s.Replace("World", "Universe"); // s = "Hello Universe"
All the occurrences of the search string are replaced.
This method can al...
Get all files in Directory
var FileSearchRes = Directory.GetFiles(@Path, "*.*", SearchOption.AllDirectories);
Returns an array of FileInfo, representing all the files in the specified directory.
Get Files with specific extension
var FileSearchRes = Directory.GetFiles(@Path, "*...
Put your dbname.sqlite or dbname.db file in assets folder of your project.
public class Databasehelper extends SQLiteOpenHelper {
public static final String TAG = Databasehelper.class.getSimpleName();
public static int flag;
// Exact Name of you db file that you put in as...
Having more than one element with the same ID is a hard to troubleshoot problem. The HTML parser will usually try to render the page in any case. Usually no error occurs. But the pace could end up in a mis-behaving web page.
In this example:
<div id="aDiv">a</div>
<div id...
A spring bean can be configured such that it will register only if it has a particular value or a specified property is met. To do so, implement Condition.matches to check the property/value:
public class PropertyCondition implements Condition {
@Override
public boolean matches(ConditionC...
Find meaningful names for computation units.
Use for comprehensions or map to combine computations together.
Let's say you have something like this:
if (userAuthorized.nonEmtpy) {
makeRequest().map {
case Success(respone) =>
someProcessing(..)
if (resendToUser) {
...
By default:
Use val, not var, wherever possible. This allows you to take seamless advantage of a number of functional utilities, including work distribution.
Use recursion and comprehensionss, not loops.
Use immutable collections. This is a corrolary to using val whenever possible.
Focus on da...
Another powerful & mature concurrency tool in Haskell is Software Transactional Memory, which allows for multiple threads to write to a single variable of type TVar a in an atomic manner.
TVar a is the main type associated with the STM monad and stands for transactional variable. They're used m...
Vectors can be map'd and fold'd,filter'd andzip`'d:
Prelude Data.Vector> Data.Vector.map (^2) y
fromList [0,1,4,9,16,25,36,49,64,81,100,121] :: Data.Vector.Vector
Reduce to a single value:
Prelude Data.Vector> Data.Vector.foldl (+) 0 y
66
These rules apply only if you use manual reference counting!
You own any object you create
By calling a method whose name begins with alloc, new, copy or mutableCopy.
For example:
NSObject *object1 = [[NSObject alloc] init];
NSObject *object2 = [NSObject new];
NSObject *object3 = [object2 ...
# Deny access to a directory from the IP 255.0.0.0
<Directory /path/to/directory>
order allow,deny
deny from 255.0.0.0
allow from all
</Directory>
# Deny access to a file from the IP 255.0.0.0
<FilesMatch "^\.ht">
order allow,deny
deny fro...
It is common for company to set up it's own nuget server for distribution of packages across different teams.
Go to Solution Explorer and click Right Mouse button then choose Manage NuGet Packages for Solution
In window that opens click on Settings
Click on + in top right corner the...
C++11
The std::is_same<T, T> type relation is used to compare two types. It will evaluate as boolean, true if the types are the same and false if otherwise.
e.g.
// Prints true on most x86 and x86_64 compilers.
std::cout << std::is_same<int, int32_t>::value << "\n&qu...
can either pass string of the json, or a filepath to a file with valid json
In [99]: pd.read_json('[{"A": 1, "B": 2}, {"A": 3, "B": 4}]')
Out[99]:
A B
0 1 2
1 3 4
Alternatively to conserve memory:
with open('test.json') as f:
data = pd.Da...
def to_flare_json(df, filename):
"""Convert dataframe into nested JSON as in flare files used for D3.js"""
flare = dict()
d = {"name":"flare", "children": []}
for index, row in df.iterrows():
parent = row[...
There are two ways to create object mocked by Mockito:
via annotation
via mock function
Via annotation:
With a JUnit test runner:
@RunWith(MockitoJUnitRunner.class)
public class FooTest {
@Mock
private Bar barMock;
// ...
}
You can also use Mockito's JUnit @Rule, which...