Skip to content

Instantly share code, notes, and snippets.

@dneprDroid
dneprDroid / find_voter.py
Last active October 15, 2019 17:18
Find Voter - check petition
# -*- coding: utf-8 -*-
###################### Параметры #########################
PETITION_ID = 73080
REQ_NAME = u'Овечко'
START_PAGE = 1
END_PAGE = 10**100
@ivanbrennan
ivanbrennan / postgres-in-minikube.sh
Last active March 13, 2025 08:30
PostgreSQL in minikube
# create/update resources
kubectl --context=minikube apply -f ./postgres.yaml
# In order for the service to reach the statefulset, the following should
# be true:
# statefulset.spec.selector.matchLabels.app == service.spec.selector.app
# statefulset.spec.selector.matchLabels.role == service.spec.selector.role
# give the server some time to start up
# ...
@dneprDroid
dneprDroid / Fridge-CMakeLists.txt
Created November 14, 2018 09:28
Fridge-CMakeLists.txt
cmake_minimum_required(VERSION 3.7)
project(fridge)
set(CMAKE_CXX_STANDARD 11)
file(GLOB SRC_FILES ${PROJECT_SOURCE_DIR}/src/* ${PROJECT_SOURCE_DIR}/src/*/* ${PROJECT_SOURCE_DIR}/src/*/*/*)
if (NOT ${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
# filter mac os source files
list(FILTER SRC_FILES EXCLUDE REGEX ".*mm$")
#!/usr/bin/env python
# Based on https://www.openwall.com/lists/oss-security/2018/08/16/1
# untested CVE-2018-10933
import sys, paramiko
import logging
username = sys.argv[1]
hostname = sys.argv[2]
command = sys.argv[3]
@dneprDroid
dneprDroid / checkpoint2proto.py
Last active August 18, 2023 06:21
Tensorflow checkpoint (*.ckpt) to proto (*.pb) model conversion: checkpoint2proto.py
import os, argparse
import tensorflow as tf
from tensorflow.python.tools import freeze_graph as freeze_tool
def freeze_graph(sess, input_checkpoint_path):
saver = tf.train.Saver() # or your own Saver
saver.restore(sess, input_checkpoint_path)
absolute_model_dir = 'absolute_model_dir1111'
graph_file_name = 'tf-model_graph'
@dneprDroid
dneprDroid / Localization+IBInspectable.m
Last active September 26, 2017 16:34
IBInspectable Localization in Storyboards.
// MARK : Localization+IBInspectable.h
@interface UILabel(Localization)
@property (nonatomic, weak) IBInspectable NSString *localizationId;
@end
@interface UIButton(Localization)
@property (nonatomic, weak) IBInspectable NSString *localizationId;
@end
fragment float4 capturedImageFragmentShader(ImageColorInOut in [[stage_in]],
texture2d<float, access::sample> capturedImageTextureY [[ texture(kTextureIndexY) ]],
texture2d<float, access::sample> capturedImageTextureCbCr [[ texture(kTextureIndexCbCr) ]]) {
constexpr sampler colorSampler(mip_filter::linear,
mag_filter::linear,
min_filter::linear);
const float4x4 ycbcrToRGBTransform = float4x4(
float4(+1.0000f, +1.0000f, +1.0000f, +0.0000f),
@dneprDroid
dneprDroid / MainNavigationProtocol.swift
Last active July 13, 2017 19:38
MainNavigationProtocol.swift
import UIKit
protocol MainNavigationProtocol: class {
var cached:Bool? {get set}
static var storyboardName: String {get}
}
extension MainNavigationProtocol where Self : UIViewController {
@gonzalo123
gonzalo123 / diff.py
Created April 17, 2017 16:08
compare images with opencv
import cv2
import numpy as np
from skimage.measure import compare_ssim as ssim
def mse(imageA, imageB):
# the 'Mean Squared Error' between the two images is the
# sum of the squared difference between the two images;
# NOTE: the two images must have the same dimension
err = np.sum((imageA.astype("float") - imageB.astype("float")) ** 2)
err /= float(imageA.shape[0] * imageA.shape[1])
@dneprDroid
dneprDroid / VideoPreviewView.swift
Last active July 13, 2023 14:43
VideoPreviewView - video capture and preview (swift 3)
// swift 3
import UIKit
import AVFoundation
class VideoPreviewView: UIView {
private var videoOutput: AVCaptureMovieFileOutput?
private var captureSession: AVCaptureSession?
private var previewLayer: AVCaptureVideoPreviewLayer?