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 chess, sys | |
import chess.svg | |
# Install python-chess to your Python3 virtualenv | |
# virtualenv -p python3 ~/path/to/myvenv | |
# source /path/to/myvenv/bin/activate | |
# Usage: python3 fen-to-svg.py 'myfenstring' outputfilename | |
# or /path/to/myvenv/bin/python3 fen-to-svg.py 'myfenstring' outputfilename | |
fen = sys.argv[1] | |
file_name = '{}.svg'.format(sys.argv[2]) |
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
>>> line = '\something' | |
>>> line | |
'\\something' | |
>>> line.startswith('\some') | |
True | |
>>> line.startswith('\\some') | |
True |
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 time | |
string_to_add = 'my_new_characters' | |
file_name = 'my_file.{}'.format(time.time()) | |
file_name = '{}{}'.format(file_name, string_to_add) | |
with open(file_name, 'w') as outfile: | |
outfile.write('hello') | |
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 time | |
file_name = 'my_file.{}'.format(time.time()) | |
with open(file_name, 'w') as outfile: | |
outfile.write('hello') | |
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
def flatten(my_list): | |
for a in my_list: | |
if not a: | |
continue | |
for b in a: | |
yield b | |
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 math import sqrt, sin | |
import numpy as np | |
import matplotlib.pyplot as plt | |
d = 0.8 | |
data = [] | |
x_values = [] | |
theta_values = [] | |
n_values = [] |
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
var path = require('path') | |
var webpack = require('webpack') | |
module.exports = { | |
entry: "./index.js", | |
output: { | |
path: __dirname, | |
filename: "build.js" | |
}, |
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
<!DOCTYPE html> | |
<meta charset="utf-8"> | |
<style> | |
body { | |
font: 10px sans-serif; | |
} | |
.axis path, | |
.axis line { |
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 | |
# Find process that tries to establish outbound SSH connections | |
for (( ; ; )) | |
do | |
sleep 1 | |
lsof -i tcp:22 -P -R | |
if [ $? -eq 0 ]; then | |
echo 'found something. See above for details' | |
exit | |
else |
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
# You can nicely pass the dictionary items as keyword arguments | |
def my_function(a, b, c): | |
print a, b, c | |
# Pass keyword arguments | |
my_function(a=10, b=20, c=30) | |
args_dict = {'a': 100, 'b': 200, 'c':300} | |
# Pass keyword arguments using a dictionary | |
# The dictionary keys map to names of the keyword arguments |