Skip to content

Instantly share code, notes, and snippets.

View andrey-str's full-sized avatar

Andrey Streltsov andrey-str

View GitHub Profile
@andrey-str
andrey-str / main.cpp
Created September 13, 2018 10:56
Blur QWidget window content(with any 3D on top)
namespace
{
QImage applyEffectToImage(QImage src, QGraphicsEffect *effect)
{
if(src.isNull()) return QImage(); // No need to do anything else
if(!effect) return src; // No need to do anything else
QGraphicsScene scene;
QGraphicsPixmapItem item;
item.setPixmap(QPixmap::fromImage(src));
item.setGraphicsEffect(effect);
@andrey-str
andrey-str / convert.sh
Created May 10, 2018 00:11 — forked from akost/convert.sh
Bash script for recursive file convertion windows-1251 --> utf-8
#!/bin/bash
# Recursive file convertion windows-1251 --> utf-8
# Place this file in the root of your site, add execute permission and run
# Converts *.php, *.html, *.css, *.js files.
# To add file type by extension, e.g. *.cgi, add '-o -name "*.cgi"' to the find command
find ./ -name "*.php" -o -name "*.html" -o -name "*.css" -o -name "*.js" -type f |
while read file
do
@andrey-str
andrey-str / gist:297792bff6d131497ee6dc1b789e100d
Created May 8, 2018 21:24 — forked from sparlampe/gist:5b9dc019a62db8a19941f6526e39dff1
OVMF passthrough of RX570 over Thunderbolt3 on Thinkpad P50
prompt:/# kvm -version
QEMU emulator version 2.9.0 (v2.9.0-dirty)
Copyright (c) 2003-2017 Fabrice Bellard and the QEMU Project developers
prompt:/# uname -a
Linux ThinkPad-P50 4.13.8-041308-generic #201710180430 SMP Wed Oct 18 08:33:18 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
@andrey-str
andrey-str / download_egghead_videos.md
Created November 3, 2017 01:53 — forked from ldong/download_egghead_videos.md
download egghead videos

Download videos from egghead

Go to the egghead website, i.e. Building a React.js App

run

$.each($('h4 a'), function(index, video){
  console.log(video.href);
});
@andrey-str
andrey-str / irb.rb
Last active January 10, 2017 09:57
Rasil Cheat Sheets
# Save all records added in IRB console
EntityName.all.each { |entity| entity.save! }
#!/bin/bash
# Загружаем модуль ядра Network Block Device
modprobe nbd
# "Подключаем" образ к устройству /dev/nbd0.
qemu-nbd --connect /dev/nbd0 --read-only /путь/к/образу.qcow2
# Ищем разделы на устройстве.
kpartx -arvs /dev/nbd0
@andrey-str
andrey-str / gist:03f32aab7a228be353c1f34deb065f23
Last active January 13, 2020 11:22
MySQL шпаргалки (основа взята отсюда: https://habrahabr.ru/post/105954/ )

#Работа с бекапами

NB: пароль в командной строке лучше не указывать, если это не крон-like задача, конечно. Ключ -p запрашивает ввод пароля поссле ввода команды.

Делаем бекап

mysqldump -u USER -pPASSWORD DATABASE > /path/to/file/dump.sql

###Создаём структуру базы без данных mysqldump --no-data - u USER -pPASSWORD DATABASE > /path/to/file/schema.sql

KVM OSX Guest 10.11 (El Capitan) with Clover

  • Some notes about this approach:
    • An OSX Installer USB drive for Install OS X El Capitan is created
    • Clover is then installed on the USB drive
    • Clover Configurator is then run on the USB drive
    • The USB drive contents are copied to the VM host
    • VNC is used to connect to the guest UI
  • The qxl virtual video device is used (part of the standard kvm qemu install)
//
// Created by Andrey Streltsov on 11/06/15.
// Based on code from here: http://stackoverflow.com/a/28172162/365754
#include "AppRunGuard.h"
#include <qcryptographichash.h>
namespace
{
@andrey-str
andrey-str / qt5-postbuild.cmake
Created July 7, 2016 11:01
Copy Qt5 dlls to app's directory [WINDOWS]
function (add_copy_qt5_postbuild_step MY_APP_NAME MY_APP_BINARY_DIR)
ADD_CUSTOM_COMMAND(
TARGET ${MY_APP_NAME} POST_BUILD
# DEBUG
COMMAND ${CMAKE_COMMAND} -E copy ${Qt5Core_DIR}/../../../bin/libEGLd.dll ${MY_APP_BINARY_DIR}
COMMAND ${CMAKE_COMMAND} -E copy ${Qt5Core_DIR}/../../../bin/libGLESv2d.dll ${MY_APP_BINARY_DIR}
COMMAND ${CMAKE_COMMAND} -E copy ${Qt5Core_DIR}/../../../bin/Qt53DCored.dll ${MY_APP_BINARY_DIR}
COMMAND ${CMAKE_COMMAND} -E copy ${Qt5Core_DIR}/../../../bin/Qt53DExtrasd.dll ${MY_APP_BINARY_DIR}
COMMAND ${CMAKE_COMMAND} -E copy ${Qt5Core_DIR}/../../../bin/Qt53DInputd.dll ${MY_APP_BINARY_DIR}