Skip to content

Instantly share code, notes, and snippets.

View fiftin's full-sized avatar

Denis Gukov fiftin

View GitHub Profile
#/bin/bash
ip_address=$(dig $1 +short)
instance_id=$(aws ec2 describe-instances --filters Name=private-ip-address,Values=${ip_address} --output text --query 'Reservations[*].Instances[*].{Instance:InstanceId}')
mssh ubuntu@${instance_id}
@fiftin
fiftin / wsl.md
Created October 8, 2022 12:53 — forked from alyleite/wsl.md
Failed to connect to bus: Host is down - WSL 2

» sudo systemctl daemon-reload

System has not been booted with systemd as init system (PID 1). Can't operate. Failed to connect to bus: Host is down

just try:

sudo apt-get update && sudo apt-get install -yqq daemonize dbus-user-session fontconfig

sudo daemonize /usr/bin/unshare --fork --pid --mount-proc /lib/systemd/systemd --system-unit=basic.target

@fiftin
fiftin / sendmail_setup.md
Created October 2, 2022 18:41 — forked from kany/sendmail_setup.md
Setup SENDMAIL on Mac OSX Yosemite
@fiftin
fiftin / mysql-docker.sh
Created September 19, 2022 10:35 — forked from spalladino/mysql-docker.sh
Backup and restore a mysql database from a running Docker mysql container
# Backup
docker exec CONTAINER /usr/bin/mysqldump -u root --password=root DATABASE > backup.sql
# Restore
cat backup.sql | docker exec -i CONTAINER /usr/bin/mysql -u root --password=root DATABASE

LDAP client configuration (Ansible Semaphore config.json):

{
  "ldap_enable": true,
  "ldap_needtls": false,
  "ldap_binddn": "cn=admin,dc=example,dc=org",
  "ldap_bindpassword": "adminpassword",
 "ldap_server": "localhost:1389",
@fiftin
fiftin / commands.sh
Last active October 29, 2024 16:23
Useful commands
# Join array in Bash
mount_lines=(
"mount to test 123",
"mount to test 545",
)
mount_lines_str=""
for line in "${mount_lines[@]}"
@fiftin
fiftin / index.js
Last active November 21, 2020 14:35
AWS Lambda for implementing static site with using S3 and CloudFront.
const path = require('path');
exports.handler = (event, context, callback) => {
const request = event.Records[0].cf.request;
if (!path.extname(request.uri)) {
if (!request.uri.endsWith('/')) {
request.uri += '/';
}
request.uri += 'index.html';
}
@fiftin
fiftin / docker-compose.yml
Created November 1, 2020 06:38
Ansible Semaphore 2.5.3
# This dockerfile provides an example of using the production image in a working stack
version: '2'
services:
mysql:
ports:
- 3306:3306
image: mysql:5.6
hostname: mysql
@fiftin
fiftin / is-email.js
Created June 2, 2020 16:50
Email regexp (JavaScript)
function isEmail(s) {
return /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/.test(s);
}
@fiftin
fiftin / download-file.js
Created March 29, 2020 14:34 — forked from javilobo8/download-file.js
Download files with AJAX (axios)
axios({
url: 'http://localhost:5000/static/example.pdf',
method: 'GET',
responseType: 'blob', // important
}).then((response) => {
const url = window.URL.createObjectURL(new Blob([response.data]));
const link = document.createElement('a');
link.href = url;
link.setAttribute('download', 'file.pdf');
document.body.appendChild(link);