Skip to content

Instantly share code, notes, and snippets.

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 Aug 29, 2015
Project Euler Solutions (in VB, because why not?) (Not that I would encourage you to use VB, of course)
View 1.vba
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 Jul 13, 2012 — forked from mabako/decode.lua
xml to real (&copy to (c) etc.)
View decode.lua
: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 Nov 26, 2015
A2 AQA Computing | Section 2.1: Programming paradigms | Exercises in OOP programming | Exercise 2
View Employee.vb
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
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
View Vapor
-- 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 Aug 12, 2013
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…
View download.php
$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
dubtrack fm swagger yaml docs
View dubtrack.swagger.yaml
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
View tut2 ex4.hs
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]
View keybase.md

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:

View DeMorgans.md

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)).

View autossh-reverse-tunnel.md

Setting up an autossh reverse tunnel

1. Set up sshtunnel user

Follow this tutorial until step five-ish

If the test does not work because of "public key" issues, run sudo passwd sshtunnel on the server to change the password of the user. (If sudo tail -f /var/log/auth.log says the account is locked, this will be the issue.)

authorized_keys should look a little like: