Bazyli Brzóska – An inventor's portfolio https://invent.life Invent Life Wed, 22 Feb 2017 21:10:57 +0000 en-US hourly 1 https://wordpress.org/?v=4.8.2 Quick and stable “useradd” with group for Docker images https://invent.life/nesity/quick-stable-useradd-group-docker-images/ https://invent.life/nesity/quick-stable-useradd-group-docker-images/#respond Wed, 22 Feb 2017 21:10:57 +0000 https://invent.life/?p=349630536
useradd --shell /bin/bash -u $UID -o -c "" -U -m $USERNAME

 …

The post Quick and stable “useradd” with group for Docker images appeared first on Bazyli Brzóska - An inventor's portfolio.

]]>

useradd --shell /bin/bash -u $UID -o -c "" -U -m $USERNAME

 

The post Quick and stable “useradd” with group for Docker images appeared first on Bazyli Brzóska - An inventor's portfolio.

]]>
https://invent.life/nesity/quick-stable-useradd-group-docker-images/feed/ 0
Offloading responsibility as a programmer https://invent.life/nesity/offloading-responsibility-programmer/ https://invent.life/nesity/offloading-responsibility-programmer/#respond Wed, 17 Feb 2016 12:32:17 +0000 https://invent.life/?p=349630463

One of the fundamental rules that people should follow as programmers is to assume that they are terrible at it, and that means offloading risky stuff to either the language (preferably) or a standard library (if the language doesn’t have built-in support) where possible.

The post Offloading responsibility as a programmer appeared first on Bazyli Brzóska - An inventor's portfolio.

]]>

One of the fundamental rules that people should follow as programmers is to assume that they are terrible at it, and that means offloading risky stuff to either the language (preferably) or a standard library (if the language doesn’t have built-in support) where possible.

— rabish12

The post Offloading responsibility as a programmer appeared first on Bazyli Brzóska - An inventor's portfolio.

]]>
https://invent.life/nesity/offloading-responsibility-programmer/feed/ 0
Can a simulation experience pleasure and pain? https://invent.life/blog/can-a-simulation-experience-pleasure-and-pain/ https://invent.life/blog/can-a-simulation-experience-pleasure-and-pain/#respond Thu, 17 Sep 2015 22:46:05 +0000 https://invent.life/?p=349630445 Thoughts on simulating a human-like mind (part 1)

There have been many attempts at simulating the human mind.…

The post Can a simulation experience pleasure and pain? appeared first on Bazyli Brzóska - An inventor's portfolio.

]]>
Thoughts on simulating a human-like mind (part 1)

There have been many attempts at simulating the human mind. Most of them, like the Blue Brain Project, try the precise route of simulating the most basic elements, such as neurons, and hooking them up together like in a real brain. This might give equally precise results that might be of special interest to neurobiologists, however are computationally expensive, hard to execute and still lack the necessary precision in the input data.

On the other side of the AI spectrum we’ve got machine learning algorithms, often driven by neural networks, but often characterized by very mathematically rugged outputs.

I’d like to propose a higher-level simulation of the human psyche, rather than the brain itself. I borrow and expand on ideas such as semantic computing, or association rule learning to create a conceptual self-expanding, autonomous simulation.

Mind: A highly associative database

Daniel Kahneman’s deconstruction of the mind into “automatic System 1” and “slow-thinking System 2” brought to my attention the associative nature of our minds, and inspired me to translate it into a simple system of connected nodes.

Imagine the value of each node representing a concept – it may hold any data, such as text, a number, image or an executable action. New nodes are added to the systems when new “experiences” are recorded. A number of them are preprogrammed nodes, which I’ll later call “instincts”. Each connection between the nodes holds a strength-value that determines the order of search and propagation. Cluster-nodes might also appear when a new concept emerges out of a combination of other previously known ones. These would most commonly be specific instances of things vs general concepts (e.g. a specific apple vs apples in general) and compound concepts like [bun + sausage] = [hot-dog].

Repetition and context

