Skip to content

Instantly share code, notes, and snippets.

@nilbus
nilbus / npm_install_error.txt
Created July 20, 2017 15:24 — forked from anonymous/npm_install_error.txt
npm install fails to symlink in Docker for Windows with app in mounted filesystem
npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "install"
npm ERR! node v4.8.4
npm ERR! npm v2.15.11
npm ERR! path ../coffee-script/bin/coffee
npm ERR! code EINVAL
npm ERR! errno -22
npm ERR! syscall symlink
npm ERR! EINVAL: invalid argument, symlink '../coffee-script/bin/coffee' -> '/exercism/node_modules/lineman/node_modules/.bin/coffee'
def update
find_user
if @user.update_attributes(user_params)
respond_to do |format|
format.html {
redirect_to admin_user_path(@user)
flash[:notice] = 'User updated'
}
format.js {
tracking = DateTime.strptime(row['tracking'], '%Y%m%d%H%M%S')
Correspondence.where(
tracking: tracking,
sender: row['remetente'],
receiver: row['destinatario']).first_or_create(
tracking: tracking,
sender: row['remetente'],
receiver: row['destinatario'],
department: row['depto'],
bay: row['baia'],
@nilbus
nilbus / git-recently-checkout-branches.sh
Created November 23, 2015 16:48 — forked from mislav/git-recently-checkout-branches.sh
Show list of recently checked-out branches in reverse-chronological order
#!/bin/bash
set -e
git reflog -n100 --pretty='%cr|%gs' --grep-reflog='checkout: moving' HEAD | {
seen=":"
git_dir="$(git rev-parse --git-dir)"
while read line; do
date="${line%%|*}"
branch="${line##* }"
if ! [[ $seen == *:"${branch}":* ]]; then
@nilbus
nilbus / gist:740a05b9454d6794e804
Last active August 29, 2015 14:25 — forked from swalke16/gist:cbc8fd10180d9d04d682
Robot Controller Exercise

#Assignment:

Create a controller for a robot

Right
Forward
Left 0
//
// Backbone.Rails.js
//
// Makes Backbone.js play nicely with the default Rails setup, i.e.,
// no need to set
// ActiveRecord::Base.include_root_in_json = false
// and build all of your models directly from `params` rather than
// `params[:model]`.
//
// Load this file after backbone.js and before your application JS.
@nilbus
nilbus / gist:6385142
Last active February 23, 2016 23:35 — forked from ryanlecompte/gist:1420133
Ruby multiple callbacks
# alternative to what is explained in the article Ruby Blocks as Dynamic Callbacks:
# http://www.mattsears.com/articles/2011/11/27/ruby-blocks-as-dynamic-callbacks
class Callbacks
def initialize(block)
block.call(self)
end
def callback(message, *args)
callbacks[message].call(*args)
Showdown.extensions['twitter'] = function(converter) {
return [
// Replace escaped @ symbols
{ type: 'lang', regex: '\\@', replace: 'red' }
];
}
@nilbus
nilbus / ransack.rb
Created January 3, 2013 15:24 — forked from ledermann/ransack.rb
# Patch for ransack (https://github.com/ernie/ransack) to use scopes
# Helps migrating from Searchlogic or MetaSearch
# Place this file into config/initializer/ransack.rb of your Rails 3.2 project
#
# Usage:
# class Debt < ActiveRecord::Base
# scope :overdue, lambda { where(["status = 'open' AND due_date < ?", Date.today]) }
# end
#
# Ransack out of the box ignores scopes. Example:
require 'lib/scrubyt'
@extractor = Scrubyt::Extractor.new do
fetch "http://www.google.com/search?&q=ruby"
books "ul.results li" do
title "//h2"
author "p.author"
book_detail "h2 a" do
name "//title"
summary "//p[1]"
end