This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| on nats server run: | |
| - start gnatsd server then: | |
| -- go run natswsproxy.go -token test -bind :8888 | |
| on client run: | |
| - go run client.go -to ws://ws.domain.tld:8888/mq?token=test -nats-user test -nats-pass test # user and pass from nats.server config |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| "io" | |
| "log" | |
| "net/http" | |
| "os" | |
| "time" | |
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Package main is an example of how handler pattern works in golang. | |
| // | |
| // At first you will need some sort of start point. To do this we create | |
| // ExampleHandler interface, this interface has a trigger method that will | |
| // execute the chain, in his case is RunExample, it accepts a writer, and a | |
| // custom input object, as you see there is an out and an in parameter. | |
| // | |
| // We could work like this you can create multiple ExampleHandlers in a helper | |
| // function and call them on in another. But this is not very handy and it smells | |
| // |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| "io" | |
| "io/ioutil" | |
| "strings" | |
| "exec" | |
| "http" | |
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # -*- coding: utf-8 -*- | |
| # i2c bus (0 -- original Pi, 1 -- Rev 2 Pi) | |
| I2CBUS = 1 | |
| # LCD Address | |
| ADDRESS = 0x27 | |
| import smbus | |
| from time import sleep |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // only 1 sensor to test | |
| const int led = 8; | |
| const int echo = 3; | |
| const int trig = 2; | |
| const long wait = 1000; //cooldown time for the sensor | |
| unsigned long last = 0; | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class MidpointLruCache: | |
| def __init__(self, size, oldpercentage): | |
| self.size = size | |
| self.oldsize = size * oldpercentage / 100 | |
| self.youngsize = size * (100 - oldpercentage) / 100 | |
| self.youngitems = collections.OrderedDict() | |
| self.olditems = collections.OrderedDict() | |
| def __call__(self, func): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| worker.bash /var/www/html/project1 devel |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| Copyright 2011 Martin Hawksey | |
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| # install docker | |
| # https://docs.docker.com/engine/installation/linux/ubuntulinux/ | |
| # install docker-compose | |
| # https://docs.docker.com/compose/install/ | |
| # install letsencrypt | |
| # https://www.digitalocean.com/community/tutorials/how-to-secure-nginx-with-let-s-encrypt-on-ubuntu-16-04 |