Skip to content

Instantly share code, notes, and snippets.

View victory-sokolov's full-sized avatar
🎯
Focusing

Viktor Sokolov victory-sokolov

🎯
Focusing
View GitHub Profile
@victory-sokolov
victory-sokolov / launch.json
Created May 11, 2022 08:11
VsCode Node debugging settings
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "attach",
"protocol": "inspector",
@victory-sokolov
victory-sokolov / Note.md
Created April 17, 2022 20:19
Express server

NodeJs Express base server

npm i express 
npm i -D nodemon

package.json

@victory-sokolov
victory-sokolov / note.md
Created April 15, 2022 09:27
Run all Ruby tests in a test directory

Run all tests in directory

ruby -Itest tests/tests.rb
@victory-sokolov
victory-sokolov / font.js
Created March 16, 2022 10:20
Dynamically load font
var junction_font = new FontFace('Junction Regular', 'url(fonts/junction-regular.woff)');
junction_font.load().then(function(loaded_face) {
document.fonts.add(loaded_face);
document.body.style.fontFamily = '"Junction Regular", Arial';
}).catch(function(error) {
// error occurred
});
@victory-sokolov
victory-sokolov / django-launch.json
Last active February 13, 2024 07:06
VSCode debugging configs
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Debugpy attach",
"type": "python",
"request": "attach",
@victory-sokolov
victory-sokolov / img_utils.py
Last active January 24, 2022 08:34
Image utils for Python
import io
import cv2
import base64
import numpy as np
from PIL import Image
# Take in base64 string and return PIL image
def string_to_image(base64_string):
imgdata = base64.b64decode(base64_string)
return Image.open(io.BytesIO(imgdata))
@victory-sokolov
victory-sokolov / settings.json
Last active January 13, 2022 16:22
vscode colors customization
"workbench.colorCustomizations": {
"[Default Dark+]": {
"titleBar.activeBackground": "#3954ee",
"titleBar.activeForeground": "#fff",
"statusBar.background": "#3954ee",
"statusBar.foreground": "#fff",
"tab.activeBorderTop": "#fbff00"
},
},
"window.titleBarStyle": "custom",
@victory-sokolov
victory-sokolov / twiiterUncheckAdsInterests.js
Created December 26, 2021 19:36
Twitter uncheck all interests
function clearNextInterest(){
const selector = "div > input[type='checkbox']:checked";
const next = document.querySelector(selector);
if(next){
next.scrollIntoView();
next.click();
setTimeout(clearNextInterest,500)
};
};
clearNextInterest();
@victory-sokolov
victory-sokolov / fetch.js
Created December 20, 2021 08:55
Fetch wrapper
export class HttpMethod {
static GET = "GET";
static POST = "POST";
static PUT = "PUT";
static DELETE = "DELETE";
}
const request = async ({endpoint, params, method = HttpMethod.GET}) {
@victory-sokolov
victory-sokolov / circular-types.py
Created December 9, 2021 15:05
Circular Types import
# Reference: https://adamj.eu/tech/2021/05/13/python-type-hints-how-to-fix-circular-imports/
from __future__ import annotations
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from models import Book