Skip to content

Instantly share code, notes, and snippets.

View iykekings's full-sized avatar
🦕
Contributing to Deno

Ikechukwu Eze iykekings

🦕
Contributing to Deno
View GitHub Profile
@iykekings
iykekings / main.dart
Created October 26, 2022 22:21
dart-naive-eval
num evaluate(String expression) {
var tokens = expression.split(' ');
print(tokens);
// Stack for numbers: 'values'
List<num> values = [];
// Stack for Operators: 'ops'
List<String> ops = [];
for (var i = 0; i < tokens.length; i++) {
if (num.tryParse(tokens[i]) != null) {
@iykekings
iykekings / main.dart
Created October 26, 2022 21:27
oval-branch-4643
num evaluate(String expr) {
var divAndMult =
RegExp(r"\(?\s*(\d+(?:\.\d*)?)\s*([/*])\s*(\d+(?:\.\d*)?)\s*\)?");
var addAndSub =
RegExp(r"\(?\s*(\d+(?:\.\d*)?)\s*([+-])\s*(\d+(?:\.\d*)?)\s*\)?");
var nextInput = expr;
while (divAndMult.hasMatch(nextInput) || addAndSub.hasMatch(nextInput)) {
var first = nextInput.replaceAllMapped(divAndMult, (match) {
@iykekings
iykekings / audit-on-push.yml
Created December 12, 2020 12:04 — forked from LukeMathWalker/audit.yml
GitHub Actions - Rust setup
name: Security audit
on:
push:
paths:
- '**/Cargo.toml'
- '**/Cargo.lock'
jobs:
security_audit:
runs-on: ubuntu-latest
steps:
@iykekings
iykekings / index.d.ts
Last active October 20, 2020 12:46
Cloudinary Upload Widget Type Declarations
declare namespace cloudinary {
/**
* Creates a widget object and frame in memory,
* but does not display it until the open() method of
* the returned widget object is called.
*/
function createUploadWidget<T extends CloudinaryEvent>(
uploadConfig: UploadInterface,
cb: (error: string, result: Event<T>) => void
): WidgetInterface;
@iykekings
iykekings / webpack.config.js
Created February 14, 2020 16:57 — forked from bo01ean/webpack.config.js
swc-loader for create-react-app webpack
'use strict';
const fs = require('fs');
const path = require('path');
const webpack = require('webpack');
const resolve = require('resolve');
const PnpWebpackPlugin = require('pnp-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const CaseSensitivePathsPlugin = require('case-sensitive-paths-webpack-plugin');
const InlineChunkHtmlPlugin = require('react-dev-utils/InlineChunkHtmlPlugin');
@iykekings
iykekings / palindrome.js
Created February 2, 2020 11:02
Generate Date Palindromes
function generatePalindromes(data) {
return data.filter(d => {
let c = d.replace('-', '');
let first = c.slice(0, 2) === c.slice(-2).split``.reverse``.join``;
let second = c.slice(2, 4) === c.slice(4, 6).split``.reverse``.join``;
return first && second;
});
}
function genDates(begin, end) {
@iykekings
iykekings / array_flattening.md
Last active December 17, 2019 16:26
Implementation of Array flattening with JavaScript

This gist discusses the implementation of Array flattening with JavaScript. It returns a single array with all of its element recursively flattened.

To Run Test

  node flat_array_test.js
@iykekings
iykekings / sort_stack.md
Created December 16, 2019 14:01 — forked from seanchen1991/sort_stack.md
Problem description for the Sort Stack problem in JS

Sort Elements in a Stack

Given a Stack class like the following:

class Stack {
  constructor() {
    this.storage = [];
  }

 push(item) {