Skip to content

Instantly share code, notes, and snippets.

View deeperton's full-sized avatar

Anton deeperton

View GitHub Profile
@deeperton
deeperton / rgba-to-hex.sass
Last active April 18, 2024 05:31
Converter RGBA() to #HEX color with applying alpha-channel + additional opacity
// converter rgba(r, g, b, a) color to #HEX string without alpha channel,
// with optional applying afterwards opacity ($opacity)
// by default alpha channel for rgba-color is applying against white background,
// but you can change it by setting third argumnet ($background)
@function rgba-to-rgb($rgba, $opacity: 0, $background: #fff) {
@if $opacity > 0 {
@if $opacity < 1 {
$opacity: $opacity * 100
}
@return mix(mix(rgb(red($rgba), green($rgba), blue($rgba)), $background, alpha($rgba) * 100%), rgb(255,255,255), $opacity)
@deeperton
deeperton / download_SQLjs_DB.js
Last active April 3, 2019 10:53
Download sql.js DB as a file
function _sqljs_download(name) {
function downloadBytes(body, filename, extension = 'db') {
const blob = new Blob([body]);
const fileName = `${filename}.${extension}`;
const link = document.createElement('a');
if (link.download !== undefined) {
const url = URL.createObjectURL(blob);
@deeperton
deeperton / sql.manager.js
Last active March 11, 2019 22:16
A very simple snippet for web-tools to run queries against sql.js database stored in localStorage
(function(DBName) {
var raw_DB = localStorage.getItem(DBName);
if (raw_DB) {
window._db = (function(raw) {
let db = new SQL.Database(JSON.parse(raw));
return {
run: function(sql) {
let data = db.exec(sql);
@deeperton
deeperton / btsync
Created December 7, 2014 16:23
btsync deamon
#! /bin/sh
### BEGIN INIT INFO
# Provides: btsync daemon
# Required-Start: $syslog
# Required-Stop: $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: BTSync server daemon
# Description: Daemon script to run a BTSync permanent peer
# Placed in /etc/init.d.
@deeperton
deeperton / suspend_vb_vms.cmd
Last active December 16, 2015 02:28
The script suspends all running virtual machines.
@FOR /F "tokens=*" %%G IN ('VBoxManage list runningvms') DO @CALL :suspend %%G
:suspend
@SETLOCAL
@SET _name=%1
@SET _uuid=%2
@IF [%1]==[] GOTO:eof
@echo Suspend: %_name%
VBoxManage controlvm %_uuid% savestate
@ENDLOCAL