View split-into-subarrays.js
/*
* Splits array into subarrays.
* count parameter indicates that how many item per subarray contains.
* Example usage: splitIntoSubArray([1,2,3,4,5], 2) -> [[1, 2], [3, 4], [5]]
*/
function splitIntoSubArray(arr, count) {
var newArray = [];
while (arr.length > 0) {
newArray.push(arr.splice(0, count));
}
View disable-vino-encryption.sh
gsettings set org.gnome.Vino require-encryption false
View update-rows-using-subquery.sql
UPDATE cars
SET model = subNewCarsTable.newModelName
FROM (SELECT
nc.id AS carId,
nc.model AS newModelName
FROM new_cars nc
WHERE year=2018) subNewCarsTable
WHERE subNewCarsTable.carId = cars.id;
View elasticsearch-adjust-max-result-window.sh
# tested on Elasticseach 6.0.0
curl -XPUT "http://es-host:9200/my_index/_settings" -H 'Content-Type:application/json' -d '{ "index" : { "max_result_window" : 1000000 } }'
View adjust-fileupload-size-ingress.yml
# tested on kubernetes 1.10.5
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
annotations:
# "0" for unlimited fileupload size
nginx.org/client-max-body-size: "100m"
name: myproject-gateway-ingress
View adjust-payload-size-ingress.yml
# tested on kubernetes 1.10.5
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
annotations:
nginx.ingress.kubernetes.io/proxy-body-size": "100m"
name: myproject-gateway-ingress
View adjust-timeouts-ingress.yml
# tested on kubernetes 1.10.5
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
annotations:
nginx.ingress.kubernetes.io/proxy-connect-timeout: "750"
nginx.ingress.kubernetes.io/proxy-read-timeout": "600"
name: my-project-gateway-ingress
View attach-listener-to-push-method.js
var eventify = function(arr, callback) {
arr.push = function(e) {
Array.prototype.push.call(arr, e);
callback(arr);
};
};
var array = [1,2,3];
eventify(array, function(newArray) {
View MockFinalClass.java
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mockito;
import org.powermock.api.mockito.PowerMockito;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
@RunWith(PowerMockRunner.class)
@PrepareForTest(MyFinalClass.class)
public class MyFinalClassTest {