Skip to content

Instantly share code, notes, and snippets.

View shanab's full-sized avatar

Ahmed Aboshanab shanab

View GitHub Profile

Essential Apps

  • Blink: Install Blink on your iPad
  • Tailscale: Install Tailscale on all your devices.
  • mosh: Install mosh on all your devices. It comes with Blink by default.

Nice to have apps

Amphetamine for Mac

@shanab
shanab / permutations.go
Last active April 11, 2020 08:48
Permutations in Go
func permutations(a []int) [][]int {
var results [][]int
permute(a, 0, func(a []int) {
results = append(results, a)
})
return results
}
func permute(a []int, start int, f func([]int)) {
if start >= len(a) {
@shanab
shanab / singleflight.go
Last active November 27, 2018 12:14
A modified version of singleflight API.
package cache
// call is an in-flight or completed Do call
type call struct {
wg sync.WaitGroup
// These fields are written once before the WaitGroup is done
// and are only read after the WaitGroup is done.
val interface{}
err error

Keybase proof

I hereby claim:

  • I am shanab on github.
  • I am shanab (https://keybase.io/shanab) on keybase.
  • I have a public key whose fingerprint is 894C 5D05 AEB1 B536 DD93 E2BB F7C1 EF29 F486 EE28

To claim this, I am signing this object:

@shanab
shanab / numeric_2.rb
Created September 5, 2014 21:48
Extending Numeric class to add currencies using method_missing
class Numeric
@@currencies = { dollar: 7.15, euro: 9.26, yen: 0.068 }
def method_missing(method_id, *args, &block)
singular_currency = method_id.to_s.gsub(/s$/, '').to_sym
if @@currencies.has_key?(singular_currency)
self * @@currencies[singular_currency]
else
super
@shanab
shanab / numeric.rb
Last active August 29, 2015 14:06
Extending Numeric class to add currencies
class Numeric
@@currencies = { dollar: 7.15, euro: 9.26, yen: 0.068 }
@@currencies.each do |currency, rate|
define_method(currency) do
self * rate
end
alias_method "#{currency}s".to_sym, currency
end