Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

Hesham Haikal iHaikal

🎯
Focusing
View GitHub Profile
@iHaikal
iHaikal / dot.py
Created Oct 12, 2021
Regular JSON to dotted
View dot.py
import json
with open('test_dictionary_regular.json') as f:
data = json.load(f)
with open('test_dictionary_dot.json') as f:
test = json.load(f)
def to_dot(data: dict) -> dict:
out = {}
@iHaikal
iHaikal / rem_comp_suff.py
Created Oct 12, 2021
Remove company suffixes
View rem_comp_suff.py
names = ['Atlantia SpA', 'Amazon.com', 'Banco Bilbao Vizcaya Argentaria SA', 'Carl Zeiss Meditec AG', 'Antofagasta PLC', 'Bunzl plc', 'SK Hynix Inc', 'Hang Seng Bank Ltd', 'Salesforce.Com', 'Kia Motors Corp', 'Zurich Insurance Group AG']
suffices = ['Inc', 'LTD', 'SA', 'AG', '.com', 'Corp', 'Group', 'SPA', 'PLC']
[w[:-len(s)] for w in names for s in suffices if w.lower().endswith(s.lower())]
@iHaikal
iHaikal / twoSums.java
Created May 28, 2019
a submitted solution to TwoSums problem in Leetcode
View twoSums.java
// problem: https://leetcode.com/problems/two-sum/
import java.util.HashMap;
class Solution {
int[] twoSum(int[] nums, int target){
int firstIndex = -1, secondIndex = -1;
HashMap<Integer, Integer> map = new HashMap<>();