This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dow(y, m d) { | |
t = { 0, 3, 2, 5, 0, 3, 5, 1, 4, 6, 2, 4 }; | |
y -= m < 3; | |
return (y + y / 4 - y / 100 + y / 400 + t[m - 1] + d) % 7; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Written by Oliver Booth | |
// Based on an XKCD comic | |
// http://xkcd.com/149/ | |
#include <stdio.h> | |
#include <stdbool.h> | |
#include <unistd.h> | |
int main() { | |
return printf(getuid() ? "What? Make it yourself.\n" : "Okay.\n"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function locationfromzone($lx, $ly) { | |
$gSAZones = array( | |
array("The Big Ear", array(-410.00,1403.30,-3.00,-137.90,1681.20,200.00)), | |
array("Aldea Malvada", array(-1372.10,2498.50,0.00,-1277.50,2615.30,200.00)), | |
array("Angel Pine", array(-2324.90,-2584.20,-6.10,-1964.20,-2212.10,200.00)), | |
array("Arco del Oeste", array(-901.10,2221.80,0.00,-592.00,2571.90,200.00)), | |
array("Avispa Country Club", array(-2646.40,-355.40,0.00,-2270.00,-222.50,200.00)), | |
array("Avispa Country Club", array(-2831.80,-430.20,-6.10,-2646.40,-222.50,200.00)), | |
array("Avispa Country Club", array(-2361.50,-417.10,0.00,-2270.00,-355.40,200.00)), | |
array("Avispa Country Club", array(-2667.80,-302.10,-28.80,-2646.40,-262.30,71.10)), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define XOR(a,b) ((!a&&b)||(a&&!b)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdlib.h> | |
#include <time.h> | |
void initrand() { | |
srand((unsigned) time(NULL)); | |
rand(); | |
} | |
int rangerand(int max, int min) { | |
if(max < min) max = min; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
int main(int argc, char *argv[]) { | |
if(argc == 1) | |
printf("Whose birthday is it?\n"); | |
else if (argc == 2) | |
for(int i = 1; i <= 4; i++) | |
printf("Happy birthday %s %s\n", i % 3 == 0 ? "dear" : "to", i % 3 == 0 ? argv[1] : "you"); | |
else | |
printf("Too many.\n"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
/// <summary> | |
/// Represents a behavior script which will cause the object to float following a sine wave pattern. | |
/// </summary> | |
public class FloatObject : MonoBehaviour | |
{ | |
[SerializeField] private float _amplitude = 0.25f; | |
[SerializeField] private float _frequency = 1f; | |
private float _t = 0f; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bool is_even(int i) { | |
char buf[10]; // Probably big enough | |
float f = (float)i; | |
f /= 2; | |
sprintf(buf, "%lf", f); | |
for (int ii = 0; ii < 10 - 1; ++ii) { | |
if (buf[ii] == '.' && buf[ii+1] == '5') { | |
return true; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Randomly chooses a file from the given directory. | |
* @param directory Optional. The directory to search. Defaults to the current directory. | |
* @param ext Optional. An array of accepted file extensions to match. Defaults to standard images. | |
* @return A string representing the name of the file | |
*/ | |
function randomFile($directory = ".", $ext = array("jpg", "jpeg", "gif", "png", "bmp")) { | |
// Find file matches using glob | |
$files = glob($directory."/*.{".implode(",",$ext)."}", GLOB_BRACE); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define SWAP(x,y) do{ x^=y; y^=x; x^=y; } while (0); |
OlderNewer