Skip to content

Instantly share code, notes, and snippets.

Avatar
💎
Searching for Ruby gems

Beyar Beyarz

💎
Searching for Ruby gems
View GitHub Profile
@Beyarz
Beyarz / hibp.rb
Created Apr 10, 2021
Scrapes HaveiBeenPwned's top 10 list
View hibp.rb
begin
require "open-uri"
rescue LoadError
system "gem install openurl"
end
begin
require "nokogiri"
rescue LoadError
system "gem install nokogiri"
@Beyarz
Beyarz / coin.rb
Created Apr 10, 2021
Scrapes all the top 100 coins from coinmarketcap.
View coin.rb
begin
require "open-uri"
rescue LoadError
system "gem install openurl"
end
begin
require "nokogiri"
rescue LoadError
system "gem install nokogiri"
View type.d
void main()
{
import std.traits;
import std.stdio: writeln;
int z = 5;
writeln(is(typeof(z) == int));
writeln(is(typeof(z) == char));
writeln(typeid(z));
View scope.d
import std.stdio : writefln, writeln;
void main()
{
writeln("<html>");
scope(exit) writeln("</html>");
{
writeln("\t<head>");
scope(exit) writeln("\t</head>");
View mixin.d
import std.stdio;
mixin template Foo()
{
int x = 5;
}
struct Bar
{
mixin Foo;
View json.d
import std.stdio;
import std.json;
void main()
{
auto obj;
obj["name"] = "Hi";
obj["age"] = 19;
writeln("Obj name: ", obj["name"]);
writeln("Obj age: ", obj["age"]);
View at_compile_time.d
void main()
{
import std.algorithm, std.conv, std.stdio;
"Starting program".writeln;
// Sort a constant declaration at Compile-Time
enum a = [ 3, 1, 2, 4, 0 ];
static immutable b = sort(a);
View superators19.rb
begin
require "superators19"
rescue LoadError
puts "Load error: gem install superators19"
end
class Array
superator "+++" do |operand|
"#{self} is equal to #{operand}"
end
View define_method.rb
class Foo
[1, 2, 3].each do |x|
define_method("get_#{x}") { x }
end
end
foo = Foo.new
foo.get_1 # 1
foo.get_2 # 2
foo.get_3 # 3
View splat.rb
def some_func(*args)
puts args[0]
puts args[1]
puts args[2]
end