Skip to content

Instantly share code, notes, and snippets.

@takaheraw
takaheraw / index.js
Created July 22, 2017 23:17
s3 thumnail
var async = require('async');
var AWS = require('aws-sdk');
var gm = require('gm').subClass({imageMagick: true});
var util = require('util');
var MAX_WIDTH = 100;
var MAX_HEIGTH = 100;
var s3 = new AWS.S3();
var SCREEN_NAME = '';
var CONSUMER_KEY = '';
var CONSUMER_SECRET = '';
var PROJECT_KEY = '';
var FOLDER_ID = '';
var API_USER_TIMELINE = 'https://api.twitter.com/1.1/statuses/user_timeline.json';
var API_USER_LOOKUP = 'https://api.twitter.com/1.1/users/lookup.json';
var LIMIT_COUNT = 200;
var SEARCH_KEY = 'MM-dd-HH-mm';
var IMG_FILE_NAME = 'yyyy-MM-dd-HH-mm-ss';
package main
import (
"image"
"image/color"
"image/gif"
"io"
"math"
"math/rand"
"os"
require 'base64'
require 'json'
require 'net/http'
require 'uri'
require 'open-uri'
VISION_API_URL = "https://vision.googleapis.com/v1/images:annotate"
API_KEY = "foobarbazhogefuga"
URL = "#{VISION_API_URL}?key=#{API_KEY}"
INPUT_IMG_FILE = 'http://blog-imgs-42-origin.fc2.com/k/o/t/kotomona/20101125183059615.jpg'

go

brew install go
mkdir ~/.go

install

# yum -y install firefox
# yum -y install xorg-x11-server-Xvfb
# yum -y install ImageMagick 
# yum -y groupinstall "Japanese Support"
# yum -y install ipa-pgothic-fonts.noarch
# yum -y install ImageMagick.x86_64 ImageMagick-devel.x86_64
$ curl -XPOST 'http://localhost:9200/twitter' -d '
{
  "settings": {
    "analysis": {
      "analyzer": {
        "ngram_analyzer": {
          "type": "custom",
          "char_filter": ["html_strip"],
          "tokenizer": "ngram_tokenizer",
$ cat tweet.json | jq -c ' .[] |
{
  id:                     .id_str,
  created_at:             .created_at,
  text:                   .text,
  analyze_text:           .text,
  source:                 .source,
  in_reply: {
    status:               .in_reply_to_status_id_str,
[
  {
    "coordinates": null,
    "favorited": false,
    "truncated": false,
    "created_at": "Wed Aug 29 17:12:58 +0000 2012",
    "id_str": "240859602684612608",
    "entities": {
      "urls": [
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>datepicker</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/themes/smoothness/jquery-ui.css">
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/jquery-ui.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){