Skip to content

Instantly share code, notes, and snippets.

Avatar

Hiro Asari BanzaiMan

View GitHub Profile
@BanzaiMan
BanzaiMan / __arguments__.rb
Last active Sep 13, 2019
Get the list of arguments passed to the current method
View __arguments__.rb
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 Jul 16, 2019
Why does it *not* work with the last example?
View named_captures.rb
HHVM_VERSION_REGEXP = /
(?:hhvm$)
|(
hhvm-(
(?<numeric>\d+(\.\d+)*)(?<lts>-lts)?$
|
(?<version>
dbg$|
dev$|
nightly$|
View gist:9cf34d25e79d367f791437a83ed02b35
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.
View gist:e627ec19b86dc01eefa85eb787685755
$ 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:
View gist:666b5cdddc02371dba6da66e53356a3e
$ 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,
View 7906.log
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
Display of Strings with newlines
View with_2.3.4.log
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 Apr 30, 2017
OpenCV: Show what camera sees, capture if anything other than 'q' is pressed
View camera.rb
require 'rubygems'
require 'opencv'
include OpenCV
camera = CvCapture.open(1)
window = GUI::Window.new("camera")
while true
View build.sh
#!/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"
View gist:1b943ab2ac85d6c0b3315b2b1d0a827c
$ 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