Skip to content

Instantly share code, notes, and snippets.

View montyanderson's full-sized avatar

Monty Anderson montyanderson

View GitHub Profile
@montyanderson
montyanderson / multipleof3and5.php
Last active August 29, 2015 14:06
Project Euler - Problem 1
<?php
$numbers = array();
/* Get all multiples of 3 and 5 */
for($i = 1; $i < 1000; $i++) {
if ($i % 3 == 0 || $i % 5 == 0) {
$numbers[] = $i;
}
}
@montyanderson
montyanderson / evenfibonaccinumbers.php
Created September 22, 2014 08:52
Project Euler - Problem 2
<?php
$numbers = array();
$numbers[0] = 1;
$numbers[1] = 2;
for($i = 2; $i <= 999; $i++) {
$numbers[$i] = $numbers[$i-1] + $numbers[$i-2];
}
$output = 0;
<?php
$primes = array();
$input = 600851475143;
/* Find the primes */
for($i = 1; $i < 10000; $i++) {
$prime = gmp_strval(gmp_nextprime($i));
if(end($primes) != $prime) {
@montyanderson
montyanderson / colors.c
Created March 12, 2015 20:06
An endless C program showing different terminal colors.
#include <stdio.h>
#define KRED "\x1B[31m"
#define KGRN "\x1B[32m"
#define KYEL "\x1B[33m"
#define KBLU "\x1B[34m"
#define KMAG "\x1B[35m"
#define KCYN "\x1B[36m"
#define KWHT "\x1B[37m"
@montyanderson
montyanderson / update.sh
Last active August 29, 2015 14:17
apt-get update script
#!/bin/bash
sudo apt-get update
sudo apt-get upgrade -y
sudo apt-get clean
@montyanderson
montyanderson / rpi-setup.sh
Last active August 29, 2015 14:17
A bash script I run, whenever I reinstall the OS on my Raspberry Pi!
# To run, enter the following:
# curl -sL https://gist.githubusercontent.com/montyanderson/fe93d3646a8d36e640bf/raw/rpi-setup.sh | sudo bash -
sudo apt-get update
sudo apt-get upgrade -y
sudo apt-get install -y apache2 php5 php5-curl libapache2-mod-php5 git screen nodejs npm
sudo chown -hR www-data /var/www
sudo chmod -R 777 /var/www
echo "Please enter a new password for user 'pi'"

Compiling Ruby on Debian or Ubuntu

1. Install all of the required dependencies.

$ sudo apt-get install autoconf bison build-essential libssl-dev libyaml-dev libreadline6-dev zlib1g-dev libncurses5-dev libffi-dev libgdbm3 libgdbm-dev

2. Go to www.ruby-lang.org/en/downloads and download the latest stable version.

3. Assuming you've saved it into downloads, extract the tar archive.

@montyanderson
montyanderson / colors.h
Created March 28, 2015 23:26
A C include file for all the terminal colors!
#define KRED "\x1B[31m"
#define KGRN "\x1B[32m"
#define KYEL "\x1B[33m"
#define KBLU "\x1B[34m"
#define KMAG "\x1B[35m"
#define KCYN "\x1B[36m"
#define KWHT "\x1B[37m"
apt-get install apache2 php5 libapache2-mod-php5 curl php5-curl git emacs lm-sensors build-essential ruby xchat gparted python2.7 chromium-browser filezilla vlc terminator quiterss bleachbit unity-tweak-tool p7zip-full
npm install -g less grunt grunt-cli bower express less request
int led = 12;
void setup() {
// initialize the digital pin as an output.
pinMode(led, OUTPUT);
}
// the loop routine runs over and over again forever:
void loop() {