Skip to content

Instantly share code, notes, and snippets.

View tejainece's full-sized avatar

Ravi Teja Gudapati tejainece

View GitHub Profile
@tejainece
tejainece / future_await_same.dart
Created October 21, 2024 12:57
Does waiting the same future multiple times succeed and give same value?
import 'dart:async';
Future<void> main() async {
final completer = Completer<bool>();
final future = completer.future;
completer.complete(true);
print(await future);
print(await future);
}
@tejainece
tejainece / pthread_cv.cpp
Created May 2, 2024 09:33
WIP! Fiddling around with pthread_cond_t
//
// Created by tejag on 2024-04-26.
//
#include <cstdint>
#include <cstring>
#include <functional>
#include <iostream>
#include <queue>
#include <syncstream>
template <typename I>
const char *tcNegSlow(I *out, const I *inp, uint64_t nel) {
constexpr size_t laneSize = simdSize<I>();
uint16_t concurrency = std::thread::hardware_concurrency();
uint64_t totalLanes = (nel + laneSize - 1) / laneSize;
uint64_t lanesPerThread = std::max(
uint64_t((totalLanes + concurrency - 1) / concurrency), uint64_t(1)
);
std::vector<std::future<void>> futures(concurrency);
@tejainece
tejainece / incomplete_dig_at_cross_platform_simd.cpp
Created April 28, 2024 14:35
Experimental dig at cross platform SIMD
template <typename T> class Simd;
#if defined(TC_ARCH_X86)
#include <bits/stdc++.h>
#include <x86intrin.h>
uint16_t simdSize = 128;
uint16_t detectSimdSize() {
if (__builtin_cpu_supports("avx512f")) {
@tejainece
tejainece / __cxa_demangle.cpp
Created April 27, 2024 17:55
Print demangled type of a variable in C++
//
// Created by tejag on 2024-04-26.
//
#include <iostream>
#include <type_traits>
#include <typeinfo>
#include <cstdint>
#include <cxxabi.h>
//
// Created by tejag on 2024-04-26.
//
#include <cxxabi.h>
#include <experimental/simd>
#include <iostream>
#include <vector>
template <typename T> void printType() {
@tejainece
tejainece / ramblings.md
Created April 18, 2024 11:14
ramblings

x86 GAS uses reverse order of destination and source registers compared to Intel documentation. This was very confusing.

@tejainece
tejainece / run.sh
Last active January 20, 2022 13:51
webdriver
curl 'http://localhost:9515/status'
# Create new headless session
curl -XPOST 'http://localhost:9515/session' -d '{"desiredCapabilities": {"browserName": "chrome", "goog:chromeOptions": {"args": ["--headless", "--no-sandbox"]}}}'
# Navigate to URL
curl -XPOST "http://localhost:9515/session/$1/url" -d '{"url": "https://google.com"}'
# Execute script
curl -XPOST http://localhost:9515/session/$1/execute/sync -d '{"script": "window.alert(\"Annoying\")", "args": []}'
@tejainece
tejainece / index.html
Last active August 21, 2020 06:39
Dart: Drawing triangle using WebGL
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="scaffolded-by" content="https://github.com/dart-lang/stagehand">
<title>Dart WebGL triangle</title>
<style>
@tejainece
tejainece / mersenne_predict.py
Created May 7, 2020 14:51 — forked from Rhomboid/mersenne_predict.py
Predict output of Mersenne Twister after seeing 624 values
#!/usr/bin/env python
#
# Mersenne Twister predictor
#
# Feed this program the output of any 32-bit MT19937 Mersenne Twister and
# after seeing 624 values it will correctly predict the rest.
#
# The values may come from any point in the sequence -- the program does not
# need to see the first 624 values, just *any* 624 consecutive values. The
# seed used is also irrelevant, and it will work even if the generator was