Skip to content

Instantly share code, notes, and snippets.

Working from home

Павел "Malo" Скрылёв majioa

Working from home
View GitHub Profile
Restuta / the-bind-problem.jsx
Last active Jun 24, 2021
React, removeEventListener and bind(this) gotcha
View the-bind-problem.jsx
/* Sometimes it's pretty easy to run ito troubles with React ES6 components.
Consider the following code: */
class EventStub extends Component {
componentDidMount() {
window.addEventListener('resize', this.onResize.bind(this)); //notice .bind
componentWillUnmount() {
window.removeEventListener('resize', this.onResize.bind(this));
View Sinatra request headers helper
require 'rubygems'
require 'sinatra'
helpers do
def request_headers
env.inject({}){|acc, (k,v)| acc[$1.downcase] = v if k =~ /^http_(.*)/i; acc}
makmanalp /
Last active Nov 11, 2020
Angular vs Backbone vs React vs Ember notes

Note: these are pretty rough notes I made for my team on the fly as I was reading through some pages. Some could be mildly inaccurate but hopefully not terribly so. I might resort to convenient fiction & simplification sometimes.

My top contenders, mostly based on popularity / community etc:

  • Angular
  • Backbone
  • React
  • Ember

Mostly about MVC (or derivatives, MVP / MVVM).

Envek / ruby_enable_gost.patch
Created Jul 26, 2014
Enable GOST cryptoalgorithms support in Ruby, patch for Rbenv
View ruby_enable_gost.patch
--- ext/openssl/ossl.c
+++ ext/openssl/ossl.c
@@ -1048,6 +1048,7 @@ Init_openssl()
/* CRYPTO_malloc_init(); */
/* ENGINE_load_builtin_engines(); */
+ OPENSSL_config(NULL); /* Makes Ruby respect system OpenSSL config */
sebmarkbage /
Last active Dec 27, 2020
New React Element Factories and JSX

New React Element Factories and JSX

In React 0.12, we're making a core change to how React.createClass(...) and JSX works.

If you're using JSX in the typical way for all (and only) React components, then this transition will be seamless. Otherwise there are some minor breaking changes described below.

The Problem

alex-zige / gist:5795358
Last active Feb 27, 2021
Rails Rspec API Testing Notes
View gist:5795358

Rails Rspec APIs Testing Notes

Folders Structure

  |--- apis #do not put into controllers folder. 
        |--- your_api_test_spec.rb  
  |--- controllers
  |--- models
  |--- factories
  |--- views


  • C-a == Ctrl-a
  • M-a == Alt-a


:q        close
:w        write/saves
:wa[!]    write/save all windows [force]
:wq       write/save and close
mildmojo / left_join_arel_example.rb
Last active Jun 16, 2021
LEFT JOIN in ARel for ActiveRecord in Ruby on Rails
View left_join_arel_example.rb
# Here's a contrived example of a LEFT JOIN using ARel. This is an example of
# the mechanics, not a real-world use case.
# NOTE: In the gist comments, @ozydingo linked their general-purpose ActiveRecord
# extension that works for any named association. That's what I really wanted!
# Go use that! Go:
# - A Taxi is a car for hire. A taxi has_many :passengers.
# - A Passenger records one person riding in one taxi one time. It belongs_to :taxi.
detunized / globals.rb
Created Jan 16, 2012
List global Ruby variables and their values
View globals.rb
global_variables.sort.each do |name|
puts "#{name}: #{eval "#{name}.inspect"}"
rstacruz /
Last active Sep 19, 2021
Rails models cheatsheet

Rails Models

Generating models

$ rails g model User