Tutorial by Examples: ect

Using GNU grep grep -r 'pattern' <directory path> To also list line numbers of matches use -n option grep -rn 'pattern' <directory path> To search only files with particular glob pattern grep --include='*.txt' -r 'pattern' <directory path> Exclude file patterns or direc...
Create custom class for calling multipart/form-data HttpURLConnection request MultipartUtility.java public class MultipartUtility { private final String boundary; private static final String LINE_FEED = "\r\n"; private HttpURLConnection httpConn; priva...
There are use cases when you might want to rename your app directory to something else. In Laravel4 you could just change a config entry, here's one way to do it in Laravel5. In this example we'll be renaming the app directory to src. Override Application class The directories name app is hardcod...
Applying a function to a collection/stream and creating a new collection/stream is called a projection. /// Projection var newReleases = [ [ "id": 70111470, "title": "Die Hard", "boxart": "http://cdn-0.nflximg.com/images...
When results need to have some logic applied 'on the fly' one can use CASE statement to implement it. SELECT CASE WHEN Col1 < 50 THEN 'under' ELSE 'over' END threshold FROM TableName also can be chained SELECT CASE WHEN Col1 < 50 THEN 'under' WHEN Col1 > 50 AND Col1 ...
Sometimes when tables are used mostly (or only) for reads, indexing does not help anymore and every little bit counts, one might use selects without LOCK to improve performance. SQL Server SELECT * FROM TableName WITH (nolock) MySQL SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;...
Enable USB Debugging on your device and from command line type adb devices. If everything is OK, the response should be: List of devices attached 1234567890 device Where 1234567890 is the device's id. If multiple devices are connected, you should see all of them: List of devices at...
Named vector can be created in several ways. With c: xc <- c('a' = 5, 'b' = 6, 'c' = 7, 'd' = 8) which results in: > xc a b c d 5 6 7 8 with list: xl <- list('a' = 5, 'b' = 6, 'c' = 7, 'd' = 8) which results in: > xl $a [1] 5 $b [1] 6 $c [1] 7 $d [1] 8 Wi...
Corner radius for all 4 edges: UIBezierPath* rectanglePath = [UIBezierPath bezierPathWithRoundedRect: CGRectMake(x,y,width,height) cornerRadius: 11]; [UIColor.grayColor setFill]; [rectanglePath fill]; Corner radius for top-left edge: UIBezierPath* rectanglePath = [UIBezierPath bezierPat...
Add the following dependency to your project level build.gradle file. dependencies { classpath "io.realm:realm-gradle-plugin:3.1.2" } Add the following right at the top of your app level build.gradle file. apply plugin: 'realm-android' Complete a gradle sync and you now have ...
You can force deallocate objects even if their refcount isn't 0 in both Python 2 and 3. Both versions use the ctypes module to do so. WARNING: doing this will leave your Python environment unstable and prone to crashing without a traceback! Using this method could also introduce security problems ...
The dot function can also be used to compute vector dot products between two one-dimensional numpy arrays. >>> v = np.array([1,2]) >>> w = np.array([1,2]) >>> v.dot(w) 5 >>> np.dot(w,v) 5 >>> np.dot(v,w) 5
You can test whether a point is inside a rectangle using Rectangle.containsPoint(): var point:Point = new Point(5, 5); var rectangle:Rectangle = new Rectangle(0, 0, 10, 10); var contains:Boolean = rectangle.containsPoint(point); // true
You can spec collections in a number of ways. coll-of allows you to spec collections and provide some additional constraints. Here's a simple example: (clojure.spec/valid? (clojure.spec/coll-of int?) [1 2 3]) ;; => true (clojure.spec/valid? (clojure.spec/coll-of int?) '(1 2 3)) ;; => tru...
Sometimes, you have to create two Disposable objects in a row. There is an easy way to avoid nesting Using blocks. This code Using File As New FileStream("MyFile", FileMode.Append) Using Writer As New BinaryWriter(File) 'You code here Writer.Writer("Hello&quot...
The rep function can be used to repeat a vector in a fairly flexible manner. # repeat counting numbers, 1 through 5 twice rep(1:5, 2) [1] 1 2 3 4 5 1 2 3 4 5 # repeat vector with incomplete recycling rep(1:5, 2, length.out=7) [1] 1 2 3 4 5 1 2 The each argument is especially useful for ex...
docker network inspect app-backend This command will output details about the app-backend network. The of the output of this command should look similar to: [ { "Name": "foo", "Id": "a0349d78c8fd7c16f5940bdbaf1adec8d8399b8309b2e8a969bd4e...
6 ES6: myFunction.name Explanation on MDN. As of 2015 works in nodejs and all major browsers except IE. 5 ES5: If you have a reference to the function, you can do: function functionName( func ) { // Match: // - ^ the beginning of the string // - function the w...
Using a Recursive CTE, you can generate an inclusive range of dates: Declare @FromDate Date = '2014-04-21', @ToDate Date = '2014-05-02' ;With DateCte (Date) As ( Select @FromDate Union All Select DateAdd(Day, 1, Date) From DateCte Where Date < @T...
context.rect(leftX, topY, width, height) Draws a rectangle given a top-left corner and a width & height. <!doctype html> <html> <head> <style> body{ background-color:white; } #canvas{border:1px solid red; } </style> <script> window.onload...

Page 31 of 99