Skip to content

Instantly share code, notes, and snippets.

@NaotoKumagai
NaotoKumagai / index.js
Created May 16, 2017 14:29
Get RSS on Cloud Function
exports.helloWorld = function helloWorld(req, res) {
var FeedParser = require('feedparser');
var request = require('request');
var feed = '====RSS_URL===';
var req2 = request(feed);
var feedparser = new FeedParser({});
var items = [];
var titles = '';
@NaotoKumagai
NaotoKumagai / sample.java
Created December 24, 2016 04:00
Day 15: Linked List
public static Node insert(Node head,int data) {
//Complete this method
if(head==null) {
return new Node(data);
}
head.next = insert(head.next, data);
return head;
}
@NaotoKumagai
NaotoKumagai / sample.java
Created December 24, 2016 03:10
Day 14: Scope
// Add your code here
Difference(int[] elements) {
this.elements = elements;
}
public void computeDifference() {
for(int i =0; i< elements.length; i++) {
for(int j=0; j < elements.length; j++) {
int difference = Math.abs(elements[i] - elements[j]);
if(difference > maximumDifference) {
@NaotoKumagai
NaotoKumagai / sample.java
Created December 22, 2016 05:48
Day 12: Inheritance
class Student extends Person{
private int[] testScores;
Student(String firstName, String lastName, int id, int[] testScores) {
super(firstName, lastName,id);
this.testScores = testScores;
}
public String calculate() {
double avarage = java.util.stream.IntStream.of(testScores)
@NaotoKumagai
NaotoKumagai / sample.java
Created December 22, 2016 04:15
Day 11: 2D Arrays
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
public class Solution {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
@NaotoKumagai
NaotoKumagai / sample.java
Created December 20, 2016 03:43
day10:2進変換して"1"が続く最大数の出力
import java.io.*;
import java.util.*;
import java.util.stream.Stream;
public class Solution {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int n = in.nextInt();
in.close();
@NaotoKumagai
NaotoKumagai / sample.java
Created December 20, 2016 03:42
day9:int[]を逆順で出力する
IntStream.of(arr)
.boxed()
.collect(Collectors.toCollection(LinkedList::new))
.descendingIterator()
.forEachRemaining(i -> System.out.print(i + " "));
@NaotoKumagai
NaotoKumagai / ohuro_kanshi.ino
Last active February 26, 2021 02:08
シェアハウスのお風呂利用状況監視君
#include <Arduino.h>
#include <Hash.h>
#include <ESP8266WiFi.h>
#include <ESP8266WebServer.h>
#include <ESP8266HTTPClient.h>
#include <WebSocketsClient.h>
#include <ArduinoJson.h>
extern "C" {
#include "user_interface.h"
@NaotoKumagai
NaotoKumagai / slack_test.ino
Last active April 3, 2017 07:46
SlackBOTのコードを少し改変
// https://github.com/urish/arduino-slack-bot
#include <Arduino.h>
#include <Hash.h>
#include <ESP8266WiFiMulti.h>
#include <ESP8266HTTPClient.h>
#include <WebSocketsClient.h>
#include <ArduinoJson.h>
#define WIFI_SSID "接続したいSSID"
@NaotoKumagai
NaotoKumagai / gist:32aa524a1b4ceba4bd4e5c5ef42a25a3
Created November 19, 2016 10:41
ESP-WROOM-02でグローバルIPを取得
String findPublicIP() {
WiFiClient client;
if (client.connect("api.ipify.org", 80)) {
//Serial.println("connected");
client.println("GET /?format=txt HTTP/1.0");
client.println("Host: api.ipify.org");
client.println();
} else {
Serial.println("connection failed");
}