Skip to content

Instantly share code, notes, and snippets.

View firedev's full-sized avatar
👁️
👁

Nick Ostrovsky firedev

👁️
👁
View GitHub Profile
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 / Railscasts.tmTheme
Created June 18, 2012 11:56
Improved Railscasts Theme for Sublime Text 2 – Makes sure you have a differently colored text selection instead of black on black
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0.sublime">
<dict>
<key>name</key>
<string>Railscasts</string>
<key>settings</key>
<array>
<dict>
<key>settings</key>
@firedev
firedev / gist:5bc7de39c7407eaad105
Last active August 29, 2015 14:22
React Searchbox in CoffeeScript
# global $
React = require('react')
class Drawer extends React.Component
@defaultProps: ->
payload: null,
drawerOpened: false
notFound: ->
import React, { Component } from 'react';
class Drawer extends Component {
getDefaultProps() {
return {
payload: null,
drawerOpened: false
};
};
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 April 29, 2015 04:17
Ruby functional-style palette maker
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 April 1, 2015 06:18
Gruntfile for setting up Slim, SASS and Coffeescript compilation to public folder
module.exports = (grunt) ->
# configuration
grunt.initConfig
# grunt sass
sass:
compile:
options:
style: 'expanded'
@firedev
firedev / equalizer.coffee
Created March 23, 2015 02:51
Height Equalizer – new Equializer('.elements') will keep all elements the same height
class @Equalizer
constructor: (selector) ->
@init $(selector)
init: ($collection)->
@attachTo($collection) if $collection.length
attachTo: ($collection) ->
@collection = $collection
@setTimeoutFunction(@equalizeHeight, @collection)
@firedev
firedev / blocks.rb
Last active August 29, 2015 14:17
Blocks
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
class TestCyrillic
class << self
def cyrillic?(string)
string[/\p{Cyrillic}/]
end
end
end
class String
def cyrillic?