This file contains 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
const formula = (params: SlackCommandParams): {} => { | |
const re = /([^]*?)((\$\$?)[^]+?\3)/g; | |
const attachments = []; | |
let last_index = 0; | |
while (1) { | |
// マッチをループ | |
const match = re.exec(params.text); | |
if (!match) break; | |
const [_, pretext, tex] = match; | |
last_index += _.length; |
This file contains 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
const getFormulaImageURL = (tex: string): string => | |
'https://chart.googleapis.com/chart?cht=tx&chl=' + encodeURIComponent(tex); |
This file contains 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
dummy |
This file contains 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
This is free and unencumbered software released into the public domain. | |
Anyone is free to copy, modify, publish, use, compile, sell, or | |
distribute this software, either in source code form or as a compiled | |
binary, for any purpose, commercial or non-commercial, and by any | |
means. | |
In jurisdictions that recognize copyright laws, the author or authors | |
of this software dedicate any and all copyright interest in the | |
software to the public domain. We make this dedication for the benefit |
This file contains 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
#!/usr/bin/env python3 | |
import sys | |
import json | |
from urllib import request, parse | |
def translate(word, org="ja", dest="en"): | |
r = request.urlopen("https://{}.wikipedia.org/w/api.php?action=query&format=json&prop=langlinks&titles={}&redirects=1&lllang={}".format(org, parse.quote(word), dest)) | |
text = r.read() | |
d = json.loads(text) |
This file contains 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
const sample = require('lodash/sample'); | |
function normalizedFreq(word){ | |
return Math.atan(freq[word])/Math.PI*2; | |
} | |
function genDummy(n){ | |
res = new Set(); | |
do{ | |
word = sample(Object.keys(ad)); |
This file contains 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 MeCab | |
import math | |
tagger = MeCab.Tagger("") | |
node=tagger.parseToNode(sentence) | |
dic={} | |
ad={} | |
g=open("corpus/wiki_wakachi.txt","w") |
This file contains 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
function doPost(e){ | |
console.log(e.parameter.trigger_word); | |
var slackApp = SlackApp.create(slackAccessToken); | |
if(e.parameter.trigger_word=="formula:"){ | |
var chId=e.parameter.channel_id; | |
var query = e.parameter.text.substr(e.parameter.trigger_word.length).trim(); | |
var url="https://chart.googleapis.com/chart?cht=tx&chl="+encodeURIComponent(query.replace(/&/g,'&').replace(/</g,'<').replace(/>/g,'>'))+"&ts="+String(Date.now()); | |
slackApp.postMessage(chId, url, {'username':'formula','icon_url':"http://icons.iconarchive.com/icons/alecive/flatwoken/512/Apps-Libreoffice-Math-B-icon.png"}); | |
} | |
} |
This file contains 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 properties=PropertiesService.getScriptProperties(); | |
var slackAccessToken = properties.getProperty('slack-access-token'); | |
function submitForm(e){ | |
var slackApp = SlackApp.create(slackAccessToken); | |
var itemResponses = e.response.getItemResponses(); | |
slackApp.postMessage("###channelID###", itemResponses[0].getResponse(), {'username':'Slack意見箱'}); | |
} |
This file contains 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
if (updateFileMap.length != 0) { | |
var slackApp = SlackApp.create(slackAccessToken); | |
if(updateFileMap.length <= 20){ | |
var attachments = []; | |
for( key in updateFileMap ){ | |
var item = updateFileMap[key]; | |
var title = item.updateType + ":"+item.filename; | |
var title_url = item.url; | |
var text = item.lastUpdate?item.updateType+'日時:' + Utilities.formatDate(item.lastUpdate, "JST", "yyyy-MM-dd HH:mm:ss") + '\n':'' | |
var color = item.color; |