Skip to content

Instantly share code, notes, and snippets.

View akost's full-sized avatar
🏠
Working from home

Andrei K akost

🏠
Working from home
View GitHub Profile
@akost
akost / har_request_urls.py
Created May 5, 2012 11:49
Parse a HAR (HTTP Archive) and return URLs which do not match specific domain
#!/usr/bin/env python
"""
Parse a HAR (HTTP Archive) and return URLs which do not match specific domain
HAR Spec: http://groups.google.com/group/http-archive-specification/web/har-1-2-spec
HAR can be saved, for example, from Chrome Developer Tools
Copyleft 2012 Andrei Kost <kost@kost.ru>
based Ian Gallagher <crash@neg9.org> script https://gist.github.com/892479
Example usage: ./har_request_urls.py foo.har
"""
@akost
akost / gist:3871322
Created October 11, 2012 09:49 — forked from lucasfais/gist:1207002
Sublime Text 2 - Useful Shortcuts

Sublime Text 2 – Useful Shortcuts (Mac OS X)

General

⌘T go to file
⌘⌃P go to project
⌘R go to methods
⌃G go to line
⌘KB toggle side bar
⌘⇧P command prompt
@akost
akost / gist:4501571
Created January 10, 2013 12:10 — forked from Dimox/gist:4501510
if ($cat == $cat1 || $parent == $cat1) $class = 'cat1';
if ($cat == $cat2 || $parent == $cat2) $class = 'cat2';
if ($cat == $cat3 || $parent == $cat3) $class = 'cat3';
if ($cat == $cat4 || $parent == $cat4) $class = 'cat4';
if ($cat == $cat5 || $parent == $cat5) $class = 'cat5';
if ($cat == $cat6 || $parent == $cat6) $class = 'cat6';
if ($cat == $cat7 || $parent == $cat7) $class = 'cat7';
@akost
akost / gist:6386238
Last active December 21, 2015 23:59
Сдача экзамена по вождению в WA, USA. Существенное отличие от сдачи в России. Цитата из Drivers Guide http://www.dol.wa.gov/driverslicense/guide.html
Экзаменатор не ставит перед собой задачу ввести в заблуждение,
запутать или потребовать от экзаменуемого совершить правонарушение.
openssl req -new -newkey rsa:2048 -nodes -keyout yourdomain.key -out yourdomain.csr
http://support.godaddy.com/help/article/3601/generating-a-certificate-signing-request-nginx
http://support.godaddy.com/help/article/4976/rekeying-an-ssl-certificate
# Be sure to remember to chain them!
cat gd_bundle-g2-g1.crt >> yourdomain.crt
# Move 'em
sudo mv yourdomain.crt /etc/ssl/certs/yourdomain.crt
@akost
akost / gist:b1fc7189ea5dc291b79e
Created September 11, 2015 23:02
Bookmarklet to show all page headers
javascript:(function(){function%20read(url){var%20r=new%20XMLHttpRequest();r.open('HEAD',url,false);r.send(null);return%20r.getAllResponseHeaders();}alert(read(window.location))})();
@akost
akost / hours.php
Created March 9, 2017 18:42
Ugly 12-hours formatting
<?php echo ($i <= 12) ? $i : (($i <= 24) ? ($i - 12) : ($i - 24)) ?><?php echo $i < 12 ? 'am' : ($i > 23) ? 'am' : 'pm' ?>
"""
Detect a cycle in a linked list. Note that the head pointer may be 'None' if the list is empty.
A Node is defined as:
class Node(object):
def __init__(self, data = None, next_node = None):
self.data = data
self.next = next_node
"""
@akost
akost / str_to_int.py
Last active July 2, 2017 16:27
Convert string to signed integer
"""
Convert string to integer
"""
import unittest
class TestStringMethods(unittest.TestCase):
def test1(self):
self.assertEqual(myInt("123"), 123)
@akost
akost / str_to_int.py
Last active July 2, 2017 18:02
Converts string to integer
"""
Convert string to integer
"""
import unittest
class TestStringMethods(unittest.TestCase):
def test1(self):
self.assertEqual(myInt("123"), 123)