Skip to content

Instantly share code, notes, and snippets.

@jacekk
jacekk / make-nokia-130-contacts-unique.js
Created January 23, 2021 19:39
make-nokia-130-contacts-unique.js
const fs = require("fs");
const lineDelimiter = "\r\n";
const entryDelimiter = "";
const lines = fs.readFileSync("./non-unique.txt", {
encoding: "utf8",
flag: "r",
});
@jacekk
jacekk / get_next_tag.sh
Last active December 21, 2020 02:18
Calculate next release tag based on latest
#!/bin/bash
# Example next versions when latest tag is 'v2.4.6':
# - major --> v3.0.0
# - minor --> v2.5.0
# - patch --> v2.4.7
# ------------------------------------------------------
TAGS_PREFIX="v"
@jacekk
jacekk / test-go-modules-and-tests.sh
Created May 17, 2019 14:57
Testing Go modules and test command
16:43:30 ~/development/go/test-go-modules-and-tests
$ ll ~/go-work/pkg/mod/github.com/shopspring
ls: cannot access '/home/jacekk/go-work/pkg/mod/github.com/shopspring': No such file or directory
16:43:46 ~/development/go/test-go-modules-and-tests
$ ll
total 8,0K
-rw-rw-r-- 1 jacekk jacekk 141 May 17 16:19 foo.go
-rw-rw-r-- 1 jacekk jacekk 211 May 17 16:23 foo_test.go
@jacekk
jacekk / simple-pagination.js
Created March 30, 2019 17:59 — forked from kottenator/simple-pagination.js
Simple pagination algorithm
// Implementation in ES6
function pagination(c, m) {
var current = c,
last = m,
delta = 2,
left = current - delta,
right = current + delta + 1,
range = [],
rangeWithDots = [],
l;
#!/bin/bash
# Usage: ./s3-remove-old-files "bucket-name" "nested-path" 1000
if [ ! "$1" ]; then
echo "1st arg (bucket name) NOT specified !!"
exit 1
fi
if [ ! "$2" ]; then
echo "2nd arg (bucket sublocations) NOT specified !!"
@jacekk
jacekk / ua.php
Created December 23, 2018 19:15
UA subdomain
<!DOCTYPE html>
<html>
<head>
<title>RQ debug</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
</head>
<body>
<div class="container">
<div class="row">&nbsp;</div>
@jacekk
jacekk / console-ouput.sh
Last active January 12, 2018 22:21
nodeJS imports and singletons
$ node ./test-imports.js
Ghost created
Ghost says: x
Ghost says: a
Ghost says: b
Ghost says: c
@jacekk
jacekk / input.js
Last active January 12, 2018 22:20
for in vs. for of in JS / ES6
const assocArray = ['zero', 'one', 2, 3, 4];
assocArray['five'] = 5;
assocArray[7] = 'seven';
const plainObj = {
zero: '0',
one: '1',
2: 'two',
4: 4,
5: 'fifth',
@jacekk
jacekk / git-branches-by-commit-date.sh
Created November 29, 2017 08:09 — forked from l15n/git-branches-by-commit-date.sh
List remote Git branches and the last commit's author and author date for each branch. Sort by most recent commit's author date.
# Credit http://stackoverflow.com/a/2514279
for branch in `git branch -r | grep -v HEAD`;do echo -e `git show --format="%ai %ar by %an" $branch | head -n 1` \\t$branch; done | sort -r
@jacekk
jacekk / list.js
Created November 21, 2017 10:46
list all non-native window props
Object.keys(window).filter(function(x) {
return window[x] instanceof Function && !/\[native code\]/.test(window[x].toString());
});