Instantly share code, notes, and snippets.

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 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 realtime-tracking-stdout-line-count.sh
docker logs -f --since 2s $(docker ps -qa --filter "name=CONTAINER_NAME") | pv -l -c > /dev/null
View access-static-constant-thymeleaf.md

From expercise project:

<td>
  <input class="form-control" type="text" name="inputValue"
          th:maxlength="${T(com.expercise.utils.Constants).MAX_TESTCASE_VALUE_LENGTH}" />
</td>
View last-records-on-elasticsearch.sh
curl -XGET "http://ES_CLUSTER/_search" -H 'Content-Type: application/json' -d'
{
"query": {
"range" : {
"@timestamp" : {
"gte" : "now-15m",
"lt" : "now"
}
}
}
View macos-mail-gmail-mail-complete.md
  • Address Book uygulamasında Preferences > Account sekmesinde Google hesabını etkinleştir.
  • Uygulamanın sunucuyla senkronize olmasını bekle.
  • Mail uygulamasını kapat aç.
View delete-by-query.json
POST INDEX_NAME/_delete_by_query
{
"query": {
"bool": {
"must": [
{
"term": {
"field1": "100"
}
},
View favorite-keygen-music-playlist.md
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;