Skip to content

Instantly share code, notes, and snippets.

View TakahikoKawasaki's full-sized avatar

Takahiko Kawasaki TakahikoKawasaki

View GitHub Profile
@TakahikoKawasaki
TakahikoKawasaki / template.sh
Last active December 20, 2015 04:48
Bash script template like C
#!/bin/bash
#--------------------------------------------------
# Global Variables
#--------------------------------------------------
__v_verbose=0
__v_dry_run="false"
@TakahikoKawasaki
TakahikoKawasaki / gist:8156948
Last active January 1, 2016 14:19
Count up letters, bytes in UTF-8 and surrogate pairs in JavaScript
<!DOCTYPE html>
<html>
<!--
* Copyright (C) 2013 Neo Visionaries Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
@TakahikoKawasaki
TakahikoKawasaki / gist:8159741
Created December 28, 2013 13:55
JavaScript で文字数、UTF-8 でのバイト数、サロゲートペアの数を数える
<!DOCTYPE html>
<html>
<!--
* Copyright (C) 2013 Neo Visionaries Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
@TakahikoKawasaki
TakahikoKawasaki / mvn-download.sh
Last active January 4, 2016 18:59
Script to download a maven artifact
#!/bin/sh
#
# Copyright (C) 2014 Neo Visionaries Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
@TakahikoKawasaki
TakahikoKawasaki / sinatra+thin+ssl.rb
Last active October 19, 2023 14:38
Sinatra + Thin + SSL
#!/usr/bin/env ruby
#
# This code snippet shows how to enable SSL in Sinatra+Thin.
#
require 'sinatra'
require 'thin'
class MyThinBackend < ::Thin::Backends::TcpServer
def initialize(host, port, options)
@TakahikoKawasaki
TakahikoKawasaki / sinatra+ssl.rb
Created December 16, 2014 14:44
Sinatra + SSL
#!/usr/bin/env ruby
#
# This code snippet shows how to enable SSL in Sinatra.
#
require 'sinatra/base'
class Application < Sinatra::Base
configure do
set :bind, '0.0.0.0'
@TakahikoKawasaki
TakahikoKawasaki / namespace.js
Last active August 29, 2015 14:18
Function to define a namespace in JavaScript.
/*
* Copyright (C) 2015 Neo Visionaries Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@TakahikoKawasaki
TakahikoKawasaki / EchoClient.java
Last active August 14, 2020 09:39
A sample WebSocket client application using nv-websocket-client library.
/*
* Copyright (C) 2015 Neo Visionaries Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
@TakahikoKawasaki
TakahikoKawasaki / NaiveSSLContext.java
Created May 3, 2015 17:18
A factory class which creates an SSLContext that naively accepts all certificates without verification.
/*
* Copyright (C) 2015 Neo Visionaries Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
@TakahikoKawasaki
TakahikoKawasaki / index.js
Created October 31, 2015 23:10
Amazon AWS Lambda function protected by OAuth 2.0 access token using Authlete
var async = require('async');
var request = require('request');
// The API credentials of your service. These are needed to call Authlete
// Web APIs.
var api_key = '{Your-Service-API-Key}';
var api_secret = '{Your-Service-API-Secret}';
// A function to call Authlete's introspection API.
//