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...
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...
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...
The blob.slice() method is used to create a new Blob object containing the data in the specified range of bytes of the source Blob. This method is usable with File instances too, since File extends Blob.
Here we slice a file in a specific amount of blobs. This is useful especially in cases where yo...
The flatMap operator help you to transform one event to another Observable (or transform an event to zero, one, or more events).
It's a perfect operator when you want to call another method which return an Observable
public Observable<String> perform(int i) {
// ...
}
Observabl...
The Fibonacci numbers are defined inductively as
F0 = 0
F1 = 1
Fn+2 = Fn + Fn+1
The sum of the first n+1 Fibonacci numbers is given by
F0 + F1 + F2 + ... + Fn = Fn+2 - 1.
This summation arises, among other places, in the analysis of Fibonacci heaps, where it's used to provide a lower b...
You can animate complex changes to your collection view using the performBatchUpdates method. Inside the update block, you can specify several modifications to have them animate all at once.
collecitonView.performBatchUpdates({
// Perform updates
}, nil)
Inside the update block, you can pe...
Pressing C-h a will run the emacs function apropos-command which makes emacs prompt for words (or a regexp) to search for. It will then show a buffer containing a list of names and descriptions related to that topic, including key bindings for each of the functions available via keystrokes.
Pressin...
C-h f runs the function describe-function, which displays information on the usage and purpose of a given function. This is especially useful for functions that do not have a mapped key binding that can be used for documentation lookup via C-h k.
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
select returns a new hash with key-value pairs for which the block evaluates to true.
{ :a => 1, :b => 2, :c => 3 }.select { |k, v| k != :a && v.even? } # => { :b => 2 }
When you will not need the key or value in a filter block, the convention is to use an _ in that place:...
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 ...
Here is a quick example of using multiple forms in one Django view.
from django.contrib import messages
from django.views.generic import TemplateView
from .forms import AddPostForm, AddCommentForm
from .models import Comment
class AddCommentView(TemplateView):
post_form_class = AddPo...
Many unbound generic parameters, like those used in a static method, cannot be recovered at runtime (see Other Threads on Erasure). However there is a common strategy employed for accessing the type satisfying a generic parameter on a class at runtime. This allows for generic code that depends on ac...
# 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...
When your app crashes, Xcode will enter the debugger and show you more information about the crash:
The most important parts are:
The red arrow
The red arrow displays which line of code crashed & why it crashed.
The debugger console
Many crashes log more information to the debugger consol...
If you either have apps generated with pre-android support or just did that on purpose, you can always add android project to your app.
$ react-native android
This will generate android folder and index.android.js inside your app.