Skip to content

Instantly share code, notes, and snippets.

<?php
// Include PHPMailer library
require("PHPMailer/class.phpmailer.php");
// Include server settings
require("server_config.php");
// Create email object
$mail = new PHPMailer();
// Set email object options
loop A: loop over old_file_height // looping over each scan line in original file
loop B:
read each rgb-triple into an array // Read each pixel value in a complete scanline into an array
end loop B
skip over padding at end of scanline
loop C: loop n times // Set up a loop. loop resize times. Write the complete scan line n times.
loop D: loop trough pixel array // read each pixel from the array we just read.
Write pixel resize times.// Write the pixel out resize times.
end of loop D
write end of line padding // write new padding required for this scan line
/**
* SOS.c by Iliyan Stankov
* Runs on TM4C123 LaunchPad
* Input from PF4(SW1),PF0(SW2), output to PF3 (Green LED)
* Pressing SW1 starts SOS (Green LED flashes SOS).
* Pressing SW2 stops SOS
*/
// Constant declarations to access port registers using
// symbolic names instead of addresses
/** * helpers.c * * Computer Science 50 * Problem Set 3 * * Helper functions for Problem Set 3. */
#include <cs50.h>
#include <math.h>
#include "helpers.h"
/** * Returns true if value is in array of n values, else false. */
bool search(int value, int array[], int n) {
// TODO: implement a searching algorithm
int high, low, i;
@robsbots
robsbots / gist:7304257
Last active December 27, 2015 09:29
Bouncing ball
// This code should be added to the updateGame function below the two lines of code currently in there.
// The ball speed is positive when moving right, and negative when moving left
// To reverse the ball direction we need to change the sign of the ball speed variable.
// If the ball speed is 100, it moves right at 100 pixels per second.
// To reverse direction we change the sign of the ball speed variable and make it -100 and it moves left.
// If ball hits left side, reverse direction
if (mBallX <= 0) mBallSpeedX = -mBallSpeedX;
// If ball hits right side of screen reverse direction
@robsbots
robsbots / Round world snippet
Created November 4, 2013 16:36
Round world snippet Ball drops off the bottom and appears at the top again. Leaves on the right, and re-enters on the left.
// Should be added to the updateGame method.
// below the current code
if (mBallX < 0) mBallX = mCanvasWidth; // If the ball hits the left wall, move it to the right
if (mBallX > mCanvasWidth) mBallX = 0; // If the ball hits the right wall, move it to the left
if (mBallY < 0) mBallY = mCanvasHeight; // If it hits the top, move it to the bottom
if (mBallY > mCanvasHeight) mBallY = 0; // If it hits the bottom, move it to the top.
@robsbots
robsbots / Random nuber generator
Last active December 28, 2015 02:59
Random numbers for Build Your First Mobile Game MOOC at FutureLearn
// # Function to generate random numbers
// # This function generates a random whole number (An integer)
// # between a min and max number inclusive
// # Paste it into your code to call it from your program
// # This function requires an import
import java.util.Random;
// # The random generator function.
public int Rand_number(int min, int max)
@robsbots
robsbots / Marlin_Conf
Created November 13, 2013 16:25
Marlin set up
#define TEMP_SENSOR_0 0
#define TEMP_SENSOR_1 0
#define TEMP_SENSOR_2 0
#define TEMP_SENSOR_BED 0
// This makes temp sensor 1 a redundant sensor for sensor 0. If the temperatures difference between these sensors is to high the print will be aborted.
//#define TEMP_SENSOR_1_AS_REDUNDANT
#define MAX_REDUNDANT_TEMP_SENSOR_DIFF 10
@robsbots
robsbots / gist:7583336
Last active December 28, 2015 23:59
Printing to the screen
// These lines create a new "ink" to write with and sets the colour and size of the text
Paint textPaint = new Paint();
textPaint.setColor(Color.WHITE);
textPaint.setTextSize(12);
// This is the code that actually writes to the screen.
// The command used takes a few values to achieve this.
// canvas.draw("text to print out",X_location,Y_location, textPaint);
@robsbots
robsbots / TheGame.java
Last active December 29, 2015 09:39
Add lives to the game
// ############################################################################################
// All added or edited lines have comments like this near at hand.
// Just a variable definition near the top of the code.
// Plus some code at the bottom of updateGame
// Otherwise the code is the same
// ############################################################################################
package uk.ac.reading.sis05kol.mooc;
//Other parts of the android libraries that we use
import android.graphics.Bitmap;