Skip to content

Instantly share code, notes, and snippets.

@infinityb
infinityb / fizzbuzz.rs
Last active September 26, 2020 18:33 — forked from gyng/fizzbuzz.rs
my first fizzbuzz
use std::io::Write;
use std::thread::{self, sleep, JoinHandle};
use std::time::Duration;
fn flush() {
std::io::stdout().flush().unwrap();
}
fn main() {
let mut threads: Vec<JoinHandle<()>> = Vec::new();
@gyng
gyng / fizzbuzz.pl
Last active September 26, 2020 19:31
my not first fizzbuzz
% https://swish.swi-prolog.org/p/KDyjHEJd.pl
fizzbuzz(_, 0, 0, 'fizzbuzz').
fizzbuzz(_, 0, _, 'fizz').
fizzbuzz(_, _, 0, 'buzz').
fizzbuzz(X, _, _, X). % yuno what it is
buzzmyfizz(N) :-
FIZZ is N mod 3,
BUZZ is N mod 5,
@gyng
gyng / fizzbuzz.rs
Last active June 3, 2020 09:46
my first fizzbuzz
use std::io::stdio::flush;
use std::io::timer::sleep;
use std::thread::{Thread, JoinGuard};
use std::time::duration::Duration;
fn main() {
let mut threads: Vec<JoinGuard<()>> = Vec::new();
threads.push(Thread::spawn(|| {
let mut i = 0u;
@gyng
gyng / amazingfib.c
Created March 11, 2014 17:02
amazing revolutionary parallel fibonacci algorithm do not steal
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/wait.h>
#include <errno.h>
void handle_error(void);
int main(int argc, char **argv)
{
@gyng
gyng / inverseProjection.cpp
Last active April 13, 2020 09:21
OpenGL inverse projection matrix
/*
Based off http://bookofhook.com/mousepick.pdf
OpenGL matrix order
m0 m4 m8 m12
m1 m5 m9 m13
m2 m6 m10 m14
m3 m7 m11 m15
Projection matrix
#define begin <%
#define End %>
#define as while
#define and ,
#define COUNTDOWN 10
#define Sub int
#define Dim int
#define cfoutput printf("%d ",
#define cfoutputted );
@WizardOfOgz
WizardOfOgz / gist:1012107
Created June 7, 2011 12:13
Save Base64-encoded images with Paperclip
class Avatar < ActiveRecord::Base
attr_accessor :content_type, :original_filename, :image_data
before_save :decode_base64_image
has_attached_file :image,
PAPERCLIP_CONFIG.merge(
:styles => {
:thumb => '32x32#',
:medium => '64x64#',