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 / validatePIN.js
Created May 16, 2016 20:40
Validate a pin
function validatePIN(pin) {
return /^(\d{4}|\d{6})$/.test(pin)
}
@edg-l
edg-l / ConfigFile.cs
Created March 1, 2017 06:22
a config class c#
using System;
using System.Collections.Generic;
using System.Configuration;
namespace Yallr.src.game
{
class ConfigFile
{
Configuration configManager = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
KeyValueConfigurationCollection confCollection;
public class ConfigFile
{
public int someconfig = 10;
public static ConfigFile Read(string path)
{
if (!File.Exists(path))
{
ConfigFile config = new ConfigFile();
/*
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
@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)
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"
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],
#include <iostream>
using namespace std;
int number_of_digits(int n) {
if(n < 10)
return 1;
return 1 + number_of_digits(n / 10);
}
@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,