Skip to content

Instantly share code, notes, and snippets.

View Sebbyastian's full-sized avatar

Sebastian Ramadan Sebbyastian

View GitHub Profile
/*****************
* bossFight.js *
*****************
*
* NO FARTHER, DR. EVAL!!!!
* YOU WILL NOT GET OUT OF HERE ALIVE!!!!
* IT'S TIME YOU SEE MY TRUE FORM!!!!
* FACE MY ROBOT WRATH!!!!!
*/
/* I hearby do solemnly declare this to be the most beautiful abuse of preprocessor macros and structs I've ever committed. */
#define ARRAY_CAT(type, array, ...) (*(type (*)[sizeof (array) / sizeof (type) + sizeof ((type[]) { __VA_ARGS__ }) / sizeof (type)]) &(struct { type foo[sizeof (array) / sizeof (*array)]; type bar[sizeof ((type[]) { __VA_ARGS__ }) / sizeof (type)]; }) { .foo = array, .bar = { __VA_ARGS__ } })
#include <stdio.h>
int main(void) {
const int array_1[] = { 0, 1, 2, 3 };
const int array_2[] = ARRAY_CAT(int, array_1, 4, 5, 6, 7, 8);
const int array_3[] = ARRAY_CAT(int, array_1, 10, 11, 12);
@Sebbyastian
Sebbyastian / looks_like_fun.c
Last active August 27, 2017 10:58 — forked from pastagatsan/gist:1d56eb280e3aa05b8572
Nice, very nice... Looks like fun to me :)
typedef struct
{
size_t size;
void** list;
} List;
int add(List** li, void* obj)
{
List* list = *li ? *li : malloc(sizeof *list);
if (list == NULL) {
@Sebbyastian
Sebbyastian / IRC_Socket.cs
Created August 7, 2014 07:09
IRC_Socket.cs
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Net.Sockets;
using System.Text;
using System.Text.RegularExpressions;
class MessageHandlerDictionary
: Dictionary<Regex, IRC_Socket.MessageHandler>
@Sebbyastian
Sebbyastian / bucky_challenge_2.c
Last active August 29, 2015 14:05
Bucky Roberts dice challenge. LUL
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#define DICE_COUNT 3
#define SIDE_COUNT 6
unsigned int roll(unsigned int side_count) {
int n;
@Sebbyastian
Sebbyastian / am_I_a_prick.cs
Last active August 29, 2015 14:05
Am I a prick or what?
class FileStream
: System.IO.FileStream
{
protected long this[string key]
{
get {
this.Position = 0;
int c, p = 0;
for (; ; )
@Sebbyastian
Sebbyastian / ack.c
Last active April 4, 2022 21:23
Ackermann function in recursive and non-recursive form
#include <assert.h>
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
int ack_recursive(int m, int n) {
if (m == 0) {
return n + 1;
}
@Sebbyastian
Sebbyastian / BR_password_challenge.c
Created December 14, 2014 02:43
BR password challenge (too easy, m8)
#include <stdio.h>
int main(void) {
unsigned int length = 0;
enum { empty = 0,
lower_alpha = 1,
upper_alpha = 2,
decim_digit = 4,
punctuation = 8 } criteria = empty;
@Sebbyastian
Sebbyastian / BR_password_challenge_scanf.c
Created December 15, 2014 21:58
BR password challenge (using scanf)
int main(void) {
int lower_length = 0,
upper_length = 0,
digit_length = 0,
length = 0;
puts("Please enter a password and I'll judge its security...");
# define LOWER_FMT "%*[qwertyuiopasdfghjklzxcvbnm]%n"
@Sebbyastian
Sebbyastian / stupid_shit.c
Created December 22, 2014 15:52
Benchmark for @wesen
#include <assert.h>
#include <stdio.h>
int main(void) {
unsigned int criteria[2] = { 0 };
#ifndef UNBUFFERED
int n = setvbuf(stdin, NULL, _IOFBF, 65536);
assert(n == 0);