Skip to content

Instantly share code, notes, and snippets.

View edg-l's full-sized avatar
🪨
making compilers

Edgar edg-l

🪨
making compilers
View GitHub Profile
@edg-l
edg-l / .vimrc
Last active October 9, 2019 11:08
my vimrc
call plug#begin('~/.vim/plugged')
" Make sure you use single quotes
Plug 'tpope/vim-fugitive'
Plug 'tpope/vim-surround'
Plug 'airblade/vim-gitgutter'
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
Plug 'nathanaelkane/vim-indent-guides'
import React from 'react';
export const Row: React.FC = props => {
return <div className="row">{props.children}</div>;
};
export interface ColProps {
size: number;
device: 'xs' | 'sm' | 'md' | 'lg';
}
@edg-l
edg-l / battlecode.d.ts
Created January 8, 2019 07:23
Type definitions for battlecode.org 2019 js
// Type definitions for battlecode
// Project: battlecode.org 2019
// Definitions by: Ryozuki <Discord: Ryozuki#1984>
// Thanks to the docs https://battlecode.org/dash/docs
declare module "battlecode" {
export enum SPECS {
CASTLE,
CHURCH,
PILGRIM,
#include <iostream>
using namespace std;
int number_of_digits(int n) {
if(n < 10)
return 1;
return 1 + number_of_digits(n / 10);
}
function(context, a)
{
a = a || {}
var internalBuffer = []
var charPatterns = {
a: [
[0, 0, 1, 0, 0],
[0, 1, 0, 1, 0],
[1, 0, 0, 0, 1],
function(c, a)
{
a = a || {}
var r = #fs.multivac.renderer()
var clone = #fs.scripts.lib().clone
var log = []
var squareWidth = 9
var squareHeight = 7
var boardRect = r.Rect(2, 2, 8 * squareWidth, 8 * squareHeight)
const words = "abcdefgh"
@edg-l
edg-l / compare.cpp
Last active September 11, 2018 21:08
Compare digit
#include <cmath>
bool compareDigit(int a, int b, int n)
{
return (a - (a % (int)pow(10, n - 1))) % (int)pow(10, n) == (b - (b % (int)pow(10, n - 1))) % (int)pow(10, n);
}
// compareDigit(234, 134, 1) == true (4 == 4)
// compareDigit(234, 134, 3) == false (2 != 1)
/*
Copyright 2018 Ryozuki
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
/*
Copyright 2018 Ryozuki
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
public class ConfigFile
{
public int someconfig = 10;
public static ConfigFile Read(string path)
{
if (!File.Exists(path))
{
ConfigFile config = new ConfigFile();