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 / 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 / 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 / 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: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 / 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"
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 / 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!'