Skip to content

Instantly share code, notes, and snippets.

View maksymx's full-sized avatar
🐍
I may be slow to respond.

Maksym L maksymx

🐍
I may be slow to respond.
View GitHub Profile
@maksymx
maksymx / ping.py
Last active August 29, 2015 13:57
Ping from python stdlibs
import os
hostname = "google.com" #example
response = os.system("ping -c 1 " + hostname)
#and then check the response...
if response == 0:
print hostname, 'is up!'
else:
print hostname, 'is down!'
data:text/html, <style type="text/css">.e{position:absolute;top:0;right:0;bottom:0;left:0;}</style><div class="e" id="editor"></div><script src="http://d1n0x3qji82z53.cloudfront.net/src-min-noconflict/ace.js" type="text/javascript" charset="utf-8"></script><script>var e=ace.edit("editor");e.setTheme("ace/theme/monokai");e.getSession().setMode("ace/mode/ruby");</script>
<!--
For other language: Instead of `ace/mode/ruby`, Use
Markdown -> `ace/mode/markdown`
Python -> `ace/mode/python`
C/C++ -> `ace/mode/c_cpp`
Javscript -> `ace/mode/javascript`
Java -> `ace/mode/java`
Scala- -> `ace/mode/scala`
@maksymx
maksymx / finder.sh
Last active August 29, 2015 13:58
Find a string in a file in some directory
find ~/path/to/file -type f | xargs grep -i "STRING"
@maksymx
maksymx / gist:700521654141e314f7bb
Created July 15, 2014 15:48
Create new Cisco Perforce client
### create new dir
### cd dir
p4_newclient -modules # list of all modules
p4_newclient -c username:project_directory:freebsd_client_name repo_name # create client
# check view in the client regarding project needs
p4 client -o # check client settings
p4 sync # download files from repo
python co_helper.py # download dependencies
@maksymx
maksymx / gist:11383ba09e95089bf330
Last active August 29, 2015 14:04
Remove specific characters from a string in python
# You can instead use str.translate:
line = line.translate(None, '!@#$')
# — which only works on Python 2.6 and newer Python 2.x versions * —
# or regular expression replacement with re.sub
import re
line = re.sub('[!@#$]', '', line)
@maksymx
maksymx / gist:1dbf157ab6d13058acca
Created September 2, 2014 14:15
Timeout decorator
import signal
class TimeOut(Exception):
def __init__(self, msg='Time out error'):
super(Exception, self).__init__(msg)
def on_alarm(signum, frame): # при надходженні сигналу кидати виняток
raise TimeOut()
def limit_time(t, default=None):
@maksymx
maksymx / parallax.js
Last active August 29, 2015 14:12 — forked from hamstu/parallax.js
var ParallaxManager, ParallaxPart;
ParallaxPart = (function() {
function ParallaxPart(el) {
this.el = el;
this.speed = parseFloat(this.el.getAttribute('data-parallax-speed'));
this.maxScroll = parseInt(this.el.getAttribute('data-max-scroll'));
}
ParallaxPart.prototype.update = function(scrollY) {
@maksymx
maksymx / singleton.py
Last active August 29, 2015 14:22 — forked from shelling/singleton.py
#!/usr/bin/env python
class Hello(object):
singleton = None
def __new__(clz):
if not clz.singleton:
clz.singleton = object.__new__(clz)
return clz.singleton
@maksymx
maksymx / Python_Test_task.py
Created July 18, 2015 16:48
SECL group test task
# coding=utf-8
TEST = True # установите True, чтобы запустить проверку
"""
***********************************************
Написать два класса: сотрудник и команда.
Сотрудник имеет имя, стоимость работы (долларов в час) и уровень квалификации (от 0 до 9).
Если сложить сотрудников (оператор +), то будет создана команда, которая будет иметь уровень
квалификации (максимальный уровень из всех сотрудников в команде), стоимость (сумма стоимости
всех сотрудников команды) и список всех сотрудников.
@maksymx
maksymx / python_soap.md
Last active September 8, 2015 13:32 — forked from diyan/python_soap.md

Python. SOAP services

SOAP services. Overview

Evaluating Tools for Developing with SOAP in Python. Doug Hellmann - http://doughellmann.com/2009/09/01/evaluating-tools-for-developing-with-soap-in-python.html

What's the best SOAP client library for Python, and where is the documentation for it? - http://stackoverflow.com/questions/206154/whats-the-best-soap-client-library-for-python-and-where-is-the-documentation-f

What's the best SOAP library for Python 3.x? - http://stackoverflow.com/questions/7817303/whats-the-best-soap-library-for-python-3-x