When we’re learning a poem by heart, repetition strengthens the neural connections responsible for keeping that poem in our memory. Likewise, every time a node connection is accessed (or is simply traversed), it too gets reinforced. But with each access it also makes new connections and reinforcements with the nodes in the “buffer of context”. That “context” is a list of most-recently accessed nodes, the “short-term” memory of the simulation, so-to-speak. To make an analogy, a specific smell, or a long unheard song can remind us of a moment from our past – because, consciously or not, the concept of that moment got connected with the concept of that smell. This side-effect feature is one of the most defining and humanizing factors of the simulation, but also the source of the simulation’s potential to become “alive” by starting to do things “on it’s own”.

Trauma, pain and pleasure

Since context of our experiences is not always relevant or worthy of remembering, we are constantly polluting our minds – and in this case the simulation – with extraneous data.

People often develop irrational phobias because they experienced something traumatic in the past. The event had such a strong impression on the person that it created an equally strong connection with its context.

These are the basis of the evolutionary feedback loop that kept our ancestors alive. If I put a finger into fire and get negative feedback, I’m not likely to do that again. Equally so however, if the person is raped in a room painted blue, he might develop an irrational fear of blue rooms as an unwanted side effect.

It is interesting to note that such a simulation would be prone to trauma and even mental illness, preoccupation, distraction, perhaps even Schizophrenia. By exposing the simulation to certain inputs with a setting of rewarding stimuli, which is one that strengthens the connections with the intuitive-concept of “want more of” – could we call the simulation’s experiences an equivalent of pleasure? Would then exposing the simulation to negative stimuli, and hence strengthening the correlation with the intuition-“avoid” make it into a “painful” experience?

It might only be a philosophical question today, but a very pressing one to discuss. It’s worth noting that consciousness is not required to experience pain and pleasure, so how do we define those when we’re dealing with an AI?

What’s next?

If you’re interested in the topic, just drop me an email at b (at) invent.life, as I’d be very happy to chat with you and go deeper into the idea. I’m also open to research collaboration if you’re somebody who’d like to give such a project a shot.
Thanks for reading.

The post Can a simulation experience pleasure and pain? appeared first on Bazyli Brzóska - An inventor's portfolio.

]]>
https://invent.life/blog/can-a-simulation-experience-pleasure-and-pain/feed/ 0
RethinkDB, or how the right tools can turn your work into pleasure https://invent.life/blog/rethinkdb-or-how-the-right-tools-can-turn-your-work-into-pleasure-meetjs/ https://invent.life/blog/rethinkdb-or-how-the-right-tools-can-turn-your-work-into-pleasure-meetjs/#respond Fri, 03 Jul 2015 17:30:22 +0000 https://invent.life/?p=475

The post RethinkDB, or how the right tools can turn your work into pleasure appeared first on Bazyli Brzóska - An inventor's portfolio.

]]>

The post RethinkDB, or how the right tools can turn your work into pleasure appeared first on Bazyli Brzóska - An inventor's portfolio.

]]>
https://invent.life/blog/rethinkdb-or-how-the-right-tools-can-turn-your-work-into-pleasure-meetjs/feed/ 0
Using Pydio’s REST API (curl examples) https://invent.life/nesity/using-pydios-rest-api-curl-examples/ https://invent.life/nesity/using-pydios-rest-api-curl-examples/#comments Wed, 29 Apr 2015 22:00:13 +0000 http://nesity.improwizuj.pl/?p=441 There are literally no examples anywhere on how to use Pydio’s RESTful API.…

The post Using Pydio’s REST API (curl examples) appeared first on Bazyli Brzóska - An inventor's portfolio.

]]>
There are literally no examples anywhere on how to use Pydio’s RESTful API.
The official docs are often incorrect, don’t include many parameters or describe them wrong.
Here are a few examples that I got to through trail & error:

Uploading files:

curl 
    -u "$PYDIO_LOGIN:$PYDIO_PASSWORD" 
    --upload-file "$file" 
    --header "X-File-Name:$(basename "$file")" 
    "$PYDIO_HOST/api/${PYDIO_REPOSITORY}/upload/input_stream${PYDIO_TARGET_DIR}?auto_rename=${PYDIO_AUTORENAME}" 
    > /dev/null # redirect required to show a progress bar

Sharing files:

curl 
     -u "$PYDIO_LOGIN:$PYDIO_PASSWORD" 
     -X POST 
    "$PYDIO_HOST/api/${PYDIO_REPOSITORY}/share/public_link/${remotePath}?downloadlimit=${downloadLimit}&custom_handle=${customHandle}"

