Skip to content

Instantly share code, notes, and snippets.

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;
const getFormulaImageURL = (tex: string): string =>
'https://chart.googleapis.com/chart?cht=tx&chl=' + encodeURIComponent(tex);
@pizzacat83
pizzacat83 / dummy
Created February 12, 2019 10:15
wiki_wakati.wv
dummy
@pizzacat83
pizzacat83 / LICENSE
Last active August 22, 2022 12:08
UTAUの周波数表をパースするコード
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
@pizzacat83
pizzacat83 / wikipedica.py
Created December 22, 2018 09:11
a function that gets the title of a Wikipedia article in another language
#!/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)
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));
import MeCab
import math
tagger = MeCab.Tagger("")
node=tagger.parseToNode(sentence)
dic={}
ad={}
g=open("corpus/wiki_wakachi.txt","w")
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(/&amp;/g,'&').replace(/&lt;/g,'<').replace(/&gt;/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"});
}
}
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意見箱'});
}
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;