Skip to content

Instantly share code, notes, and snippets.

@barsv
barsv / BindingTest.cs
Last active September 26, 2020 19:38
Binding Proof of concept
using System;
using System.Linq.Expressions;
using PostSharp.Aspects;
namespace BindingTest
{
class Program
{
static void Main()
{
@barsv
barsv / logger.ps1
Last active October 23, 2024 10:27
Logging in powershell with log rotation
# all logging settins are here on top
$logFile = "log-$(gc env:computername).log"
$logLevel = "DEBUG" # ("DEBUG","INFO","WARN","ERROR","FATAL")
$logSize = 1mb # 30kb
$logCount = 10
# end of settings
function Write-Log-Line ($line) {
Add-Content $logFile -Value $Line
Write-Host $Line
@barsv
barsv / matplotlib_in_tkinter.py
Created April 11, 2020 11:52
How to put matplot lib graph into tkinter window
# minimal example on how to put matplot lib graph into tkinter window
import tkinter as tk
import matplotlib.backends.backend_tkagg as tka
from matplotlib.figure import Figure
import numpy as np
win = tk.Tk()
fig = Figure()
canvas = tka.FigureCanvasTkAgg(fig, win)
toolbar = tka.NavigationToolbar2Tk(canvas, win)
@barsv
barsv / gist:7c0c788daa185797518db646937b0d1d
Created June 10, 2020 08:33
remove shit from jira kanban
#ghx-header.contains-breadcrumbs {
position: absolute;
right: 0;
width: 400px !important;
z-index: 999999999;
}
#breadcrumbs-container {
display: none !important;
}
#page-body > #content {
@barsv
barsv / heap.py
Last active November 30, 2021 20:15
Fixed version of the heap implementation from https://www.programiz.com/dsa/heap-data-structure
# Max-Heap data structure in Python
import math
def siftDown(arr, n, i):
largest = i
l = 2 * i + 1
r = 2 * i + 2
if l < n and arr[i] < arr[l]:
largest = l
# Keymap file for https://github.com/samvel1024/kbct
# Maps left Ctrl+Alt+hjkl to arrows.
- keyboards: ["AT Translated Set 2 keyboard"]
# Specify layered configurations (much similar to fn+F keys)
layers:
# Specify the modifiers of the layer
- modifiers: ['leftalt','leftctrl']
keymap:
@barsv
barsv / dash_get_js_event_on_server.py
Last active June 19, 2024 06:27
Demonstrates asynchronous data transfer from client-side JavaScript to a Dash server using a hidden input. The script handles button clicks, updates input via setTimeout, and logs counts on the server.
# this program shows how to pass payload from async client javascript to the server side in dash.
# you click on the button and the server logs the number of clicks.
# !pip install dash
import dash
from dash import html, Input, Output, dcc
app = dash.Dash(__name__)
app.layout = html.Div([
html.Button('Click Me', id='button'),
@barsv
barsv / gist:f61b954dd9df834ba5328b87298df6df
Last active July 2, 2024 20:23
MicroStrategy Bitcoin Purchase History
//@version=4
// data source: https://bitcointreasuries.com/microstrategy/
study("MicroStrategy Bitcoin Purchase History", overlay=true)
x = if time > timestamp(2024, 6, 20, 0, 0) and time < timestamp(2024, 6, 21, 0, 0)
11931
else if (time > timestamp(2024, 4, 1, 0, 0) and time < timestamp(2024, 4, 2, 0, 0))
164
else if (time > timestamp(2024, 3, 19, 0, 0) and time < timestamp(2024, 3, 20, 0, 0))
9245