Skip to content

Instantly share code, notes, and snippets.

def bar
:bar
end
def foo(a, b=bar)
puts [a, b].inspect
end
foo("hi")
# => ["hi", :bar]
@jc00ke
jc00ke / authenticated.rb
Last active August 14, 2018 15:42
Using Module prepend with an argument
# spec/support/authenticated.rb
class Authenticated < Module
def initialize(current_user:)
super() do
define_method :current_user do
current_user
end
end
end
end
[CLI] I | 2018-06-29T15:49:44-07:00 | Using config from 'omnibus.rb'
[Software: config_guess] W | 2018-06-29T15:49:44-07:00 | Version master for software config_guess was not parseable. Comparison methods such as #satisfies? will not be a
vailable for this version.
Building aptible-toolbelt ...
[Software: preparation] I | 2018-06-29T15:49:44-07:00 | Resolving manifest entry for preparation
[NullFetcher: preparation] I | 2018-06-29T15:49:44-07:00 | Fetching `preparation' (nothing to fetch)
[Software: config_guess] I | 2018-06-29T15:49:44-07:00 | Resolving manifest entry for config_guess
[Software: config_guess] W | 2018-06-29T15:49:44-07:00 | Version master for software config_guess was not parseable. Comparison methods such as #satisfies? will not be a
vailable for this version.
[Software: config_guess] W | 2018-06-29T15:49:44-07:00 | Version master for software config_guess was not parseable. Comparison methods such as #satisfies? will not be a
@jc00ke
jc00ke / install-2.3.1.md
Last active June 28, 2019 22:21
Install Ruby 2.3.1 on Manjaro Linux
$> sudo pacman -S gcc5 openssl-1.0
$> CC=gcc-5 CXX=g++-5 PKG_CONFIG_PATH=/usr/lib/openssl-1.0/pkgconfig/:/usr/lib/pkgconfig/RUBY_CONFIGURE_OPTS=--with-openssl-dir=/usr
/lib/openssl-1.0/ asdf install ruby 2.3.1

Detailed steps

@jc00ke
jc00ke / capybara-headless-chrome.rb
Created April 5, 2018 04:41 — forked from matthewrudy/capybara-headless-chrome.rb
Running headless chrome on capybara with selenium webdriver
require "selenium/webdriver"
Capybara.register_driver :chrome do |app|
Capybara::Selenium::Driver.new(app, browser: :chrome)
end
Capybara.register_driver :headless_chrome do |app|
capabilities = Selenium::WebDriver::Remote::Capabilities.chrome(
chromeOptions: { args: %w(headless disable-gpu) }
)
@jc00ke
jc00ke / ssh_agent_start.fish
Created March 6, 2018 06:37 — forked from gerbsen/ssh_agent_start.fish
Auto-launching ssh-agent in fish shell
# content has to be in .config/fish/config.fish
# if it does not exist, create the file
setenv SSH_ENV $HOME/.ssh/environment
function start_agent
echo "Initializing new SSH agent ..."
ssh-agent -c | sed 's/^echo/#echo/' > $SSH_ENV
echo "succeeded"
chmod 600 $SSH_ENV
. $SSH_ENV > /dev/null
@jc00ke
jc00ke / Dockerfile
Created December 8, 2017 04:36
Dockerfile for Swift 4
FROM ubuntu:16.04
LABEL maintainer="Haris Amin <[email protected]>"
LABEL Description="Docker Container for the Apple's Swift programming language"
# Yoinked from
# https://github.com/swiftdocker/docker-swift/blob/5c83628d4696bca62aec3136a4ee9b854e8d548e/4.0/Dockerfile
# Install related packages and set LLVM 3.8 as the compiler
RUN apt-get -q update && \
apt-get -q install -y \
@jc00ke
jc00ke / Makefile
Created November 12, 2017 23:50 — forked from isaacs/Makefile
# Hello, and welcome to makefile basics.
#
# You will learn why `make` is so great, and why, despite its "weird" syntax,
# it is actually a highly expressive, efficient, and powerful way to build
# programs.
#
# Once you're done here, go to
# http://www.gnu.org/software/make/manual/make.html
# to learn SOOOO much more.
@jc00ke
jc00ke / README.md
Last active April 9, 2017 14:34
Remove duplicate lines while keeping the order of the lines

From http://unix.stackexchange.com/a/194790/159078

I doubt it will make a difference but, just in case, here's how to do the same thing in Perl:

perl -ne 'print if ++$k{$_}==1' out.txt

If the problem is keeping the unique lines in memory, that will have the same issue as the awk you tried. So, another approach could be:

cat -n out.txt | sort -k2 -k1n  | uniq -f1 | sort -nk1,1 | cut -f2-
defmodule Foo do
defmacro foo_macro(i) do
quote do
unquote(i)
end
end
def bar(foo_macro(1) = i), do: IO.puts(i)
def bar(foo_macro(2) = i) do
IO.puts "This better be 2: #{i}"