Skip to content

Instantly share code, notes, and snippets.

View aliva's full-sized avatar
🤖
Hello Humans!

Ali Vakilzade aliva

🤖
Hello Humans!
View GitHub Profile
@aliva
aliva / move-cursor-linux.cpp
Created August 16, 2012 18:17
move mouse pointer to given position in linux
#include <X11/Xlib.h>
#include <iostream>
#include <unistd.h>
int main(void) {
Display* dpy = XOpenDisplay(0);
int scr = XDefaultScreen(dpy);
Window root_window = XRootWindow(dpy, scr);
int height = DisplayHeight(dpy, scr);
@aliva
aliva / timer.py
Created December 27, 2012 15:02
a very simple timer with kivy
import kivy
kivy.require('1.0.6') # replace with your current kivy version !
import datetime
from kivy.app import App
from kivy.clock import Clock
from kivy.uix.label import Label
from kivy.uix.button import Button
from kivy.uix.image import Image
@aliva
aliva / daemon.json
Created May 12, 2019 11:59
docker daemon.json - registry mirrors which work in iran
{
"registry-mirrors": ["https://registry.docker-cn.com", "http://repo.docker.ir:5000"]
}
@aliva
aliva / copy.sh
Created April 13, 2019 10:30
add ssh key to authorized_keys in all servers (give access to all server for a new key)
#!/bin/bash
# create a file named key which contains the public key for new user
export SERVERS="ip1 ip2 ip3"
for server in $SERVERS
do
echo "============="
echo $server
@aliva
aliva / redis-all-keys.sh
Created February 16, 2019 08:36
print all redis keys
seq 16 | xargs -I{} sh -c 'echo ===== {} ===== && redis-cli -n {} keys "*"'
kubectl get pods --no-headers -o custom-columns=":metadata.name" | xargs -I{} sh -c "kubectl logs {} > {}.txt"
#!/bin/bash
# curl link-to-raw | bash
set -e
export DEBIAN_FRONTEND=noninteractive
apt-get -y update
apt-get -y upgrade
apt-get -y install docker.io
@aliva
aliva / parallel_queue.py
Created October 27, 2018 08:24
A sample code for python ParallelQueue
import queue
import threading
import time
from random import randint
class ParallelQueue:
def _worker(self, i):
print("Starting worker: ", i)
while True:
@aliva
aliva / genetic.py
Created April 10, 2013 15:34
solve n-queens with genetic algorithm
#!/usr/bin/python3
import sys
import copy
import math
import random
class Board:
def __init__(self, board_size, goal):
''' initialize a board'''
self.board_size = board_size
#!/bin/bash
function displaytime {
local T=`echo $1 / 1 | bc`
local D=$((T/60/60/24))
local H=$((T/60/60%24))
local M=$((T/60%60))
local S=$((T%60))
(( $D > 0 )) && printf '%d days ' $D
(( $H > 0 )) && printf '%d hours ' $H