Skip to content

Instantly share code, notes, and snippets.

View lavir's full-sized avatar

Alex Lukyanov lavir

  • ContractMill
  • Finland
View GitHub Profile
@lavir
lavir / get-hardcore.sh
Created August 24, 2018 09:13 — forked from mfojtik/get-hardcore.sh
Initialize a developer machine in DigitalOcean
#!/bin/bash
#
#
size=512mb
remote_user=mfojtik
# size=32gb
#
#
echo "--> Waiting for 'dev' (size: $size) to be ready ..."
doctl compute droplet create dev \
@lavir
lavir / slackstatus.sh
Created October 13, 2017 10:34
A command line utility for changing your Slack status.
#!/bin/bash
slacktoken=INSERT_SLACK_TOKEN_HERE
apiurl="https://slack.com/api/users.profile.set?token="$slacktoken"&profile="
lastname="LAST_NAME_HERE"
if [ $# -eq 0 ]
then
status=""
else
status=" | $@"
@lavir
lavir / pocket_exporter.py
Created June 20, 2017 09:24 — forked from jasonrdsouza/pocket_exporter.py
Export archived article data from Pocket
'''This script can be used to export data from Pocket (getpocket.com)
Uses include migrating to a different "read it later" service, saving
specific articles to another service, backing up your reading history,
and more.
Currently it can be used to export links and metadata for archived
articles with a given tag, which are more recent than a given timestamp.
An example use case is to export all articles you have tagged as
"to-export", which are newer than 10 days old. The timestamp functionality
@lavir
lavir / chrome-a11y-experiment-instructions.md
Created November 7, 2016 07:21 — forked from marcysutton/chrome-a11y-experiment-instructions.md
Enable Chrome Accessibility Experiment

Just like any good element inspector helps you debug styles, accessibility inspection in the browser can help you debug HTML and ARIA exposed for assistive technologies such as screen readers. There's a similar tool in Safari (and reportedly one in Edge) but I like the Chrome one best.

As an internal Chrome experiment, this tool differs from the Accessibility Developer Tools extension in that it has privileged Accessibility API access and reports more information as a result. You can still use the audit feature in the Chrome Accessibility Developer Tools, or you could use the aXe Chrome extension. :)

To enable the accessibility inspector in Chrome stable:

  1. Go to chrome://flags to enable Devtools experiments Chrome flags with Developer Tools Experiments enabled
  2. Open developer tools, go to Settings (Devtools menu or Chrome cu
@lavir
lavir / pushbullet.php
Created September 22, 2016 09:31 — forked from ghostbitmeta/pushbullet.php
Synology + Pushbullet
<?php
// Used code from the following sources:
// https://gist.github.com/styxit/e34d4c6f8cb23d55f5af#file-synology-pushover-php
// http://pastebin.com/iHAFAHGq
// Thanks to: https://styxit.com/2014/05/10/synology-pushover.html
// Only allow request made by localhost?
@lavir
lavir / synology-pushover.php
Created September 22, 2016 09:20 — forked from styxit/synology-pushover.php
A php script that can be used on a Synology Nas to revive Pushover notifications. https://styxit.com/2014/05/10/synology-pushover.html
<?php
/************************************/
/********** CONFING START ***********/
// Only allow request made by localhost?
// Set this to false if this script is not running on your synology webserver (less secure)
$localOnly = true;
/********** CONFING END *************/
/************************************/
@lavir
lavir / slackpost
Created September 18, 2016 20:46 — forked from dopiaza/slackpost
Post a message to a Slack channel
#!/bin/bash
# Usage: slackpost <token> <channel> <message>
# Enter the name of your slack host here - the thing that appears in your URL:
# https://slackhost.slack.com/
slackhost=PUT_YOUR_HOST_HERE
token=$1
@lavir
lavir / README.md
Created March 15, 2016 14:37 — forked from renchap/README.md
One-line certificate generation/renews with Letsencrypt and nginx

Prerequisites : the letsencrypt CLI tool

This method allows your to generate and renew your Lets Encrypt certificates with 1 command. This is easily automatable to renew each 60 days, as advised.

You need nginx to answer on port 80 on all the domains you want a certificate for. Then you need to serve the challenge used by letsencrypt on /.well-known/acme-challenge. Then we invoke the letsencrypt command, telling the tool to write the challenge files in the directory we used as a root in the nginx configuration.

I redirect all HTTP requests on HTTPS, so my nginx config looks like :

server {
@lavir
lavir / bash_aliases
Created February 4, 2016 08:31 — forked from frdmn/bash_aliases
Nginx and PHP-FPM configuration + default virtual host
alias nginx.start='sudo launchctl load /Library/LaunchDaemons/homebrew.mxcl.nginx.plist'
alias nginx.stop='sudo launchctl unload /Library/LaunchDaemons/homebrew.mxcl.nginx.plist'
alias nginx.restart='nginx.stop && nginx.start'
alias php-fpm.start="launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.php56.plist"
alias php-fpm.stop="launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.php56.plist"
alias php-fpm.restart='php-fpm.stop && php-fpm.start'
alias mysql.start="launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist"
alias mysql.stop="launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist"
alias mysql.restart='mysql.stop && mysql.start'
alias nginx.logs.error='tail -250f /usr/local/etc/nginx/logs/error.log'
@lavir
lavir / aes_gcm_encryption.py
Created November 2, 2015 13:12 — forked from cptwunderlich/aes_gcm_encryption.py
Implemented examples from https://docs.pushbullet.com/#end-to-end-encryption in python2/3 with python-cryptography (https://cryptography.io)
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from binascii import a2b_base64, b2a_base64
from cryptography.hazmat.primitives import hashes
from cryptography.hazmat.primitives.kdf.pbkdf2 import PBKDF2HMAC
from cryptography.hazmat.backends import default_backend
from cryptography.hazmat.primitives.ciphers import (