Other options you may use:
– password
– expiration (how many days until the link expires)

In the response body you’ll get the link to the file.

Downloading files:

curl 
    -u "$PYDIO_LOGIN:$PYDIO_PASSWORD" 
    --remote-name 
    "$PYDIO_HOST/api/${PYDIO_REPOSITORY}/download/${remoteFile}"

References:

The post Using Pydio’s REST API (curl examples) appeared first on Bazyli Brzóska - An inventor's portfolio.

]]>
https://invent.life/nesity/using-pydios-rest-api-curl-examples/feed/ 4
Dumping a sample from a MySQL instance or a database https://invent.life/nesity/dumping-a-sample-from-a-mysql-instance-or-a-database/ https://invent.life/nesity/dumping-a-sample-from-a-mysql-instance-or-a-database/#respond Wed, 29 Apr 2015 21:54:01 +0000 http://nesity.improwizuj.pl/?p=442 Say you want to dump a database, or even all databases, but with just a sample of all the data, say, 10 000 records per table of each of the databases.…

The post Dumping a sample from a MySQL instance or a database appeared first on Bazyli Brzóska - An inventor's portfolio.

]]>
Say you want to dump a database, or even all databases, but with just a sample of all the data, say, 10 000 records per table of each of the databases.
Here’s a way to do that:

mysqldump -uroot -p --all-databases --opt --where="1 limit 10000" > all-db-sample.sql

Reference: http://stackoverflow.com/questions/135835/limiting-the-number-of-records-from-mysqldump

The post Dumping a sample from a MySQL instance or a database appeared first on Bazyli Brzóska - An inventor's portfolio.

]]>
https://invent.life/nesity/dumping-a-sample-from-a-mysql-instance-or-a-database/feed/ 0
Running Pydio under Nginx and PHP5-FPM https://invent.life/nesity/running-pydio-under-nginx/ https://invent.life/nesity/running-pydio-under-nginx/#respond Wed, 29 Apr 2015 21:47:21 +0000 http://nesity.improwizuj.pl/?p=438 This is what you need to add to the server scope of your pydio host (please correct the paths to the data folder below):

location @shares {
            rewrite ^ /dav.php;
        }
        location ~ ^/index { }
        location ~ ^/plugins { }
        location ~ ^/shares {
            try_files $uri $uri/ @shares;
        }
        location ~ ^/user {
            rewrite ^ /index.php?get_action=user_access_point last;
        }
        location ~ ^/api {
            rewrite ^ /rest.php last;
        }
        location / {
            rewrite ^/(dashboard|welcome|settings|ws-) /index.php last;
        }
        rewrite ^/data/public/([a-zA-Z0-9_-]+).php$ /data/public/share.php?hash=$1 last;
        rewrite ^/data/public/([^=&?]+)$ /data/public/share.php?hash=$1 last;

        client_max_body_size 2047m;
        location ~ ^/conf       { deny all; }
        location ~ ^/data/public/
        {
            allow all;
        }
        location = /robots.txt  { access_log off; log_not_found off; }
        location = /favicon.ico { access_log off; log_not_found off; }
        location ~ /.

The post Running Pydio under Nginx and PHP5-FPM appeared first on Bazyli Brzóska - An inventor's portfolio.

]]>
This is what you need to add to the server scope of your pydio host (please correct the paths to the data folder below):

location @shares {
            rewrite ^ /dav.php;
        }
        location ~ ^/index { }
        location ~ ^/plugins { }
        location ~ ^/shares {
            try_files $uri $uri/ @shares;
        }
        location ~ ^/user {
            rewrite ^ /index.php?get_action=user_access_point last;
        }
        location ~ ^/api {
            rewrite ^ /rest.php last;
        }
        location / {
            rewrite ^/(dashboard|welcome|settings|ws-) /index.php last;
        }
        rewrite ^/data/public/([a-zA-Z0-9_-]+).php$ /data/public/share.php?hash=$1 last;
        rewrite ^/data/public/([^=&?]+)$ /data/public/share.php?hash=$1 last;

        client_max_body_size 2047m;
        location ~ ^/conf       { deny all; }
        location ~ ^/data/public/
        {
            allow all;
        }
        location = /robots.txt  { access_log off; log_not_found off; }
        location = /favicon.ico { access_log off; log_not_found off; }
        location ~ /.          { access_log off; log_not_found off; deny all; }
        location ~ ~$           { access_log off; log_not_found off; deny all; }

        location ~ ^/data/ { internal; }
        proxy_set_header X-Sendfile-Type X-Accel-Redirect;
        proxy_set_header X-Accel-Mapping /YOUR/PATH/TO/DATADIR/data/=/data/;
        fastcgi_param X-Accel-Mapping /YOUR/PATH/TO/DATADIR/data/=/data/;

