Skip to content

Instantly share code, notes, and snippets.

View stevefan1999-personal's full-sized avatar

Steve Fan stevefan1999-personal

View GitHub Profile
@cslarsen
cslarsen / palindrome-linear.cpp
Created March 2, 2011 19:56
Linear scan for palindromes
/*
* Find the longest palindrome in the text.
*
* This is Greplin's first challenge, and I originally solved it in Python.
*
* This algorithm is linear on the average input, but has a quadratic
* worst case running time. There exists an even better algorithm, but
* this should do.
*
* There might also be a small error below, but you get the general idea.
@tkihira
tkihira / hack version.c
Created March 22, 2012 19:09
switch hack on C
void switch_func(int n) {
char *s;
switch(n) {
case 0:
s = "Sun";
if(0)
case 1:
{ s = "Mon"; }
if(0)
case 2:
@codebrainz
codebrainz / c99.l
Created June 14, 2012 23:49
C99 Lex/Flex & YACC/Bison Grammars
D [0-9]
L [a-zA-Z_]
H [a-fA-F0-9]
E ([Ee][+-]?{D}+)
P ([Pp][+-]?{D}+)
FS (f|F|l|L)
IS ((u|U)|(u|U)?(l|L|ll|LL)|(l|L|ll|LL)(u|U))
%{
#include <stdio.h>
@puffnfresh
puffnfresh / overloading.js
Created September 6, 2012 00:55
Operator overloading in JavaScript
// This file shows a hack to achieve operator overloading in
// JavaScript. I have defined 3 different operators:
//
// >= = monadic bind
// >> = kleisli composition
// > = functor map
// * = applicative apply
// + = semigroup append
//
// Head straight to the bottom to see example usages.
@tsiege
tsiege / The Technical Interview Cheat Sheet.md
Last active April 20, 2024 16:52
This is my technical interview cheat sheet. Feel free to fork it or do whatever you want with it. PLEASE let me know if there are any errors or if anything crucial is missing. I will add more links soon.

ANNOUNCEMENT

I have moved this over to the Tech Interview Cheat Sheet Repo and has been expanded and even has code challenges you can run and practice against!






\

@alexhawkins
alexhawkins / nativeJavaScript.js
Last active February 2, 2024 16:57
Implementation of Native JavaScript Methods (forEach, Map, Filter, Reduce, Every, Some)
'use strict';
/*****************NATIVE forEACH*********************/
Array.prototype.myEach = function(callback) {
for (var i = 0; i < this.length; i++)
callback(this[i], i, this);
};
//tests
1. Build GraphQL server using `express-graphql` package.
2. Configure `schema.js` file.
3. Query for data.
@DmitrySoshnikov
DmitrySoshnikov / sr-rr-confilct.md
Last active September 22, 2023 17:43
Parsing notes: "Shift-reduce" and "Reduce-reduce" conflicts in LR parsing

"Shift-reduce" and "Reduce-reduce" conflicts in LR parsing.

How to determine?

A full parsing table is not needed, only the canonical collection. In the canonical collection, find all final items (and only final items), and see if:

  • There are both shift and reduce in the same item ("shift-reduce", s/r)
  • There are two reduce actions in the same item ("reduce-reduce", r/r)

If none of these is true, there are no conflicts, even in LR(0). If there are some of the above, SLR(1) still may solve it.

@sasq64
sasq64 / func.cpp
Last active October 1, 2017 08:16
C++ Type erased dispatch - or whatever
#include <cstdio>
#include <functional>
#include <string>
#if __cplusplus <= 201200L
namespace std {
// index_sequence
anonymous
anonymous / list27.txt
Created May 8, 2016 17:40
000(023Rb|001Rb)
001(017La|002Rb)
002(021La|003Rb)
003(021La|004La)
004(009Rb|005Lb)
005(004Ra|005La)
006(008La|007La)
007(009Rb|007La)
008(009Ra|008La)
009(010Ra|026Ra)