Skip to content

Instantly share code, notes, and snippets.

View nlevchuk's full-sized avatar
🪐

Nikita Levchuk nlevchuk

🪐
View GitHub Profile
@gaearon
gaearon / modern_js.md
Last active April 14, 2024 22:17
Modern JavaScript in React Documentation

If you haven’t worked with JavaScript in the last few years, these three points should give you enough knowledge to feel comfortable reading the React documentation:

  • We define variables with let and const statements. For the purposes of the React documentation, you can consider them equivalent to var.
  • We use the class keyword to define JavaScript classes. There are two things worth remembering about them. Firstly, unlike with objects, you don't need to put commas between class method definitions. Secondly, unlike many other languages with classes, in JavaScript the value of this in a method [depends on how it is called](https://developer.mozilla.org/en-US/docs/Web/Jav
@francois-ferrandis
francois-ferrandis / active_admin.rb
Created March 7, 2018 11:59
Customize the active admin layout
# config/initializers/active_admin.rb
# ...rest of the initializer here...
module AdminPageLayoutOverride
def build(*args)
# you can move the call to super at the end, if you wish
# to insert things at the begining of the page
super
@reborg
reborg / rich-already-answered-that.md
Last active February 23, 2024 13:09
A curated collection of answers that Rich gave throughout the history of Clojure

Rich Already Answered That!

A list of commonly asked questions, design decisions, reasons why Clojure is the way it is as they were answered directly by Rich (even when from many years ago, those answers are pretty much valid today!). Feel free to point friends and colleagues here next time they ask (again). Answers are pasted verbatim (I've made small adjustments for readibility, but never changed a sentence) from mailing lists, articles, chats.

How to use:

  • The link in the table of content jumps at the copy of the answer on this page.
  • The link on the answer itself points back at the original post.

Table of Content

@sharipov-ru
sharipov-ru / exceptions_handling.rb
Last active August 29, 2015 14:01
Exceptions handling with ruby 2.1
class ServiceException < StandardError; end
class RepositoryException < StandardError; end
class RethinkDBError < StandardError; end
class RecordsController
def self.update
RecordsService.update(@record)
rescue ServiceException => error
puts "Failure: #{error.inspect}"
puts "Original failure: #{error.cause.inspect}"
@niquola
niquola / list.md
Last active May 20, 2018 04:52
Must Read from Ravil Bayramgalin (https://github.com/brainopia) + my small adds :)

Books

Concepts-Techniques-Models-Computer-Programming CMT это известная книжка CMT, за которой слава закрепилась не хуже чем у SICP

это из этой книжки классификация различных парадигм Если присмотришься, то увидишь, что Oz поддерживает большинство вариаций (с этой целью его и конструировали, чтобы можно было наглядно продемонстрировать различные подходы в одном языке)

@the-teacher
the-teacher / spec_helper.rb
Created December 10, 2013 19:23
Rspec + Views + Isolated Engine
ActionView::TestCase::TestController.instance_eval do
helper MyEngine.routes.url_helpers
helper ApplicationHelper
include Devise::TestHelpers
end
@nicolashery
nicolashery / environment-variables-jekyll-templates.md
Last active January 22, 2023 15:56
Make environment variables available in Jekyll Liquid templates

Environment variables in Jekyll templates

This is one way to pass some data (API tokens, etc.) to your Jekyll templates without putting it in your _config.yml file (which is likely to be committed in your GitHub repository).

Copy the environment_variables.rb plugin to your _plugins folder, and add any environment variable you wish to have available on the site.config object.

In a Liquid template, that information will be available through the site object. For example, _layouts/default.html could contain:

@jhilden
jhilden / tabs.js.coffee
Created August 28, 2012 10:33
Remove jquery-ui styling for tabs
$ ->
jquery_ui_classes = [".ui-tabs", ".ui-tabs-nav", ".ui-tabs-panel", ".ui-widget", ".ui-widget-header", ".ui-widget-content", ".ui-corner-all", ".ui-corner-top", ".ui-corner-bottom", ".ui-helper-clearfix", ".ui-helper-reset", ".ui-state-default"]
$(".js-tabs").tabs().each ->
# removes all the jquery-ui specific classes (except ones like ui-state-active)
$elements = $(this).find( jquery_ui_classes.join(", ") ).andSelf()
$elements.removeClass( jquery_ui_classes.join(" ").replace(/\./g, "") )
@shunchu
shunchu / convert-seconds-into-hh-mm-ss-in-ruby.rb
Created July 25, 2012 07:58
Convert seconds into HH:MM:SS in Ruby
t = 236 # seconds
Time.at(t).utc.strftime("%H:%M:%S")
=> "00:03:56"
# Reference
# http://stackoverflow.com/questions/3963930/ruby-rails-how-to-convert-seconds-to-time
@mustafaturan
mustafaturan / ruby.2.0.0-setup.sh
Last active May 21, 2019 23:00
ruby 2.0.0 centos 6
#!/usr/bin/env bash
# repository
cd /tmp
wget http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
rpm -Uvh epel-release-6-8.noarch.rpm
# system update
yum -y update
yum -y groupinstall "Development Tools"
yum -y install libxslt-devel libyaml-devel libxml2-devel gdbm-devel libffi-devel zlib-devel openssl-devel libyaml-devel readline-devel curl-devel openssl-devel pcre-devel git memcached-devel valgrind-devel mysql-devel ImageMagick-devel ImageMagick