PHP-FPM pool configuration:

php_admin_value[upload_max_filesize] = 10240M
php_admin_value[output_buffering] = Off
php_admin_value[max_file_uploads] = 20000
php_admin_value[file_uploads] = On
;php_flag[output_buffering] = 0
php_admin_value[post_max_size] = 10240M
php_admin_value[upload_max_size] = 10240M
php_admin_value[max_execution_time] = 300
php_admin_value[max_input_time] = -1
php_admin_value[memory_limit] = 2047M

The post Running Pydio under Nginx and PHP5-FPM appeared first on Bazyli Brzóska - An inventor's portfolio.

]]>
https://invent.life/nesity/running-pydio-under-nginx/feed/ 0
Replacing a RAID1 disk with GPT partition table https://invent.life/nesity/replacing-a-raid1-disk-with-gpt-partition-table/ https://invent.life/nesity/replacing-a-raid1-disk-with-gpt-partition-table/#respond Fri, 06 Mar 2015 19:35:08 +0000 http://nesity.improwizuj.pl/?p=430
sgdisk -R <New_Disk> <Existing_Disk>
# Also set a new GUID on new drive after cloning the partition table
sgdisk -G <New_Disk>

# Add new partitions to RAID, for example:
mdadm --manage /dev/md0 --add /dev/sda1
mdadm --manage /dev/md1 --add /dev/sda2
mdadm --manage /dev/md2 --add /dev/sda3

References:

The post Replacing a RAID1 disk with GPT partition table appeared first on Bazyli Brzóska - An inventor's portfolio.

]]>

sgdisk -R <New_Disk> <Existing_Disk>
# Also set a new GUID on new drive after cloning the partition table
sgdisk -G <New_Disk>

# Add new partitions to RAID, for example:
mdadm --manage /dev/md0 --add /dev/sda1
mdadm --manage /dev/md1 --add /dev/sda2
mdadm --manage /dev/md2 --add /dev/sda3

References:

The post Replacing a RAID1 disk with GPT partition table appeared first on Bazyli Brzóska - An inventor's portfolio.

]]>
https://invent.life/nesity/replacing-a-raid1-disk-with-gpt-partition-table/feed/ 0
Mounting dev & proc inside chrooted environment https://invent.life/nesity/mounting-dev-proc-inside-chrooted-environment/ https://invent.life/nesity/mounting-dev-proc-inside-chrooted-environment/#respond Sat, 07 Feb 2015 14:28:21 +0000 http://nesity.improwizuj.pl/?p=425
cd /mnt # or where you are preparing the chroot dir
mount -t proc proc proc/
mount -t sysfs sys sys/
mount -o bind /dev dev/

Source: http://superuser.com/a/417004/316130

The post Mounting dev & proc inside chrooted environment appeared first on Bazyli Brzóska - An inventor's portfolio.

]]>

cd /mnt # or where you are preparing the chroot dir
mount -t proc proc proc/
mount -t sysfs sys sys/
mount -o bind /dev dev/

Source: http://superuser.com/a/417004/316130

The post Mounting dev & proc inside chrooted environment appeared first on Bazyli Brzóska - An inventor's portfolio.

]]>
https://invent.life/nesity/mounting-dev-proc-inside-chrooted-environment/feed/ 0
Purging old, trashed or spam emails with DoveAdm (iRedMail) https://invent.life/nesity/purging-old-emails-trashed-or-spam-with-doveadm-iredmail/ https://invent.life/nesity/purging-old-emails-trashed-or-spam-with-doveadm-iredmail/#respond Sat, 10 Jan 2015 22:33:16 +0000 http://nesity.improwizuj.pl/?p=412
doveadm expunge -u '*@yourdomain.com' mailbox Trash savedbefore 7d

