Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/cajacko/whimsical-code
https://github.com/cajacko/whimsical-code
Last synced: 2 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/cajacko/whimsical-code
- Owner: cajacko
- Created: 2018-05-04T13:20:14.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2018-05-04T13:57:14.000Z (over 6 years ago)
- Last Synced: 2024-11-10T01:38:19.814Z (about 2 months ago)
- Size: 3.91 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Whimsical Code
A collection of fun code comments, logs and miscellaneous programming related hilarity. Pull Requests most welcome.
---
Congratulate worthy warriors
```
/**
* For the brave souls who get this far: You are the chosen ones,
* the valiant knights of programming who toil away, without rest,
* fixing our most awful code. To you, true saviors, kings of men,
* I say this: never gonna give you up, never gonna let you down,
* never gonna run around and desert you. Never gonna make you cry,
* never gonna say goodbye. Never gonna tell a lie and hurt you.
*/
```A great way to put a metric on the pain a specific routine is causing
```
//
// Dear maintainer:
//
// Once you are done trying to 'optimize' this routine,
// and have realized what a terrible mistake that was,
// please increment the following counter as a warning
// to the next guy:
//
// total_hours_wasted_here = 42
//
```Maybe not a great real world example, but still tickles me
```
Exception up = new Exception("Something is really wrong.");
throw up; //ha ha
```Shameless fun
```
stop(); // Hammertime!
```A Good way of stopping morons from messing with your code
```
// Autogenerated, do not edit. All changes will be undone.
```Take a cue from books
```
// I dedicate all this code, all my work, to my wife, Darlene, who will
// have to support me and our three children and the dog once it gets
// released into the public.
```When it's really time to just take it out on someone
```
//Code sanitized to protect the foolish.
using System;
using System.Collections.Generic;
using System.Text;
using System.Reflection;
using System.Web.UI;namespace Mobile.Web.Control
{
///
/// Class used to work around Richard being a fucking idiot
///
///
/// The point of this is to work around his poor design so that paging will
/// work on a mobile control. The main problem is the BindCompany() method,
/// which he hoped would be able to do everything. I hope he dies.
///
public abstract class RichardIsAFuckingIdiotControl : MobileBaseControl, ICompanyProfileControl
{
protected abstract Pager Pager { get; }public void BindCompany(int companyId) { }
public RichardIsAFuckingIdiotControl()
{
MakeSureNobodyAccidentallyGetsBittenByRichardsStupidity();
}private void MakeSureNobodyAccidentallyGetsBittenByRichardsStupidity()
{
// Make sure nobody is actually using that fucking bindcompany method
MethodInfo m = this.GetType().GetMethod("BindCompany", BindingFlags.DeclaredOnly |
BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
if (m != null)
{
throw new RichardIsAFuckingIdiotException("No!! Don't use the fucking BindCompany method!!!");
}
// P.S. this method is a joke ... the rest of the class is fucking serious
}///
/// This returns true if this control is supposed to be doing anything
/// at all for this request. Richard thought it was a good idea to load
/// the entire website during every request and have things turn themselves
/// off. He also thought bandanas and aviator sunglasses were "fuckin'
/// gnarly, dude."
///
protected bool IsThisTheRightPageImNotSureBecauseRichardIsDumb()
{
return Request.QueryString["Section"] == this.MenuItemKey;
}protected override void OnLoad(EventArgs e)
{
if (IsThisTheRightPageImNotSureBecauseRichardIsDumb())
{
Page.LoadComplete += new EventHandler(Page_LoadComplete);
Pager.RowCount = GetRowCountBecauseRichardIsDumb();
}
base.OnLoad(e);
}protected abstract int GetRowCountBecauseRichardIsDumb();
protected abstract void BindDataBecauseRichardIsDumb();void Page_LoadComplete(object sender, EventArgs e)
{
BindDataBecauseRichardIsDumb();
}// the rest of his reduh-ndant interface members
public abstract string MenuItemName { get; set; }
public abstract string MenuItemKey { get; set; }
public abstract bool IsCapable(CapabilityCheck checker, int companyId);
public abstract bool ShowInMenu { get; }
public virtual Control CreateHeaderControl()
{
return null;
}
}
}
```The optimism!
```
// somedev1 - 6/7/02 Adding temporary tracking of Login screen
// somedev2 - 5/22/07 Temporary my ass
```The truth, the whole truth and nothing but the truth
```
// drunk, fix later
```The universal
```
// I'm sorry.
```When documentation goes too far
```
return 1; # returns 1
```When the opportunity presents itself
```
// Replaces with spaces the braces in cases where braces in places cause stasis
$str = str_replace(array("\{","\}")," ",$str);
```The scary reality
```
Catch (Exception e) {
//who cares?
}
```Forewarning
```
/*
* You may think you know what the following code does.
* But you dont. Trust me.
* Fiddle with it, and youll spend many a sleepless
* night cursing the moment you thought youd be clever
* enough to "optimize" the code below.
* Now close this file and go play with something else.
*/
```Hope against hope
```
try {} finally { // should never happen
}
```When you don't have prettier or eslint you can get away with
```
#Christmas tree initializer
toConnect = []
toRead = [ ]
toWrite = [ ]
primes = [ ]
responses = {}
remaining = {}
```Own your mistakes
```
//This code sucks, you know it and I know it.
//Move on and call me an idiot later.
```Honesty
```
// If this comment is removed the program will blow up
```When you just don't know anymore
```
// I don't know why I need this, but it stops the people being upside-downx = -x;
```When you just can't spend the time
```
// I am not sure if we need this, but too scared to delete.
```Some opportunities you have to take
```
doRun.run(); // ... "a doo run run".
```Damn PM's
```
// I am not responsible of this code.
// They made me write it, against my will.
```Notes to self
```
//Dear future me. Please forgive me.
//I can't even begin to express how sorry I am.
```When your user level isn't high enough
```
/* You are not meant to understand this */
```Using logic
```
// no comments for you
// it was hard to write
// so it should be hard to read
```Poking fun
```
// hack for ie browser (assuming that ie is a browser)
```Educational
```
/* Emits a 7-Hz tone for 10 seconds.
True story: 7 Hz is the resonant frequency of a
chicken's skull cavity. This was determined
empirically in Australia, where a new factory
generating 7-Hz tones was located too close to a
chicken ranch: When the factory started up, all the
chickens died.
Your PC may not be able to emit a 7-Hz tone. */main()
{
sound(7);
delay(10000);
nosound();
}
```Threats
```
/* We will NOT put a fucking timestamp in the header here. Every
time you put it back, I will come in and take it out again. */
```Can do what you want on your last day
```
/*
This isn't the right way to deal with this, but today is my last day, Ron
just spilled coffee on my desk, and I'm hungry, so this will have to do...
*/return 12; // 12 is my lucky number
```More puns
```
class Act //That's me!!!
{}
```Impending doom
```
try {}
catch (SQLException ex) {
// Basically, without saying too much, you're screwed. Royally and totally.
}
catch(Exception ex)
{
//If you thought you were screwed before, boy have I news for you!!!
}
```Pigs!
```
def format_ticket_content(text, recursive = true)
if text.is_a?(TicketNote)
note = text
text = note.content
else
note = nil
end## Safety pig has arrived!
text = h(text)
## _
## _._ _..._ .-', _.._(`))
## '-. ` ' /-._.-' ',/
## ) \ '.
## / _ _ | \
## | a a / |
## \ .-. ;
## '-('' ).-' ,' ;
## '-; | .'
## \ \ /
## | 7 .__ _.-\ \
## | | | ``/ /` /
## /,_| | /,_/ /
## /,_/ '`-'
##
```Consult the tomes
```
/*
after hours of consulting the tome of google
i have discovered that by the will of unknown forces
without the below line, IE7 believes that 6px = 12px
*/
font-size: 0px;
```Sometimes it has to happen
```
if (/*you*/ $_GET['action']) { //celebrate
```## Sources
* https://stackoverflow.com/questions/184618/what-is-the-best-comment-in-source-code-you-have-ever-encountered