Skip to content

Instantly share code, notes, and snippets.

View icholy's full-sized avatar
💥
breaking things

Ilia Choly icholy

💥
breaking things
View GitHub Profile
// in C++
class Foo {
int a;
int b;
void set_a(int a) {
this->a = a;
}
@icholy
icholy / vector.c
Last active August 29, 2015 14:10
typedef struct {
int *data; // array
int cap; // capacity
int len; // length
} Vector;
Vector * vector_create(int length, int capacity) {
Vector *v = malloc(sizeof(Vector));
if (v == NULL) {
#!/usr/bin/env
from datetime import datetime
import matplotlib.pyplot as plt
def main():
lines = open("commits.txt").read().split("\n")
lines = [l.split(",") for l in lines]
lines = [l for l in lines if l[0].strip() != '']
#!/bin/bash
# Examples:
#
# //break
# //break if foo == 5
#
# Usage:
#
/// <reference path="../types/tsd.d.ts" />
/// <reference path="../services.ts" />
module Directives {
interface IRefreshSrcScope extends ng.IScope {
src: string;
delay: string;
}
var gulp = require('gulp'),
typescript = require('gulp-typescript'),
sass = require('gulp-sass'),
concat = require('gulp-concat'),
livereload = require('gulp-livereload'),
http = require('http'),
st = require('st');
gulp.task('scripts', function () {
package main
import (
"net/http"
"strconv"
)
type ParamParser struct {
params map[string]string
err error
@icholy
icholy / nagios_status.peg
Last active August 29, 2015 14:16
PEG parser for Nagios Status.dat file.
start = group*
identifier = [a-zA-Z_]+
whitespace = [ \r\n\t]
comment = '#' [^\n]* '\n'
ignored = whitespace / comment
_ = ignored*
value = word:[^\n]+ '\n' {
return word;
}

Prefix all interfaces with Foo

interface IFooOptions {}

class Foo {
  constructor(options: IFooOptions) {}
}

// usage
class JSONParser {
static parse(json: string): any {
var parser = new JSONParser(json);
return parser.parseValue();
}
private index: number = 0;
private ch: string;
private text: string;