Source: http://www.iredmail.org/forum/topic6507-iredmail-support-howto-clean-trash-and-spam-folders-from-all-users.html

The post Purging old, trashed or spam emails with DoveAdm (iRedMail) appeared first on Bazyli Brzóska - An inventor's portfolio.

]]>

doveadm expunge -u '*@yourdomain.com' mailbox Trash savedbefore 7d

Source: http://www.iredmail.org/forum/topic6507-iredmail-support-howto-clean-trash-and-spam-folders-from-all-users.html

The post Purging old, trashed or spam emails with DoveAdm (iRedMail) appeared first on Bazyli Brzóska - An inventor's portfolio.

]]>
https://invent.life/nesity/purging-old-emails-trashed-or-spam-with-doveadm-iredmail/feed/ 0
Getting a download from BitBucket with Curl (wget doesn’t work) https://invent.life/nesity/getting-a-download-from-bitbucket-with-curl-wget-doesnt-work/ https://invent.life/nesity/getting-a-download-from-bitbucket-with-curl-wget-doesnt-work/#comments Sat, 10 Jan 2015 21:09:56 +0000 http://nesity.improwizuj.pl/?p=410 I was trying to install iRedMail, but it’s just impossible to download it.…

The post Getting a download from BitBucket with Curl (wget doesn’t work) appeared first on Bazyli Brzóska - An inventor's portfolio.

]]>
I was trying to install iRedMail, but it’s just impossible to download it. Neither wget or curl does the trick without some curl-fu applied.

curl -L -O https://bitbucket.org/zhb/iredmail/downloads/iRedMail-0.9.0.tar.bz2

The key is using the -L switch. wget’s equivalent should be “–content-disposition” but that still doesn’t work when downloading from bitbucket. Just gives a 403 and gives up.

The post Getting a download from BitBucket with Curl (wget doesn’t work) appeared first on Bazyli Brzóska - An inventor's portfolio.

]]>
https://invent.life/nesity/getting-a-download-from-bitbucket-with-curl-wget-doesnt-work/feed/ 1
Good security practice with CloudFlare in combination with IPv6 https://invent.life/nesity/good-security-practice-with-cloudflare-and-great-usefulness-of-ipv6/ https://invent.life/nesity/good-security-practice-with-cloudflare-and-great-usefulness-of-ipv6/#respond Sat, 03 Jan 2015 11:34:44 +0000 http://nesity.improwizuj.pl/?p=405 Since CloudFlare can make sites listening exclusively on IPv6 accessible to people with a IPv4-only connection, I decided to remove the A records altogether and let CloudFlare connect with my server via IPv6 exclusively.…

The post Good security practice with CloudFlare in combination with IPv6 appeared first on Bazyli Brzóska - An inventor's portfolio.

]]>
Since CloudFlare can make sites listening exclusively on IPv6 accessible to people with a IPv4-only connection, I decided to remove the A records altogether and let CloudFlare connect with my server via IPv6 exclusively.

This seems like a really good practice. Here’s why. For one, I don’t even need to assign a public IPv4 for the server at all (which some hosts that’s saving money). The other benefit is that it, arguably, somewhat increases security, by making it harder to find out the real IP of the backend server. Most evil-bots do bruteforce scans via IPv4 nowadays, only because there are only so many combinations, and trying them all seems quite plausible. With the massive IPv6 pool, it effectively decreases the possibility of finding out and hitting the right IPv6 to attack. It’s simply about the chances of finding out the real IP – since you’re routing all traffic via IPv6, nobody should, in theory, find out the real IPv6 of your backend. Even though it is “security by obscurity”, it gives measurable benefits and in effect is an extra layer of defense. Don’t treat it as the only one, though.

One more tip: Don’t decrease the entropy of finding out your real IPv6 by only using the last bits and leaving the middle part with zeros. Make a truly random subnet and if you can, randomize the last segment (don’t use sequential mapping too). Don’t use word-based IPv6 addresses either, since they’re too cool and seem to be the first thing to try by potential evil IPv6-enabled scanners. Means unfortunately no dead:dad:beef:cafe in your address :-)

