Skip to content

Instantly share code, notes, and snippets.

View rinchik's full-sized avatar
🎯
Focusing

rinchik rinchik

🎯
Focusing
View GitHub Profile
@rinchik
rinchik / bitmasks.js
Last active January 12, 2024 18:35
Bitmask JavaScript Example
function logger() {
//MASKS
this.ADMIN = this.permissions.CAN_SEE_ERRORS | this.permissions.CAN_SEE_DEBUGS | this.permissions.CAN_SEE_INFOS;
this.SUPERUSER = this.permissions.CAN_SEE_DEBUGS | this.permissions.CAN_SEE_INFOS;
this.USER = this.permissions.CAN_SEE_INFOS;
}
// FLAGS
logger.prototype.permissions = {
CAN_SEE_ERRORS: 1, // 0001
@rinchik
rinchik / gist:f2f22025842e15def09f1e955b313e1f
Last active May 29, 2016 17:24
Setting up Python Selenium to use one default Firefox user profile
BROWSER_PROFILE_PATH = '/Users/rinat/Library/Application Support/Firefox/Profiles/4yu1sfet.rinat'
TIMESHEET_URL = 'http://url.to.pwa'
def set_up_firefox(self):
print "Configuring Firefox web-browser..."
profile = webdriver.FirefoxProfile(self.BROWSER_PROFILE_PATH)
self.driver = webdriver.Firefox(firefox_profile=profile)
self.driver.get(self.TIMESHEET_URL)
print "Done."
@rinchik
rinchik / SeleniumClicks.py
Last active June 26, 2018 09:48
Double-click + click in Python Selenium for rich tables editing
from selenium import webdriver
from selenium.webdriver.common.action_chains import ActionChains
def enter_hours(self, cell, amount):
#Double-click
actions = ActionChains(self.driver)
actions.move_to_element(cell)
actions.double_click(cell)
actions.perform()
@rinchik
rinchik / SeleniumScreenCapture.py
Created June 4, 2016 17:04
Capturing screenshots with Python and Selenium
from selenium import webdriver
import os
class ScreenCapture:
STAGING_URL = 'http://www.yahoo.com'
PRODUCTION_URL = 'http://www.yahoo.com'
driver = None
def __init__(self):
@rinchik
rinchik / Grid.py
Created June 4, 2016 17:37
Drawing grid on the image
from PIL import Image, ImageDraw
class Grid:
def __init__(self):
self.capture_image()
def capture_image(self):
screenshot = Image.open("screenshots/screen_staging.png")
columns = 60
@rinchik
rinchik / AverageRegionBrightness.py
Last active June 4, 2016 20:20
Calculating image region brightess
def process_region(self, image, x, y, width, height):
region_total = 0
# This is the sensitivity factor, the larger it is the less sensitive the comparison
factor = 10
for coordinateY in range(y, y+height):
for coordinateX in range(x, x+width):
try:
pixel = image.getpixel((coordinateX, coordinateY))
@rinchik
rinchik / ScreenAnalysis.py
Last active February 10, 2021 14:55
Analyzing and finding differences between 2 screenshots captured with Selenium in Python
from PIL import Image, ImageDraw
from selenium import webdriver
import os
import sys
class ScreenAnalysis:
STAGING_URL = 'http://www.yahoo.com'
PRODUCTION_URL = 'http://www.yahoo.com'
driver = None
@rinchik
rinchik / SmallServer.py
Last active June 12, 2016 16:11
Small Python web server that supports get and post
from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer
from urlparse import parse_qs
PASSWORD = "abba"
class Handler(BaseHTTPRequestHandler):
def _set_headers(self):
self.send_response(200)
self.send_header('Content-type', 'text/html')
self.end_headers()
@rinchik
rinchik / PasswordGenerator.py
Last active June 11, 2016 19:43
Python string permutations to generate all possible password variations with given length and known characters
from datetime import datetime
startTime = datetime.now()
password = "abba"
character_list = 'abcdefghijklmnopqrstuvwxyz'
a = []
for current in xrange(len(password)):
a = [i for i in character_list]
for y in xrange(current):
from selenium import webdriver
from selenium.common.exceptions import NoSuchElementException
from datetime import datetime
class BruteForce:
URL = 'http://localhost:3333'
character_list = 'abcdefghijklmnopqrstuvwxyz'