Skip to content

Instantly share code, notes, and snippets.

use std::str;
fn main() {
// the string literal is actually a &str (slice ref to a String) that is "owned" by the
// runtime when it starts, it's shipped as part of the binary as pre-allocated and readonly
// memory and is not on the heap.
// it needs to be converted to a String so it can be placed on the heap, and borrowed and
// resized if needed. This is the job of .to_string(). It might seem strange to take a string
// and immediately convert it to a String, but basically you need to ship it from "const" land
@sbeam
sbeam / holla.rb
Created April 2, 2020 14:19
ruby mixin with callbacks demo
module Moo
def self.included(base)
base.extend(ClassMethods)
end
def jump!
trigger(:before_jump)
puts 'JUMP'
trigger(:after_jump)
end
@sbeam
sbeam / chat.py
Created July 30, 2019 11:58
python chat
#!/usr/bin/env python
import datetime
import flask
import redis
import os
app = flask.Flask(__name__)
app.secret_key = 'asdf'
red = redis.Redis(host=os.environ['REDIS_HOST'], port=6379, db=0)
# Add truecolor support{{{
set-option -sa terminal-overrides ",xterm*:Tc"
# color 256!
set -g default-terminal "screen-256color"
# }}}
# enter copy mode on any C-Up{{{
# bind -n C-Up copy-mode -eu
# }}}
#!/usr/bin/perl -w
my $dict = "/usr/share/dict/words";
my $maxlen = shift @ARGV;
my $wordmin = 3;
my $wordmax = 12;
my $num_words = 4;
my $skip_possessives = 1; # db contains 's forms for every noun
request = require 'request'
logger = require('winston')
lineReader = require('line-reader')
q = require 'q'
now = new Date
first_time = null
host = 'hydra-staging.herokuapp.com'
@sbeam
sbeam / t
Created November 6, 2014 19:52
14:45:40 - ERROR - Cannot decode JSON from PhantomJS runner: 795: unexpected token at 'Unsafe JavaScript attempt to access frame with URL about:blank from fra
me with URL file:///Users/samoeba/.gem/ruby/2.0.0/gems/guard-jasmine-1.19.0/lib/guard/jasmine/phantomjs/guard-jasmine.js. Domains, protocols and ports must ma
tch.
> [#50A8AF5DD37C]
> [#50A8AF5DD37C] Unsafe JavaScript attempt to access frame with URL about:blank from frame with URL file:///Users/samoeba/.gem/ruby/2.0.0/gems/guard-jasmine-
1.19.0/lib/guard/jasmine/phantomjs/guard-jasmine.js. Domains, protocols and ports must match.
> [#50A8AF5DD37C]
require 'spec_helper.rb'
describe "Top Nav Menus", vcr: true, js: true do
category! 'ovens'
context 'on desktop' do
#before { page.driver.resize(3000, 1200) }
fit 'should have populated content for reviews dropdown' do
varnishtest "#1030"
server s1 {
rxreq
expect req.url == "/test"
txresp
rxreq
@sbeam
sbeam / -
Created October 3, 2014 17:50
--- /Users/samoeba/Downloads/123d2pKhY1JNsNsc0bzw4L_38.vcl 2014-10-03 08:22:03.000000000 -0400
+++ /Users/samoeba/Downloads/123d2pKhY1JNsNsc0bzw4L_39.vcl 2014-10-03 13:49:59.000000000 -0400
@@ -421,7 +421,7 @@
# Header rewrite Whitelist Querystring : 10
- set req.url = regsuball(req.url, "(^|[\\?&]+)([^&\\/=]+(?:(&|$))|(?!_escaped_fragment_|brand|branch|type|min_msrp|max_msrp|_type|keywords|page|per_page|tags|name|order_by|adid|return_url|event|classifications|zip|website_ids\\b)[^&\\/=]+=[^&]+)", "&");
+ set req.url = regsuball(req.url, "(^|[?&]+)([^&/=]+(?:(&|$))|(?!_escaped_fragment_|brand|branch|type|min_msrp|max_msrp|_type|keywords|page|per_page|tags|name|order_by|adid|return_url|event|classifications|zip|website_ids)[^&/=]+=[^&]+)", "&");