Note: CloudFlare has a bug with internal routing, making it impossible to use CNAME records pointing to domains which only define AAAA records that are CloudFlare enabled. When you only have a CNAME pointing to a AAAA record, you’ll get CloudFlare Error 1000: DNS points to prohibited IP.
It seems to me this is a bug – CloudFlare is trying to route all CNAME record only to A records and doesn’t even try to use available AAAA records.
The workaround is to replace all CNAMEs for AAAA records, avoiding any CNAME for CF-enabled subdomains, but that makes it tiresome to update a record in the future (you’ll have to update all the subdomain records). I’ve reported that bug to CloudFlare.

The post Good security practice with CloudFlare in combination with IPv6 appeared first on Bazyli Brzóska - An inventor's portfolio.

]]>
https://invent.life/nesity/good-security-practice-with-cloudflare-and-great-usefulness-of-ipv6/feed/ 0
Creating encrypted loopfs under Ubuntu https://invent.life/nesity/creating-encrypted-loopfs-under-ubuntu/ https://invent.life/nesity/creating-encrypted-loopfs-under-ubuntu/#respond Wed, 31 Dec 2014 18:30:43 +0000 http://nesity.improwizuj.pl/?p=403
  • https://www.digitalocean.com/community/tutorials/how-to-use-dm-crypt-to-create-an-encrypted-volume-on-an-ubuntu-vps
  • https://wiki.archlinux.org/index.php/Dm-crypt/Encrypting_a_non-root_file_system
  • https://wiki.archlinux.org/index.php/Tomb
  • The post Creating encrypted loopfs under Ubuntu appeared first on Bazyli Brzóska - An inventor's portfolio.

    ]]>
  • https://www.digitalocean.com/community/tutorials/how-to-use-dm-crypt-to-create-an-encrypted-volume-on-an-ubuntu-vps
  • https://wiki.archlinux.org/index.php/Dm-crypt/Encrypting_a_non-root_file_system
  • https://wiki.archlinux.org/index.php/Tomb
  • The post Creating encrypted loopfs under Ubuntu appeared first on Bazyli Brzóska - An inventor's portfolio.

    ]]>
    https://invent.life/nesity/creating-encrypted-loopfs-under-ubuntu/feed/ 0
    UFW deny all but one IP https://invent.life/nesity/ufw-deny-all-but-one-ip/ https://invent.life/nesity/ufw-deny-all-but-one-ip/#respond Fri, 14 Nov 2014 11:55:45 +0000 http://nesity.improwizuj.pl/?p=387

    Put the specific rules first and the generic second. Once a rule is matched the others will not be evaluated (see manual below) so you must put the specific rules first.

    The post UFW deny all but one IP appeared first on Bazyli Brzóska - An inventor's portfolio.

    ]]>

    Put the specific rules first and the generic second. Once a rule is matched the others will not be evaluated (see manual below) so you must put the specific rules first. As rules change you may need to delete old rules to ensure that new rules are put in the proper order.

    So, first add “allow from XXX port 1234”, later “deny 1234”.

    The post UFW deny all but one IP appeared first on Bazyli Brzóska - An inventor's portfolio.

    ]]>
    https://invent.life/nesity/ufw-deny-all-but-one-ip/feed/ 0
    nginx & PHP – no output, no error https://invent.life/nesity/nginx-php-no-output-no-error/ https://invent.life/nesity/nginx-php-no-output-no-error/#respond Thu, 13 Nov 2014 23:27:59 +0000 http://nesity.improwizuj.pl/?p=382 This is a terrible thing to debug. No output, no error, could mean you’re missing this parameter.…

    The post nginx & PHP – no output, no error appeared first on Bazyli Brzóska - An inventor's portfolio.

    ]]>
    This is a terrible thing to debug. No output, no error, could mean you’re missing this parameter.

    fastcgi_param  SCRIPT_FILENAME    $document_root$fastcgi_script_name;

    The post nginx & PHP – no output, no error appeared first on Bazyli Brzóska - An inventor's portfolio.

    ]]>
    https://invent.life/nesity/nginx-php-no-output-no-error/feed/ 0