Skip to content

Instantly share code, notes, and snippets.

View udhayprakash's full-sized avatar
🎯
Focusing

Udhay Prakash Pethakamsetty udhayprakash

🎯
Focusing
View GitHub Profile
@btray77
btray77 / xml2json.js
Last active April 15, 2021 23:56
RegEX to parse XML to JSON
// Original from: http://killzonekid.com/worlds-smallest-fastest-xml-to-json-javascript-converter/
// Thanks to Loamhoof for helping get this working!
// http://stackoverflow.com/questions/15675352/regex-convert-xml-to-json/15680000
//Load XML into XML variable
var regex = /(<\w+[^<]*?)\s+([\w-]+)="([^"]+)">/;
while (xml.match(regex)) xml = xml.replace(regex, '<$2>$3</$2>$1>');
xml = xml.replace(/\s/g, ' ').
@willurd
willurd / web-servers.md
Last active November 13, 2024 13:44
Big list of http static server one-liners

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000
@danieltanfh95
danieltanfh95 / findSmallestDivisor.py
Created December 18, 2019 15:09
findSmallestDivisor
def findSmallestDivisor(s,t):
if(check_if_divisible(s, t)):
return len(find_shortest_repeating_substring(t))
else:
return -1
def check_if_divisible(s, t):
is_length_divisible = (len(s) % len(t)) == 0
if(is_length_divisible):
return t*(len(s)//len(t)) == s