Skip to content

Instantly share code, notes, and snippets.

@sakal
sakal / script-template.sh
Created December 27, 2020 23:11 — forked from m-radzikowski/script-template.sh
Minimal safe Bash script template - see the article with full description: https://betterdev.blog/minimal-safe-bash-script-template/
#!/usr/bin/env bash
set -Eeuo pipefail
trap cleanup SIGINT SIGTERM ERR EXIT
script_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd -P)
usage() {
cat <<EOF
Usage: $(basename "${BASH_SOURCE[0]}") [-h] [-v] [-f] -p param_value arg1 [arg2...]
sakal@sakal:~$ xrandr -q
Screen 0: minimum 8 x 8, current 1920 x 1080, maximum 8192 x 8192
VGA-0 connected 1920x1080+0+0 (normal left inverted right x axis y axis) 477mm x 268mm
1920x1080 60.0*+ 59.9
1920x1200 60.0
1680x1050 60.0 59.9
1600x1200 60.0
1440x900 59.9
1400x1050 60.0
1360x768 60.0 59.8
@sakal
sakal / gist:722ce2ef8bfda8235e1b5009e888bc65
Created March 28, 2018 14:35
py3.6 string format vs concat
> $ python3.6 [±claymore-115 ✓▴]
Python 3.6.5rc1 (default, Mar 14 2018, 06:54:23)
[GCC 7.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import timeit
>>> def d1(a, b):
... return a + '_' + b
...
>>> def d2(a, b):
... return '%s_%s' % (a, b)
@sakal
sakal / keytool-gen-x509.txt
Last active July 23, 2017 11:35
Generating X.509 Certificates
# https://www.playframework.com/documentation/2.5.x/CertificateGeneration
# https://jamielinux.com/docs/openssl-certificate-authority/create-the-intermediate-pair.html
# https://docs.docker.com/engine/security/certificates/
# http://pki-tutorial.readthedocs.io/en/latest/simple/root-ca.conf.html
# https://support.ssl.com/Knowledgebase/Article/View/19/0/der-vs-crt-vs-cer-vs-pem-certificates-and-how-to-convert-them
X.509 Certificates
Public key certificates are a solution to the problem of identity. Encryption alone is enough to set up a secure connection, but there’s no guarantee that you are talking to the server that you think you are talking to. Without some means to verify the identity of a remote server, an attacker could still present itself as the remote server and then forward the secure connection onto the remote server. Public key certificates solve this problem.
Vladimir Grishin, [24.07.16 11:26] aka @Vogre at t.me/react_js
но вообще в целом
//actioncreator
const fetchData(pageNum) = dispatch=>
fetch('mydata', {pageNum}).then(data=>dispatch({type: 'DATA_RECEIVED', payload: {data, pageNum}}))
//reducer
switch(action.type){
case 'DATA_RECEIVED':
name of display: :0
display: :0 screen: 0
direct rendering: Yes
server glx vendor string: SGI
server glx version string: 1.4
server glx extensions:
GLX_ARB_create_context, GLX_ARB_create_context_profile,
GLX_ARB_create_context_robustness, GLX_ARB_fbconfig_float,
GLX_ARB_framebuffer_sRGB, GLX_ARB_multisample,
GLX_EXT_create_context_es2_profile, GLX_EXT_create_context_es_profile,
@sakal
sakal / Xorg.0.log
Last active February 28, 2016 22:23
[ 7.647]
X.Org X Server 1.18.1
Release Date: 2016-02-08
[ 7.647] X Protocol Version 11, Revision 0
[ 7.647] Build Operating System: Linux 3.16.0-4-amd64 x86_64 Debian
[ 7.647] Current Operating System: Linux sakalz 4.4.0-1-amd64 #1 SMP Debian 4.4.2-3 (2016-02-21) x86_64
[ 7.647] Kernel command line: BOOT_IMAGE=/vmlinuz-4.4.0-1-amd64 root=/dev/mapper/sakalz--vg-root ro quiet cgroup_enable=memory swapaccount=1 radeon.dpm=1
[ 7.647] Build Date: 09 February 2016 11:06:03AM
[ 7.647] xorg-server 2:1.18.1-1 (http://www.debian.org/support)
[ 7.647] Current version of pixman: 0.33.6
sakalz# aptitude search "~ifirmware-linux"
i firmware-linux - Binary firmware for various drivers in the Linux kernel (meta-package)
i A firmware-linux-free - Binary firmware for various drivers in the Linux kernel
i firmware-linux-nonfree - Binary firmware for various drivers in the Linux kernel (meta-package)
sakalz#
sakalz# aptitude search "~ilibgl1-mesa"
i A libgl1-mesa-dev - free implementation of the OpenGL API -- GLX development files
i A libgl1-mesa-dri - free implementation of the OpenGL API -- DRI modules
i A libgl1-mesa-dri:i386
def isgameover(self):
player1 = self.game.player1
player2 = self.game.player2
if (player1 and player2) is None:
raise Exception("Not initialized players")
for barisan in self.enumseq():
if self.iscontainfive(barisan, player1):
return True
if self.iscontainfive(barisan, player2):
>>> foo = dict([v, k] for k, v in enumerate(["HELO", "INSERT", "REMOVE", "QUIT"]))
>>> foo
{'INSERT': 1, 'HELO': 0, 'REMOVE': 2, 'QUIT': 3}