Skip to content

Instantly share code, notes, and snippets.

View ohtomi's full-sized avatar
🐈
enjoy

Kenichi Ohtomi ohtomi

🐈
enjoy
View GitHub Profile
@ohtomi
ohtomi / lookup.py
Last active May 8, 2019 14:38
PandasのDataFrameを使ってCSVファイルから特定の行をルックアップするサンプル
import sys
import pandas as pd
def main(name):
df = pd.read_csv('./sample.csv', header=0)
filtered = df[df['token'] == name]
if len(filtered.index) > 0:
value = filtered.loc[filtered.index[0]]['normalized']
print(value)
else:
@ohtomi
ohtomi / init.gradle
Last active November 28, 2018 13:00
Gradle initialization scripts to run lazybones
import org.apache.tools.ant.types.Commandline
import org.gradle.api.tasks.options.Option
import java.util.Arrays
apply plugin: LazybonesPlugin
class LazybonesPlugin implements Plugin<Gradle> {
void apply(Gradle gradle) {
gradle.allprojects { project ->
project.repositories {
@ohtomi
ohtomi / fabfile.py
Created July 5, 2018 17:30
Fabric task function is wrapped by decorator.decorator
from invoke import task, context
from decorator import decorator
def ctask(f, *args, **kwds):
print('wraps')
if len(args) >= 1 and isinstance(args[0], context.Context):
print('context!')
print(args[0])
return
@ohtomi
ohtomi / bookmarklet.js
Last active May 8, 2019 14:37
Scrapboxのブックマークレット例
javascript:(function(){var title=window.prompt('Scrap "Scrapbox" to ohtomi.',document.title);
if (!title) return;
if (window.location.href.startsWith('https://github.com') && title.indexOf(':')!==-1) title=title.substr(0,title.indexOf(':'));
var lines=[];
if (window.location.href.startsWith('https://github.com')) lines.push('[https://assets-cdn.github.com/images/modules/open_graph/github-mark.png]');
else if (window.location.href.startsWith('http://stackoverflow.com')) lines.push('[https://cdn.sstatic.net/Sites/stackoverflow/company/img/logos/so/so-logo.png]');
else if (window.location.href.startsWith('http://qiita.com')) lines.push('[https://cdn.qiita.com/assets/qiita-fb-2887e7b4aad86fd8c25cea84846f2236.png]');
else if (window.location.href.startsWith('http://www.slideshare.net/')) lines.push('[http://public.slidesharecdn.com/b/images/logo/linkedin-ss/SS_Logo_Black_Large.png]');
else if (window.location.href.startsWith('https://speakerdeck.com')) lines.push('[http://www.cytoscape.org/images/icon/SpeakerDeck1
@ohtomi
ohtomi / style.css
Created December 9, 2016 02:09
Scrapboxでページの余白を狭めるスタイル例
.col-page {
width: calc(100% - 132px);
max-width: 1260px;
}
@media (min-width: 1092px)
.col-page-side {
width: calc((100% - 1260px) / 2);
}
@ohtomi
ohtomi / mbp-provisioning.md
Last active December 1, 2016 13:33
MacBook Proのプロビジョニング方針

preparation

  • Xcode
  • Homebrew
  • Ansible

directory layout

$HOME                    : $GOPATH
│
├── .aws                 : awscli
@ohtomi
ohtomi / start_cgi_http_server.sh
Last active July 21, 2022 03:39
File Upload CGI Script written in Python
#!/bin/bash
mkdir ./cgi-bin/
cp upload.cgi ./cgi-bin/
chmod +x ./cgi-bin/upload.cgi
mkdir ./upload/
python -m CGIHTTPServer 8080
@ohtomi
ohtomi / learning-machine-learning-with-jupyter.ipynb
Last active November 23, 2015 20:03
Tech Talk #2 (2015/11/24)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.