Skip to content

Instantly share code, notes, and snippets.

View ellcs's full-sized avatar

ellcs

  • Hamburg, Germany
  • 10:35 (UTC -07:00)
View GitHub Profile
require 'contracts'
# https://ruby-doc.org/core-2.6/RubyVM/InstructionSequence.html
module B
def c; end
end
def global_method; end
class A
@ellcs
ellcs / hacks.rb
Last active April 22, 2020 07:39
Helpful ruby oneliners
# create random groups of people
%w(james bob alice eve tux).shuffle.each_slice(2).to_a
# => [["bob", "eve"], ["alice", "tux"], ["james"]]
# assign random tools to people (tools can be empty)
people = %w(james bob alice eve tux)
tools = %w(hammer chainsaw screwdriver)
people.shuffle.zip(tools)
# => [["alice", "hammer"], ["james", "screwdriver"], ["tux", "chainsaw"], ["bob", nil], ["eve", nil]]
@ellcs
ellcs / fibbonacci.rb
Created April 27, 2020 09:34
Fast fibbonacci
# https://en.wikipedia.org/wiki/Fibonacci_number#Closed-form_expression
N = (1 + Math::sqrt(5)) / 2
M = (1 - Math::sqrt(5)) / 2
def fibb(n)
(N**n - M**n) / (N - M)
end
# https://en.wikipedia.org/wiki/Fibonacci_number#Matrix_form
# gleiche zuweisung
var1=abc
var2="abc"
echo "$var1"
echo "$var2"
# string mit spaces
var3="abc def"
var4=abc\ def
# https://crystal-lang.org/api/0.22.0/JSON.html
# online repl: https://play.crystal-lang.org/#/r/995s
require "json"
value = JSON.parse("[1, 2, 3]").raw # : JSON::Any
# (Array(JSON::Any) | Bool | Float64 | Hash(String, JSON::Any) | Int64 | String | Nil)
typeof(value)
if value.is_a?(Array)
@ellcs
ellcs / easy_ipc.rb
Created September 16, 2020 20:09
easy ipc
require 'set'
module SpecialMessages
module Stop; end
module Ack; end
end
class WorkerFactory
def initialize
@set = Set.new
@ellcs
ellcs / r2.sh
Last active October 6, 2020 22:47
radare2 notes
# get only import names
afl~sym.imp[3]
# get only import addrs
afl~sym.imp[0]
# set breakpoint at 0x0 and 0x1
db $$ @@= `!echo -e "0x0\n0x1"`
# set breakpoint at every imported function
<html>
<head>
</head>
<body>
<h1>asdf</h1>
<script>alert(1);</script>
</body>
</html>
## GOAL:
## re-create a figure similar to Fig. 2 in Wilson et al. (2018),
## Nature 554: 183-188. Available from:
## https://www.nature.com/articles/nature25479#s1
##
## combines a boxplot (or violin) with the raw data, by splitting each
## category location in two (box on left, raw data on right)
# initial set-up ----------------------------------------------------------
List(
Identifier(
id = 8832L,
argumentIndex = 1,
argumentName = None,
code = "used",
columnNumber = Some(value = 3),
dynamicTypeHintFullName = ArraySeq(),
lineNumber = Some(value = 633),
name = "used",