Skip to content

Instantly share code, notes, and snippets.

@Ravenstine
Ravenstine / aws-couchdb-setup.md
Last active April 19, 2024 15:03
Fast CouchDB setup in AWS

Fast CouchDB setup in AWS

CouchDB is a NoSQL database for storing JSON documents. It comes with a REST API out of the box so your client applications can persist data while requiring you to write little or no server-side code. CouchDB's killer feature is its ability to easily replicate, which allows for horizontal scaling, easy backup, and for client adapters to synchronize documents. This is perfect if you want to write an application that is offline-first. It's become my go-to database when creating new

@pketh
pketh / 1-promises.coffee
Last active April 5, 2023 02:12
Promises in Coffeescript
# Create a promise:
myCoolPromise = new Promise (resolve, reject) ->
# do a thing
success = true
if success
resolve 'stuff worked'
else
reject Error 'it broke'
@robd
robd / bundle_gem_libs.rb
Last active October 27, 2017 17:20
Rubymine bundle dependencies
# This script is to work round the problem of broken RubyMine dependencies for bundle files.
# It uses an undocumented feature for RubyMine (but available in Intellij Idea) to create a
# gems library xml file and update the iml file.
#
# See Rubymine issues:
# https://youtrack.jetbrains.com/issue/RUBY-16428
# https://youtrack.jetbrains.com/issue/RUBY-15026
# https://youtrack.jetbrains.com/issue/RUBY-14542
#
# Usage:
@matugm
matugm / caesar.rb
Last active September 16, 2023 05:23
Caesar cipher using Ruby
ALPHABET_SIZE = 26
def caesar_cipher(string)
shiftyArray = []
charLine = string.chars.map(&:ord)
shift = 1
ALPHABET_SIZE.times do |shift|
shiftyArray << charLine.map do |c|
((c + shift) < 123 ? (c + shift) : (c + shift) - 26).chr
@SteveBenner
SteveBenner / yaml-aliases-groups.rb
Last active April 16, 2022 03:34
Define aliases in your shell with YAML instead of in Bash
#!/usr/bin/env ruby
#
# If you've got a collection of Bash aliases that just keeps growing... Consider using YAML!
#
# This version is designed to parse aliases organized under named groups in the YAML
# file, so the first level of mappings are purely semantic, and are used to keep the
# data organized and well-documented.
#
require 'pathname'
require 'yaml'
@ttscoff
ttscoff / cdt.bash
Created June 12, 2014 14:22
cdt function to change directory based on a tag filing system
# In my tag-filing system where top-level "context" folders are tagged with
# "=Context" tags and subfolders are tagged with "@project" tags, this function
# lets me quickly cd to any tagged folder in my filing system. The first
# argument is a context folder, the rest are a chain of subfolders. The
# subfolders don't need to be contiguous, and the matching is fuzzy.
cdt() {
local fuzzy
local root
local sub
local list
@SteveBenner
SteveBenner / unbrew.rb
Last active January 3, 2024 01:44
Homebrew uninstall script
#!/usr/bin/env ruby
#
# CLI tool for locating and removing a Homebrew installation
# http://brew.sh/
#
# Copyright (C) 2014 Stephen C. Benner
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
@lfender6445
lfender6445 / gist:9919357
Last active March 28, 2024 08:38
Pry Cheat Sheet

Pry Cheat Sheet

Command Line

  • pry -r ./config/app_init_file.rb - load your app into a pry session (look at the file loaded by config.ru)
  • pry -r ./config/environment.rb - load your rails into a pry session

Debugger

@brandonb927
brandonb927 / gist:9587436
Created March 16, 2014 18:13
Simple JSON database with Node.JS

From: http://run-node.com/littlest-database-that-could/

I've written numerous tiny databases. They don't have much features, but they don't need much features. Usually I'm looking for fast simple key/value stores and Node never disappoints. The point here is, why abstract key value store when JS gives us one for free, as it's most basic component: object.

Will it meet every need? No. But it will meet ALOT of scenarios.

In memory JS object lookups, were talking hundreds of thousands of lookups (you'll easily flood http before the db), and save hundreds of thousands of records in a JSON file written to disk. Not a 200ms r/t to some hosted Redis. Hey, that's fine if that's your thing.

Here's the requirements:

@DanHerbert
DanHerbert / fix-homebrew-npm.md
Last active February 12, 2024 17:18
Instructions on how to fix npm if you've installed Node through Homebrew on Mac OS X or Linuxbrew

OBSOLETE

This entire guide is based on an old version of Homebrew/Node and no longer applies. It was only ever intended to fix a specific error message which has since been fixed. I've kept it here for historical purposes, but it should no longer be used. Homebrew maintainers have fixed things and the options mentioned don't exist and won't work.

I still believe it is better to manually install npm separately since having a generic package manager maintain another package manager is a bad idea, but the instructions below don't explain how to do that.

Fixing npm On Mac OS X for Homebrew Users

Installing node through Homebrew can cause problems with npm for globally installed packages. To fix it quickly, use the solution below. An explanation is also included at the end of this document.