Skip to content

Instantly share code, notes, and snippets.

View bespokoid's full-sized avatar

Stanislav Bernstein bespokoid

View GitHub Profile
@bespokoid
bespokoid / concurrecy_sandbox.py
Last active August 24, 2020 08:13
Sandbox to try and measure different flavors of Python concurrency
# Python concurrecy sandbox, inspired by Ned Batchelder's (@nedbat) articles on Python concurrency and raising the progressbar (links below)
# Exec workfn() for every tuple generated by argsfn() in concurrent fashion. By default spans 1M tasks using different mechanics, draw progressbar and time execution
# Current example trying to calculate mean of the Beast, to do so we collect fractions of 666, pow them and calculate average
# If you want less satanic example, just implement workfn and argsfn functions to your liking.
# I haven't much time for this yet, was merely currious with Ned Batchelder code from his articles "Doing a pile of work" and "Do a pile of work better"
# Turned out Ned's solution caries some overhead, but my code also left much to be desired. In other words there is no danger of sudden bugs or ideas shortage
# Original articles by Ned Batchelder
# https://nedbatchelder.com/blog/202008/do_a_pile_of_work.html
@bespokoid
bespokoid / Transforming_code_into_beautiful_idiomatic_python.md
Last active January 24, 2024 07:01
Transforming code into Beautiful, Idiomatic Python by Raymond Hettinger

Transforming code into Beautiful, Idiomatic Python

This is merely a gist of great speech made by Raymond Hettinger @raymondh at PyCon 2013 Original video can be enjoyed here and original slides can be found there

Almost all code snippets are presenting two or three ways of doing things: bad, ugly and pythonic :) I changed code a bit to make it Python3 compatible and added some notes regarding Python2/3 transition

@bespokoid
bespokoid / vscode_vim_cheatsheet.md
Last active February 15, 2021 14:47
VS Code Vim mode cheatsheet

VSCode Vim mode cheatsheet

Baby Steps

  • h move cursor to the left
  • j move down
  • k move up
  • l move right
  • i Go into Insert mode
@bespokoid
bespokoid / SpaceVim.md
Last active October 31, 2024 17:57
SpaceVim cheatsheet #tools
@bespokoid
bespokoid / linux_wifi_setup.md
Created October 13, 2019 21:14
Connecting to wifi network through command line #linux #cmd

Connecting to wifi network through command line

I am trying to connect to my WEP network just using the command-line (Linux).

I run:

sudo iwconfig wlan0 mode Managed essid 'my_network' key 'xx:xx:... hex key, 26 digits'

Then I try to obtain an IP with

@bespokoid
bespokoid / tradingview_editor_settings.js
Created September 20, 2019 02:54
TamperMonkey script to change editor settings like fontSize for TradingView script editor
// ==UserScript==
// @name TradingView editor options
// @namespace https://www.tradingview.com/
// @version 1.0
// @author bespokoid
// @match https://www.tradingview.com/*
// ==/UserScript==
(function() {
document.addEventListener("load", event =>
@bespokoid
bespokoid / Parabolic SAR
Created September 8, 2019 04:20 — forked from marketcalls/Parabolic SAR
Parabolic SAR
study(title="Parabolic SAR", shorttitle="P-SAR", overlay=true)
start = input(2, minval=0, maxval=10, title="Start - Default = 2 - Multiplied by .01")
increment = input(2, minval=0, maxval=10, title="Step Setting (Sensitivity) - Default = 2 - Multiplied by .01" )
maximum = input(2, minval=1, maxval=10, title="Maximum Step (Sensitivity) - Default = 2 - Multiplied by .10")
sus = input(true, "Show Up Trending Parabolic Sar")
sds = input(true, "Show Down Trending Parabolic Sar")
disc = input(false, title="Start and Step settings are *.01 so 2 = .02 etc, Maximum Step is *.10 so 2 = .2")
//"------Step Setting Definition------"
//"A higher step moves SAR closer to the price action, which makes a reversal more likely."
# === EDITOR ===
Pry.editor = 'vim'
# == Pry-Nav - Using pry as a debugger ==
Pry.commands.alias_command 'c', 'continue' rescue nil
Pry.commands.alias_command 's', 'step' rescue nil
Pry.commands.alias_command 'n', 'next' rescue nil
Pry.commands.alias_command 'r!', 'reload!' rescue nil
Pry.config.color = true
@bespokoid
bespokoid / gist:2498433
Created April 26, 2012 10:03
Controll deprecation warnings output in Rails
# Simple turn it off
ActiveSupport::Deprecation.silenced = true
# Or add custom handler
# ActiveSupport::Deprecation.behavior = Proc.new { |msg, stack| MyLogger.warn(msg) }
@bespokoid
bespokoid / gist:2334042
Created April 8, 2012 02:41
Convert all .ERB files in given directory tree to .HAML
Find.find('vendor/extensions/shop').each {|f| puts ("html2haml, #{f}, #{f.slice(0...-3)+"haml"}") if f =~ /.*\.erb/}