Skip to content

Instantly share code, notes, and snippets.

👁
👁

Nick Ostrovsky firedev

👁
👁
Block or report user

Report or block firedev

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
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: ->
View gist:c3dfb6f892fce2c6ac18
import React, { Component } from 'react';
class Drawer extends Component {
getDefaultProps() {
return {
payload: null,
drawerOpened: false
};
};
View gist:528140a8b44ce5c111e6
months:
['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
render: ->
DOM.select
onChange: @onMonthChange
value: @props.date.getMonth()
DOM.option(
value: i, key: i, @months[i]
) for i in [0..(@months.length-1)]
@firedev
firedev / color_order.rb
Created Apr 29, 2015
Ruby functional-style palette maker
View color_order.rb
require 'paleta'
colors = %w( 669900 66FF00 66CCFF 6699FF 6633FF )
to_color = ->(color) { Paleta::Color.new(:hex, color) }
to_div = ->(color) { "<div style='width: 3em; height: 3em; background: ##{color}; float: left'></div>" }
puts colors.uniq.map(& to_color).sort_by(&:hue).map(&:hex).map(& to_div)
@firedev
firedev / Gruntfile.coffee
Created Apr 1, 2015
Gruntfile for setting up Slim, SASS and Coffeescript compilation to public folder
View Gruntfile.coffee
module.exports = (grunt) ->
# configuration
grunt.initConfig
# grunt sass
sass:
compile:
options:
style: 'expanded'
@firedev
firedev / equalizer.coffee
Created Mar 23, 2015
Height Equalizer – new Equializer('.elements') will keep all elements the same height
View equalizer.coffee
class @Equalizer
constructor: (selector) ->
@init $(selector)
init: ($collection)->
@attachTo($collection) if $collection.length
attachTo: ($collection) ->
@collection = $collection
@setTimeoutFunction(@equalizeHeight, @collection)
View blocks.rb
class Page
has_many :blocks, -> { ordered }, dependent: :destroy
attr_accessors :title
def visible_blocks
@visible_block ||= blocks.current_locale.map(&:blockable)
end
end
class Block
You can’t perform that action at this time.