Skip to content

Instantly share code, notes, and snippets.

View wildonion's full-sized avatar
💭
future.await;

dewo wildonion

💭
future.await;
View GitHub Profile
@wildonion
wildonion / starter
Last active June 5, 2021 06:50
VPS config
.....[copy from local to vps using ssh]
sudo scp file_name user@ip:/home/$USER/
.....[copy from vps to local using rsync excluding .git folder]
rsync -av -e ssh --exclude='.git' cds@cdsapply.com:/home/cds/cds2_cockpitBackend/ /home/wildonion/Documents/cds_backend_backup
.....[jekyll installation]
https://jekyllrb.com/docs/installation/ubuntu/
@wildonion
wildonion / tp_stat.sh
Created October 26, 2020 21:11
touch-pad controller script
#!/bin/bash
read TPdevice <<< $( xinput | sed -nre '/TouchPad|Touchpad/s/.*id=([0-9]*).*/\1/p' ) # getting the id of the touchpad device
state=$( xinput list-props "$TPdevice" | grep "Device Enabled" | grep -o "[01]$" ) # getting the status of touchpad
if [ "$state" -eq '1' ];then
xinput --disable "$TPdevice" && notify-send -i emblem-nowrite "Touchpad" "Disabled"
@wildonion
wildonion / pp.py
Last active October 30, 2020 10:23
python playground
import numpy as np
import math
# lambda complex syntax
print((lambda name, number: str(number)+name)(input("[+] Enter A Name : "), 456))
# =====================================
# overloading * operator
@wildonion
wildonion / all_combo.py
Last active October 28, 2020 11:50
all possible subset combinations of a set
# =====================================
# calculate all possible subset for a set
# base prespective for n nested loop and other dynamic problems!
# for i in [0..2]:
# for j in [0..2]:
# for p in [0..2]:
# for q in [0..2]:
# 0 0 0 0 -> 0 0 0 2 -> 0 0 1 0 -> 0 0 1 2
# 0000, 0001, 0002, 0010, 0011, 0012, 0020, ..., 2222, (1)0000
@wildonion
wildonion / student_portal.py
Created October 28, 2020 11:48
python dictionary example
# >>> d={"adventurous":"aventurero","bold":"audaz","courageous":"valiente"}
# >>>d.items()
# [('courageous', 'valiente'), ('adventurous', 'aventurero'), ('bold', 'audaz')]
# >>> d.keys()
# ['courageous', 'adventurous', 'bold']
# >>> d.values()
# ['valiente', 'aventurero', 'audaz']
# >>> my_list = [('a', 1), ('b', 2)]
# >>> dict(my_list)
# {'a': 1, 'b': 2}
@wildonion
wildonion / topol.py
Last active October 28, 2020 11:58
topol algo __ subset combination problem
from typing import Callable
# topol algo
tsbst: list = [None]
def subset(sett: list) -> list:
biN:Callable[str, str] = lambda el : ''.join(reversed([str((el>>i) & 1) for i in range(len(sett))]))
tpx:int = 2**len(sett)
for i in range(1,tpx):
@wildonion
wildonion / emp.py
Last active October 28, 2020 11:58
employees design pattern example
# -------------------------------------------------------------------------------------------
# designing pattern on a simple OOP problem
# employees insured and salary
employees = []
# ======================================
# CLASSES
import os
@wildonion
wildonion / act.py
Created October 28, 2020 11:54
activity greedy problem
# ACTIVITY PROBLEMS
# given a set of n activities with their start and finish times,
# we need to select maximum number of non-conflicting activities
# that can be performed by a single person,
# given that the person can handle only one activity at a time.
activities = [(1, 3), (3, 4), (2, 5), (0, 7), (5, 9), (8, 10), (11, 12)]
@wildonion
wildonion / lols.py
Created October 28, 2020 11:55
longest substring without repeating characters
# longest substring without repeating characters
class lols:
def __init__(self, string : str):
self.string = string
def solve(self) -> int:
if len(self.string) == 0:
return 0
if len({self.string[i] : i for i in range(len(self.string))}) == 1:
return 1
@wildonion
wildonion / uf.py
Created October 28, 2020 11:56
unhappy friends
import sys, os
# unhappy friends
# https://leetcode.com/contest/weekly-contest-206/problems/count-unhappy-friends/
# eg ::: input: [[1, 3, 2], [2, 3, 0], [1, 3, 0], [0, 2, 1]], pairs = [[1, 3], [0, 2]], output: 4
if __name__ == "__main__":
f_n = int(input("Enter friends ::: "))
if 2 <= f_n <= 500 and f_n % 2 == 0:
preferences = []