Skip to content

Instantly share code, notes, and snippets.

import random
peeps = {
'Matt': '',
'Al': '',
'Bebop': '',
'Mum': '',
'Dad': '',
'Gramps': ''
}
@MattDiesel
MattDiesel / example.c
Last active April 26, 2017 01:04
Delete multiples for prime sieve on linked list
node* Deletemultiples(node* head, int k)
{
node* temp = head, *old = head, *todelete;
if (head == NULL)
return NULL;
while (temp!=NULL) {
if (temp->data % k ==0 && temp->data != k) {
todelete = temp;
#include <iostream>
#include "inst_none.h"
const int matrixSize = 1000;
int a[matrixSize][matrixSize];
int b[matrixSize][matrixSize];
int c[matrixSize][matrixSize];
int main() {
Global $packetID = "UCAS"
Local $inbuff = "", $n
While 1
;ManageTray()
;Sleep(50) ; (to allow script to make way for other software. Not sure if it does though?)
$inbuff = $inbuff & _Commgetstring()
Local $handleDLL = DLLOpen("C:\DelcomDLL.dll")
Local $devices = DllCall($handleDLL,"dword","DelcomGetDeviceCount","dword",0)
Local $stStrings[$devices[0]]
Local $tDeviceArray = DllStructCreate("wchar* Items[" & $devices[0] & "]")
For $i = 1 To $devices[0]
$stStrings[$i - 1] = DllStructCreate("wchar Name[512]")
DllStructSetData($tDeviceArray, "Items", $stStrings[$i - 1], $i)
@MattDiesel
MattDiesel / _ToBase.au3
Created June 19, 2013 10:44
Convert to/from numeric bases/
Func _ToBase($iNumber, $iBase, $iPad = 1, $sCharSet = Default)
Local Static $sDefCharSet = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz+/"
Local $sRet = "", $iDigit
If $sCharSet = Default Then $sCharSet = $sDefCharSet
Do
$iDigit = Mod($iNumber, $iBase)
$sRet = StringMid($sCharSet, $iDigit + 1, 1) & $sRet
$iNumber = Int($iNumber / $iBase)
@MattDiesel
MattDiesel / AuLex_GenDb
Created June 13, 2013 07:53
Generates include files used in AuLex.au3
Local $__AL_AU3API = FileRead("C:\Program Files\AutoIt3\SciTE\api\au3.api")
Global $__AL_KEYWORDS = StringRegExp($__AL_AU3API, "(\w+)\?4", 3)
Global $__AL_FUNCS = StringRegExp($__AL_AU3API, "(?:\n|\A)([^\_]\w+)\s\(", 3)
Global $__AL_MACROS = StringRegExp($__AL_AU3API, "(?:\n|\A)(@\w+)\?3", 3)
Local $aTypes[3] = ["KEYWORDS", "FUNCS", "MACROS"]
Local $aArrays[3] = [$__AL_KEYWORDS, $__AL_FUNCS, $__AL_MACROS]
Local $hFile, $a
@MattDiesel
MattDiesel / AuParse.au3
Created June 12, 2013 22:08
AutoIt parser written in AutoIt.
#cs
Syntax Tree Usage:
The syntax tree is a flat array of "branches". The branches can point to each other by referencing
the child branches index. In a simplistic way, the following tree:
1
/ \
@MattDiesel
MattDiesel / AuOpt.au3
Created June 11, 2013 21:02
Example of using AuLex to write a preprocessor. Currently supports #define #undef #ifdef #ifndef #else #endif.
#include <Array.au3>
#include "AuLex.au3"
Local $s = "TestOpt.au3"
MsgBox(0, $s, _PreProcess($s))
Func _PreProcess($sFile)
Local $aDefined[1][2] = [[0, 0]] ; NAME, VALUE
#include <Array.au3>
#include <Math.au3>
Global $__CmdLine_StrictMode = False
Global $__CmdLine_PrefixLong = "--"
Global $__CmdLine_PrefixShort = "-"
Global $__CmdLine_StringChars = "'"""
Global $__CmdLine_SplitChars = " =:" & @TAB