Instantly share code, notes, and snippets.

View luhn_test.go
package luhn
import (
type testCase struct {
input string
View luhn.go
package luhn
func IsValid(digits []int) bool {
sum := 0
alt := false
for i := len(digits) - 1; 0 <= i; i-- {
d := digits[i]
if alt {
d *= 2
if d > 9 {
import requests
import json
url = '{}/{}'
result = requests.get(url.format(10, 'json')).json()
for i, x in enumerate(result['feed']['entry'], 1):
print(i, x['im:name']['label'])
def is_anagram1(s1, s2):
if len(s1) != len(s2):
return False
return sorted(list(s1)) == sorted(list(s2))
def is_anagram2(s1, s2):
if len(s1) != len(s2):
return False
import MySQLdb
import urllib.request
from bs4 import BeautifulSoup
from datetime import datetime
rss_url = '{rank_limit}/{rss_format}'
rank_limit = 200
rss_format = 'xml'
current_date ="%Y%m%d")
#!/usr/bin/env bash
# set -eu
sudo localedef -f UTF-8 -i ja_JP ja_JP
echo "Asia/Tokyo" | sudo tee /etc/timezone
sudo dpkg-reconfigure --frontend noninteractive tzdata
sudo apt-get -y install zlib1g-dev libssl-dev libreadline-dev \
libsqlite3-dev libbz2-dev libncurses5-dev libgdbm-dev liblzma-dev tk-dev zlibc
View VagrantFile
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure(2) do |config| = "debian/jessie64" "private_network", ip: ""
config.vm.synced_folder "./src/" , "/home/vagrant/src"
config.vm.provision "shell" do |s|
s.path = "provisioning/"
def sum_for(arg):
total = 0
for i in arg:
total += i
return total
def sum_while(arg):
total = cnt = 0
while cnt < len(arg):
View Dockerfile
FROM debian:latest
RUN apt-get update
RUN apt-get install -y --no-install-recommends \
git tig vim \
python3 python-dev python-pip python-virtualenv
View Effective Python.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.