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
| // regex to match and|or with minimal match to left and maximal to right /^\s*(.+?)\s+(or|and)\s+(.+?)\s*$/ | |
| // foo = 192.168.0.1 or foo = 192.168.0.110 and bar = baz | |
| // Gives "foo = 192.168.0.1", "or", "foo = 192.168.0.110 and bar = baz" | |
| // The third match is ready to be re-input to the regex | |
| // ...Or should it be the other way around with the maximal match on the left for correct left to right associativity? | |
| // Not sure right now, so keep it in mind removing the ? from (.+?) will do it /^\s*(.+)\s+(or|and)\s+(.+?)\s*$/ | |
| // | |
| // regex to match '=' /(\S+)\s*(=)\s*(\S+)/ | |
| // foo = 192.168.0.1 |
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
| @Override | |
| public void update( final @Nullable OnResult<LeoRootObject> resultHandler ) | |
| { | |
| // Throttle the update rate. | |
| long currentTime = System.currentTimeMillis(); | |
| long timeToNextUpdate = MIN_TIME_BETWEEN_UPDATES - currentTime -_lastTimeUpdated; | |
| if(timeToNextUpdate <= 0) | |
| { | |
| _lastTimeUpdated = currentTime; | |
| super.update(resultHandler); |
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
| #. | |
| # Add to the end of existing file | |
| #. | |
| #. | |
| # By default this is not a CI environment | |
| # To configure for CI either pass to the gradle command -PisCI=true or | |
| # set ORG_GRADLE_PROJECT_isCI=true in the environment | |
| isCI=false |
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 | |
| /** | |
| * Throttle the rate at which a function is called | |
| */ | |
| fun throttle(function: () -> Unit, rate: Long): () -> Unit { | |
| var throttled = false | |
| var called = false | |
| fun emit() { |
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
| package com.naimaudio.discovery.helpers | |
| import android.os.AsyncTask | |
| import java.net.InetAddress | |
| internal class Ping(val ipAddress: String, val timeout: Int = 100, val listener: (Boolean) -> Unit) : | |
| AsyncTask<Unit, Unit, Boolean>() { | |
| override fun doInBackground(vararg params: Unit?): Boolean { | |
| val address: InetAddress = InetAddress.getByName(ipAddress) |
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
| /** | |
| * withEither takes three parameters and returns a function. | |
| * When the returned function is called a decision is made to call either the first or second functions. | |
| * | |
| * @param {function} funcTrue The function to call if choice returns true | |
| * @param {function} funcFalse The function to call if choice returns false | |
| * @param {function} choice The function which returns true or false depending on the input params | |
| * @returns {function} | |
| */ | |
| const withEither = (funcTrue, funcFalse, choice) => { |
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 curryFn = function(fn, ...args) { | |
| return function(...args2) { | |
| return fn.apply(this, args.concat(args2)); | |
| }; | |
| }; |
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
| { | |
| "method": "$context.httpMethod", | |
| "body" : $input.json('$'), | |
| "headers": { | |
| #foreach($param in $input.params().header.keySet()) | |
| "$param": "$util.escapeJavaScript($input.params().header.get($param))" #if($foreach.hasNext),#end | |
| #end | |
| }, | |
| "queryParams": { |