Skip to content

Instantly share code, notes, and snippets.

View arockwell's full-sized avatar

Alex Rockwell arockwell

View GitHub Profile
@arockwell
arockwell / gist:a6e450a1d60b99fb6c4494b6635645b9
Created May 6, 2025 00:52
Improved number parsing - balanced approach
fn number(&mut self, graphemes: &[&str]) {
let token_col = self.column - 2;
let mut is_float = false;
let mut number = graphemes[self.column - 2].to_string();
// Part 1: Handle integer part (required)
while self.consume_digits(&mut number, graphemes) {}
// Part 2: Handle decimal part (optional)
if self.column - 1 < graphemes.len() && graphemes[self.column - 1] == "." {
@arockwell
arockwell / gist:5ce76c4f464f8c2c299ef4a62b72ef56
Created May 6, 2025 00:51
Complete refactor of number parsing for lexer - mega-mind edition
// BEFORE: Complex, nested conditionals with inconsistent flow
// AFTER: State machine approach with clear phases
fn number(&mut self, graphemes: &[&str]) {
let token_col = self.column - 2;
let mut number = graphemes[self.column - 2].to_string();
// Use an enum to track parsing state
enum NumberState {
Digits, // Consuming integer digits
@arockwell
arockwell / gist:df93e36d53f42d97d8b8c5510e636b1d
Created May 6, 2025 00:47
Improved scientific notation parsing for lexer
// Handle scientific notation (e.g., 1.23e45 or 1e-10)
} else if grapheme == "e" || grapheme == "E" {
if is_scientific {
self.errors.push(LexError::new(
graphemes.concat(),
self.line,
self.column,
"number may not contain multiple exponential parts".to_owned(),
));
return;

Keybase proof

I hereby claim:

  • I am arockwell on github.
  • I am alexrockwell (https://keybase.io/alexrockwell) on keybase.
  • I have a public key ASAfWQFL_oX3tYueOlCBe14OrpANgsBgAY2qQUxEL2l67wo

To claim this, I am signing this object:

@arockwell
arockwell / server.js
Created December 12, 2017 20:29
Simple GraphQL proxy
var express = require('express');
var graphqlHTTP = require('express-graphql');
var { buildSchema } = require('graphql');
var fetch = require('node-fetch');
// Construct a schema, using GraphQL schema language
var schema = buildSchema(`
type User {
first_name: String
last_name: String
2) Apns #processBatch() should pass:
Error: global leak detected: key
at Runner.checkGlobals (/usr/local/lib/node_modules/mocha/lib/runner.js:104:21)
at Runner.<anonymous> (/usr/local/lib/node_modules/mocha/lib/runner.js:43:44)
at Runner.emit (events.js:88:20)
at /usr/local/lib/node_modules/mocha/lib/runner.js:321:16
at done (/usr/local/lib/node_modules/mocha/lib/runnable.js:134:5)
at Test.run (/usr/local/lib/node_modules/mocha/lib/runnable.js:149:7)
at Runner.runTest (/usr/local/lib/node_modules/mocha/lib/runner.js:272:10)
at /usr/local/lib/node_modules/mocha/lib/runner.js:316:12
checkRedis = () ->
redis.ping (err, data) ->
if err then false else true
node-c2dm (master) $ gitc setup arockwell node-c2dm ed50a0830
Configuration saved.
node-c2dm (master) $ gitc branch https://bleacherreport.lighthouseapp.com/projects/6296-bug-reporting/tickets/8858-node-c2dm-disable-retry-on-quota-errors
Your work will eventually merge into 'master'. Is this correct? (y/n)
y
Retrieving branch information from gitcycle.
redis 127.0.0.1:6379> get 'batch_count:QDLKFEJ1340:android'
"4"
redis 127.0.0.1:6379> get 'batch_count:QDLKFEJ1341:android'
"3"
redis 127.0.0.1:6379> get 'batch_count:QDLKFEJ1341:android'
"3"
redis 127.0.0.1:6379> get 'batch_count:QDLKFEJ1341:android'
"3"
redis 127.0.0.1:6379> get 'batch_count:QDLKFEJ1341:android'
"3"
updateRedisBatchInfo = (batch_id, device_type, count) ->
console.log("Setting key: sent_alerts:#{batch_id}:#{device_type}")
redis.incrby("sent_alerts:#{batch_id}:#{device_type}", count)
redis.incrby("batch_count:#{batch_id}:#{device_type}", 1)
redis.get("batch_count:#{batch_id}:#{device_type}", (err, data) ->
console.log("sent: #{data}")
)