Skip to content

Instantly share code, notes, and snippets.

@TakahisaShiratori
TakahisaShiratori / city_info.json
Created June 26, 2016 04:13
Randomly generated city position on x-y coordinate for Traveling Salesman Problem
[
{
"id": 0,
"x": -0.9476209907737456,
"y": 0.09242753936279535
},
{
"id": 1,
"x": -0.31881529547019216,
"y": 0.5676147817727233
@TakahisaShiratori
TakahisaShiratori / random_cities.py
Last active June 26, 2016 04:23
Code to generate position of cities randomly for Traveling Salesman Problem
import json
import random
cities = []
nnmax = 50
for nn in range(nnmax):
city = {}
city['id'] = nn
city['x'] = (random.random() - 0.5)*2
@TakahisaShiratori
TakahisaShiratori / traveling_salesman.py
Last active June 26, 2016 04:25
Traveling Salesman Problem with Genetic Algorithm. Execute this code on EC2 with proper IAM Role.
import math
import random
import json
import csv
import datetime
import boto3
import os
population = 100
generation = 10000
@TakahisaShiratori
TakahisaShiratori / regular_boxnotes.py
Created June 26, 2016 04:32
Lambda functon to generate Box Note regularly
# -*- coding: utf-8 -*-
# See also http://blog.serverworks.co.jp/tech/2016/06/02/minutes-automation/
import json
import boto3
import urllib2
import httplib
from base64 import b64encode, b64decode
from datetime import datetime, timedelta
@TakahisaShiratori
TakahisaShiratori / gui-setup.sh
Created December 22, 2016 12:24
Ubuntu GUI setup
#!/bin/bash
# Setup of GUI
add-apt-repository -y ppa:x2go/stable
apt-get -y update
apt-get -y install x2goserver x2goserver-xsession
apt-add-repository -y ppa:ubuntu-mate-dev/ppa
apt-add-repository -y ppa:ubuntu-mate-dev/trusty-mate
apt-get -y update
apt-get -y install ubuntu-mate-core ubuntu-mate-desktop
@TakahisaShiratori
TakahisaShiratori / ubuntu1710_openfoam5.def
Created December 26, 2017 08:50
Tried to create Singularity Container of OpenFOAM v5 but failed to run
Bootstrap: docker
From: ubuntu:17.10
%post
apt-get -y update
apt-get -y upgrade
apt-get -y install apt-file
apt-get -y install software-properties-common
apt-get -y install wget
apt-get -y install apt-transport-https
@TakahisaShiratori
TakahisaShiratori / rescale_job_submit.ipynb
Created January 12, 2018 08:08
Submitting a sample job to Rescale from Amazon SageMaker
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@TakahisaShiratori
TakahisaShiratori / basic_mathematics_jupyter.ipynb
Last active February 19, 2018 13:02
Learn Basic Mathematics with Jupyter Notebook
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@TakahisaShiratori
TakahisaShiratori / firstJob.json
Created September 23, 2018 14:42
Rescale Persistent Cluster with REST API
{
"name": "First Job",
"jobanalyses": [
{
"analysis": {
"code": "user_included",
"version": "0"
},
"command": "echo first_job_start; sleep 5m; echo first_job_end",
"flags": {},
@TakahisaShiratori
TakahisaShiratori / rescale_rest_api_com.py
Last active June 14, 2019 15:38
Sample script to use Rescale with REST API
import json
import requests
api_token = "a0************************************4b"
token_in_header = "Token " + api_token
platform = "platform.rescale.com"
job_configuration = {
"name": "Example Job from API",
"jobanalyses": [