Skip to content

Instantly share code, notes, and snippets.

View cancel_key_event_sample.html
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
.lock {
overflow: hidden;
}
.overlay {
View translate_from_s3.py
import json
import urllib.parse
import boto3
import datetime
print('Loading function')
s3 = boto3.client('s3')
def read_input_text(bucket_name, input_key):
View MyReceiveQueueEmail.php
<?php
require '../vendor/autoload.php';
use Aws\Sqs\SqsClient;
use Aws\Exception\AwsException;
use Aws\Ses\SesClient;
$queueUrl = '<QUEUE_URL>';
$client = new SqsClient([
View MySendQueueEmail.php
<?php
require '../vendor/autoload.php';
use Aws\Sqs\SqsClient;
use Aws\Exception\AwsException;
date_default_timezone_set('Asia/Tokyo');
$client = new SqsClient([
'region' => 'ap-northeast-1',
View PrimeNumber.java
package com.example.demo;
public class PrimeNumber {
boolean primeNumber(int n) {
if (n < 2) return false;
int sqrt = (int) Math.sqrt(n);
for (int i = 2; i <= sqrt; i++) {
if (n % i == 0) {
return false;
@kntmr
kntmr / Fib.java
Created Sep 4, 2019
Fibonacci sequence
View Fib.java
package com.example.demo;
public class Fib {
int fib(int n) {
if (n == 0) return 0;
if (n == 1) return 1;
return fib(n - 2) + fib(n - 1);
}
@kntmr
kntmr / BinarySearch.java
Created Sep 4, 2019
Binary search algorithm
View BinarySearch.java
package com.example.demo;
public class BinarySearch {
int binarySearch(int[] a, int n, int left, int right) {
if (left > right) return -1;
int mid = (left + right) / 2;
if (n < a[mid]) {
return binarySearch(a, n, 0, mid - 1);
}
@kntmr
kntmr / MergeSort.java
Created Sep 4, 2019
Merge sort algorithm
View MergeSort.java
package com.example.demo;
public class MergeSort {
void mergeSort(int[] a, int[] temp, int left, int right) {
if (left >= right) return;
int mid = (left + right) / 2;
mergeSort(a, temp, left, mid);
mergeSort(a, temp, mid + 1, right);
merge(a, temp, left, right, mid);
@kntmr
kntmr / QuickSort.java
Last active Apr 6, 2020
Quick sort algorithm
View QuickSort.java
package com.example.demo;
public class QuickSort {
void quickSort(int[] a, int left, int right) {
int index = replace(a, left, right);
if (left < index - 1) {
quickSort(a, left, index - 1);
}
if (index < right) {
@kntmr
kntmr / BubbleSort.java
Created Sep 4, 2019
Bubble sort algorithm
View BubbleSort.java
package com.example.demo;
public class BubbleSort {
void bubbleSort(int[] a) {
for (int i = 0; i < a.length; i++) {
for (int j = i + 1; j < a.length; j++) {
if (a[i] > a[j]) {
int temp = a[i];
a[i] = a[j];