Skip to content

Instantly share code, notes, and snippets.

@ksomemo
ksomemo / dsp.py
Created January 14, 2021 04:40 — forked from takegue/dsp.py
Simple DSP Server for AdTech Competition 2016. To run this code, you have to install "tornado" which is a Python Framework.
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from tornado import ioloop, httpserver, web, httpclient
import json
import urllib.parse
import logging
import time
  • BIOS
    • enabled BIOS virtual CPU
  • windows
    • update kernel
    • set WSL version 2
    • enabled Virtual machine platform and WSL
    • install Ubuntu from store
    • git bash for windows
    • install vscode
  • install remote extension
@ksomemo
ksomemo / py_json_formatter.sh
Created June 19, 2020 01:45
ensure_ascii のためだけの onliner
python -c 'import sys,json as j;print(j.dumps(j.loads(sys.stdin.read()),indent=2,ensure_ascii=False))'
# no ensure_ascii
python -m json.tool
@ksomemo
ksomemo / googleSearchLang2English.js
Created June 18, 2020 01:16
bookmarklet, google search language to english
javascript:(() => {location.href += '&lr=lang_en';})()
@ksomemo
ksomemo / Main.java
Last active January 17, 2020 01:30
digdag plugin downloader
import io.digdag.core.plugin.RemotePluginLoader;
import io.digdag.core.plugin.Spec;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Arrays;
public class Main {
public static void main(String[] args) {
Spec spec = Spec.of(
@ksomemo
ksomemo / gist:890d2cfef1491185dec2bf566751ab99
Created December 25, 2019 14:51 — forked from kwatch/gist:4672421
How to convert query object into non-prepared sql string in SQLAlchemy and psycopg2
def query2sql(query):
"""convert query object into non-prepared sql string in SQLAlchemy and psycopg2"""
compiler = query.statement.compile()
params = compiler.params
prepared_sql = compiler.string # or str(compiler)
psycopg2_cursor = query.session.connection().connection.cursor()
sql = psycopg2_cursor.mogrify(prepared_sql, params)
return sql
@ksomemo
ksomemo / ansible.yml
Created September 1, 2019 16:16 — forked from bennylope/ansible.yml
Deployment w/ Capistrano style deployments with Ansible & Capistrano
---
- name: Deploy new site release
user: deployer
hosts: all
tasks:
- name: Fetch repo updates
git: >
[email protected]:my/repo.git
@ksomemo
ksomemo / global_nonlocal.py
Last active August 31, 2019 06:51
global, nonlocal
a = 0
a2 = 100
def main():
global a, a2
print('a2', a2)
print(a)
a += 1
print(a)
a += 5
@ksomemo
ksomemo / TSP.jl
Created March 29, 2018 19:14 — forked from dnishiyama85/TSP.jl
Julia言語による巡回セールスマン問題の焼きなまし法を使った解法
using PyPlot
const AREA_SCALE = 100
const NUM_POINTS = 100
# 頂点をランダムな位置に配置
function generate_points()
points = zeros(NUM_POINTS, 2)
points[:, 1] = rand(NUM_POINTS) * AREA_SCALE
points[:, 2] = rand(NUM_POINTS) * AREA_SCALE