Skip to content

Instantly share code, notes, and snippets.

View deniszh's full-sized avatar

Denis Zhdanov deniszh

View GitHub Profile
@deniszh
deniszh / gist:d35be4c38b41a771fd7b
Created August 7, 2014 14:49
Google hiring task (first 10-digit prime in e) in bash
#!/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
@deniszh
deniszh / gist:f7a91ffc0327f2402a9a
Created August 7, 2014 15:00
Google hiring task (first 10-digit prime in e) in bash one-liner
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 / .vimrc
Created September 30, 2014 09:02
My .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 October 3, 2014 07:47
util.py from graphite-web 0.9.12, patched for caching bug, which cause delays in graphite graphs rendering
"""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,
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
<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"
@deniszh
deniszh / whisper-diff-standalone.py
Created June 7, 2015 16:12
Standalone whisper-diff command. Quick hack based on https://github.com/graphite-project/whisper/pull/30
# 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 June 19, 2015 08:08
whitenoise fix
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
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
@deniszh
deniszh / gist:272d8b9474feed69a3f1
Created February 29, 2016 18:00
### Keybase proof
### 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: