Skip to content

Instantly share code, notes, and snippets.

#!/bin/bash
# Looks for jshint unnecessary semicolon errors and automatically strips them
# out, dealing with trailing white spaces.
IFS=$'\n'
for line in $(./node_modules/.bin/jshint ./lib | grep 'Unnecessary semicolon');
file=$(echo $line | sed -e 's/: .*//')
lNum=$(echo $line | sed -e 's/.* line \([0-9]*\),.*/\1/')
sed -i -e "$lNum s/ *$//" -e "$lNum s/;$//" $file
done
/*
* Demo of causing timer drift due to node's single threaded nature and the
* underlying timer implementation (each timer period, TIMER_MS, gets its own
* linked list that is invoked serially).
*
* This demo uses a sync block in fnOne(), but you can imagine a scenario where
* you have too many timers performing both sync and async operations that
* would cause a similar behavior. This can become a problem when you need
* timer driven calculations to be completed inside of a window and/or rely on
* current system time to determine a time window to insert data into.

Keybase proof

I hereby claim:

  • I am sbisbee on github.
  • I am sbisbee (https://keybase.io/sbisbee) on keybase.
  • I have a public key whose fingerprint is A71B A40E 2BBB E62E 656C 63A8 996E 481E D584 2A1F

To claim this, I am signing this object:

@sbisbee
sbisbee / transmission-remote-magnet.bash
Last active October 3, 2022 18:29
Quick and easy way of making Chrome send bittorrent magnet links to a remote Transmission instance using its API on Ubuntu with xdg.

Quick and easy way of making Chrome send bittorrent magnet links to a remote Transmission instance using its API on Ubuntu with xdg. This method does not require modifying any system files or xdg's scripts, whereas most of the examples I found on the Internet did require such hacks.

Chrome does not handle default applications, instead relying on the OS to manage that. The default handler in Ubuntu is xdg, which maps the MIME type to the default application. Extra tooling is required because xdg requires a registered desktop file, so you can't simply give it a command to run.

Steps:

  1. Install the shell script transmission-remote-magnet ideally in /usr/local/bin: ln -s ~/src/transmission-remote-magnet.bash transmission-remote-magnet

  2. Install the desktop file, which is required for xdg to work and will likely require sudo: desktop-file-install ./transmission-remote-magnet.desktop

@sbisbee
sbisbee / gist:3090838
Created July 11, 2012 14:42
Quick example of how to overwrite docs without a full GET request to fetch the _rev.
/*
* A real quick example that shows you how to overwrite the entire contents of
* a document without doing a full GET to fetch the document's current _rev.
* This can be dangerous depending on your application because you don't know
* what was written before you and you might be overwriting something
* important.
*
* What it does:
* 1. For the purposes of this test, it issues a PUT to create a document we
#!/usr/bin/perl
# foo.plx
# This is what the other file sends its contents to.
open(FILE, ">/tmp/foo");
print FILE "----start----\n";
# Write all of the piped input to the FILE
while(<STDIN>) {
<?php
$arr = array("bwah");
var_dump(in_array(0, $arr, true)); //false
?>
<?php
$response = new StdClass();
$response->body = new StdClass();
$response->body->foo = "bar";
$response->headers = new StdClass();
$response->headers->Etag = "\"asdfasfsadfsadf\"";
$cache = new SagMemoryCache();
sample();
sag.setDatabase('bwah');
sag.login({
user: 'user',
pass: 'pass'
); //using basic auth
sag.get({
url: '/someDoc',
callback: function(resp, worked) {
@sbisbee
sbisbee / compact.js
Created December 23, 2011 21:45
Sag-JS Docu Examples 2
//Compact the db
couch.compact({
callback: function(resp, succ) {
//do stuff
}
});
//Compact the view
couch.compact({
viewName: 'app',