Skip to content

Instantly share code, notes, and snippets.

View cmd05's full-sized avatar
:electron:
Experimenting

cmd05 cmd05

:electron:
Experimenting
  • undefined
View GitHub Profile
@cmd05
cmd05 / leibniz-series-pi.cpp
Created November 23, 2021 06:28
Estimate PI using Leibiniz series
#define _USE_MATH_DEFINES
#include <math.h>
#include <iostream>
#include <iomanip>
/**
* Estimate PI using Leibiniz series
* 1 - (1/3) + (1/5) - (1/7) + (1/9) .... = (pi / 4)
*/
??=include <iostream>
int main() ??<
int x<:1:> = <%??-(1??'(??-1)) ??!??! ??/
??-(0??'0)%>;
std::cout << x<:0:>;
??>
/** Golfed
??=include<iostream>
@cmd05
cmd05 / Temperature_Format_Parse.cpp
Last active June 15, 2021 18:09
YMD Temperature Format Parser
#include <iostream>
#include <string>
#include <algorithm>
#include <fstream>
#include <vector>
#include <map>
#include <math.h>
/* Example format for ymd_temp_readings.txt
START
<?php
if(isset($_POST['txt'])) {
$value = $_POST['txt'];
}
$newtxt = preg_replace('#\*{2}(.*?)\*{2}#', '<b>$1</b>', $value); //bold **something**
$newtxt = preg_replace('#\_{2}(.*?)\_{2}#', '<i>$1</i>', $newtxt); //italics __something__
$newtxt = preg_replace('#\`{2}(.*?)\`{2}#', '<img src = "$1">', $newtxt); //image ``something.jpg/png``
$newtxt = preg_replace('#\-{2}(.*?)\-{2}#', '<br>', $newtxt); //break line ----
@cmd05
cmd05 / doctag_parser.php
Last active March 23, 2022 16:54
docblock tag to array
<?php
$str ='
/**
* @param integer $int An integer
* @return boolean
* @postParams [display_name, username, about, email, gender, password, confirm_password]
*/
';
if (preg_match_all('/@(\w+)\s+(.*)\r?\n/m', $str, $matches)){