Skip to content

Instantly share code, notes, and snippets.

View Noble-Mushtak's full-sized avatar

Noble Mushtak Noble-Mushtak

View GitHub Profile
@Noble-Mushtak
Noble-Mushtak / code.txt
Created July 20, 2015 14:57
Link to KA Embed Code
data:text/html,<h2><a href="https://www.khanacademy.org/computer-programming/what-is-it-adjustable/4857201710727168">What is it? (adjustable)</a></h2> <script src="https://www.khanacademy.org/computer-programming/what-is-it-adjustable/4857201710727168/embed.js?editor=yes&amp;buttons=yes&amp;author=yes&amp;embed=yes"></script> <p>Made using: <a href="http://www.khanacademy.org/computer-programming">Khan Academy Computer Science</a>.</p>
@Noble-Mushtak
Noble-Mushtak / bot.js
Last active August 29, 2015 14:25
KA Contest Judging System Server Bot
//Include Firebase and jQuery AJAX
var http = require("http");
var Firebase = require("Firebase");
var najax = require("najax");
var minuteInterval = 30;
var howOften = 60 * 1000 * minuteInterval; //Should evaluate to "minuteInterval" minutes
//ka_api.js
/***
/*
* Step 1: Check to make sure user is logged in (if not, leave page)
* Step 2: Check to make sure logged in user, is an administrator (if not, leave page)
* Step 3: Load all tools onto the page.
*/
/* The data we have on the current user. */
var userData;
/* True iff we're done with the auth checks. */
var authChecksDone = false;
@Noble-Mushtak
Noble-Mushtak / website.js
Created August 8, 2015 16:04
Lightweight Dropdowns:
//The event names. These change according to whether or not the user is on a mobile device, or specifically a Windows Phone.
var isIEMobile = navigator.userAgent.indexOf("IEMobile") != -1;
var isMobile = navigator.userAgent.indexOf("Mobile") != -1;
var mouseevents = {
click: "click",
mousedown: isIEMobile ? "pointerdown" : (isMobile ? "touchstart" : "mousedown"),
mouseup: isIEMobile ? "pointerup" : (isMobile ? "touchend" : "mouseup"),
mousemove: isIEMobile ? "pointermove" : (isMobile ? "touchmove" : "mousemove"),
mouseenter: isIEMobile ? "pointerenter" : (isMobile ? "touchenter" : "mouseenter"),
mouseleave: isIEMobile ? "pointerleave" : (isMobile ? "touchleave" : "mouseleave")
@Noble-Mushtak
Noble-Mushtak / Calculator.lua
Last active April 8, 2024 16:56
Simple Calculator for Lua
function characterPresent(stringParam, character)
--[[
This function returns true if and only if character is in stringParam.
]]--
--Loop through stringParam:
for i=1, #stringParam do
--If the current character is character, return true.
if stringParam:sub(i, i) == character then return true end
end
--If we go through the whole string without returning true, we get to this point.
@Noble-Mushtak
Noble-Mushtak / test.py
Created April 18, 2016 23:31
Does a prime h^2+1 divide (2p)^2+1 for all prime p?
from math import sqrt
max = 800000
smallest_prime_factor = []
for num in range(max): smallest_prime_factor.append(0)
for num in range(2, max):
if smallest_prime_factor[num] == 0:
smallest_prime_factor[num] = num
for num2 in range(max//num):
if smallest_prime_factor[num*num2] == 0:
def implies(x, y):
'''Tells us if x --> y'''
return ((not x) or y)
def digits(num, base=10):
'''Converts num to an array containing its digits from base specified'''
if num < base: return [num]
return digits((num-(num % base))//base, base)+[num % base]
# Answer for part d
@Noble-Mushtak
Noble-Mushtak / Expression.java
Created October 6, 2016 15:53
APCS Unit 3 Design a Class Project
/**
* A class that models mathematical expressions.
*
* @author Noble H. Mushtak
* @version 1.0 (6 Oct 2016)
*/
public class Expression
{
/**
* These are the five operations allowed in our expressions.
@Noble-Mushtak
Noble-Mushtak / record.c
Created October 11, 2016 21:59
How to Convert Record ID into Record Side and Record Number -- https://github.com/retepsmada/Rockola477Arduino
#include <stdio.h>
#include <stdlib.h>
//This is a datatype that can be either "A" or "B".
enum side { A, B };
typedef enum side side;
//This is a datatype representing a record.
//It has both a side and a record number.
typedef struct {
side side;
@Noble-Mushtak
Noble-Mushtak / Template.java
Last active October 30, 2016 14:34
APCS Template.java
import java.util.*;
/**
* Description
*
* @author Noble Mushtak
* @version 1.0 (DATE)
*/
public class Template {
/**