Skip to content

Instantly share code, notes, and snippets.

ksdev-pl / naturalOrderBy.js
Last active December 2, 2022 11:03
Natural sort orderBy filter for vue.js #js
naturalSort.insensitive = true;
Vue.filter('naturalOrderBy', function (arr, sortKey, reverse) {
if (!sortKey) {
return arr;
var order = (reverse && reverse < 0) ? -1 : 1;
return arr.slice().sort(naturalSort.bind(null, sortKey, order));
ksdev-pl /
Last active August 29, 2015 14:14
Write / append some text to a file #serwer

If you want to write some text to a file that needs a root privileges, you do it this way:

echo "Text I want to write" | sudo tee /path/to/file > /dev/null


sudo sh -c 'echo "Text I want to write" > /path/to/file'

If you just want to append some text, you do it this way:

ksdev-pl /
Last active August 29, 2015 14:12
"This" in JavaScript #js
  1. The keyword "this" refers to whatever is left of the dot at call-time.
  2. If there's nothing to the left of the dot, then "this" is the root scope (e.g. Window).
  3. A few functions change the behavior of "this"—bind, call and apply
  4. The keyword "new" binds this to the object just created

So if you're using the value of "this" in someFunction...

thing.someFunction(); // this === thing
someFunction();       // this === Window
new someFunction(); // this === the newly created object
ksdev-pl /
Created November 30, 2014 17:48
Znajdź i usuń plik #serwer

To remove multiple files such as *.jpg or *.sh with one command find, use:

find . -name "FILE-TO-FIND" -exec rm -rf {} \;


find . -type f -name "FILE-TO-FIND" -exec rm -f {} \;

The only difference between above two syntax is that the first command remove directories as well where second command only removes files. Options:

ksdev-pl /
Last active October 15, 2020 07:26
Polling (setInterval, setTimeout) #js

The setInterval Technique

Now, if you needed to poll your web service, your first instinct might be to do something like this with JavaScript and jQuery:

    $.ajax({ url: "server", success: function(data){
        //Update your dashboard gauge
 }, dataType: "json"});
C:\Program Files (x86)\JetBrains\PyCharm Community Edition 3.1.2\helpers\ run on 07/24/14 19:34:45
DEPRECATION: --no-install, --no-download, --build, and --no-clean are deprecated. See
Downloading/unpacking pelican
Getting page
URLs to search for versions for pelican:
Analyzing links from page
Found link (from, version: 3.4.0
Found link (from, version: 1.1.1
ksdev-pl /
Last active November 28, 2015 16:17
Usuń pliki i foldery starsze niż #serwer
find /home/protected/app/storage/backups/* -type d -not -newerct '30 minutes ago' -print0 | xargs -r rm -rf
find /var/www/* -type d -mmin +30 -exec rm -rf {} +
ksdev-pl /
Last active August 29, 2015 14:01
Identyfikacja, uwierzytelnianie i autoryzacja #metodyka

Identyfikacja (identification)

Podmiot deklaruje swoją tożsamość (identity). Na przykład:

  • w rozmowie telefonicznej z centrum obsługi banku klient deklaruje swoje imię, nazwisko i numer konta (bank jest stroną ufającą);
  • w procesie logowania do serwera użytkownik wpisuje nazwę (login) (serwer jest stroną ufającą);
  • podczas połączenia przeglądarki z serwerem SSL, ten ostatni przedstawia certyfikat X.509 zawierający jego nazwę (przeglądarka jest stroną ufającą).

Uwierzytelnianie (authentication)

Strona ufająca stosuje odpowiednią technikę uwierzytelniania (authentication mechanism) w celu weryfikacji zadeklarowanej wcześniej tożsamości. Na przykład:

ksdev-pl /
Last active August 29, 2015 14:01
RESTful routes #metodyka
Verb Path Action Route Name
GET /resource index resource.index
GET /resource/create create resource.create
POST /resource store
GET /resource/{resource} show
GET /resource/{resource}/edit edit resource.edit
PUT/PATCH /resource/{resource} update resource.update
DELETE /resource/{resource} destroy resource.destroy