Skip to content

Instantly share code, notes, and snippets.

View sasivarnakumar's full-sized avatar
🎯
Focusing

Sasi varna kumar sasivarnakumar

🎯
Focusing
View GitHub Profile
@chrisbloom7
chrisbloom7 / longest_common_substring.php
Created June 12, 2011 03:27
Find the longest common substring in an array of strings (PHP)
<?php
function longest_common_substring($words)
{
$words = array_map('strtolower', array_map('trim', $words));
$sort_by_strlen = create_function('$a, $b', 'if (strlen($a) == strlen($b)) { return strcmp($a, $b); } return (strlen($a) < strlen($b)) ? -1 : 1;');
usort($words, $sort_by_strlen);
// We have to assume that each string has something in common with the first
// string (post sort), we just need to figure out what the longest common
// string is. If any string DOES NOT have something in common with the first
// string, return false.
@thomasfr
thomasfr / Git push deployment in 7 easy steps.md
Last active July 3, 2024 02:22
7 easy steps to automated git push deployments. With small and configurable bash only post-receive hook
kgislData = open("C:\\kgisl.csv").read().splitlines()
countByDegree = {}
for i in kgislData:
degree = "Engineering" if(i.split("\t")[3]
in ["CSE", "IT", "ECE"]) \
else "Non Engineering"
if(countByDegree.has_key(degree)):
countByDegree[degree] = countByDegree[degree] + 1
else:
countByDegree[degree] = 1 #{"CSE" : 1}