This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const renderPropFromHook = useHook => { | |
const Component = ({ children, ...rest }) => { | |
return children(useHook(rest)); | |
}; | |
return Component; | |
}; | |
// `useCount` is my custom hook with a bunch of | |
// complicated hook usage inside. | |
const useCount = ({ initial }) => { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from time import strftime | |
from datetime import datetime | |
tt = datetime(2018, 4, 2).timetuple() | |
strftime('%b. %-d, %Y', tt) | |
# 'Apr. 10, 2018' | |
strftime('%B %-d, %Y', tt) | |
# 'April 10, 2018' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<style> | |
body { | |
margin: 0; | |
background-color: #111; | |
font-family: sans-serif; | |
} | |
.wrapper { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# https://en.wikipedia.org/wiki/Preferred_number | |
def preferred_numbers(x, precision=2) | |
root = 10 ** (1 / x.to_f) | |
return x.times.map {|i| (root ** i).round(precision)} | |
end | |
<<EXAMPLES | |
> preferred_numbers(2) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Don't do this. It's fun, but stacks will overflow. | |
module Enumerable | |
def flatten_recursive(verbose=false, level=0) | |
car, cdr = self[0], self[1..-1] | |
is_enumerable = car.is_a?(Enumerable) | |
if verbose | |
indent = " " * level | |
if is_enumerable | |
puts "Recurring on Enumerable : #{indent} #{car.inspect}" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Instructions | |
# install required packages by running: | |
# gem install json typhoeus awesome_print | |
# Download this .rb into a new directory on your PC (called something like "pinboard" or whatever) | |
# Fill out KIPPT_USERNAME, KIPPT_API_TOKEN, and PINBOARD_AUTH_TOKEN (below) by changing xxx to the real value. | |
# Run the script by running |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### Keybase proof | |
I hereby claim: | |
* I am baddox on github. | |
* I am shaddox (https://keybase.io/shaddox) on keybase. | |
* I have a public key whose fingerprint is 326A 3C60 FFEE 147E 9611 6560 413A 661B 220C B38D | |
To claim this, I am signing this object: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
a = [1,2,3] | |
# => [1, 2, 3] | |
enum = a.map! | |
# => #<Enumerator: [1, 2, 3]:map!> | |
enum.map(&:to_s) | |
# => ["1", "2", "3"] | |
a |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
irb(main):010:0> puts(<<X, <<Y) | |
irb(main):011:1" this is x | |
irb(main):012:1" X | |
irb(main):013:1" this is y | |
irb(main):014:1" Y | |
this is x | |
this is y | |
=> nil |