This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension Dictionary where Value: Equatable | |
{ | |
func allKeys(for value: Value) -> [Key] | |
{ | |
return self.enumerated().compactMap { | |
$0.element.value == value ? $0.element.key : nil | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
int sum0(int n) | |
{ | |
return n > 0 ? sum0(n - 1) + n : 0; | |
} | |
int sum1(int n) | |
{ | |
return n > 0 ? sum1(n / 10) + (n % 10) : 0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension String | |
{ | |
func character(at index: Int) -> Character? | |
{ | |
guard index <= self.count && index >= -self.count && index != 0 else { | |
return nil | |
} | |
return Array(self)[(index > 0 ? index - 1 : self.count + index)] | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <winsock.h> | |
#define PORT 7096 | |
#pragma comment(lib, "wsock32.lib") | |
int main(void) | |
{ | |
std::cout << "Start of program." << std::endl; | |
WORD wVersion = MAKEWORD(1, 1); | |
WSADATA wsaData; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <netdb.h> | |
#include <stdio.h> | |
#include <string.h> | |
#include <sys/socket.h> | |
#include <sys/types.h> | |
#include <unistd.h> | |
#define DSTADDR "darklite.be.eu.SwiftIRC.net" | |
#define DSTPORT 6667 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//feb 1 2009 | |
#include <stdio.h> | |
#include <string.h> | |
#include <windows.h> | |
#include <winsock.h> | |
int main(int argc, char * argv[]) | |
{ | |
int eid; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* @Author tjhv | |
* @Version 1.0.1 | |
* @year 2009 | |
**/ | |
#include <arpa/inet.h> | |
#include <netinet/in.h> | |
#include <stdio.h> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//jan 21 2009 | |
<?php | |
class Client | |
{ | |
var $server; | |
function server($dstaddr=NULL) | |
{ | |
if (!$dstaddr) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @author tjhv | |
* @version 1.2, 09/18/2008 | |
* @since 1.0 | |
*/ | |
import java.nio.ByteBuffer; | |
import java.nio.channels.FileChannel; | |
import java.nio.channels.ServerSocketChannel; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//simple btree done as an exmaple | |
//not all null pointers checked, incomplete EXAMPLE | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <assert.h> | |
#define myassert(x, y) printf(y); assert(x); | |
//btree consists of a search, insert and delete. |
NewerOlder