Skip to content

Instantly share code, notes, and snippets.

View Doaxan's full-sized avatar
🎯
Focusing

Amir Fazleev Doaxan

🎯
Focusing
View GitHub Profile
@Doaxan
Doaxan / from_str.rs
Last active March 27, 2022 15:23
rustlings/exercises/conversions/from_str.rs
// from_str.rs
// This is similar to from_into.rs, but this time we'll implement `FromStr`
// and return errors instead of falling back to a default value.
// Additionally, upon implementing FromStr, you can use the `parse` method
// on strings to generate an object of the implementor type.
// You can read more about it at https://doc.rust-lang.org/std/str/trait.FromStr.html
use std::num::ParseIntError;
use std::ops::Not;
use std::str::FromStr;
@Doaxan
Doaxan / 00_js.md
Created January 7, 2022 02:49
JavaScript Cheatsheets

JavaScript

@Doaxan
Doaxan / diagcmd_bands.py
Last active August 29, 2025 10:55
Convert Bands to Hex [QXDM, diagcmd]
# 7 -> 0000001 -> reverse -> 1000000 -> to dec -> 64 -> to hex -> 40 -> 0x000040
# 3 -> 001 -> reverse -> 100 -> to dec -> 4 -> to hex -> 4 -> 0x000004
import sys
bands = list(map(int, input("Enter bands numbers: ").replace(',', ' ').split()))
bits = [0] * 64
for band in bands:
bits[band - 1] = 1
bits.reverse()
@Doaxan
Doaxan / rust_fast.rs
Created September 4, 2018 10:39
rust_fast_0.146sec
fn main() {
let mut count = 0;
for k in 3_u32..4 {
for x in 1_u32..41 {
for a in 1_u32..41 {
for b in 1_u32..41 {
for c in 1_u32..41 {
for d in 1_u32..41 {
if u32::pow(x, k) == u32::pow(a, k) + u32::pow(b, k) + u32::pow(c, k) + u32::pow(d, k) {
count += 1;
@Doaxan
Doaxan / main_fast.c
Created September 4, 2018 10:38
c_fast_6sec
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
int main() {
int count = 0;
for (int k = 2; k < 3; k++) {
for (int x = 1; x < 101; x++) {
for (int a = 1; a < 101; a++) {
for (int b = 1; b < 101; b++) {
@Doaxan
Doaxan / main_slow.rs
Last active September 4, 2018 10:39
rust_slow_12sec
fn main() {
let mut count = 0;
for k in 2_u32..3 {
for x in 1_u32..101 {
for a in 1_u32..101 {
for b in 1_u32..101 {
for c in 1_u32..101 {
for d in 1_u32..101 {
if u32::pow(x, k) == u32::pow(a, k) + u32::pow(b, k) + u32::pow(c, k) + u32::pow(d, k) {
count += 1;
[doaxan@doaxan-pc untitled]$ nimble build -d:release -f
Verifying dependencies for untitled@0.1.0
Building untitled/untitled using c backend
Tip: 5 messages have been suppressed, use --verbose to show them.
Error: Build failed for package: untitled
... Details:
... Execution failed with exit code 1
... Command: "/usr/bin/nim" c --noBabelPath -d:release -f -o:"/home/doaxan/Dev/Nim/untitled/untitled" "/home/doaxan/Dev/Nim/untitled/src/untitled.nim"
... Output: Hint: used config file '/etc/nim.cfg' [Conf]
... Hint: system [Processing]
@Doaxan
Doaxan / playground.rs
Created August 22, 2017 13:00 — forked from anonymous/playground.rs
Rust code shared from the playground
/**
Simple example on how to use the nwg template system.
*/
#[macro_use] extern crate native_windows_gui as nwg;
use nwg::{Event, Ui, simple_message, fatal_message, dispatch_events};
/// Custom enums are the preferred way to define ui ids. It's clearer and more extensible than any other types (such as &'str).
#[derive(Debug, Clone, Hash)]
##run_once is a script in /usr/bin that prevents running script if it is running already
##
## To enable pulseaufio, uncomment this and run sudo pacman -S pavucontrol pulseaudio-ctl manjaro-pulse
#pulseaudio --start &
#sleep 2s && volume 37 &
## Load appearance settings
xsetroot -cursor_name left_ptr &
#export GTK2_RC_FILES="$HOME/.gtkrc-2.0" &
#xrdb merge .Xresources &
xfsettingsd --sm-client-disable &
#! /bin/sh
gap=4
PANEL_HEIGHT=22
BORDER_WIDTH=2
export gap
export PANEL_HEIGHT
export BORDER_WIDTH
#This creates negative padding equal to window gap so that gaps are shown only between windows and not on desktop edges.
bspc config window_gap $gap;