UpgradableRWMutex is an enhanced version of the standard sync.RWMutex. It has the all methods sync.RWMutex with exact same semantics. It gives more methods to give upgradable-read feature.
The new semantics for upgradable-read are as follows:
- Multiple goroutines can get read-lock together with a single upgradable-read-lock.
- Only one goroutine can have a write-lock and no read-lock/upgradable-read-lock can be acquired in this state.
Organizing your Go (Golang) project's folder structure can help improve code readability, maintainability, and scalability. While there is no one-size-fits-all structure, here's a common folder structure for a Go project:
project-root/
├── cmd/
│ ├── your-app-name/
│ │ ├── main.go # Application entry point
│ │ └── ... # Other application-specific files
This file contains 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 ( | |
"database/sql" | |
"encoding/json" | |
"flag" | |
"fmt" | |
"log" | |
"net/http" | |
"os" |
This file contains 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
/** | |
* WiFiAutoSelector.h - Include file for class WiFiAutoSelector | |
* Copyright (c) 2016 Andreas Schaefer <[email protected]> | |
* | |
* A class to pick a wifi network from a list, based on the | |
* highest receive signal strength, and connect to it. | |
* Inspired by "WiFiMulti" | |
* | |
* This source code is free software; you can redistribute it and/or | |
* modify it under the terms of the GNU Lesser General Public |
This file contains 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
/** | |
* HumanReadableDuration | |
* | |
* Retruns a human readable duration for totalSeconds. | |
* Make sure outputBuffer is big enough to hold the | |
* complete string incl. temrinate '\0' character. | |
*/ | |
char* HumanReadableDuration(unsigned long totalSeconds, char* outputBuffer ) { | |
if(outputBuffer) { |
This file contains 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
/** | |
* GetOnboardTemperature | |
* | |
* Read temperature from the onbaord sensor. Check specs if sensor exist for your cpu. ;-) | |
* | |
* Example: | |
* char buff[10]; | |
* Serial.print("CPU temp.: " ); | |
* Serial.print(dtostrf(GetOnboardTemperature(), 5, 2, buff)); |
This file contains 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
/** | |
* PulseHeartbeat | |
* | |
* Blink the onboard LED to signal "Yepp, we are still runnning". | |
* The onbaord LED is on pin 13 and so pin 13 will be set to OUTPUT. | |
* | |
* Call this at the beginning of your loop() function. | |
* Caution: Will only work if millis() if functional and no one else | |
* did hook up timer0. | |
*/ |
This file contains 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
/* | |
Taken and cribbed from blog.datalicious.com/free-download-all-australian-postcodes-geocod | |
May contain errors where latitude and longitude are off. Use at own non-validated risk. | |
*/ | |
SET NAMES utf8; | |
SET sql_mode = 'NO_AUTO_VALUE_ON_ZERO'; | |
DROP TABLE IF EXISTS postcodes_geo; |