Skip to content

Instantly share code, notes, and snippets.

View Kreijstal's full-sized avatar
↗️

Kreijstal Kreijstal

↗️
View GitHub Profile
Create an application that manages cable account information. A form allows the entry of the following data: accountholder id (integer), first name(string), last name(string), debits (decimal), and credits (decimal). The form should have the buttons: Add (which adds a customer to the Cable.txt sequential file), Clear (which clears all text boxes for a new account entry), Balance (credits – debits), and Exit (which closes the form). When the Balance button is clicked, an independent function is called that calculates the balance from the given credits and debits of that user and returns the balance to be displayed in the balance label.
The sequential file must hold the following information:
a) Accountholder id
b) First name
c) Last name
d) Debits
e) Credits
f) balance
The accountholder id must be between 6000 and 22000 (inclusive). If it is not within this range, an error message should be displayed to the user via an error message label on the form and the Add button disabled until an accountholder id within
@Kreijstal
Kreijstal / gist:4041896
Created November 8, 2012 21:46
addEventSimple & removeEventSimple
function addEventSimple(obj, evt, fn, bo) {
if (obj.addEventListener) // W3C
obj.addEventListener(evt, fn, bo);
else if (obj.attachEvent) // Microsoft
obj.attachEvent('on' + evt, fn);
else obj['on'+evt]=fn;
};
function removeEventSimple(obj, evt, fn, bo) {
var pasteCatcher;
if (!window.Clipboard) {
pasteCatcher = document.createElement("div");
// Firefox allows images to be pasted into contenteditable elements
pasteCatcher.setAttribute("contenteditable", "");
// We can hide the element and append it to the body,
pasteCatcher.style.opacity = 0;
//No Space LOL!
https://fbcdn-photos-d-a.akamaihd.net/hphotos-ak-frc3/1255483_366286623502281_450124228_n.jpg
https://fbcdn-photos-d-a.akamaihd.net/hphotos-ak-frc3/1239843_366286180168992_253712228_n.jpg
https://fbcdn-photos-d-a.akamaihd.net/hphotos-ak-frc3/1238866_366285943502349_1466041292_n.jpg
https://fbcdn-photos-d-a.akamaihd.net/hphotos-ak-frc3/995501_366285563502387_142714849_n.jpg
https://fbcdn-photos-d-a.akamaihd.net/hphotos-ak-frc3/547495_366284773502466_783950834_n.jpg
https://fbcdn-photos-d-a.akamaihd.net/hphotos-ak-frc3/1240406_366284680169142_1269127666_n.jpg
https://fbcdn-photos-d-a.akamaihd.net/hphotos-ak-frc3/543454_366284310169179_725275890_n.jpg
https://fbcdn-photos-d-a.akamaihd.net/hphotos-ak-frc3/545941_704856372862314_792122070_n.jpg
https://fbcdn-photos-d-a.akamaihd.net/hphotos-ak-frc3/66998_366284190169191_947237890_n.jpg
https://fbcdn-photos-d-a.akamaihd.net/hphotos-ak-frc3/67000_366284053502538_740440185_n.jpg
@Kreijstal
Kreijstal / gist:6757808
Created September 30, 2013 00:21
Some obfuscated bullshit
function UNPACKER(U5C) {//Unpacks string packed arguments
//backtick and 3 arguments
//first argument, is length +5
//second and third argument is distance from current index..
//these arguments are in character form..
for (var b5C = "", z5C = 0, o5C = function(U5C, H5C) {
for (var x5C = 0, J5C = 0; J5C < H5C; J5C++) {
x5C *= 96;
var Z5C = U5C.charCodeAt(J5C);
if (Z5C >= 32 && Z5C <= 127) { //from 32 to 127
function TokenizeHTML(string){
var state=0,firststatechars=['<!','</','<'],endingTag=true,returnObject=[],ret='',c='',d,ii,ll,tagname='';
//sorry for uncommented shit, I don't even know what Im'd doing
//state 0 is outside tag, 1 is inside a normal tag
//ret,c,d,ii,ll have various uses dependent on the state and loop, so I can't really know what each one does, they're like counters and state keepers
//ret usually works as adding the text outside the tags
function ifret(){
if(ret){
returnObject.push({Type:"text",Content:ret});
ret='';
fibspiralS: (function (angle) {
return (function init() {
var direction = angle;
var fibwords = [0, 1],
addchang = Math.PI / 2;
function fibbonacci() {
var i = fibwords[1];
fibwords[1] += fibwords[0];
return fibwords[0] = i;
OKAY, so we(me) want to convert base 2 into base10 (any base to any base), alright each digit is stored in an array so base10 number 2012 would be stored as [2,0,1,2] in the array, basically
There MUST NOT be intermidate values, this is because it should support arrays of absolutely any size.
And it's not base 2 and 10 exclusive, it should support any (reasonable) base
//bigint suggestions may be ignored, I do this for learning purposes and because I'm insane.
We have the value [1,0] (10 in binary, 2 in decimal) we have to somehow convert this value to [2];
What is the best solution for this?
Attempt 1
[1,0] is the initial array is base 2, we want it to convert it to base10
each value in each array equals 2^i*v (reverse index, whatever (using big endian)) multiplied by it's value.
first we convert the numeric number of the base, this is '2' into base 10, we have the value number '2' already, the function that converts base to other base, basically, takes the FromBase and the ToBase arguments, and the array wh
@Kreijstal
Kreijstal / gist:6985515
Last active December 25, 2015 13:39
Converting bases into other bases
OKAY, so we(me) want to convert base 2 into base10 (any base to any base)
HOWEVER, this values will be big enough to fit in most integer size the language can support natively
each digit is stored in an array so base10 number 2012 would be stored as [2,0,1,2] in the array, basically
There MUST NOT be intermidate values, this is because it should support arrays of absolutely any size.
And it's not base 2 and 10 exclusive, it should support any (reasonable) base
//bigint suggestions may be ignored, I do this for learning purposes and because I'm insane.
We have the value [1,0] (10 in binary, 2 in decimal) we have to somehow convert this value to [2];
What is the best solution for this?
Attempt 1
var chunks = {
"IHDR": function (bytes) {
var i = 0;
return {
Width: bytesToNumber(bytes.slice(i, i += 4)),
Height: bytesToNumber(bytes.slice(i, i += 4)),
bitDepth: bytesToNumber(bytes.slice(i, ++i)),
colourType: bytesToNumber(bytes.slice(i, ++i)),
compressionMethod: bytesToNumber(bytes.slice(i, ++i)),
filterMethod: bytesToNumber(bytes.slice(i, ++i)),