Skip to content

Instantly share code, notes, and snippets.

View ilyazub's full-sized avatar
🇺🇦

ilyazub

🇺🇦
View GitHub Profile
@manfe
manfe / helper.rb
Last active January 14, 2020 10:15
Rails Helper to build Hierachical HTML List
module TreeListHelper
# the collection need to be the root parents
def tree_list(collection)
content_tag(:ul) do
collection.each do |item|
if item.children.any?
concat(
content_tag(:li, id: item.id) do
concat(item.name)
concat(tree_list(item.children))
@craigbeck
craigbeck / introspection-query.graphql
Created April 6, 2016 20:20
Introspection query for GraphQL
query IntrospectionQuery {
__schema {
queryType { name }
mutationType { name }
subscriptionType { name }
types {
...FullType
}
directives {
@rosswd
rosswd / laptops.md
Last active March 30, 2023 15:46
Linux Laptops
@paulirish
paulirish / what-forces-layout.md
Last active June 8, 2024 13:18
What forces layout/reflow. The comprehensive list.

What forces layout / reflow

All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.

Generally, all APIs that synchronously provide layout metrics will trigger forced reflow / layout. Read on for additional cases and details.

Element APIs

Getting box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent
@palkan
palkan / gist:d89757a90cfbeb047c63
Last active October 22, 2023 23:16
Rails debug cheat sheet

Setup

Replace IRB with Pry (in your Gemfile) and Byebug with pry-byebug.

gem 'pry-rails', group: [:development, :test]
gem 'pry-byebug', group: [:development, :test]

Using PRY

@rahul286
rahul286 / rbenv-ubuntu.sh
Created April 7, 2015 07:15
rbenv ubuntu server cheatsheet
## ubuntu server with bash shell
git clone https://github.com/sstephenson/rbenv.git ~/.rbenv
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile
echo 'eval "$(rbenv init -)"' >> ~/.bash_profile
git clone https://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build
## verify
type rbenv
@abaird
abaird / output.txt
Last active January 3, 2020 09:54
Run tests with RSpec formatter in Rake task
require 'rspec/core/rake_task'
require 'ci/reporter/rake/rspec'
RSpec::Core::RakeTask.new(:spec) do |t|
t.rspec_opts = ['--format html', '--out spec/reports/results.html']
t.pattern = 'spec/heartbeat/heartbeat_spec.rb'
end
task :clean do
rm_rf 'spec/reports'
@guilhermesimoes
guilhermesimoes / line_count_benchmark.rb
Last active September 11, 2023 09:36
Ruby Benchmark: Counting the number of lines of a file
# gem install benchmark-ips
require "benchmark/ips"
path = "lib/rubycritic/cli/options.rb"
Benchmark.ips do |x|
x.report("read + each_line") { File.read(path).each_line.count }
x.report("open + each_line") { File.open(path, "r").each_line.count }
@raecoo
raecoo / random.string.rb
Created December 2, 2014 13:54
random string in ruby
# Only upper case alphabets [A-Z]
value = "";
8.times{value << (65 + rand(25)).chr} >>}
#or
(0...8).map{65.+(rand(26)).chr}.join
(0...8).map{ ('A'..'Z').to_a[rand(26)] }.join
# Lower case and upper case [a-zA-Z]
value = "";
8.times{value << ((rand(2)==1?65:97) + rand(25)).chr} >>}
@rattrayalex
rattrayalex / MessageStore_FluxBone.js
Last active June 19, 2020 09:40
Flux and Backbone
var ChatAppDispatcher = require('../dispatcher/ChatAppDispatcher');
var ChatConstants = require('../constants/ChatConstants');
var ChatMessageUtils = require('../utils/ChatMessageUtils');
var EventEmitter = require('events').EventEmitter;
var ThreadStore = require('../stores/ThreadStore');
var merge = require('react/lib/merge');
var ActionTypes = ChatConstants.ActionTypes;
var CHANGE_EVENT = 'change';