Skip to content

Instantly share code, notes, and snippets.

View yokawasa's full-sized avatar
:octocat:
debugging

Yoichi Kawasaki yokawasa

:octocat:
debugging
View GitHub Profile
@yokawasa
yokawasa / xml2json.pl
Created June 8, 2015 23:08
Generating JSON Data for Azure Search from Wikipedia Database Dump File
#!/usr/bin/perl -w
use strict;
use XML::Twig;
use Getopt::Std;
use Encode;
use JSON;
my $UPLOAD_THRESHOLD=100;
my %opts=();
getopts('c:o:', \%opts) or die "Wrong Options!\n";
@yokawasa
yokawasa / rssCrawler4Docdb.py
Last active November 18, 2021 22:57
RSS Crawler - Crawling and parsing data with feedparser and storing results into Azure DocumentDB with pydocumentdb
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import feedparser
import pydocumentdb.documents as documents
import pydocumentdb.document_client as document_client
import pydocumentdb.errors as errors
import pydocumentdb.http_constants as http_constants
Docdb_masterKey = '<Your Documentdb master key string>'
Docdb_host = 'https://<documentdb account>.documents.azure.com:443/'
@yokawasa
yokawasa / azuresshconfig_completion.bash
Last active October 31, 2016 06:04
Bash completion file for azuresshconfig
# bash completion for azuresshconfig
# azuresshconfig HOME: https://github.com/yokawasa/azure-ssh-config
#
# In order to load this, do either
# put this file under /etc/bash_completion.d, /usr/local/etc/bash_completion.d, or ~/bash_completion.d
# or
# append 'source /path/to/azuresshconfig_completion.bash' to .bashrc
_azuresshconfig() {
local cmd cur prev
@yokawasa
yokawasa / run.csx
Last active May 22, 2018 15:36
Azure Function HTTP Trigger Function Sample
using System.Net;
using Newtonsoft.Json;
public static async Task<HttpResponseMessage> Run(HttpRequestMessage req, TraceWriter log)
{
log.Info("C# HTTP trigger function to process fluentd output request.");
log.Info( string.Format("Dump request:\n {0}",req.ToString()));
// parse query parameter
string payload = req.GetQueryNameValuePairs()
.FirstOrDefault(q => string.Compare(q.Key, "payload", true) == 0)
@yokawasa
yokawasa / ud_normalize_ja.py
Created May 15, 2017 04:05
unicodedata.normalizeのNFKC(Normalization Form Compatibility Composition)で文字列正規化サンプル: 半角カタカナ、全角記号、濁音、特殊文字などなどを正規化
# -*- coding: utf-8 -*-
import unicodedata
"""
unicodedata.normalizeのNFKC(Normalization Form Compatibility Composition)で半角カタカナ、全角英数、濁音、特殊文字などなどを正規化
"""
data = u"㈱㍉㌶ (%&!?@#)カタカナザザザザザア"
normal = unicodedata.normalize('NFKD', data).encode('utf-8', 'ignore')
print normal
@yokawasa
yokawasa / blobxfer-include-and-strip-components-option.md
Last active April 25, 2018 00:19
About Blobxfer option --inlcude and --strip-components
@yokawasa
yokawasa / mysql-deploy.yaml
Created April 25, 2018 00:57
Kubernetes YAML file for sample deployment of application that leverage Open Service Broker for MySQL PaaS on Azure
apiVersion: apps/v1beta1
kind: Deployment
metadata:
name: sample-osba-mysql
spec:
replicas: 1
template:
metadata:
labels:
app: sample-osba-mysql
@yokawasa
yokawasa / sample-osba-mysql.py
Created April 25, 2018 01:01
Sample Python application that reads MySQL configurations from ENV and executes simple operations
import MySQLdb as db
import os
# MySQL configurations
MYSQL_USER = os.environ['MYSQL_USER']
MYSQL_PASSWORD = os.environ['MYSQL_PASSWORD']
MYSQL_HOST = os.environ['MYSQL_HOST']
MYSQL_DATABASE = os.environ['MYSQL_DATABASE']
print(MYSQL_USER)
@yokawasa
yokawasa / ticketmonster-frontend-setup.md
Last active May 11, 2018 10:39
TicketMonster App Setup Memo - Frontend (mod-cluster and wildfly)

TicketMonster App Setup Memo - Frontend: Wildfly and mod-cluster

Environment:

  • CentOS based 7.4
$ cat /etc/redhat-release
CentOS Linux release 7.4.1708 (Core)
@yokawasa
yokawasa / ticketmonster-database-setup.md
Last active May 9, 2018 09:36
TicketMonster App Setup Memo - Database (PostgreSQL)

TicketMonster App Setup Memo - Database: PostgreSQL

Environment:

  • CentOS based 7.4
  • PostgreSQL 9.6
$ cat /etc/redhat-release
CentOS Linux release 7.4.1708 (Core)