Skip to content

Instantly share code, notes, and snippets.

View nderkach's full-sized avatar
✏️

Nikolay Derkach nderkach

✏️
View GitHub Profile
@nderkach
nderkach / find_missing_packages
Created September 19, 2014 17:36
Find missing python packages
#!/usr/bin/env python
import os
import importlib
for fn in os.listdir():
if fn.endswith(".py"):
with open(fn, 'r') as f:
for line in f:
if "import" in line:
#!/usr/bin/env python
import unittest
class Stack(list):
def push(self, item):
self.append(item)
def isEmpty(self):
return not self
def peek(self):
#!/usr/bin/python
import unittest
class Node(object):
def __init__(self, data, children=None):
self.children = []
self.right = None
self.data = data
#!/usr/bin/python
import itertools
from collections import defaultdict
from timeit import Timer
class Feature(object):
def __init__(self, name):
self.name = name
@nderkach
nderkach / read_mitmproxy_dumpfile.py
Last active April 18, 2023 21:36
Read a mitmproxy dump file and generate a curl command
#!/usr/bin/env python
#
# Simple script showing how to read a mitmproxy dump file
#
### UPD: this feature is now avaiable in mitmproxy: https://github.com/mitmproxy/mitmproxy/pull/619
from libmproxy import flow
import json, sys
@nderkach
nderkach / ios_github_gif.md
Last active February 15, 2024 23:31
How to record iOS screen and share it on github

Record a screencast with QuickTime Player

  1. Connect an iOS defice with a cable
  2. In QuickTime Player: Option-Cmd-N (New Movie Recording) -> Select your device from the recording menu:

http://cl.ly/image/1w0y3Y0H2g2X/record.png

Install gifify

@nderkach
nderkach / octopress_github.md
Last active August 29, 2015 14:13
How to setup and configure an existing Octopress blog with github pages

Say, you have an existing octopress blog published on github pages, here is how to configure it:

git clone https://github.com/username/username.github.io.git
cd username.github.io.git
git checkout source
mkdir _deploy
cd _deploy
git init
git remote add -t master -f origin https://github.com/username/username.github.io.git
@nderkach
nderkach / parse_nssortdescriptor
Last active October 16, 2015 10:19
Parse with NSSortDescriptor example
NSSortDescriptor *commonLikesDescriptor = [NSSortDescriptor sortDescriptorWithKey:@"fblikes" ascending:YES comparator:^NSComparisonResult(NSArray* obj1, NSArray* obj2) {
NSMutableSet *intersection1 = [NSMutableSet setWithArray:user[@"fblikes"]];
[intersection1 intersectSet:[NSSet setWithArray:obj1]];
NSMutableSet *intersection2 = [NSMutableSet setWithArray:user[@"fblikes"]];
[intersection2 intersectSet:[NSSet setWithArray:obj2]];
return [@([intersection1 count]) compare:@([intersection2 count])];
}];
- (void)objectsDidLoad:(nullable NSError *)error {
[super objectsDidLoad:error];
__block PFGeoPoint *currentLocation = [PFUser currentUser][@"location"];
NSSortDescriptor *distanceDescriptor = [NSSortDescriptor sortDescriptorWithKey:@"location" ascending:YES comparator:^NSComparisonResult(PFGeoPoint* obj1, PFGeoPoint* obj2) {
return [@([currentLocation distanceInMilesTo:obj1]) compare:@([currentLocation distanceInMilesTo:obj2])];
}];
[self setValue:[[self.objects sortedArrayUsingDescriptors:@[distanceDescriptor]] mutableCopy] forKey:@"_mutableObjects"];
@nderkach
nderkach / NSDateFormatter cheat sheet
Created October 7, 2015 04:40 — forked from romaonthego/NSDateFormatter cheat sheet
Date Formats for NSDateFormatter
a: AM/PM
A: 0~86399999 (Millisecond of Day)
c/cc: 1~7 (Day of Week)
ccc: Sun/Mon/Tue/Wed/Thu/Fri/Sat
cccc: Sunday/Monday/Tuesday/Wednesday/Thursday/Friday/Saturday
d: 1~31 (0 padded Day of Month)
D: 1~366 (0 padded Day of Year)