Skip to content

Instantly share code, notes, and snippets.

View mozeryansky's full-sized avatar
🌴
On vacation

Michael Ozeryansky mozeryansky

🌴
On vacation
View GitHub Profile
@mozeryansky
mozeryansky / test.py
Created September 3, 2016 03:39
Python 2.7 Array vs Set Performance
import timeit
print 'set/array of numbers'
print ''
print 'first in set:', timeit.timeit('1 in set([1, 2, 3, 4, 5, 6, 7, 8, 9])', number=10000000)
print 'last in set: ', timeit.timeit('9 in set([1, 2, 3, 4, 5, 6, 7, 8, 9])', number=10000000)
print 'not in set: ', timeit.timeit('0 in set([1, 2, 3, 4, 5, 6, 7, 8, 9])', number=10000000)
print ''
@mozeryansky
mozeryansky / wikiReporter.php
Last active August 29, 2015 14:18
T-Square Wiki Reporting Tool
<?php
$teamURL = "";
$username = "";
$password = "";
if(empty($teamURL)){
echo "You can hard code your team's main site URL, along with all user inputs at the top of the source file.\n";
echo "To find your team's site, login to t-square, navigate to your team's site, and copy the current url.\n";
echo "It should look something like this: https://t-square.gatech.edu/portal/site/abcd1234-ab12-cd34-ad14-abcd1234a1b2\n";
@mozeryansky
mozeryansky / UITextField Phone Number
Created December 17, 2014 22:33
This will maintain the text field to be formatted like a phone number, and have a placeholder as the user types in the number, i.e. "(12 ) - ". And all while maintaining the cursor position where the last number is typed.
- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
{
// new number
NSString *phoneNumber = [textField.text stringByReplacingCharactersInRange:range withString:string];
// strip non-numbers
NSString *rawPhoneNumber = [[phoneNumber componentsSeparatedByCharactersInSet:[[NSCharacterSet decimalDigitCharacterSet] invertedSet]] componentsJoinedByString:@""];
if(string.length == 0 && rawPhoneNumber.length == 3){
// delete again
phoneNumber = [phoneNumber stringByReplacingCharactersInRange:NSMakeRange(range.location-2, range.length) withString:string];