Skip to content

Instantly share code, notes, and snippets.

View shukob's full-sized avatar
🏊‍♂️

Shumpei Kobayashi shukob

🏊‍♂️
View GitHub Profile
#=
quantum_walk:
- Julia version: 1.1.1
- Author: shunpeik
- Date: 2019-11-30
=#
using Plots
using LinearAlgebra
gr()
import "github.com/aws/aws-lambda-go/events"
type CognitoEventUserPoolsDefineCustomAuth struct {
events.CognitoEventUserPoolsHeader
Request CognitoEventUserPoolsDefineCustomAuthRequest `json:"request"`
Response CognitoEventUserPoolsDefineCustomAuthResponse `json:"response"`
}
type CognitoEventUserPoolsDefineCustomAuthRequest struct {
UserAttributes map[string]string `json:"userAttributes"`
@shukob
shukob / part_of_RichText.php
Last active May 9, 2018 07:39
Hashtag to link in humhub
public static function convertHashtags($text)
{
return preg_replace_callback(
'/#(?!039)([\w]+)/', // all "word" characters, all digits, and underscore
// brackets around the string AFTER the hashtag
function ($hit) {
// $matches[0] is the complete match (including the hashtag)
// $matches[1] is the match for the subpattern enclosed in brackets
return '[' . $hit[0] . '](' . 'http://localhost:8080/index.php?r=' . Html::encode('search/search/index') .
@shukob
shukob / gist:5721611
Last active December 18, 2015 03:58
Ruby: Construction of a closed curve with discrete edge points, that calculate its area and the center of mass.
class Point
def initialize(x, y)
self.x = x
self.y = y
end
def inspect
"(#{x}, #{y})"
end
@shukob
shukob / gist:5720542
Created June 6, 2013 10:08
Java: Simple Japanese Hyphenation Tokenizer
class JapaneseHyphenationTokenizer {
protected String mSourceString = "";
protected int mTokenLength = 1;
protected int mCurrentPositionInLine = 0;
protected int mCurrentLine = 0;
protected String[] mLines = new String[0];
public JapaneseHyphenationTokenizer(int tokenLength) {
super();
@shukob
shukob / gist:5719839
Last active December 18, 2015 03:39
C++: Simple 1d equation solver
#include <cstdio>
#include <string>
#include <sstream>
template<typename T>
class Fraction{
public:
typedef T number_type;
@shukob
shukob / gist:5715231
Last active December 18, 2015 02:59
JS: Simple implementation of sum/sub, mult/divide calculation on input string.
var OperatorTokens = ['+','-','*','/']; //In priority ascending order
//class for a number
function Number(str){
this.str = str;//string representation of the number
}
//parse and return as float
Number.prototype.to_f = function(){