Skip to content

Instantly share code, notes, and snippets.

View ysinjab's full-sized avatar
🎯
Focusing

Yasser Sinjab ysinjab

🎯
Focusing
View GitHub Profile
import bisect
import random
def search_index(numbers, number):
i = bisect.bisect_left(numbers, number)
if i == len(numbers):
return i - 1
elif numbers[i] == number:
return i
elif i > 0:
j = i - 1
from timeit import default_timer as timer
import seaborn as sns
import pandas as pd
import sys
times = {}
numbers = []
for i in xrange(3000000):
start = timer()
numbers.append(random.randint(0, 100000))
def append_to_list(size=1000000):
result = []
for i in range(size):
result.append(1)
def fill_pre_allocated_list(size=1000000):
result = size * [None]
for i in range(size):
result[i]= 1
from sqlalchemy import create_engine, Column, Integer, String
from sqlalchemy.orm import sessionmaker
from sqlalchemy.ext.declarative import declarative_base
engine = create_engine('sqlite:///users.db', echo=True)
Base = declarative_base()
class User(Base):
__tablename__ = 'users'
# in users app i added this model
class User(models.Model):
name = models.CharField(max_length=10)
# in django shell execute the following
from users.models import *
# the object will hold all the logic
new_user = User(name='Yasser')
# this will execute an INSERT
ubuntu@ip:~$ awk -F':' '{ print $1}' /etc/passwd
root
daemon
bin
sys
sync
games
man
lp
mail
ubuntu@ip:~$ sudo docker stats 4263b7da070e
CONTAINER CPU % MEM USAGE / LIMIT MEM % NET I/O BLOCK I/O PIDS
4263b7da070e 0.00% 972KiB / 990.7MiB 0.10% 828B / 0B 745kB / 0B 1
CONTAINER CPU % MEM USAGE / LIMIT MEM % NET I/O BLOCK I/O PIDS
4263b7da070e 0.00% 972KiB / 990.7MiB 0.10% 828B / 0B 745kB / 0B 1
CONTAINER CPU % MEM USAGE / LIMIT MEM % NET I/O BLOCK I/O PIDS
4263b7da070e 0.00% 972KiB / 990.7MiB 0.10% 828B / 0B 745kB / 0B 1

Keybase proof

I hereby claim:

  • I am ysinjab on github.
  • I am ysinjab (https://keybase.io/ysinjab) on keybase.
  • I have a public key ASBtC1_AMzilP5xM9L_o4zBx3pQbGrzfNr5nx0-3NgwBSgo

To claim this, I am signing this object:

func fibonacci(n int) int {
if n <= 1 {
return n
}
return fibonacci(n-1) + fibonacci(n-2)
}
func main() {
// fibCalculator will calculate fibonacci number for a stream of numbers
fibCalculator := func(done <-chan interface{}, numbers <-chan int) <-chan interface{} {
@ysinjab
ysinjab / main.go
Last active September 3, 2022 09:56
547.number.of.provinces.disjoint.set.with.path.compression
package main
import "fmt"
type DisjointSet struct {
Nodes []int
RootsNumber *int
}
func (ds DisjointSet) Find(n int) int {