Skip to content

Instantly share code, notes, and snippets.

View Nikamura's full-sized avatar
🐥

Karolis Mažukna Nikamura

🐥
View GitHub Profile
@Nikamura
Nikamura / builder.ts
Last active November 16, 2020 09:49
Fluent builder pattern in TypeScript with type support
// Types Except & SetRequired from https://github.com/sindresorhus/type-fest
type Except<ObjectType, KeysType extends keyof ObjectType> = Pick<ObjectType, Exclude<keyof ObjectType, KeysType>>;
type SetRequired<BaseType, Keys extends keyof BaseType = keyof BaseType> = Except<BaseType, Keys> &
Required<Pick<BaseType, Keys>> extends infer InferredType
? { [KeyType in keyof InferredType]: InferredType[KeyType] }
: never;
class ChainableBuilder<T, X> {
constructor(public args: T, public x: new (...args: any[]) => X) {}
{
"why": "no gist?"
}
File.open('/Users/karolis/Desktop/t.html', 'w+') { |f| f.puts(last_response.body) }
<?php
/*---------------------------------------------------+
| PHP-Fusion 6 Content Management System
+----------------------------------------------------+
| Copyright © 2002 - 2006 Nick Jones
| http://www.php-fusion.co.uk/
+----------------------------------------------------+
| Released under the terms & conditions of v2 of the
| GNU General Public License. For details refer to
| the included gpl.txt file or visit http://gnu.org
<?php
/*---------------------------------------------------+
| PHP-Fusion 6 Content Management System
+----------------------------------------------------+
| Copyright © 2002 - 2006 Nick Jones
| http://www.php-fusion.co.uk/
+----------------------------------------------------+
| Released under the terms & conditions of v2 of the
| GNU General Public License. For details refer to
| the included gpl.txt file or visit http://gnu.org
@import url(https://fonts.googleapis.com/css?family=Roboto:400,700,500,300);@import url(https://fonts.googleapis.com/css?family=Roboto+Mono:400,700,500,300);@keyframes a{0%{transform:rotate(0deg)}to{transform:rotate(1turn)}}@keyframes b{0%{opacity:1}50%{opacity:0}to{opacity:1}}[src$="blue.png"]{background-image:url(data:image/svg+xml;base64,PHN2ZyBoZWlnaHQ9IjE4IiB2aWV3Qm94PSIwIDAgMjQgMjQiIHdpZHRoPSIxOCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48cGF0aCBmaWxsPSIjMDA5Njg4IiBkPSJNMTIgMkM2LjQ4IDIgMiA2LjQ4IDIgMTJzNC40OCAxMCAxMCAxMCAxMC00LjQ4IDEwLTEwUzE3LjUyIDIgMTIgMnptLTIgMTVsLTUtNSAxLjQxLTEuNDFMMTAgMTQuMTdsNy41OS03LjU5TDE5IDhsLTkgOXoiLz48L3N2Zz4=)}[src$="red.png"]{background-image:url(data:image/svg+xml;base64,PHN2ZyBoZWlnaHQ9IjE4IiB2aWV3Qm94PSIwIDAgMjQgMjQiIHdpZHRoPSIxOCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48cGF0aCBmaWxsPSIjRjQ0MzM2IiBkPSJNMTIgMkM2LjQ4IDIgMiA2LjQ4IDIgMTJzNC40OCAxMCAxMCAxMCAxMC00LjQ4IDEwLTEwUzE3LjUyIDIgMTIgMnptMSAxNWgtMnYtMmgydjJ6bTAtNGgtMlY3aDJ2NnoiLz48L3N2Zz4=)}[src$="yellow.png
make all-recursive
make[1]: Entering directory `/usr/local/ruby-2.4.1/lib/ruby/gems/2.4.0/gems/gpgme-2.0.13/ext/gpgme/tmp/x86_64-linux-gnu/ports/gpgme/1.9.0/gpgme-1.9.0'
Making all in src
make[2]: Entering directory `/usr/local/ruby-2.4.1/lib/ruby/gems/2.4.0/gems/gpgme-2.0.13/ext/gpgme/tmp/x86_64-linux-gnu/ports/gpgme/1.9.0/gpgme-1.9.0/src'
/bin/bash ../libtool --tag=CC --mode=compile gcc -DHAVE_CONFIG_H -I. -I.. -I/usr/local/ruby-2.4.1/lib/ruby/gems/2.4.0/gems/gpgme-2.0.13/ports/x86_64-linux-gnu/libassuan/2.4.3/include -I/usr/local/ruby-2.4.1/lib/ruby/gems/2.4.0/gems/gpgme-2.0.13/ports/x86_64-linux-gnu/libgpg-error/1.27/include -fPIC -Wall -Wcast-align -Wshadow -Wstrict-prototypes -MT conversion.lo -MD -MP -MF .deps/conversion.Tpo -c -o conversion.lo conversion.c
libtool: compile: gcc -DHAVE_CONFIG_H -I. -I.. -I/usr/local/ruby-2.4.1/lib/ruby/gems/2.4.0/gems/gpgme-2.0.13/ports/x86_64-linux-gnu/libassuan/2.4.3/include -I/usr/local/ruby-2.4.1/lib/ruby/gems/2.4.0/gems/gpgme-2.0.13/ports/x86_64-linux-gn

Keybase proof

I hereby claim:

  • I am nikamura on github.
  • I am karolis (https://keybase.io/karolis) on keybase.
  • I have a public key ASDD6zbI1PkC0Cw0Gg85R8aS1_k4FskLC-Xk81ZkT7r5_go

To claim this, I am signing this object:

@Nikamura
Nikamura / solve.rb
Created February 11, 2016 21:43
Hash code 2016 solution in Ruby 123665 points
require 'JSON'
rows = 0
cols = 0
no_drones = 0
deadline = 0 # 1000000
max_load = 0
number_of_producs = 0
weights = []
@Nikamura
Nikamura / btc.30s.rb
Created February 10, 2016 19:56
Bitbar BTC price with icon
#!/usr/bin/env ruby
require 'json'
begin
data = `curl -s https://localbitcoins.com/bitcoinaverage/ticker-all-currencies/`
price = JSON.parse(data).fetch('EUR').fetch('avg_1h').round(2)
puts "\xEF\x85\x9A #{price} | font=FontAwesome"
rescue
end