Skip to content

Instantly share code, notes, and snippets.

@DTSCode
DTSCode / out.cpp
Last active August 29, 2015 14:08
Various C++ Codes
#include <ostream>
#include <string>
namespace dts {
void whisper(std::ostream &out, std::string msg) {
for(char &next : msg) {
out << ((next >= 'A' && next <= 'Z') ? (next - ('Z' - 'z')) : next);
}
}
@DTSCode
DTSCode / Books
Last active August 29, 2015 14:09
Christmas Book List
Programming Languages: Application and Interpretation by Shriram Krishnamurthi
http://www.amazon.com/Operating-System-Concepts-Abraham-Silberschatz/dp/1118129385
http://rads.stackoverflow.com/amzn/click/0201734842
http://rads.stackoverflow.com/amzn/click/0321113586
http://rads.stackoverflow.com/amzn/click/0321227255
http://www.nostarch.com/lyah.htm
http://www.amazon.com/The-Programming-Language-2nd-Edition/dp/0131103628
http://www.amazon.com/Clean-Code-Handbook-Software-Craftsmanship/dp/0132350882
http://www.amazon.com/The-Pragmatic-Programmer-Journeyman-Master/dp/020161622X
http://www.amazon.com/Design-Patterns-Object-Oriented-Professional-Computing/dp/0201634988
@DTSCode
DTSCode / example.ts
Last active August 29, 2015 14:09
example.ts - shows off some basic features of the language
import stdlib
routine main : string args
while true
print("Please enter a number between 1-10: ")
int num = NOVAL
read(num)
if num < 1
print("Too Small. Wrong. ")
@DTSCode
DTSCode / Too learn
Created November 12, 2014 08:53
DTSCode's programming language backlog
php/hack
c
c++
python3
ruby
perl
AT&T assembly
javascript
haskell
crystal
@DTSCode
DTSCode / ai.cpp
Last active August 29, 2015 14:10
A* implementation in c++ using the standard library
#include <iostream>
#include <array>
#include <utility>
class node {
public:
node(bool=true);
node &operator=(bool);
friend std::ostream &operator<<(std::ostream&, const node&);
@DTSCode
DTSCode / MY FIRST LESSON!!!!!!
Created December 2, 2014 01:49
The basics of std::basic_stream<char>
The basics of std::basic_stream<char>
=====================================
As a part of the standard library, a class is defined called basic_stream<char>, which is typedef-ed to look like this:
typedef std::basic_stream<char> std::istream; // note that it might not look exactly like this, but it will evaluate to the same thing
The most known instance of std::istream is std::cin, which is linked to stdin, and currently all we are focusing on. There are two common operations used on std::cin. The first is operator >>, which reads one token from the input stream. There are two new terms here: token, and input stream. The input stream is literally just the collection of characters that are waiting to be read in to variables. In the case of std::cin, these characters typically come from the keyboard. For example, if I were to type "My name is DTSCode and I am an 3l1t3 h4xx0r. 10 20 30.4 -7", then that is what the input stream would consist of. The second term, token, is just a part of the input stream. Contin
@DTSCode
DTSCode / racketball.rkt
Last active August 29, 2015 14:18
Racketball - A webserver written in racket
#lang racket
(define (serve port-no)
(define listener
(tcp-listen port-no 5 #t))
(define (loop)
(accept-and-handle listener)
(loop))
(loop))
@DTSCode
DTSCode / tables
Last active August 29, 2015 14:18
CREATE TABLE Nicks ( id MEDIUMINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, nick VARCHAR(200) NOT NULL);
CREATE TABLE Quote (
id MEDIUMINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
grabber_id MEDIUMINT UNSIGNED NOT NULL,
sayer_id MEDIUMINT UNSIGNED NOT NULL,
quote VARCHAR(1500) NOT NULL,
CONSTRAINT `fk_grabber_id`
FOREIGN KEY (grabber_id) REFERENCES Nicks (id)
ON DELETE CASCADE,
import irc, asyncdispatch
import strutils
import times
proc getDaysLeft(year_s: string, today: string, holiday: string): string =
var table = @[31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
var month: int
var day: int
var dayOfTheYear: int = 0
var dayOfChristmas: int = 358
@DTSCode
DTSCode / timeout.nim
Last active August 29, 2015 14:22
simple timeout script written in nim for a ZNC bouncer. After 10 minutes of inactivity it sends "AWAY :<nick> is currently afk (set by timeoutbot)". After becoming active again it sends "AWAY" to the server. To change it to suit your needs, edit all of the top const variables to their appropriate values.
import irc, asyncdispatch, posix
const
time: cint = 600
server: string = "dtscode.io"
port: int = 3038
nick: string = "dtscode"
user: string = "dtscode"
real: string = "nchambers - dtscode.io"
pass: string = "REDACTED_PASSWORD"