Skip to content

Instantly share code, notes, and snippets.

View Helios-vmg's full-sized avatar

Víctor M. González Helios-vmg

  • Nektra S.A.
  • Buenos Aires, Argentina
View GitHub Profile
@Helios-vmg
Helios-vmg / float.cpp
Last active September 30, 2023 10:22
#include <iostream>
#include <queue>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <sstream>
#include <limits>
template <typename Float>
struct float_info{};
//Returns an integer in [0;max], where max <= RAND_MAX
int unbiased_rand(int max){
const int rand_max = RAND_MAX - (RAND_MAX + 1) % (max + 1);
int r;
do
r = rand();
while (r > rand_max);
return r % (max + 1);
}
#include <iostream>
#include <typeinfo>
bool is_prime(unsigned n, unsigned i){
if (i * i >= n)
return true;
if (n % i == 0)
return false;
return is_prime(n, i + 2);
}
#include <cstdint>
class Crc32{
std::uint32_t crc32;
static std::uint32_t lookup[];
public:
Crc32(){
this->clear();
}
void clear(){
@Helios-vmg
Helios-vmg / rsa.cpp
Last active December 23, 2016 23:49
#include "EasyBigNum.h"
#include <iomanip>
const unsigned rsa_bits = 1024;
struct rsa_info{
EasyBigNum p1, p2, n, totient, e, d;
};
EasyBigNum generate_rsa_prime(std::mt19937 &source, unsigned rsa_bits) {
@Helios-vmg
Helios-vmg / gps.ino
Created February 5, 2017 17:42
Arduino GPS
#include <SPI.h>
#include <SD.h>
#include <SoftwareSerial.h>
#include <EEPROM.h>
#include <Arduino.h> // for type definitions
int EEPROM_writeInt(int ee, int value){
byte *p = (byte *)(void *)&value;
unsigned i;
for (i = 0; i < sizeof(value); i++)
// Given a range [begin, end) and a T->bool mapping f such that
// map(begin, end, f) gives of any of the following forms:
// * [true, ..., true]
// * [false, ..., false, true, ..., true]
// * [false, ..., false]
// Then find_first_true(begin, end, f) returns the first iterator such that
// f(*iterator), or end if it does not exist.
// In other words, given a sorted range [begin, end),
// the range [begin(begin, end, (>= x)), begin(begin, end, (> x)))
// is equivalent to the subrange of [begin, end) that is equal to x.
#include <iostream>
#include <fstream>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cstdlib>
#include <cstdio>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <memory>
#include <unordered_map>
#include <stdexcept>
#include <algorithm>
#include <cmath>
#include <random>
// ==UserScript==
// @name MoronSilencer
// @version 1
// @grant none
// @match http://www.cplusplus.com/forum/*
// ==/UserScript==
console.log('MoronSilencer is working its magic');
var morons = [ /*write the name of your morons here*/ ];