Skip to content

Instantly share code, notes, and snippets.

View afrachioni's full-sized avatar

Anthony Frachioni afrachioni

View GitHub Profile
#!/bin/bash
# This script will setup the git repository where it is executed to ignore
# output, metadata, and execution count data from ipython/jupyter notebooks
# anywhere in the local tree. It will install a fast JSON parser called jq
# to help in this effort. This will take ~50 MB on your disk, but it's likely
# a good idea to add the whole jq directory to .gitignore.
# with guidance from http://timstaley.co.uk/posts/making-git-and-jupyter-notebooks-play-nice/
# Note that this script will overwrite .gitconfig and .gitattributes in its
@afrachioni
afrachioni / box_muller.c
Last active February 5, 2024 18:36
Example implementation of basic and polar Box-Muller transforms for generating normally distributed random numbers.
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#define _USE_MATH_DEFINES
const float two_pi = 2*M_PI;
void basic_box_muller(float *retval);
void polar_box_muller(float *retval);
@afrachioni
afrachioni / mpi_hello.c
Last active August 29, 2015 14:14
Simple MPI program which prints rank from each process.
#include<stdio.h>
#include<mpi.h>
int main (char **args, int nargs) {
MPI_Init (&nargs, &args);
int rank;
MPI_Comm_rank (MPI_COMM_WORLD, &rank);
fprintf (stdout, "Greetings from process of rank %d.\n", rank);
MPI_Finalize();
return 0;
@afrachioni
afrachioni / timing.c
Created January 27, 2015 00:31
Example of timing using gettimeofday
#include <sys/time.h>
#include <stdio.h>
unsigned long get_time();
int main(int nargs, char **args) {
fprintf (stdout, "The current epoch time / ms: %ld\n", get_time());
long start_time = get_time();
int i;
for (i = 0; i < 1e8; ++i);
@afrachioni
afrachioni / rectangle.html
Created December 8, 2014 01:01
Draw a moving rectangle on an HTML canvas
<!DOCTYPE html>
<html>
<body>
<canvas id="myCanvas" width="500" height="500" style="border:1px solid #c3c3c3;">
Your browser does not support the HTML5 canvas tag.
</canvas>
<script>