Skip to content

Instantly share code, notes, and snippets.

@broquaint
broquaint / env.js
Created February 9, 2024 08:26
The deno TypeScript compiler output for env.ts
// Plucked from the output of: deno bundle impls/ts/step3_env.ts
class Env {
outer;
data;
constructor(outer){
this.outer = outer ?? null;
this.data = {};
}
set(k, v) {
this.data[k.value] = v;
@broquaint
broquaint / reddit-scroll-divider.user.js
Last active September 25, 2020 22:59
Greasemonkey userscript to visually divide scrolled in content on Reddit
// ==UserScript==
// @name Reddit - Visually divide scrolled in content
// @version 1
// @grant none
// @include https://www.reddit.com/*
// ==/UserScript==
const dividerCls = 'gm-section-divider',
dividerStyle = `
.${dividerCls} {
@broquaint
broquaint / drop-favourited-tweets.js
Created September 3, 2015 10:07
Unfavourite all favourited tweets currently on your favourites page
// Usage:
// 1. Go to https://twitter.com/favorites in a browser that supports ES6
// 2. Open local equivalent of the JS console
// 3. Run this code.
function unfavourite(tweet) {
let $tweet = (sel) => jQuery(sel, tweet);
$tweet('.js-actionFavorite:visible').click();
console.log(
"Unfavourited:\n",
@broquaint
broquaint / startdocker.js
Created November 17, 2014 23:23
A script to get docker booting under wscript.exe (mostly so I don't lose it)
/*
* Wee script to get docker into a working state.
* Once run one should be able to ssh without needing cmd.exe pain.
*/
// Closer to what I expect.
function run(cmd) {
var WshShell = new ActiveXObject("WScript.Shell"),
oExec = WshShell.Exec(cmd);
// Let it run.
@broquaint
broquaint / node-http-server-example.cljs
Created January 18, 2014 13:25
The HTTP example from nodejs.org translated into ClojureScript.
(let [http (js/require "http")]
(do
(.listen
(.createServer http (fn [req res]
(do
(.writeHead res 200 #js {"Content-Type" "text/plain"})
(.end res "Hello World\n"))))
1337 "127.0.0.1")
(.log js/console "Server running at http://127.0.0.1:1337/")))
@broquaint
broquaint / not-understanding-let-oddness.clj
Last active December 31, 2015 19:59
When I call addField on solr-doc in the let and evaluate solr-doc last I always end up with the exception.
galen.core> (let [solr-doc (SolrInputDocument.)]
(.getFieldValue solr-doc "id")
solr-doc)
{}
galen.core> (let [solr-doc (SolrInputDocument.)]
(.addField solr-doc "id" "xyz")
solr-doc)
ClassCastException org.apache.solr.common.SolrInputField cannot be cast to java.util.Map$Entry clojure.core/key (core.clj:1482)
@broquaint
broquaint / ruby-yaml-span.txt
Created May 5, 2013 08:46
For every YAML.load this happens. Not so good for performance when importing in bulk.
# ruby's yaml spamming gems at .load
open("/home/dbrook/dev/soup-stash/app/enc/utf16_be.so.rb", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/home/dbrook/dev/net-http-follow/lib/enc/utf16_be.so.rb", O_RDONLY) = -1 ENOENT (No such file or directory)
getcwd("/home/dbrook/dev/soup-stash", 200) = 28
open("/home/dbrook/dev/soup-stash/lib/enc/utf16_be.so.rb", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/home/dbrook/.rvm/gems/ruby-1.9.3-p194/gems/slop-3.4.4/lib/enc/utf16_be.so.rb", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/home/dbrook/.rvm/gems/ruby-1.9.3-p194/gems/warden-1.2.1/lib/enc/utf16_be.so.rb", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/home/dbrook/.rvm/gems/ruby-1.9.3-p194/gems/orm_adapter-0.4.0/lib/enc/utf16_be.so.rb", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/home/dbrook/.rvm/gems/ruby-1.9.3-p194/gems/bcrypt-ruby-3.0.1/lib/enc/utf16_be.so.rb", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/home/dbrook/.rvm/gems/ruby-1.9.3-p194/ge
@broquaint
broquaint / var-test.rb
Created September 29, 2012 19:39
Ruby's variable scope is not what I expect
$ cat > var-test.rb
s = 'yay?'
def f
puts s
end
f
$ ruby var-test.rb
var-test.rb:3:in `f': undefined local variable or method `s' for main:Object (NameError)
from var-test.rb:5:in `<main>'
@broquaint
broquaint / gist:1673180
Created January 24, 2012 22:38
Why is the debugger not breaking at the first test?
$ perl -Mlocal::lib=local-lib5 -Mblib -d t/model_collectionofrepos.t
Loading DB routines from perl5db.pl version 1.33
Editor support available.
Enter h or `h h' for help, or `man perldebug' for more help.
main::(t/model_collectionofrepos.t:26):
26: my $run_options = {};
DB<1> c Gitalist::Model::CollectionOfRepos::build_per_context_instance
@broquaint
broquaint / lein-test-output.txt
Created December 22, 2011 14:22
Confused by for and nested structures
$ lein test
Testing fore-clojure.test.core
PFS [[[[:a :b]]] [[:c :d]] [:e :f]]
COND true [[:a :b]] [[[:a :b]]]
- PFS [[:a :b]]
COND true [:c :d] [[:c :d]]
- PFS [:c :d]
COND false :e [:e :f]
- COND false :a [:a :b]
FAIL in (can-partially-flatten-a-sequence) (core.clj:6)