Skip to content

Instantly share code, notes, and snippets.

@le717
le717 / battleship-v1-2.js
Created August 28, 2014 18:51
v1.2 of Elisabeth Robson ( https://github.com/bethrobson )'s Battleship game from her book Head First JavaScript program, which I am using as the textbook at college. I call it v1.2 as I made it slightly more advanced than it should be at the end of Chapter 2. 😃
/* jshint -W097 */
/* global prompt, alert */
"use strict";
var guess,
loc1 = Math.floor(Math.random() * 5),
loc2 = loc1 + 1,
loc3 = loc1 + 2,
hits = 0,
isSunk = false,
guesses = [];
@le717
le717 / winver.py
Last active August 29, 2015 14:07
Generate the version numbers of the major Windows releases to date.
#! /usr/bin/env/python
# -*- coding: utf-8 -*-
from __future__ import print_function
version = 0
jumps = [3, 8]
namedVersions = ["95", "98", "98SE", "ME", "XP", "Vista"]
def release(verNum):
print("Windows {0}".format(verNum))
@le717
le717 / scramble-name.js
Last active August 29, 2015 14:09
Randomly scrambles the given username.
/**
* Randomly scrambles the given username.
* @param {String} realName The username to be scrambled.
* @returns {String} The scrambled username.
*/
function scrambleName(realName) {
"use strict";
var newName = "",
usedChar = [];
@le717
le717 / six-billion-names.js
Created November 14, 2014 20:02
For my blog post "6 billion names" (http://wp.me/p1V5ge-1KI)
/**
* Randomly scrambles the given username.
* https://gist.github.com/le717/4c2188ca814f56575a26.
* @param {String} realName The username to be scrambled.
* @returns {String} The scrambled username.
*/
function scrambleName(realName) {
"use strict";
var newName = "",
function Rabbit() {
this.color = "white";
this.children = [];
}
Rabbit.prototype.pullFromHat = function() {
return !!Math.floor(Math.random() * 2);
};
Rabbit.prototype.haveChildren = function() {
class SOPOMessages:
def __init__(self):
self.__encodeLegend = {}
self.__decodeLegend = {}
# Only decode the legends once per instance
# We only need to check if the encoding legend is generated
# for both legends are generated at the same time
if len(self.__encodeLegend) == 0:
@le717
le717 / such-scoping-and-variables.py
Last active August 29, 2015 14:17
I have no clue what younger me was trying to do. At all. File dated January 9, 2013.
def circle_info(Peri, Area):
if select == "Area":
area_of_circle(rad)
elif select == "Peri":
peri_of_circle(rad)
else:
print("Sorry, invalid selection.")
def area_of_circle(rad):
return (3.14 * (rad ** 2))
def peri_of_circle(rad):
<?php
if (PHP_OS == 'WIN32' || PHP_OS == 'WINNT') {
define('EOL', "\r\n");
} else if (PHP_OS == 'Linux') {
define('EOL', "\n");
} else {
define('EOL', "\n");
}
?>
@le717
le717 / gist:c698671893aa2a1ab8ac
Last active May 9, 2018 13:50 — forked from howtogeek/gist:6b3ed7d917900229b37e
Change font to Comic Sans if reader is using Adblock (and display a message at the top)
<script type="text/javascript">
var iframe = document.createElement("iframe");
iframe.height = "1px";
iframe.width = "1px";
iframe.id = "ads-text-iframe";
iframe.src = "/adframe.js";
document.body.appendChild(iframe);
var a = [
"In a world free from ads, one font reigns supreme. COMIC SANS!",
@le717
le717 / tracking-cookie.html
Created October 1, 2015 14:40
Expanded form of sneaky tracking cookie system as exposed in https://wp.me/p1V5ge-23v