Skip to content

Instantly share code, notes, and snippets.

View kleviscipi's full-sized avatar
🦁
Focusing

Klevis Cipi kleviscipi

🦁
Focusing
View GitHub Profile
@kleviscipi
kleviscipi / jsx-javascript-standarts-code.md
Last active March 14, 2022 17:07
Standards recommendation for JSX,JavaScript code

Define variables

  • Local variables must be defined in camelCase starting with lowercase like, without underscores and without numbers:
  • Should be used let instead of var
    function getDetails(){
        let name = 'React'
        let version = 'V1'
        ...
    }
@kleviscipi
kleviscipi / php-standarts-code.md
Last active March 14, 2022 17:08
Standard recommendation for coding

Define variables

  • Local variables must be defined in camelCase starting with lowercase like, without underscores and without numbers:
    //Good for me
    $userInRange = true;
const path = require('path'),
webpack = require('webpack'),
AssetsPlugin = require('assets-webpack-plugin'),
BrotliPlugin = require('brotli-webpack-plugin'),
HtmlWebpackPlugin = require('html-webpack-plugin'),
UglifyJsPlugin = require('uglifyjs-webpack-plugin');
const isProd = process.env.NODE_ENV === 'production';
/**
@kleviscipi
kleviscipi / sources.list
Created August 2, 2020 14:30 — forked from ishad0w/sources.list
Ubuntu 20.04 LTS (Focal Fossa) -- Full sources.list
deb http://archive.ubuntu.com/ubuntu/ focal main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu/ focal main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ focal-updates main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu/ focal-updates main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ focal-security main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu/ focal-security main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ focal-backports main restricted universe multiverse
@kleviscipi
kleviscipi / manage-etc-hosts.sh
Created July 30, 2020 09:18 — forked from irazasyed/manage-etc-hosts.sh
Bash Script to Manage /etc/hosts file for adding/removing hostnames.
#!/bin/sh
# PATH TO YOUR HOSTS FILE
ETC_HOSTS=/etc/hosts
# DEFAULT IP FOR HOSTNAME
IP="127.0.0.1"
# Hostname to add/remove.
HOSTNAME=$1
@kleviscipi
kleviscipi / race_condition.py
Created October 18, 2019 10:52
Resolve a race conditions example
from threading import Thread,Lock
"""
How ro resolve a Race Conditions in Python
Python is one of programming languages which support multiprocess and multi-threads and this is prety cool.
At the end python is not one of the best for parallel programming but lets see how we can use and resolve a common problem which is : Race Conditions
Before,I show you an example, first we should be familiar with this concept: Mutual Exlusion, Lock, Race Conditions
Mutual Exlusion ?: When tow or more processes/threads wants to access to a shared resources, and after thread has accessed that resource than block all others concurrent
Lock ?: A thread before accesses a shared resource, should graph or acquired a Lock,at this point all other councurrent are waiting for release of tha Lock.
@kleviscipi
kleviscipi / threads.py
Created October 17, 2019 15:44
Using a Lock for passing the race conditions during a multithread egzecution
from threading import Thread,Lock
import sys
"""
Mutual Exlusion:
When tow concurrent threads or processes want to use a shared resource,
that means one thread block the concurrent since its is using that resource
Process A
@kleviscipi
kleviscipi / contact.py
Created October 16, 2019 13:55
Refactoring a class using the OOP features in Python
import json
# Class Name : Contact
class Contact_Old:
#Class Attributes
name = str
subname = str
tel = str
email = str
@kleviscipi
kleviscipi / article.py
Created October 14, 2019 08:59
Pyhon OOP Example Factory
import json
#Class Name : Article
# class Article:
# # Class Attributes
# title=str
# author=str
@kleviscipi
kleviscipi / BubbleSort.py
Last active July 25, 2019 12:22
Sort a range of numbers with BubleSort using Python
##########################################
# Check if a range of numbers is sorted #
##########################################
def isSorted(numbers):
i = 0
for n in numbers:
if i < len(numbers)-1 and n > numbers[i+1]:
return False
i = i+1
return True