Skip to content

Instantly share code, notes, and snippets.

root@dnsfreebsd:~/npm [master]# node cli.js config set loglevel verbose
npm info it worked if it ends with ok
npm info version 0.1.27-12
npm info config set loglevel verbose
npm ok
root@dnsfreebsd:~/npm [master]# make install
node cli.js install npm
npm info it worked if it ends with ok
npm verb cli [ 'install', 'npm' ]
npm info version 0.1.27-12
(...)
npm info install npm@0.1.27-12
npm ERR! Failed unpacking the tarball.
npm ERR! This is very rare. Perhaps the 'gzip' or 'tar' configs
npm ERR! are set improperly?
npm ERR!
npm ERR! install failed Error: Failed gzip "--decompress" "--stdout" "/home/node/.node_libraries/.npm/.cache/npm/0.1.27-12/package.tgz"
npm ERR! install failed exited with 1
npm ERR! install failed at ChildProcess.<anonymous> (/usr/home/marcin/npm/lib/utils/exec.js:41:19)
npm ERR! install failed at ChildProcess.emit (events:33:26)
/**
* BEM Mixin for Sass (v3.4.0)
*
* Block / Element / Modifier
*
* Example:
*
* @include b(test) {
* background: red;
* @include e(element){
# http://stackoverflow.com/a/29490456
#!/bin/bash
# Uninstall node.js
#
# Options:
#
# -d Actually delete files, otherwise the script just _prints_ a command to delete.
# -p Installation prefix. Default /usr/local
# -f BOM file. Default /var/db/receipts/org.nodejs.pkg.bom
#! /usr/bin/env ruby
# USAGE:
# sudo port install pwgen
# bundle exec ruby script/dev/bash_friendly_password.rb nil 49
def bash_friendly_password(password=nil, length=128)
password ||= `pwgen -syv #{length} 1`
password.size.times do |i|
password = password.
#! /usr/bin/env ruby
require 'dotenv'
Dotenv.load
require 'redis'
# USAGE:
# Put credentials in .env file, wrapped in single quotes. DO NOT COMMMIT this file to git!
# Wrap values in single quotes and escape all quotes inside strings with \.
# bundle exec ruby script/dev/example_redis-rb.rb
#! /usr/bin/env ruby
require 'dotenv'
Dotenv.load
require 'aws-sdk'
# USAGE:
# Put credentials in .env file, wrapped in single quotes. DO NOT COMMMIT this file to git!
# Wrap values in single quotes and escape all quotes inside strings with \.
# bundle exec ruby script/dev/example_s3.rb
# https://github.com/jgm/pandoc/releases/1.14.0.1
pandoc -V geometry:"top=1.5cm, bottom=1.5cm, left=1.5cm, right=1.5cm" --latex-engine=xelatex *.md -o out.pdf
@rubyconvict
rubyconvict / comment.rb
Last active July 26, 2017 05:14
NullObject
class Comment < ActiveRecord::Base
delegate :email, to: author, prefix: true, allow_nil: true
end
@rubyconvict
rubyconvict / activity_finder.rb
Last active August 23, 2017 07:24 — forked from sqrtsanta/activity_finder.rb
Preload associations of polymorphic objects
# http://api.rubyonrails.org/classes/ActiveRecord/EagerLoadPolymorphicError.html
# https://github.com/chaps-io/public_activity/issues/297
# https://ksylvest.com/posts/2017-08-23/eager-loading-polymorphic-associations-with-ruby-on-rails
class ActivityFinder
attr_reader :activities, :user
def initialize(user)
@user = user
@activities = Activity.all.where(:user_id => user_ids).