Skip to content

Instantly share code, notes, and snippets.

@l0gicpath
l0gicpath / problem_2.erl
Created January 31, 2014 13:35
Because my other 5 line Erlang solution was too long.
-module(problem_2).
-export([s/0]).
-define(L, 4000000).
s() -> s(1, 2, 0).
s(P, N, S) when P >= ?L; N >= ?L -> S;
s(P, N, S) -> S1 = case N rem 2 of 0 -> N + S; _ -> S end, s(N, P + N, S1).
@EslaMx7
EslaMx7 / ProjectEuler.P2.cs
Last active December 26, 2018 06:16
Project Euler Problem 2 Solution with C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsolesTests
{
class Program
{
@gr33ndata
gr33ndata / gist:8727727
Created January 31, 2014 07:08
Even Fibonacci numbers
# Solving this problem:
# http://projecteuler.net/problem=2
# Sum: 4,613,732
def fab(a,b, maxlimit):
while b < maxlimit:
yield b
a, b = b, a+b
@l0gicpath
l0gicpath / problem_2.erl
Last active August 29, 2015 13:55
Project Euler Problem #2
-module(problem_2).
-export([solve/1]).
-define(LIMIT, 4000000).
%% Normalizing the start value, need to start with an odd value and enter tail recursion
solve(Start) when Start rem 2 == 0, Start > 0 -> solve(Start - 1, Start, 0);
solve(Start) -> solve(Start, Start + 1, 0).
%% guard against the limit and drop out of recursion if we hit it
solve(Prev, Next, Sum) when Prev >= ?LIMIT; Next >= ?LIMIT -> Sum;
%% Sum even values
@MohamedAlaa
MohamedAlaa / problem_2.rb
Last active August 29, 2015 13:55
Egyptian Geeks - Project Euler Problem 2
#! /usr/bin/env ruby
first = 0
second = 1
i = 0
sum = 0
limit = 4000000
while i <= limit
i = first + second
#! /usr/bin/env python3
from functools import lru_cache
from itertools import count, takewhile
numbers = count(1)
MAX = 4000000
@lru_cache(maxsize=None)
def fib(n) :
#include <stdio.h>
#include <string.h>
int main(int argc, char *argv[]) {
(void) argc;
(void) argv;
//stores the last two terms, and the new sum
int terms[] = {1, 2, 3};
//stores indeces used to access the above array,
@rxaviers
rxaviers / gist:7360908
Last active May 15, 2025 21:36
Complete list of github markdown emoji markup

People

:bowtie: :bowtie: πŸ˜„ :smile: πŸ˜† :laughing:
😊 :blush: πŸ˜ƒ :smiley: ☺️ :relaxed:
😏 :smirk: 😍 :heart_eyes: 😘 :kissing_heart:
😚 :kissing_closed_eyes: 😳 :flushed: 😌 :relieved:
πŸ˜† :satisfied: 😁 :grin: πŸ˜‰ :wink:
😜 :stuck_out_tongue_winking_eye: 😝 :stuck_out_tongue_closed_eyes: πŸ˜€ :grinning:
πŸ˜— :kissing: πŸ˜™ :kissing_smiling_eyes: πŸ˜› :stuck_out_tongue:
@bradmontgomery
bradmontgomery / install-comodo-ssl-cert-for-nginx.rst
Last active March 20, 2025 17:17
Steps to install a Comodo PositiveSSL certificate with Nginx.

Setting up a SSL Cert from Comodo

I use Namecheap.com as a registrar, and they resale SSL Certs from a number of other companies, including Comodo.

These are the steps I went through to set up an SSL cert.

Purchase the cert

@PWSdelta
PWSdelta / rspec_model_testing_template.rb
Last active March 11, 2025 21:14
Rails Rspec model testing skeleton & cheat sheet using rspec-rails, shoulda-matchers, shoulda-callbacks, and factory_girl_rails. Pretty much a brain dump of examples of what you can (should?) test in a model. Pick & choose what you like, and please let me know if there are any errors or new/changed features out there. Reddit comment thread: http…
# This is a skeleton for testing models including examples of validations, callbacks,
# scopes, instance & class methods, associations, and more.
# Pick and choose what you want, as all models don't NEED to be tested at this depth.
#
# I'm always eager to hear new tips & suggestions as I'm still new to testing,
# so if you have any, please share!
#
# @kyletcarlson
#
# This skeleton also assumes you're using the following gems: