Skip to content

Instantly share code, notes, and snippets.

View pdabrowski6's full-sized avatar
✍️
The hybrid of writer and developer

Paweł Dąbrowski pdabrowski6

✍️
The hybrid of writer and developer
View GitHub Profile
import React, { useState } from 'react';
import {default as UUID} from "node-uuid";
export default function App() {
const [books, setBooks] = useState([]);
const [action, setAction] = useState('list');
const [formData, setFormData] = useState({title: "", author: ""});
const [currentBookId, setCurrentBookId] = useState(null);
const deleteBook = (id) => { setBooks(books.filter((book) => book.id != id)); };
@pdabrowski6
pdabrowski6 / ruby_rogues.rb
Created June 18, 2018 11:38
The Ruby Rogues podcast - Hall of Fame
data = {}
1.upto(20) do |page|
puts "page #{page}"
url = "https://devchat.tv/ruby-rogues/page/#{page}"
response = RestClient.get(url)
html = Nokogiri::HTML(response)
html.css("h3.entry-title a").map { |e| e[:href] }.each do |url|
response = RestClient.get(url)
html = Nokogiri::HTML(response)
@pdabrowski6
pdabrowski6 / stats.rb
Created June 14, 2018 04:55
Code for checking Ruby Rogues stats
data = {}
timeouts = []
1.upto(20) do |page|
puts "page #{page}"
url = "https://devchat.tv/ruby-rogues/page/#{page}"
response = RestClient.get(url)
html = Nokogiri::HTML(response)
html.css("h3.entry-title a").map { |e| e[:href] }.each do |url|
begin
@pdabrowski6
pdabrowski6 / active_model_serializers.rb
Last active July 9, 2019 09:27
BENCHMARKS: How to create fast JSON serialization in Rails?
# post_serializer.rb
class PostSerializer < ActiveModel::Serializer
has_many :comments
attributes :id, :title, :content
end
# comment_serializer.rb
@pdabrowski6
pdabrowski6 / highlight.css
Created May 16, 2018 09:59
Syntax highlighting CSS
.highlight {
border-radius: 5px;
font-family: -apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif;
font-weight: normal;
font-size: 15px;
padding: 10px;
padding-bottom: 0px;
margin-bottom: 20px;
}
@pdabrowski6
pdabrowski6 / simple_benchmark.rb
Created February 10, 2018 03:53
Avoid let and before blocks in your test when you don't really have to use them
# user.rb file
class User
attr_reader :admin
def initialize(admin: false)
@admin = admin
end
end
class Test
end
class Test
def test
end
end
require 'colorize'
class NumberService
def number
12
end
end
class Describe
attr_reader :context_name, :examples
class NumberService
def number
12
end
end
class Describe
attr_reader :context_name, :examples
def initialize(context_name, &block)