Skip to content

Instantly share code, notes, and snippets.

@Joker-vD
Joker-vD / mh.py
Created Jul 28, 2020
Monty Hall simulation
View mh.py
import random
show_games = False
all_doors = [1, 2, 3]
def show(*args, **kwargs):
if show_games:
print(*args, **kwargs)
def player_chose_first_time():
@Joker-vD
Joker-vD / MSVS_output_properties.md
Last active May 18, 2020
Separating src/obj/bin from each other
View MSVS_output_properties.md
  • for C/C++ projects to have output in "Debug-x86" instead of "Debug-Win32":
 <PropertyGroup>
   <IntermediateOutputPath>$(SolutionDir)..\obj\$(Configuration)-$(Platform)\$(MSBuildProjectName)\</IntermediateOutputPath>
   <OutputPath>$(SolutionDir)..\bin\$(Configuration)-$(Platform)\</OutputPath>
   <IntDir>$(SolutionDir)..\obj\$(Configuration)-$(Platform)\$(MSBuildProjectName)\</IntDir>
   <OutDir>$(SolutionDir)..\bin\$(Configuration)-$(PlatformShortName)\</OutDir>
 </PropertyGroup>
View async_file_rw.cpp
#include <errno.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <cstdio>
#include <cstring>
#include <stdexcept>
#include <string>
View make_joker_user.sh
#!/bin/sh -e
NEW_USERNAME=joker
test -n "$NEW_USERNAME"
command -v sudo >/dev/null
test -x /bin/bash
adduser --shell=/bin/bash -- "$NEW_USERNAME"
adduser -- "$NEW_USERNAME" sudo
@Joker-vD
Joker-vD / quadratures.cs
Created Jul 16, 2019
Some horribly unoptimized quadrature rules, integrating the "black swan" function from Eric Lippert's "Fixing Random" series.
View quadratures.cs
using System;
using System.Collections.Generic;
using System.Linq;
namespace Quadratures
{
interface Integrator
{
double Integrate(Func<double, double> f, double a, double b);
}
View generate.c
// Uncompressed version of
// https://gist.github.com/munificent/b1bcd969063da3e6c298be070a22b604
#include <time.h> // Robert Nystrom
#include <stdio.h> // @munificentbob
#include <stdlib.h> // for Ginny
#include <stdbool.h> // 2008-2019
const int HEIGHT = 40;
const int WIDTH = 80;
View ssh_driver.cpp
#include <errno.h>
#include <fcntl.h>
#include <sys/select.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <unistd.h>
#include <pty.h>
#include <stdlib.h>