Skip to content

Instantly share code, notes, and snippets.

@gsf
gsf / gist:5252533
Last active December 15, 2015 11:19
node-elasticsearch notes

Calling elasticsearch() without an index would mean querying across all indexes, and anything requiring an index would result in an error.

Indexes can be specified at client creation elasticsearch({index: 'test'}) or in the opts of certain calls es.add({index: 'test'},...).

Maybe try putting an _indices array on the client instance to manage the affected indices for any operation (only one for certain operations like add). Then, a call like es.index('hex') would set _indices to ['hex'] and create the "hex" index if it doesn't exist. This also means es.index doesn't need its own constructor -- it's just a method on the client instance with attached sub-methods.

Move es.query() to es.search() -- with deprecation? And passed parameters should be (opts, req, cb).

##Steps

  1. Document current API
@gsf
gsf / gist:5377654
Last active July 31, 2017 06:07
Dev Chromebook
  1. Switch the Chromebook to developer mode.

  2. Download crouton.

  3. Create a chroot for a CLI environment.

crosh> shell
chronos@localhost /$ sudo sh -e ~/Downloads/crouton -t cli-extra
@gsf
gsf / server.js
Created May 22, 2013 23:37
Pipe server
var http = require('http');
var server = http.createServer();
server.on('request', function (req, res) {
res.writeHead(200, {'Content-Type': 'application/json'});
req.pipe(res);
req.pipe(process.stdout);
});
#!/bin/bash
# 1. mkdir $study in svn repo
# 2. Copy template into new dir
# Die on any command failure
set -e
[ -z $1 ] && echo "Usage: $0 study_name" && exit
@gsf
gsf / bluetoothctl
Created July 16, 2013 15:18
bluetooth audio receiver
# bluetoothctl
[NEW] Controller 00:02:72:DE:16:59 manheim [default]
[NEW] Device 00:10:61:00:01:92 GT BT-Receiver
[bluetooth]# devices
Device 00:10:61:00:01:92 GT BT-Receiver
[bluetooth]# info 00:10:61:00:01:92
Device 00:10:61:00:01:92
Name: GT BT-Receiver
Alias: GT BT-Receiver
Class: 0x240404
@gsf
gsf / deploy.md
Last active December 20, 2015 16:49

Easy CI virtual hosting.

  • http proxy
  • process manager
  • git deploy

One command (like ploy) that starts bouncy connected to servers (server name based on directory structure) and listens for git deploys with cicada.

@gsf
gsf / ploy
Last active December 21, 2015 00:39
ploy init
#!/bin/sh
### BEGIN INIT INFO
# Provides: ploy
# Required-Start: $local_fs $remote_fs $network $syslog
# Required-Stop: $local_fs $remote_fs $network $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: starts ploy services
# Description: starts services with ploy
@gsf
gsf / notes.md
Last active December 21, 2015 11:19
Arch Linux on the Asus UX31A

Added acpi_osi="!Windows2012" to the boot options based on advice in https://wiki.archlinux.org/index.php/Backlight.

Mounting the efi at /boot is simpler but after kernel upgrades I need to manually run grub-mkconfig -o /boot/grub/grub.cfg.

Installed the infinality-bundle.

In /etc/default/grub:

GRUB_CMDLINE_LINUX="add_efi_memmap i915.i915_enable_rc6=1 pcie_aspm=force drm.vblankoffdelay=1 i915.semaphores=1 acpi_osi= video.use_native_backlight=1"
@gsf
gsf / PluginConnector.class.php
Last active December 23, 2015 08:59
updateUserEvents
// ...
/**
* Updates UserEvents that are in the past and if the selection strategy of
* first is used will update, but not mark as incomplete, encounters that are
* ongoing. This method does not normally need to be modified.
*/
protected function updateUserEvents()
{
//$this->updateExpiredUserEvents();
@gsf
gsf / gist:6958141
Last active December 25, 2015 09:59
Death tracks

[Originally posted in a comment at http://www.westphillylocal.com/2013/10/11/a-woman-critically-injured-in-hit-and-run-accident-near-38th-and-spruce/.]

I'm not kidding. Road-level trolley tracks and cyclists simply do not mix. I've been in accidents due to tracks in Philadelphia and San Francisco -- the two cities I've lived in with tracks in the streets. Nearly every cyclist I know in Philadelphia has been in at least one minor accident involving tracks, and several have real horror stories. A friend broke several bones in her face due to a slip on the tracks just weeks ago.

But you're right. I may be overestimating in my "thousands of injuries" claim. Unfortunately, we don't have solid data around this issue to reason from. No one keeps track of the number of bicycle accidents caused by trolley tracks, and cycling accidents in general are sorely under-reported. According to the 2012 PennDot Crash Facts & Statistics [1], there were 1,369 total bicycle accidents in Pennsylvania. Considering the estimated 36