Skip to content

Instantly share code, notes, and snippets.

View davidjmemmett's full-sized avatar

David JM Emmett davidjmemmett

View GitHub Profile
@davidjmemmett
davidjmemmett / gist:5cac3b79e8373dcb8d3de9f143df4f53
Created April 11, 2021 20:53
Steam - System Information - 11th April 2021
Computer Information:
Manufacturer: Unknown
Model: Unknown
Form Factor: Desktop
No Touch Input Detected
Processor Information:
CPU Vendor: GenuineIntel
CPU Brand: Intel(R) Core(TM) i7-6700K CPU @ 4.00GHz
CPU Family: 0x6
#include <stdio.h>
#include <sys/time.h>
int repetitions = 100000000;
double time_diff(struct timeval x, struct timeval y);
double native_add(double a, double b) {
double x;
from math import sqrt
from time import time
def standup_hash(i):
first_six_dp = str(sqrt(sqrt(sqrt(sqrt(sqrt(i)))))).split('.')[1][:6]
nums = [x for x in first_six_dp]
nums.sort()
return ''.join(nums)
@davidjmemmett
davidjmemmett / pi_estimator.py
Last active April 9, 2017 21:37
Using standupmaths logic, estimating pi. See https://www.youtube.com/watch?v=RZBhSi_PwHU for more information
import random
import decimal
from fractions import gcd
decimal.getcontext().prec = 10
class PiCalculator:
def __init__(self):
operands = {
'+': lambda a, b: a + b,
'-': lambda a, b: a - b,
'x': lambda a, b: a * b,
'/': lambda a, b: a / b
}
def parse(eq):
bits = []
@davidjmemmett
davidjmemmett / actual_migration.sql
Created December 8, 2011 18:46
multiple aggregate_column behaviours in Propel
ALTER TABLE `table_1` ADD
(
`nb_something_else` INTEGER
);
@davidjmemmett
davidjmemmett / insanity.php
Created October 27, 2011 15:34
Can't believe PHP lets you do this...
<?php
$foo = 'This, yes, is insane...';
${$foo} = 1;
${'This gets worse...'} = 1;
<?php
class Vehicle {
private $speed;
private $distance_travelled;
private $time_taken;
public function setSpeed($speed) {
$this->speed = $speed;
}
public function travelTime($time) {
<?php
class SlowClockCalculator {
private $target_hour = 0;
private $target_minute = 0;
private $slow = 0;
private $difference = 0;
private $result = 0;
program HelloWorld
write (*,*) 'Hello, world!'
end program