Skip to content

Instantly share code, notes, and snippets.

View dazfuller's full-sized avatar
🤌
reality.foldLeft

Darren Fuller dazfuller

🤌
reality.foldLeft
View GitHub Profile
@dazfuller
dazfuller / lambda_capture_list.cpp
Created December 16, 2011 15:20
Ignoring the Voices: C++11 Example - Lambda Capture Lists
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
void PrintList(const vector<int>& list)
{
for (auto i : list)
{
@dazfuller
dazfuller / lambda_functions.cpp
Created December 16, 2011 16:06
Ignoring the Voices: C++11 Example - Lambda Parameters
#include <functional>
#include <iostream>
#include <vector>
#include <math.h>
using namespace std;
double Sum(const vector<double>& values, function<double (double x)> f)
{
@dazfuller
dazfuller / Data.java
Created January 4, 2012 12:55
Method for transforming XML to XML using XSLT for Java/Android
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import java.io.StringReader;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
@dazfuller
dazfuller / sqrt.go
Created February 27, 2012 17:11
My solution to the golang tour #44 and #67 exercises
package main
import (
"fmt"
"math"
)
var (
DELTA float64 = 1e-15
)
@dazfuller
dazfuller / Conversion.go
Created March 29, 2012 13:17
Converts a string to ASCII
package main
import (
"fmt"
"strings"
)
var ignoreNonASCII bool = false
// Converts a given string to it's ASCII representation, if the ignore parameter
@dazfuller
dazfuller / project_euler_problem3.go
Created October 18, 2012 21:02
2 solutions for problem 2 from Project Euler
package main
import "fmt"
func MakeFibonacciGenerator() chan int {
a, b := 0, 1
c := make(chan int)
go func() {
for {
@dazfuller
dazfuller / primes.go
Created October 19, 2012 20:59
Solution to Project Euler problem 3
package primes
// Simple function for checking if a value coming in on a channel is divisible by a
// divisor, if it is then it is passed to the output channel
func checkDivisor(divisor int64, in chan int64, out chan int64) {
for {
val := <-in
if val % divisor != 0 {
out <- val
}
@dazfuller
dazfuller / primes.go
Created October 23, 2012 18:39
A solution to Project Euler problem 7
package primes
import (
"container/list"
"math"
)
// Simple function for checking if a value coming in on a channel is divisible by a
// divisor, if it is then it is passed to the output channel
func checkDivisor(divisor int64, in chan int64, out chan int64) {
@dazfuller
dazfuller / problem12.go
Created November 5, 2012 15:03
Project Euler - Problem 12 Solution
package main
import (
"fmt"
)
func numberOfDivisors(n int64) int64 {
if n % 2 == 0 {
n /= 2
}
@dazfuller
dazfuller / problem14.cpp
Created November 13, 2012 11:57
Project Euler - Problem 14 Solution
#include <iostream>
#include <time.h>
using namespace std;
unsigned long* _chains;
unsigned long _chainLength;
double DiffClock(clock_t t0, clock_t t1)
{