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
// Autor Leonardo Antunes, 2019 | |
#include <algorithm> // std::shuffle | |
#include <chrono> // std::chrono::system_clock | |
#include <iostream> | |
#include <random> // std::default_random_engine | |
#include <string> | |
#include <vector> | |
using namespace std; |
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
import core.thread; | |
import vibe.vibe; | |
import std.stdio; | |
int fib(int n) | |
{ | |
if (n <= 1) | |
return n; | |
return fib(n - 1) + fib(n - 2); | |
} |
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
import std.stdio; | |
import std.random; | |
import std.algorithm; | |
bool make_game(bool change) | |
{ | |
static auto list = [1, 2, 3]; | |
int car = list.choice(); |
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
from bottle import run, request, get, post, response | |
@get('/<full_url:path>') | |
def index(full_url): | |
if full_url == 'test': | |
return 'cool' | |
elif full_url == 'double': | |
return 'triple' | |
else: |
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
import time | |
import asyncio | |
import functools | |
import os | |
import threading | |
from concurrent.futures import ThreadPoolExecutor | |
contextvars = None | |
class SyncToAsync: |
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
import aiohttp | |
import asyncio | |
async def fetch(session, url): | |
async with session.get(url) as response: | |
print(response.status) | |
async def main(): |
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
import vibe.vibe; | |
import vibe.core.log; | |
import std.conv; | |
void main() | |
{ | |
listenHTTP("localhost:8080", &handleRequest); | |
runApplication(); | |
} |
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
# Each thread only read 10 messages, | |
# to read more use more threads or increase visibility (lock) time and run again | |
# Debug True only print, False delete | |
import boto3 | |
import boto3.session | |
import threading | |
DEBUG = True | |
QUEUE_URL = 'https://sqs*.fifo' |
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
# Delete remote tag | |
git push --delete origin tagname | |
# Delete local tag | |
git tag -d tagname |
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
import time | |
# Method | |
def hello(name, t): | |
time.sleep(t) | |
print(f'Hello {name}') | |
# Parallel thread using a single processor core (use the same main core) | |
import threading | |
t = threading.Thread(target=hello, args=('Leo', 3)) |