Skip to content

Instantly share code, notes, and snippets.

Avatar
📚
Studying

Shadi Abdelsalam FloydanTheBeast

📚
Studying
  • Higher School of Economics
  • Moscow, Russia
View GitHub Profile
@FloydanTheBeast
FloydanTheBeast / vite.config.ts
Created Sep 15, 2022
Vite + React extended config
View vite.config.ts
import dns from 'dns';
import path from 'path';
import react from '@vitejs/plugin-react';
import { defineConfig, loadEnv, splitVendorChunkPlugin } from 'vite';
import checker from 'vite-plugin-checker';
import svgr from 'vite-plugin-svgr';
// Open localhost instead of 127.0.0.1
dns.setDefaultResultOrder('verbatim');
@FloydanTheBeast
FloydanTheBeast / SinglyLinkedList.cpp
Created Sep 16, 2020
Algorithms and data structures
View SinglyLinkedList.cpp
struct Node {
int val;
Node *next;
Node(int x) : val(x), next(NULL) {}
};
class MyLinkedList {
public:
int length;
Node *head;
View Cpp unsync streams and untie cin.md

This code optimizes prefomance as a side effect. USE CAREFULY

The two calls have different meanings that have nothing to do with performance; the fact that it speeds up the execution time is (or might be) just a side effect. You should understand what each of them does and not blindly include them in every program because they look like an optimization.

ios_base::sync_with_stdio(false);

This disables the synchronization between the C and C++ standard streams. By default, all standard streams are synchronized, which in practice allows you to mix C- and C++-style I/O and get sensible and expected results. If you disable the synchronization, then C++ streams are allowed to have their own independent buffers, which makes mixing C- and C++-style I/O an adventure.

Also keep in mind that synchronized C++ streams are thread-safe (output from different threads may interleave, but you get no data races).

@FloydanTheBeast
FloydanTheBeast / volcanoes.csv
Created Jan 13, 2020
Volcanoes in the USA dataset
View volcanoes.csv
We can make this file beautiful and searchable if this error is corrected: It looks like row 9 should actually have columns, instead of 5. in line 8.
VOLCANX020,NUMBER,NAME,LOCATION,STATUS,ELEV,TYPE,TIMEFRAME,LAT,LON
509.000000000000000,1201-01=,Baker,US-Washington,Historical,3285.000000000000000,Stratovolcanoes,D3,48.7767982,-121.8109970
511.000000000000000,1201-02-,Glacier Peak,US-Washington,Tephrochronology,3213.000000000000000,Stratovolcano,D4,48.1118011,-121.1110001
513.000000000000000,1201-03-,Rainier,US-Washington,Dendrochronology,4392.000000000000000,Stratovolcano,D3,46.8698006,-121.7509995
515.000000000000000,1201-05-,St. Helens,US-Washington,Historical,2549.000000000000000,Stratovolcano,D1,46.1997986,-122.1809998
516.000000000000000,1201-04-,Adams,US-Washington,Tephrochronology,3742.000000000000000,Stratovolcano,D6,46.2057991,-121.4909973
517.000000000000000,1201-06-,West Crater,US-Washington,Radiocarbon,1329.000000000000000,Volcanic field,D7,45.8797989,-122.0810013
518.000000000000000,1201-07-,Indian Heaven,US-Washington,Radiocarbon,1806.000000000000000,Shield volcanoes,D7,45.9297981,-121.8209991
519.000000000000000,1202-01-,Hood,US-Oregon,Histo
@FloydanTheBeast
FloydanTheBeast / event-handler-override.py
Created Jan 12, 2020
Event handler override example
View event-handler-override.py
from PyQt5.QtWidgets import QApplication, QWidget, QMessageBox, QLabel, QVBoxLayout
from PyQt5.QtCore import Qt
class UI(QWidget):
def __init__(self):
super().__init__()
layout = QVBoxLayout()
self.label = QLabel('x: _; y: _')
self.label.setStyleSheet('font-size: 48px; font-weight: 800')
@FloydanTheBeast
FloydanTheBeast / custom-signals.py
Last active Jan 12, 2020
Custom signal example
View custom-signals.py
from PyQt5.QtWidgets import QApplication, QWidget, QVBoxLayout, QSlider, QLabel
from PyQt5.QtCore import Qt, pyqtSignal
class ColorPicker(QWidget):
scrollChanged = pyqtSignal(tuple, name='ScrollChanged')
color = { 'r': 0, 'g': 0, 'b': 0 }
def __init__(self):
super().__init__()
@FloydanTheBeast
FloydanTheBeast / custom-slot.py
Created Jan 12, 2020
PyQt custom slot example
View custom-slot.py
from PyQt5.QtWidgets import QApplication, QWidget, QVBoxLayout, QScrollBar, QMessageBox
from PyQt5.QtCore import Qt
class Example(QWidget):
def __init__(self):
super(QWidget, self).__init__()
self.scrollBar = QScrollBar(Qt.Horizontal)
self.scrollBar.valueChanged.connect(self.customSlot)
@FloydanTheBeast
FloydanTheBeast / signals-and-slots.py
Last active Jan 12, 2020
PyQt signals and slots example.py
View signals-and-slots.py
from PyQt5.QtWidgets import QApplication, QWidget, QVBoxLayout, QSlider, QProgressBar
from PyQt5.QtCore import Qt
app = QApplication([])
window = QWidget()
layout = QVBoxLayout()
slider = QSlider(Qt.Horizontal)
progressBar = QProgressBar()
@FloydanTheBeast
FloydanTheBeast / stylesheets.py
Created Jan 12, 2020
PyQt stylesheets example
View stylesheets.py
from PyQt5.QtWidgets import QApplication, QWidget, QPushButton, QLabel, QVBoxLayout
app = QApplication([])
window = QWidget()
# Применение стилей напрямую к элементу
window.setStyleSheet('background-color: #0E171E')
layout = QVBoxLayout()
View Logger.cs
static readonly string loggerPath = Path.Combine(Environment.CurrentDirectory, "Log.txt");
public static void Logger(string log)
{
try
{
File.AppendAllText(loggerPath, log + "\n");
}
catch (IOException ex)
{