Skip to content

Instantly share code, notes, and snippets.

Avatar

Denis Zhdanov deniszh

View GitHub Profile
@deniszh
deniszh / gist:f7a91ffc0327f2402a9a
Created Aug 7, 2014
Google hiring task (first 10-digit prime in e) in bash one-liner
View gist:f7a91ffc0327f2402a9a
e=$(BC_LINE_LENGTH=0 bc -l <<<"scale=1000;e(1)"|sed 's#\.##');for i in {0..990};do a="${e:$i:10}";[ "$(factor $a | cut -d' ' -f2)" == "$a" ]&& echo $a;done
@deniszh
deniszh / gist:d35be4c38b41a771fd7b
Created Aug 7, 2014
Google hiring task (first 10-digit prime in e) in bash
View gist:d35be4c38b41a771fd7b
#!/bin/bash
N=1000
e=$(BC_LINE_LENGTH=0 bc -l <<<"scale=$N;e(1)"|sed 's#\.##'g)
M=$((N-10))
for i in $(seq 0 $M)
do
a="${e:$i:10}"
[ "$(factor $a | cut -d' ' -f2)" == "$a" ] && echo $a
done
View .vimrc
scriptencoding utf-8
set encoding=utf-8
set nocompatible " use vim default
syntax on
set background=dark
colorscheme delek
set t_Co=256
set list
set listchars=eol:¶,extends:>,precedes:<,nbsp:·,tab:\|_,trail:.
set hidden " http://nvie.com/posts/how-i-boosted-my-vim/
@deniszh
deniszh / util.py
Created Oct 3, 2014
util.py from graphite-web 0.9.12, patched for caching bug, which cause delays in graphite graphs rendering
View util.py
"""Copyright 2008 Orbitz WorldWide
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
View gist:512ecb742b7148c1d5c0
root@vagrant-ubuntu-precise-64:~# go build github.com/dgryski/carbonapi
root@vagrant-ubuntu-precise-64:~# go build github.com/dgryski/carbonzipper
root@vagrant-ubuntu-precise-64:~# go build github.com/grobian/carbonserver
root@vagrant-ubuntu-precise-64:~# ls -al ~/go/bin/carbon*
total 53552
drwxr-xr-x 2 root root 4096 Nov 28 16:32 .
drwxr-xr-x 5 root root 4096 Aug 8 13:20 ..
-rwxr-xr-x 1 root root 8796848 Oct 28 16:38 carbonapi
-rwxr-xr-x 1 root root 8526040 Oct 28 16:36 carbonserver
-rwxr-xr-x 1 root root 8515904 Oct 28 16:37 carbonzipper
View gist:ec7888645baaacb93fbc
<LoadPlugin python>
Globals true
</LoadPlugin>
<Plugin python>
ModulePath "/usr/lib/collectd/plugins/python"
Import "collectd_iostat_python"
<Module collectd_iostat_python>
Path "/usr/bin/iostat"
View whisper-diff-standalone.py
# Copyright 2009-Present The Graphite Development Team
# Copyright 2008 Orbitz WorldWide
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
@deniszh
deniszh / wsgi.py
Created Jun 19, 2015
whitenoise fix
View wsgi.py
import os
import sys
try:
from importlib import import_module
except ImportError:
from django.utils.importlib import import_module
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'graphite.settings') # noqa
View instrumentation.py
import os
import time
import socket
from resource import getrusage, RUSAGE_SELF
from twisted.application.service import Service
from twisted.internet.task import LoopingCall
from carbon.conf import settings
View gist:272d8b9474feed69a3f1
### Keybase proof
I hereby claim:
* I am deniszh on github.
* I am deniszh (https://keybase.io/deniszh) on keybase.
* I have a public key whose fingerprint is A477 D65F 62A7 59DD 1333 16A9 841F F4A7 BEF1 7C12
To claim this, I am signing this object: