Skip to content

Instantly share code, notes, and snippets.

View xbeta's full-sized avatar
🏠
Working from home

Sam Xiao xbeta

🏠
Working from home
  • Monte Carlo Data
  • San Francisco, CA
  • 13:44 (UTC -07:00)
  • LinkedIn in/samxsxiao
View GitHub Profile
@xbeta
xbeta / Bitlbee+Weechat_on_Mac.mkd
Last active February 23, 2022 17:36 — forked from cstrahan/homebrew.mxcl.bitlbee.plist
Bitlbee + Weechat on Mac

Using bitlbee with HipChat

Initial setup

  • account add jabber USERNAME@chat.hipchat.com 'PASSWORD'
  • account hipchat set nick_source full_name
  • account hipchat set resource bot
  • account hipchat on

Local (OS X) Side

~/Library/LaunchAgents/pbcopy.plist

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
     <key>Label</key>
     <string>localhost.pbcopy</string>
@xbeta
xbeta / RegexBuilder.java
Last active August 29, 2015 13:57
Various simple regex parsers
public class RegexBuilder {
public boolean isMatch(String s, String p) {
if(p.length() == 0)
return s.length() == 0;
//p's length 1 is special case
if(p.length() == 1 || p.charAt(1) != '*'){
if(s.length() < 1 || (p.charAt(0) != '.' && s.charAt(0) != p.charAt(0)))
return false;
@xbeta
xbeta / distance_away.rb
Last active August 29, 2015 13:57
Find all words from a dictionary that are 1 edited distance away.
#!/usr/bin/ruby
#
# Find all words from a dictionary that are 1 edited distance away.
#
# dictionary = ['bat', 'batt', 'cat', 'beetle']
# similar(q) => all words in dictionary that are edit distance <= 1 from q
# edits: adding a letter, changing, or deleting
#
# similar('bat') => ['bat', 'batt', 'cat']
# similar('beatle') => ['beetle']
@xbeta
xbeta / kafka.md
Created March 23, 2014 00:53 — forked from ashrithr/kafka.md

Introduction to Kafka

Kafka acts as a kind of write-ahead log (WAL) that records messages to a persistent store (disk) and allows subscribers to read and apply these changes to their own stores in a system appropriate time-frame.

Terminology:

  • Producers send messages to brokers
  • Consumers read messages from brokers
  • Messages are sent to a topic
@xbeta
xbeta / setup_kafka.sh
Last active December 23, 2019 23:57
Quick start on Kafka
# To Setup and build Kafka:
$ git clone git@github.com:apache/kafka.git
$ cd kafka
$ git checkout -b 0.8 remotes/origin/0.8
$ ./gradlew jarAll
# Start Zookeeper
$ bin/zookeeper-server-start.sh config/zookeeper.properties
$ brew install redis
$ redis-server
defmodule SecureRandom do
@moduledoc """
Ruby-like SecureRandom module.
## Examples
iex> SecureRandom.base64
"xhTcitKZI8YiLGzUNLD+HQ=="
iex> SecureRandom.urlsafe_base64(4)