Skip to content

Instantly share code, notes, and snippets.

View BanzaiMan's full-sized avatar

Hiro Asari BanzaiMan

View GitHub Profile
@BanzaiMan
BanzaiMan / __arguments__.rb
Last active September 13, 2019 17:16
Get the list of arguments passed to the current method
class BasicObject
def __arguments__(bdg)
method_symbol = caller(1,1).first.match(/\`(?<name>[^']*)'/)[:name].to_sym
self.method(method_symbol).parameters.map { |e| [e[1], bdg.local_variable_get(e[1])] }
end
end
def foo(a, b='c', *d, e:, f: "foo", **g)
__arguments__(binding)
end
@BanzaiMan
BanzaiMan / named_captures.rb
Created July 16, 2019 19:48
Why does it *not* work with the last example?
HHVM_VERSION_REGEXP = /
(?:hhvm$)
|(
hhvm-(
(?<numeric>\d+(\.\d+)*)(?<lts>-lts)?$
|
(?<version>
dbg$|
dev$|
nightly$|
foo@ecf00eb298cc:~$ rvm use --install --binary --fuzzy jruby-9.2.5.0
Required jruby-9.2.5.0 is not installed - installing.
Searching for binary rubies, this might take some time.
Found remote file https://repo1.maven.org/maven2/org/jruby/jruby-dist/9.2.5.0/jruby-dist-9.2.5.0-bin.tar.gz
Checking requirements for ubuntu.
Installing requirements for ubuntu.
Updating systemfoo password required for 'apt-get --quiet --yes update':
....
Installing required packages: patch, bzip2, gawk, g++, make, openjdk-8-jre-headless............................................................
Requirements installation successful.
$ brew install gnu-tar
==> Downloading https://homebrew.bintray.com/bottles/gnu-tar-1.30.high_sierra.bottle.tar.gz
######################################################################## 100.0%
==> Pouring gnu-tar-1.30.high_sierra.bottle.tar.gz
==> Caveats
gnu-tar has been installed as "gtar".
If you really need to use it as "tar", you can add a "gnubin" directory
to your PATH from your bashrc like:
$ curl -H "Travis-API-version: 3" -H "Authorization: token $(travis token --org)" https://api.travis-ci.org/repo/travis-ci%2fphp-src-builder/builds?event_type=cron
{
"@type": "builds",
"@href": "/repo/travis-ci%2fphp-src-builder/builds?event_type=cron",
"@representation": "standard",
"@pagination": {
"limit": 25,
"offset": 0,
"count": 0,
"is_first": true,
Unable to find image 'quay.io/travisci/travis-jvm:latest' locally
latest: Pulling from travisci/travis-jvm
f0a98344d604: Already exists
4aec07c74624: Already exists
2d19892c698f: Already exists
27f1e965b4ef: Already exists
a3ed95caeb02: Already exists
b7d30a7463b4: Already exists
fa09c141fad8: Already exists
90c3e87bd2cf: Already exists
@BanzaiMan
BanzaiMan / with_2.3.4.log
Last active May 30, 2017 17:52
Display of Strings with newlines
strokkur[~]$ rbenv global 2.3.4
strokkur[~]$ irb
irb(main):001:0> "a\nb"
=> "a\nb"
irb(main):002:0> exit
strokkur[~]$ pry
[1] pry(main)> "a\nb"
=> "a\nb"
[2] pry(main)> exit
@BanzaiMan
BanzaiMan / camera.rb
Created April 30, 2017 16:21
OpenCV: Show what camera sees, capture if anything other than 'q' is pressed
require 'rubygems'
require 'opencv'
include OpenCV
camera = CvCapture.open(1)
window = GUI::Window.new("camera")
while true
#!/bin/bash
if [[ -s //etc/profile ]]; then
source //etc/profile
fi
if [[ -s $HOME/.bash_profile ]] ; then
source $HOME/.bash_profile
fi
ANSI_RED="\033[31;1m"
$ curl -vIL https://status.github.com
* Rebuilt URL to: https://status.github.com/
* Trying 50.16.242.83...
* Connected to status.github.com (50.16.242.83) port 443 (#0)
* TLS 1.2 connection using TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256
* Server certificate: status.github.com
* Server certificate: DigiCert SHA2 High Assurance Server CA
* Server certificate: DigiCert High Assurance EV Root CA
> HEAD / HTTP/1.1
> Host: status.github.com