//How I can properly implement
//the runtime polymorphism on c++ std::map value_type without using pointer type
//i.e. node size is not the same anymore but varies.
// +---------------------+
// |_Node* _Left |
// |_Node* _Parent |
// |_Node* _Right |
// |int _Color |
// |bool _Isnil |
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
| # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
| # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
| # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | |
| # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |
| # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | |
| # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | |
| # THE SOFTWARE. | |
| # Tested with QT 5.15.2 on Windows 10 | |
| # https://mrfaptastic.github.io |
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
| // | |
| // Created by Jan Gabriel on 3/19/2021. | |
| // | |
| #include "example/example.h" | |
| Example::Example(std::string name) : name_(std::move(name)) {} | |
| void Example::PrintName() const { | |
| std::cout << name_ << std::endl; |
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
| # use `route -n` to debug route table | |
| # the nameservers may change which can create issue | |
| Gateway=`ip route show 0.0.0.0/0 dev ppp0 | cut -d\ -f3` | |
| echo Found Gateway: $Gateway | |
| sudo route del -net 0.0.0.0 netmask 0.0.0.0 dev ppp0 | |
| # Route for cluster access | |
| sudo route add -net 136.159.79.0 gw $Gateway netmask 255.255.255.0 dev ppp0 | |
| # Routes for nameservers | |
| sudo route add -net 136.159.1.21 gw $Gateway netmask 255.255.255.255 dev ppp0 | |
| sudo route add -net 136.159.34.201 gw $Gateway netmask 255.255.255.255 dev ppp0 |
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
| public enum MyPermission { | |
| // declare runtime permissions specific to your app here (don't keep unused ones) | |
| READ_PHONE_STATE(Manifest.permission.READ_PHONE_STATE), | |
| FINE_LOCATION(Manifest.permission.ACCESS_FINE_LOCATION); | |
| public static MyPermission fromAndroidPermission(String androidPermission) { | |
| for (MyPermission permission : MyPermission.values()) { | |
| if (permission.getAndroidPermission().equals(androidPermission)) { | |
| return permission; | |
| } |
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
| #include <codecvt> | |
| std::string name = "李研"; // GBK encoding | |
| std::wstring w_name = string2wstring(name, ".936"); | |
| std::string utf8_name = wstring2utf8(w_name); |
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
| #include <iostream> | |
| #include <cassert> | |
| #include <iomanip> | |
| #include <fstream> | |
| #include "single_include/nlohmann/json.hpp" | |
| using namespace std; | |
| using json = nlohmann::json; | |
| // add snippnets here. |
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
| import androidx.lifecycle.get | |
| import androidx.lifecycle.ViewModel | |
| import androidx.lifecycle.ViewModelProvider | |
| import androidx.lifecycle.ViewModelStore | |
| import androidx.lifecycle.ViewModelStoreOwner | |
| /** | |
| * Returns a property delegate to access the wrapped value, which will be retained for the | |
| * duration of the lifecycle of this [ViewModelStoreOwner]. | |
| * |
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
| <?php // Checksum: 5173f2c74dab371d015ba84ce4b9a343 ?> | |
| <?php | |
| // Implementation by https://github.com/tayyebi | |
| // Based on a talk by https://bendechrai.com/ | |
| // VIRUS:START | |
| error_reporting(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
| /** Downloader app following https://www.youtube.com/watch?v=_z-RS0rXg9s but | |
| * use libcurl (C API) with some adjusted API usage. | |
| * | |
| * Compile with | |
| * g++ -std=c++11 -DNO_PROXY SimpleDownloader.cpp -lpthread -lcurl | |
| * */ | |
| #include <iostream> | |
| #include <fstream> | |
| #include <string> |
NewerOlder