This file contains hidden or 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
//Because the normal initcap function lowercases the string first | |
private static String upperFirstchar( String pString) { | |
return pString.substring(0,1).toUpperCase() + pString.substring(1); | |
} | |
//Use java reflection to try and get private member values from an object | |
// MemberPath is of format "Object.Object.lPrivateVariable", the first object being a member of pStartingObject | |
//This function is quite possibly the inelegant thing I've coded for a while | |
public static Object getPrivateMembers (String pMemberPath, Object pStartingObject) | |
throws ExInternal { | |
if (pStartingObject == null) { |
This file contains hidden or 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
CREATE OR REPLACE PACKAGE SCOTT.np_reddit IS | |
g_xmldata XMLTYPE; | |
PROCEDURE get_top_25 (p_subreddit VARCHAR2 default null); | |
PROCEDURE get_comments (p_item NUMBER); | |
PROCEDURE get_image (p_item NUMBER, p_scale NUMBER default 10, p_end VARCHAR2 default null); | |
END; | |
/ | |
This file contains hidden or 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 | |
if(!isset($_GET['pure'])){ | |
?> | |
<style> | |
pre { | |
line-height: 11px; | |
font-family:"Courier New", Courier, monospace; | |
} | |
#error { | |
font-family: Arial, Helvetica, sans-serif; |
This file contains hidden or 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
void Instructions::doReturn(CPU* cpu, BYTE pOpcode) { | |
if (pOpcode == 0xc9 | |
|| (pOpcode == 0xc0 && cpu->reg->getFlagZ() == 0) | |
|| (pOpcode == 0xc8 && cpu->reg->getFlagZ() == 1) | |
|| (pOpcode == 0xd0 && cpu->reg->getFlagC() == 0) | |
|| (pOpcode == 0xd8 && cpu->reg->getFlagC() == 1)) { | |
cpu->reg->setPC((WORD)((cpu->mem.readByte(cpu->reg->getSP() + 1) << 8) | cpu->mem.readByte(cpu->reg->getSP()))); | |
cpu->reg->incSP(2); | |
cpu->clock.m += 5; | |
cpu->clock.t += 20; |
This file contains hidden or 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
void Instructions::do8bitSubRegToA(CPU* cpu, BYTE (Registers::*getRegFunc)()){ | |
BYTE lInitialValue = cpu->reg->getA(); | |
BYTE lToSub = (cpu->reg->*getRegFunc)(); | |
WORD lTotal = lInitialValue - lToSub; | |
// If the lower nibble of the original value is less than the lower nibble of what we're subtracting, it'll need a half carry | |
cpu->reg->setFlagH((lInitialValue & 0x0f) < (lToSub & 0x0f)? 1 : 0); | |
// If the original value is less than we're subtracting it'll carry | |
cpu->reg->setFlagC(lInitialValue < lToSub ? 1 : 0); |
This file contains hidden or 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
Attribute VB_Name = "Module1" | |
Sub Stockreport1() | |
Attribute Stockreport1.VB_ProcData.VB_Invoke_Func = " \n14" | |
' Comments start with apostrophes :) | |
' Select a bunch of columns, then remove them | |
Range("F:F,I:I,X:X,AD:AD,AE:AE,AA:AC,AH:AP").Select | |
Selection.Delete Shift:=xlToLeft | |
' Insert a new column and put "Stores OOS" in the first item to be the title |
This file contains hidden or 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 | |
class Database { | |
private $dbHandle; | |
private $preparedStatements = array(); | |
public $rowCount; | |
public $lastInsertId; | |
public function __construct($host, $database, $username, $password, $errorMode='silent') { | |
try { |
This file contains hidden or 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
// for some reason the challenege only let you use these letters, not full A-Z | |
var letters = "acdegilmnoprstuw"; | |
// Implementation of their hash function to test against | |
function doHash(string) { | |
var hash = 7; | |
for(var i = 0; i < string.length; i++) { | |
hash = (hash * 37 + letters.indexOf(string[i])); | |
} | |
return hash; |
This file contains hidden or 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
// This is whatever has your JSON before you call the tagger | |
var tagItemsJSON = ... | |
// This takes the JSON and splits it into an array of the items in it | |
// It then sorts that array by the suggestion field on each item | |
var sortedBySuggestion = $.map(tagItemsJSON, function(p){return p;}).sort(function(a, b){ | |
if(a.suggestion < b.suggestion ) return -1; | |
if(a.suggestion > b.suggestion ) return 1; | |
return 0; | |
}); |
This file contains hidden or 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
//Draw a wrapped sting | |
private static boolean isBreakable(char c) { | |
return (c == ' ' || c == '\t' || c == '-' || c == '\\' || c == '/' || c == '_'); | |
} | |
private static boolean isNewLine(char c) { | |
return (c == '\n' || c == '\r'); | |
} | |
/** | |
* Draw a string onto a graphics2d object, wrapping words at pWidth pixels wide. |
OlderNewer