Skip to content

Instantly share code, notes, and snippets.

@raghunayak
raghunayak / adapter.cpp
Created July 2, 2015 09:31
Adapter Example
/*
* (c) 2015 Raghavendra Nayak, All Rights Reserved.
* www.openguru.com/
*/
#include <iostream>
#include <string>
// Window is the abstract base for all concrete Window implementations
class Window {
@raghunayak
raghunayak / shared_ptr.cpp
Last active February 27, 2022 08:27
A simple shared_ptr example.
/*
* Simple implementation of shared_ptr.
* Below code is non thread safe.
*
* (c) 2015 Raghavendra Nayak, All Rights Reserved.
* http://www.openguru.com/
*/
#include <iostream>
@raghunayak
raghunayak / strategy_design_pattern.cpp
Created July 16, 2015 10:59
Shows strategy design pattern.
/*
* (c) 2015 Raghavendra Nayak, All Rights Reserved.
* www.openguru.com/
*/
#include <iostream>
#include <string>
// This abstract class provides the SortingAlgorithm interface
class SortingAlgorithms
@raghunayak
raghunayak / pizza_decorator_design_pattern.cpp
Created July 16, 2015 11:02
decorator design pattern example with Pizza
/*
* (c) 2015 Raghavendra Nayak, All Rights Reserved.
* www.openguru.com/
*/
#include <iostream>
#include <string>
// Pizza is the abstract base for all concrete Pizza implementations
class Pizza {
/*
* Copyright (C) 2020 Raghavendra Nayak
*
* Permission to use, copy, modify, and/or distribute this software for any purpose
* with or without fee is hereby granted.
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
* INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
URL="https://download.qt.io/snapshots/qtcreator/"
main_ver=$(wget -qO- ${URL} | sed 's/</\'$'\n''</g' | sed -ne '/<table>$/,$ p' | grep -m1 -oP 'href="\K\d+\.\d+\.?\d*')
URL=${URL}${main_ver}/
sub_ver=$(wget -qO- ${URL} | sed 's/</\'$'\n''</g' | sed -ne '/<table>$/,$ p' | grep -m1 -oP 'href="\K\d+\.\d+\.?\d*')
URL=${URL}${sub_ver}/
package=$(wget -qO- ${URL} | sed 's/</\'$'\n''</g' | sed -ne '/<table>$/,$ p' | grep -m1 -oP 'href=".+">\K(.+\.run)')
wget -c $URL$package
:: Call this batch file with source directory as command line argument.
@echo off
if ["%~1"]==[""] (
goto end
)
if exist %~s1 (
if exist %~s1\NUL (
set dir_set=1
cd %~1
)
#!/usr/bin/env bash
# Immediately exit upon any failures, or undefined variable usage
set -ue
# Enable Ubuntu included VNC server
echo "Enabling VNC server"
export DISPLAY=:0
gsettings set org.gnome.Vino enabled true
gsettings set org.gnome.Vino prompt-enabled false
@raghunayak
raghunayak / nested_qmap.cpp
Created March 26, 2021 11:03
Nested QMap example
#include <QMap>
#include <QString>
#include <QDebug>
int main(int argc, char *argv[])
{
enum VehicleManufacturer { Toyota, Holden };
enum VehicleType { HatchBack, Coupe, Sedan };
@raghunayak
raghunayak / nested_qmap.cpp
Last active March 26, 2021 11:41
Nested QMap with std::array
#include <QMap>
#include <QString>
#include <QDebug>
#include <array>
int main(int argc, char *argv[])
{
enum Gnss { Phoenix, Serell };
enum ImuType { VH301, VD231, Seldov };