Skip to content

Instantly share code, notes, and snippets.

View qaisjp's full-sized avatar
🧪
why has the new github hidden statuses?

Qais Patankar qaisjp

🧪
why has the new github hidden statuses?
View GitHub Profile
@qaisjp
qaisjp / 1.vba
Last active August 29, 2015 14:16
Project Euler Solutions (in VB, because why not?) (Not that I would encourage you to use VB, of course)
Module Module1
Sub Main()
Dim maxNumber As Integer = 1000
Dim value As Integer = 0
For i As Integer = 1 To maxNumber - 1
If (i Mod 3 = 0) Or (i Mod 5 = 0) Then
value += i
End If
Next
@qaisjp
qaisjp / decode.lua
Created July 13, 2012 20:13 — forked from mabako/decode.lua
xml to real (&copy to (c) etc.)
:gsub("&#%d%d%d%d;", decode)
function decode(str)
local num = tonumber(str:sub(3,6))
local first = math.floor(num/4096)
num = num - 4096 * first
return string.char(first+224, math.floor(num/64)+128, num%64+128)
end
@qaisjp
qaisjp / Employee.vb
Last active November 26, 2015 07:04
A2 AQA Computing | Section 2.1: Programming paradigms | Exercises in OOP programming | Exercise 2
Public Class Employee
' These private variables cannot be accessed outside the class
' This means that in Module1.vb, we can't do emp.EmployeeID
' The only time we really need to do this is when validating data
' See the comments for each function to see how they *could* be validated
Private EmployeeID As String
Private DateOfBirth As String
Private JobTitle As String
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
-- this can be a json file
return {
engine = "love-0.8.0",
image = "github://img/screenie.png", -- also allow "http://"
source = "github://src" -- if src is a folder, downlaod as zip via Ghub api, if it is a .love file then downlaod that instead
-- other meta
}
@qaisjp
qaisjp / download.php
Created August 12, 2013 12:03
Assuming you have a "www" folder inside a "web" folder. You'd have a tree like: "/downloads/file.love", "/www/download.php", this prevents hotlinking from avoiding download counts. This also just throws the actual file to the user as if they were downloading the file directly, instead of forwarding them to another file, reducing the number of HT…
$valid_files = Array(
"trAInsported.love" => True;
);
if (!empty($_GET["file"]) {
$request = $_GET["file"];
if $valid_files[$request] {
$path = "../downloads/" . str_replace('/', '_', $request);
header("Content-type: application/octet-stream");
header("Content-disposition: attachment;filename=" . $request);
@qaisjp
qaisjp / dubtrack.swagger.yaml
Last active May 1, 2016 17:15
dubtrack fm swagger yaml docs
swagger: '2.0'
info:
title: Dubtrack API
description: |
Unofficial documentation. All responses are wrapped in `{ code: 200, data: <response>, message: "OK" }`.
version: "1.0.0"
# the domain of the service
host: api.dubtrack.com
# array of all schemes that your API supports
@qaisjp
qaisjp / tut2 ex4.hs
Last active October 9, 2016 14:58 — forked from Fasand/tut2 ex4
lookUp :: Char -> [(Char, Char)] -> Char
lookUp needle xs = if (null selected) then needle else snd $ selected !! 0
where
selected = [x | x <- xs, fst x == needle]

Keybase proof

I hereby claim:

  • I am qaisjp on github.
  • I am qaisjp (https://keybase.io/qaisjp) on keybase.
  • I have a public key whose fingerprint is 5D90 87F0 7DC7 E6CB 1CE0 814A 39A7 A845 3517 B0FD

To claim this, I am signing this object:

I don't know if we've been taught the general method for De Morgan's, but I'll say it anyway:

  • NOT the whole sentence
  • NOT each item in the brackets (direct children only)
  • INVERT each AND/OR. This makes AND become OR, and vice-versa (direct children only)

When I say direct children only, I mean that if you have (A or (B and C)), you should end up with not (not A and not (B and C)) by De Morgan's.

You should NOT end up with not (not A and (not B or not C)).

@qaisjp
qaisjp / INF1OP_NoughtsAndCrosses.java
Created February 25, 2017 18:31
Some magnificently shite code
public class NoughtsAndCrosses {
boolean drawn;
int winner;
public NoughtsAndCrosses(int[][] board) {
// First check all columns
for (int x = 0; x < 3; x++) {
Integer winner = board[x][0];