Skip to content

Instantly share code, notes, and snippets.

View jossef's full-sized avatar
🌶️

Jossef Kadouri jossef

🌶️
View GitHub Profile
@jossef
jossef / main.dart
Last active May 23, 2020 11:20
dart string split with maximum
import 'dart:convert';
List<String> split(String string, String separator, {int max = 0}) {
var result = List<String>();
if (separator.isEmpty) {
result.add(string);
return result;
}
@jossef
jossef / compare_aws_twilio_sms.py
Created January 2, 2020 06:55
compare AWS and Twilio SMS prices
#!/usr/bin/env python3
from collections import defaultdict
import csv
import concurrent.futures
import numpy
import requests
import pycountry
@jossef
jossef / sample_waze_police_coordinates.py
Last active October 2, 2024 06:52
python script that samples Waze's reported police coordinates and log them with a timestamp
#!/usr/bin/env python3
import json
import datetime
import requests
def get_police_coordinates_from_waze():
headers = {
"referer": "https://www.waze.com/livemap",
@jossef
jossef / main.py
Last active August 13, 2019 06:49
Active Directory create test users and groups, link them to the groups
import ldap3
from ldap3 import Server, Connection
from ldap3.extend.microsoft.addMembersToGroups import ad_add_members_to_groups
def domain_to_distinguished_name(domain):
return ','.join(map(lambda x: 'dc=' + x, domain.split('.')))
def main():
@jossef
jossef / main.dart
Created January 14, 2019 21:43
dart-so-question
import 'dart:convert';
String toJson(dynamic object) {
var encoder = new JsonEncoder.withIndent(" ");
return encoder.convert(object);
}
dynamic fromJson(String jsonString) {
return json.decode(jsonString);
}
@jossef
jossef / keybindings.json
Created December 15, 2018 14:56
intellij-vs to vscode keybindings
[
{
"key": "ctrl+alt+f",
"command": "editor.action.formatDocument",
"when": "editorTextFocus && !editorReadonly"
},
{
"key": "ctrl+shift+i",
"command": "-editor.action.formatDocument",
"when": "editorTextFocus && !editorReadonly"
@jossef
jossef / brackets.py
Created March 12, 2018 15:39
python brackets / parenthesis split join to list
def split_brackets(text, brackets_open_character='(', brackets_close_character=')', depth=0):
items = []
word = ''
counter = 0
start = -1
for index, character in enumerate(text):
if character == brackets_open_character:
@jossef
jossef / github.py
Created September 15, 2017 11:26
simple github branch creation functions via rest api
import requests
class GitHubClient(object):
def __init__(self, api_token, verify_ssl=True):
self.api_token = api_token
self.headers = {'Authorization': 'token {}'.format(api_token)}
self.verify_ssl = verify_ssl
def get_branches(self, username, repository):
@jossef
jossef / common.py
Last active March 3, 2023 13:56
python run once
import sys
import fcntl
import os
_run_once_file_handle = 0
def run_once():
global _run_once_file_handle
@jossef
jossef / encapsulate-erspan.py
Created June 1, 2017 12:55
GRE ERSPAN Scapy pcap encapsulator
#! /usr/bin/python
from scapy.layers.inet import *
from scapy.layers.l2 import *
from scapy.all import *
class ERSPAN(Packet):
name = "ERSPAN"
fields_desc = [BitField("version", 1, 4),
BitField("vlan", 0, 12),