Skip to content

Instantly share code, notes, and snippets.

@yarinb
yarinb / arithmetic.py
Created December 1, 2019 14:02 — forked from adamnew123456/arithmetic.py
Pratt Parser For Arithmetic Expressions
"""
This implements a fairly simple expression language via a Pratt-style parser.
The language supports fairly standard floating point literals, such as:
5
1.09
.16
12e7
  • 🎨 when improving the format/structure of the code
  • 🚀 when improving performance
  • ✏️ when writing docs
  • 💡 new idea
  • 🚧 work in progress
  • ➕ when adding feature
  • ➖ when removing feature
  • 🔈 when adding logging
  • 🔇 when reducing logging
  • 🐛 when fixing a bug
@yarinb
yarinb / styles.less
Created December 3, 2016 23:06 — forked from brandondurham/styles.less
Using Operator Mono in Atom
/**
* Using Operator Mono in Atom
*
* 1. Open up Atom Preferences.
* 2. Click the “Open Config Folder” button.
* 3. In the new window’s tree view on the left you should see a file called “styles.less”. Open that up.
* 4. Copy and paste the CSS below into that file. As long as you have Operator Mono SSm installed you should be golden!
* 5. Tweak away.
*
* Theme from the screenshot (http://cdn.typography.com/assets/images/blog/operator_ide2.png):
@yarinb
yarinb / osx-10.11-setup.md
Created October 1, 2015 14:37 — forked from kevinelliott/osx-10.11-setup.md
Mac OS X 10.11 El Capitan Setup

Mac OS X 10.11 El Capitan

Custom recipe to get OS X 10.11 El Capitan running from scratch, setup applications and developer environment. This is very similar (and currently mostly the same) as my 10.10 Yosemite setup recipe (as found on this gist https://gist.github.com/kevinelliott/0726211d17020a6abc1f). Note that I expect this to change significantly as I install El Capitan several times.

I use this gist to keep track of the important software and steps required to have a functioning system after a semi-annual fresh install. On average, I reinstall each computer from scratch every 6 months, and I do not perform upgrades between distros.

This keeps the system performing at top speeds, clean of trojans, spyware, and ensures that I maintain good organizational practices for my content and backups. I highly recommend this.

You are encouraged to fork this and modify it to your heart's content to match your own needs.

@yarinb
yarinb / performanceSpec.scala
Last active August 30, 2015 22:10
Json4s with many custom formats
package com.indeni.measurements
import com.mongodb.DBObject
import com.mongodb.util.JSON
import org.json4s.ext.JodaTimeSerializers
import org.json4s.mongo.JObjectParser
import org.json4s.{DefaultFormats, Formats, JValue}
import org.scalatest._
case class SimpleObject(name: String, map: Map[String, Long], aNumber: Long)
package my.elasticsearch;
import java.io.File;
import java.io.IOException;
import java.io.RandomAccessFile;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;

Folder Structure

Motivations

  • Clear feature ownership
  • Module usage predictibility (refactoring, maintainence, you know what's shared, what's not, etc)
  • CI runs only the tests that matter (future)
# OSX for Hackers (Mavericks/Yosemite)
#
# Source: https://gist.github.com/brandonb927/3195465
#!/bin/sh
# Some things taken from here
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
# Ask for the administrator password upfront
@yarinb
yarinb / config
Created December 21, 2012 20:19
Reuse SSH sessions
# put this in ~/.ssh/config
Host *
Compression yes
CompressionLevel 7
Cipher blowfish
ServerAliveInterval 600
ControlMaster auto
ControlPath /tmp/ssh-%r@%h:%p
@yarinb
yarinb / solve.rb
Created October 27, 2012 21:24
scrabble solve
#!/usr/bin/env ruby
dict = File.open('/usr/share/dict/words', 'r').read
letters = ARGV[0] unless ARGV.empty?
def can_make?(word, letters)
return letters.include? word if word.size == 1
letters.include? word[0] and
can_make?(word[1..-1], letters.sub(/#{word[0]}/, ""))
end