Skip to content

Instantly share code, notes, and snippets.

View narutaro's full-sized avatar
:octocat:
On vacation

narutaro narutaro

:octocat:
On vacation
View GitHub Profile
@narutaro
narutaro / mqtt-in-your-browser.md
Last active September 19, 2024 12:59
MQTT in your browser

MQTT in your browser

MQTT is probably best known as a lightweight messaging protocol implemented for small sensors, but there is actually a JavaScript implementation called MQTT.js. It's a JavaScript implementation, so of course it works in a browser. I think it's a great option for front-end engineers who are working with MQTT/IoT-related projects (for example, creating a dashboard to visualize MQTT data). In this article, I'd like to write about what I did when I tried to connect MQTT.js to the test server (broker) of Mosquitto™.

@narutaro
narutaro / connecting-svelte-to-apollo.md
Last active October 30, 2021 05:55
Connecting Svelte to Apollo

Connecting Svelte to Apollo

@narutaro
narutaro / query-to-search-for-an-item-with-apollo.md
Last active October 30, 2021 12:03
Query to Search for an Item with Apollo

Query to Search for an Item with Apollo

Last time was to get list of todo from Apollo. This time I am going to add task search functionality by id.

Code

const { ApolloServer, gql } = require('apollo-server');
@narutaro
narutaro / update-tasks-with-mutations.md
Last active December 4, 2021 01:41
Update Tasks with Mutations

Update Tasks with Mutations

last time was search by id form the task list. This time, I am going to update the liset. It's called Mutation, which is a cool name in the GraphQL community :D

Code

@narutaro
narutaro / simple-list-view-with-apollo.md
Last active December 4, 2021 01:36
Simple list view with Apollo

Simple list view with Apollo

I've been playing around with GraphQL lately and that's fun. After playing with GraphQL for a while, I thought I'd write about it in a series of articles.

The best way to get started with GraphQL now is to start with these two great sites to grasp the concept.

@narutaro
narutaro / swagger-json-auto-complete.rb
Last active September 11, 2020 00:54
class version
require "readline"
require "yaml"
require "json"
class CLI
attr_accessor :command_tree
def initialize(swagger_json)
# TODO: json might be broken
if swagger_json.nil?
@narutaro
narutaro / tab-completion-with-multi-command.rb
Created September 6, 2020 02:26
[Tab completion with multi-command] #repl #tab
require "readline"
require "yaml"
command_tree = {"pet"=>
{"buy"=>{"dog"=>nil, "cat"=>nil},
"sell"=>{"bird"=>nil, "fox"=>nil},
"sellGroup"=>{"pig"=>nil, "kingfisher"=>nil},
"list"=>{"all"=>nil, "filter_by"=>nil}},
"store"=>
{"find"=>{"by_name"=>nil, "by_tag"=>nil, "by_address"=>nil}, "list"=>nil},
@narutaro
narutaro / tab-completion
Created September 6, 2020 02:24
[Tab completion] REPL tab completion in ruby #tab #repl
require "readline"
pet_store = [ "pet", "store", "user"]
Readline.completion_proc = proc do |input|
pet_store.select { |name| name.start_with?(input) }
end
while input = Readline.readline("$ ", false)
if input
@narutaro
narutaro / odd-and-even.js
Last active September 21, 2019 08:14
Filter an array based on odd or even
let ary = [
'0:00',
'0:30',
'1:00',
'1:30',
'2:00',
'2:30',
'3:00',
'3:30',
'4:00',

How much is a data center

I will start with the cost of the power to run servers.

Number of servers

I wanted to know how much servers IT giants have. There is no official data on it off cource but some estimates.

As of today (dez/2015) both microsoft and google are leading - MS is 1,020,00 machines and google 750,000. Facebook 2015 is 'undisclosed' but their operation is quite small compared to those million-machine business.