Skip to content

Instantly share code, notes, and snippets.

View sotnikov-link's full-sized avatar
🛸
UFO driver

Valeriy Sotnikov sotnikov-link

🛸
UFO driver
View GitHub Profile
@amorev
amorev / bash
Last active December 30, 2024 10:48
Telegram backup script
# создаем один tar.bz2 архив
backupDirectory=<backups_directory>
projectDirectory=<projects_directory>
chatId=<telegram_chat_id>
botToken=<telegram_bot_token>
cd $backupDirectory
tar -cvjf $backupDirectory/archive.full.tar.bz2 $projectDirectory
split -b 40M archive.full.tar.bz2 "archiver.tar.bz.part"
for i in `ls $backupDirectory | grep part`
@ubergesundheit
ubergesundheit / readme.md
Last active April 17, 2025 16:30
systemd traefik.service

systemd Service Unit for Traefik

Adapted from caddy systemd Service Unit

The provided file should work with systemd version 219 or later. It might work with earlier versions. The easiest way to check your systemd version is to run systemctl --version.

Instructions

We will assume the following:

@Roadmaster
Roadmaster / google-chrome-lxc.sh
Created October 18, 2017 21:16
Set up an lxc container with google chrome so it runs confined but displays on localhost.
#!/bin/bash
# Set up an lxc container with google chrome so it runs confined but displayed on the
# localhost.
# Adapted from https://blog.simos.info/how-to-run-graphics-accelerated-gui-apps-in-lxd-containers-on-your-ubuntu-desktop/
# Assume setguid/setid for root is properly setup
# root:1000:1
# Assume aptcache profile exists, see https://gist.github.com/Roadmaster/754110f3f49fef19ec89ae29f29edd11
LXC_NAME=chrome-container
@ChrisCates
ChrisCates / sha-emoji.js
Last active October 17, 2023 05:10
Emoji in a SHA like format.
let emoji_list = [
"😀", "😃", "😄", "😁", "😆", "😅", "😂", "🤣", "😊", "😇", "🙂", "🙃", "😉", "😌", "😍", "😘", "😗", "😚", "😋",
"😜", "😝", "😛", "🤑", "🤗", "🤓", "😎", "🤡", "🤠", "😏", "😒", "😞", "😔", "😟", "😕", "🙁", "☹️", "😣", "😖", "😫", "😩",
"😤", "😠", "😡", "😶", "😐", "😑", "😯", "😦", "😧", "😮", "😲", "😵", "😳", "😱", "😨", "😰", "😢", "😥", "🤤", "😭", "😓",
"😪", "😴", "🙄", "🤔", "🤥", "😬", "🤐", "🤢", "🤧", "😷", "🤒", "🤕", "😈", "👿", "👹", "👺", "💩", "👻", "💀", "☠️", "👽",
"👾", "🤖", "🎃", "😺", "😸", "😹", "😻", "😼", "😽", "🙀", "😿", "😾", "👐", "🙌", "👏", "🙏", "🤝", "👍", "👎", "👊", "✊",
"🤛", "🤜", "🤞", "✌️", "🤘", "👌", "👈", "👉", "👆", "👇", "☝️", "✋", "🤚", "🖐", "🖖", "👋", "🤙", "💪", "🖕", "✍️", "🤳",
"💅", "🖖", "💄", "💋", "👄", "👅", "👂", "👃", "👣", "👁", "👀", "🗣", "👤", "👥", "👶", "👦", "👧", "👨", "👩", "👱"
];
@risingnote
risingnote / jest-suppertest.js
Last active September 25, 2017 16:39
Use Jest (Jasmine) and supertest to test REST API.
// Need to run test async and use jest/jasmine done.fail to let it know when an assertion did not work.
const routerUnderTest = require('../../client_api')
const httptest = require('supertest')
const express = require('express')
const app = express()
app.use('/', routerUnderTest)
describe('I can use the REST api', () => {
it('displays text for the landing page', (done) => {
@mheiber
mheiber / app.js
Created January 7, 2016 02:38
Memoizing React stateless function components
import React from 'react';
import {render} from 'react-dom';
import memoize from 'memoization';
const Foo = ({number}) => {
console.log(`Rendering with number= ${number}`);
return <div>{number}</div>
};
// `memoize` caches the return value of a function.
@branneman
branneman / better-nodejs-require-paths.md
Last active April 11, 2025 10:39
Better local require() paths for Node.js

Better local require() paths for Node.js

Problem

When the directory structure of your Node.js application (not library!) has some depth, you end up with a lot of annoying relative paths in your require calls like:

const Article = require('../../../../app/models/article');

Those suck for maintenance and they're ugly.

Possible solutions

@pjdietz
pjdietz / Virtual Box Host Only Static IP.md
Created June 12, 2013 19:01
VirtualBox Host-Only Adapter with Static IP

VirtualBox Host-Only Static IP

My typical setup for a development box in VirtualBox uses two NICs. The first uses NAT to allow the box to communicate with the outside world through my host computer’s network connection. (NAT is the default, so shouldn't require any setup.) The second is a "host-only" connection that allows my host and guest to interact.

To create a host-only connection in VirtualBox, start by opening the preferences in VirtualBox. Go to the "Network" tab, and addd a Host-only Network. Modify the host-only network, and disable DHCP. Make a note of the IP address. (Feel free to set the IP address as well, if you like.)

Next, assign this host-only adapter to the virtual machine. Select the VM and press "Settings". Go to the "Network" tab, and select "Adpater 2". Enable the adapter, set it to a "Host-only Adapter", and select the adpater you created above.

Temporary

@bartoszmajsak
bartoszmajsak / prepare-commit-msg.sh
Last active January 22, 2025 09:31
How to automatically prepend git commit with a branch name
#!/bin/bash
# This way you can customize which branches should be skipped when
# prepending commit message.
if [ -z "$BRANCHES_TO_SKIP" ]; then
BRANCHES_TO_SKIP=(master develop test)
fi
BRANCH_NAME=$(git symbolic-ref --short HEAD)
BRANCH_NAME="${BRANCH_NAME##*/}"