Skip to content

Instantly share code, notes, and snippets.

View qwertyowmx's full-sized avatar

qwertyowmx

  • 18:33 (UTC +04:00)
View GitHub Profile
@qwertyowmx
qwertyowmx / reverse_str1.py
Created January 18, 2023 14:55
Python reverse string (slow)
def reverse_str(s: str):
accumulator_str = []
index = len(s)
while index:
index -= 1
accumulator_str.append(s[index])
return ''.join(accumulator_str)
print(reverse_str("abcde"))
@qwertyowmx
qwertyowmx / variadic-println1.cpp
Created January 18, 2023 14:54
C++ variadic println
#include <iostream>
#include <string>
namespace out {
struct OutConf {
std::string sep = " ";
std::string end = "\n";
std::ostream& file = std::cout;
bool flush = false;
@qwertyowmx
qwertyowmx / println1.cpp
Created January 18, 2023 14:53
C++ fold println
#include <iostream>
template <const char sep = ' ', typename ... Args>
void print(Args ... args) {
((std::cout << args << sep), ...);
}
template <const char sep = ' ', typename ... Args>
void println(Args ... args) {
@qwertyowmx
qwertyowmx / helloworld.cpp
Created January 18, 2023 14:52
C++ helloworld
#include <iostream>
int main(int argc, char** argv) {
std::cout << "Hello, World" << std::endl;
return 0;
}
@qwertyowmx
qwertyowmx / github-zipball-downloader.py
Last active January 18, 2023 14:53
Python github-zipball-downloader.py
import argparse
import logging
import os
import shutil
import sys
import time
from abc import abstractmethod
from typing import List, Dict, Any
# Type aliases
@qwertyowmx
qwertyowmx / fold-print1.cpp
Created January 18, 2023 14:51
C++ fold print 1
#include <iostream>
template <const char sep = ' ', typename ... Args>
void println(Args ... args) {
((std::cout << args << sep), ...);
}
int main()
{
@qwertyowmx
qwertyowmx / callonce1.cpp
Created January 18, 2023 14:50
C++ Call once sample 1
#include <iostream>
#include <string>
#include <thread>
#include <vector>
#include <mutex> // call once
#include <chrono>
namespace game {
using namespace std::literals::chrono_literals;
@qwertyowmx
qwertyowmx / callonce2.cpp
Created January 18, 2023 14:50
C++ Call once sample
#include <iostream>
#include <string>
#include <thread>
#include <vector>
#include <mutex> // call once
#include <chrono>
namespace game {
using namespace std::literals::chrono_literals;