Skip to content

Instantly share code, notes, and snippets.

View Tes3awy's full-sized avatar
👨‍💻
Focusing

Osama Abbas Tes3awy

👨‍💻
Focusing
View GitHub Profile
@debojitkakoti
debojitkakoti / api.php
Created January 28, 2014 10:14
Simple API in PHP to return data in JSON format
<?php
include_once 'db.php';
global $con;
define('ERROR','404');//Define Your Error message HERE
define('REQADDR', '127.0.0.1');//Define your REQUESTIN SERVER ADDR
if($_SERVER['REMOTE_ADDR']=='127.0.0.1'){
//process it
if(isset($_GET['q'])){
$q=mysql_real_escape_string($_GET['q']);//TO get rid of SQL Enjection
@alexanderfefelov
alexanderfefelov / gist:df3c562ea2e42438c940
Created August 29, 2014 06:41
How to configure a Cisco Catalyst switch to act as a DHCP relay agent with option 82
  +-------------+
  |             |
  | DHCP server |
  |             |
  +-------------+
          | 192.168.1.34
          |
          |
   VLAN 1 | 192.168.1.12

+------[1]----+

/*
* Extends ColorThief plugin to mark the most intense color in a palette.
*
* var colorThief = new ColorThief();
* var palette = colorThief.getPalette(image, 5);
* var palette = colorThief.markBoomColors(palette);
*
* It ranks all colors in a palette according to the sum of saturation and color value (HSV) descending.
* The palette colors will be extended with boomRank and boomColor.
* boomColor is set to true if the color is the most intense color in the given palette.
@tachyondecay
tachyondecay / models.py
Last active July 7, 2024 09:00
Tags in Flask via SQLalchemy and association proxies
from app import db
from sqlalchemy import desc, event, func, orm
from sqlalchemy.ext.associationproxy import association_proxy
from sqlalchemy.ext.declarative import declared_attr
from sqlalchemy_utils import ArrowType, auto_delete_orphans
from slugify import slugify_unicode
tags = db.Table('tag_associations',
db.Column('tag_id', db.Integer, db.ForeignKey('tags.id')),
db.Column('article_id', db.Integer, db.ForeignKey('articles.id')))
@ktbyers
ktbyers / threading_csv.py
Created February 24, 2017 20:10
Netmiko Threading from a CSV file
import csv
import threading
from Queue import Queue
from getpass import getpass
from netmiko import ConnectHandler
from datetime import datetime
USER = 'pyclass'
PASSWORD = getpass()
@Tes3awy
Tes3awy / gist:6dd5b45c1c6bbd8c673eb8421f4032c6
Last active September 24, 2017 15:09 — forked from bergantine/gist:5243223
CSS grayscale filter (go from grayscale to full color on hover) #css #sethneilson
/* At first the image is grayscaled by the filter and then on hover the filter is set to 0% */
img {
-moz-filter: grayscale(100%);
-o-filter: grayscale(100%);
-webkit-filter: grayscale(100%);
filter: grayscale(100%);
-moz-transition: .5s ease-in-out;
-o-transition: .5s ease-in-out;
-webkit-transition: .5s ease-in-out;
from requests import Session
session = Session()
# HEAD requests ask for *just* the headers, which is all you need to grab the
# session cookie
session.head('http://sportsbeta.ladbrokes.com/football')
response = session.post(
url='http://sportsbeta.ladbrokes.com/view/EventDetailPageComponentController',
@TannerRayMartin
TannerRayMartin / serial_test1.py
Created December 28, 2017 11:47
Connecting to a Cisco switch via console cable through a serial port with a laptop using python (pySerial)
__author__ = 'Tanner Ray Martin'
#this is for python 3, for python 2: change input to raw_input
import serial
#serial is the main module used and needs to be installed
import time
'''
@mgeeky
mgeeky / VLANHopperDTP.py
Last active July 15, 2023 17:19
VLAN Hopping via DTP Trunk (Switch) Spoofing exploit - script automating full VLAN Hopping attack, from DTP detection to VLAN Hop with DHCP lease request.
#!/usr/bin/python
#
# This script is performing DTP Trunk mode detection and VLAN Hopping
# attack automatically, running sniffer afterwards to collect any other
# VLAN available. To be launched only in Unix/Linux environment as the
# script utilizes following applications:
# - 8021q.ko
# - vconfig
# - ifconfig / ip / route
@ipwnponies
ipwnponies / asyncio.md
Last active March 6, 2024 21:35
concurrent.futures (threading) vs. asyncio (event loop)

Summary

This gist demonstrates the difference between threading and asyncio. To be clear, they're both limited by the Global Interpreter Lock and are both single process, multi-threaded. They are both forms of concurrency but not parallelism.

Threading, via concurrent.futures

Threading (via Thread, concurrent.futures) employs time-slicing of CPU. All threads are given a slot of CPU time to do work. If the thread is blocking (sleeping or blocked on sockets), then off it goes to the next thread. With many threads that are blocked for long periods, this begins to degrade into polling (polling vs. interrupt)