Skip to content

Instantly share code, notes, and snippets.

Avatar
👁️
👁

Nick Ostrovsky firedev

👁️
👁
View GitHub Profile
View gist:50d83311519898fb0f9635b87bbf1c22
### Keybase proof
I hereby claim:
* I am firedev on github.
* I am firedev (https://keybase.io/firedev) on keybase.
* I have a public key ASAx0EdMDYGlPGXQUvWIvi76fKLc6n5oeYeFyPAhfqlB3Ao
To claim this, I am signing this object:
@firedev
firedev / .md
Last active Apr 22, 2020
PICO-8 Class-like Objects in pico-8 https://www.lexaloffle.com/bbs/?tid=2951
View .md

With the introduction of the function type() it is now possible to know the type of the variable.

So I tried to find a way to implement a simple class system and I think I found a way

First we need a function to copy tables

function copy(o)
  local c
@firedev
firedev / .p8
Created Apr 22, 2020
PICO8 Tweetcart
View .p8
-- https://twitter.com/lucatron_/status/1252171663883423745
-- https://gist.github.com/lucatronica/5d1b2bdceced5d5f1315b8e2f252146e
for i=1,8 do pal(i,({8,11,10,140,14,12,7})[i],1)end
::_::cls()
?"#pico8♥",0,0,8
for i=0,2 do
k=.25+i/60+cos(t()/8)/5
for y=0,5,.25 do
for x=0,30,.25 do
@firedev
firedev / asyncWrap.js
Created Apr 21, 2020
AsyncWrap — so there is no catch
View asyncWrap.js
const asyncWrap = (promise) => (
promise.then(res => [res]).catch(err => [undefined, err])
)
const func = async () => {
const [result, error] = await asynced( doStuff()) )
}
View collision.p8
--[[ collision detection ]]--
-- point inside the rectangle
function is_point_in_rect(x,y,left,top,right,bottom)
return top<y and y<bottom and left<x and x<right
end
function lines_overlapping(min1, max1, min2, max2)
return min1>min2 and max2>min1
end
View icons.rb
require 'ostruct'
css = File.read('apps/src/stylesheets/sagamore/_buttons.scss').split("\n")
find_images = -> line { line[/"(.+)"/]; $1 }
check_for_file = -> name { OpenStruct.new(name: name, exists: File.exists?("apps/src/images/icons/#{name}.png")) }
format_filenames = -> file_exists { OpenStruct.new(name: (file_exists.name + '.png' + ' ' * 20)[0, 20], exists: file_exists.exists) }
print_results = -> file_exists { puts "#{file_exists.name}\t #{file_exists.exists ? '✅' :'⛔'}" }
css.map(& find_images).compact.map(& check_for_file).map(& format_filenames).map(& print_results)
View bottomless_spec.rb
class BottomlessHash < Hash
def initialize
super &-> h, k { h[k] = self.class.new }
end
def self.from_hash(hash)
new.merge(hash)
end
end
@firedev
firedev / colors.rb
Last active Apr 15, 2016
Colors.rb – Functional programming in Ruby example
View colors.rb
#!/usr/bin/env ruby
require 'paleta'
to_paleta = ->(color) { Paleta::Color.new(:hex, color) rescue nil }
to_div = ->(str) {
"<div style='font-family: sans-serif; width: 5em; height: 3em;
line-height: 3em; display: inline-block; text-align: center;
margin: 0.25em; border-radius: 0.25em; padding: 1em;
background: ##{str}'>
@firedev
firedev / gist:5bc7de39c7407eaad105
Last active Aug 29, 2015
React Searchbox in CoffeeScript
View gist:5bc7de39c7407eaad105
# global $
React = require('react')
class Drawer extends React.Component
@defaultProps: ->
payload: null,
drawerOpened: false
notFound: ->