This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
See https://www.codewars.com/kata/digital-cypher | |
""" | |
import itertools | |
import string | |
ABC = string.ascii_lowercase | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
See the full table at http://www.hemi.nsu.ru/mends.htm | |
""" | |
MENDELEEV_TABLE = { | |
'H': 1, | |
'He': 4, | |
'Li': 7, | |
'Be': 9, | |
'B': 11, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
See https://www.codewars.com/kata/all-that-is-open-must-be-closed-dot-dot-dot | |
## Background | |
We all know about "balancing parentheses" (plus brackets, braces and chevrons) | |
and even balancing characters that are identical. | |
Read that last sentence again, I balanced different characters and identical | |
characters twice and you didn't even notice... :) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
message_file=$1 | |
echo "" >> $message_file | |
random_wiki=`curl -s --head https://en.wikipedia.org/wiki/Special:Random | grep 'location: ' | cut -d ' ' -f 2` | |
echo "In case you are interested, you may read about $random_wiki" >> $message_file |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
import numpy as np | |
def get_reads_and_writes(lines, wanted): | |
result = [] | |
for line in lines: | |
_, name, value = line.split(':') | |
if name == wanted: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Sends system's pulse to a watchdog device | |
Usage: | |
python pulse.py <serial device> | |
Example: | |
SLEEP=25 python pulse.py /dev/ttyUSB0 | |
""" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from __future__ import print_function | |
""" | |
Pre-commit hook for Cyclomatic Complexity check | |
Works well with radon==2.2.0 | |
""" | |
__author__ = 'Ivan Styazhkin <[email protected]>' | |
import subprocess |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"encoding/json" | |
"flag" | |
"fmt" | |
linuxproc "github.com/c9s/goprocinfo/linux" | |
"github.com/streadway/amqp" | |
"log" | |
"os" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
In [39]: a = {} | |
In [40]: for i in xrange(4): | |
...: key = ''.join(random.sample(string.ascii_lowercase, 10)) | |
...: a[key] = key | |
...: | |
In [41]: a | |
Out[41]: | |
{'beuvqlcnyp': 'beuvqlcnyp', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
from __future__ import print_function | |
import csv | |
import glob | |
import logging | |
import os | |
logging.basicConfig( | |
level=logging.WARNING, |