Skip to content

Instantly share code, notes, and snippets.

@satomacoto
satomacoto / __README.md
Created Mar 17, 2019
How to add Slack incoming webhook
View __README.md
  1. https://api.slack.com/apps
  2. Create New App
  3. Set App Name and Development Slack Workspace
  4. Tap App to move Building Apps for Slack
  5. Add features and functionality
  6. Select Incoming Webhooks
  7. Add New Webhook to Workspace
@satomacoto
satomacoto / extract_youtube_videoid.py
Last active Feb 23, 2019
Extract youtube video id from html
View extract_youtube_videoid.py
#!/usr/bin/env python
# -*- coding:utf-8 -*-
# extract YouTube videoids from html
import re
import json
import urllib2
from BeautifulSoup import BeautifulSoup
def get_videoids(url):
View google_langs.js
(function() {
var language_info = {
languages_top: [
{ code: "de", name: "Deutsch" },
{ code: "en", name: "English", checked: true },
{ code: "es", name: "español" },
{ code: "es-419", name: "español (Latinoamérica)" },
{ code: "fr", name: "français" },
{ code: "hr", name: "hrvatski" },
{ code: "it", name: "italiano" },
View image_np_to_image_string.py
import cv2
from PIL import Image
cap = cv2.VideoCapture(0)
_, img = cap.read()
image_string = cv2.imencode(".png", img)[1].tostring()
output = io.BytesIO()
Image.fromarray(img).save(output, format='PNG')
buf = output.getvalue()
@satomacoto
satomacoto / setup.sh
Last active Oct 25, 2018
Install node and npm with n
View setup.sh
# install node & npm
apt-get install -y nodejs npm apt-transport-https
npm cache clean
npm install n -g
n stable
ln -sf /usr/local/bin/node /usr/bin/node
ln -sf /usr/local/bin/npm /usr/bin/npm
View colorDict.py
import seaborn as sns
colorDict = {}
palette = "hls"
colorPalette = sns.color_palette(palette, len(allLabels))
for i, label in enumerate(allLabels):
colorDict[label] = colorPalette[i]
View gensim_vs_sklearn.py
# -*- coding: utf-8 -*-
import gensim
from sklearn.feature_extraction.text import CountVectorizer
from gensim.corpora.dictionary import Dictionary
from gensim.corpora import MmCorpus
import numpy as np
import lda
View rm-docker.sh
docker images | awk '/<none/{print $3}' | xargs docker rmi
docker ps -f "status=exited" -q | xargs docker rm
@satomacoto
satomacoto / dsdr.py
Created Dec 10, 2012
[He 2012] Document Summarization based on Data Reconstruction
View dsdr.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import numpy as np
class DSDR:
"""Z He, et al. Document Summarization based onData Reconstruction (2012)
http://www.aaai.org/ocs/index.php/AAAI/AAAI12/paper/viewPaper/4991
"""
@satomacoto
satomacoto / create.py
Last active Apr 27, 2018
kNN on xvideos.com-db.csv
View create.py
# -*- coding:utf-8 -*-
from pymongo import MongoClient
client = MongoClient()
db = client.xvideos
def create_db():
f = open('xvideos.com-db.csv')
for line in f:
You can’t perform that action at this time.