Skip to content

Instantly share code, notes, and snippets.

class CustomSet
def initialize
@elements = []
end
def insert(element)
@elements << element unless includes?(element)
end
def includes?(element)
@rwehresmann
rwehresmann / ruby_tracing.rb
Created October 31, 2022 11:10
Enable ruby tracing of method calls
tracer = TracePoint.new(:c_call) do |tp| p [tp.lineno, tp.event, tp.defined_class, tp.method_id] end
tracer.enable { Time.now.to_json }
11 funding rounds
A round of funding
A-Round funding
B round
B round financing
B round of funding
Black-owned Small Business Impact Fund grant
Buy-to-Let loans
C round of financing
C1 round of funding
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "@chainlink/contracts/src/v0.8/interfaces/AggregatorV3Interface.sol";
contract FundMe {
mapping(address => uint256) public addressToAmountFunded;
address[] public funders;
# frozen_string_literal: true
require "bundler/inline"
gemfile(true) do
source "https://rubygems.org"
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
gem "rails"
class FakeRedis
attr_reader :counts, :vars
def initialize(counts: {}, vars: {})
@counts = counts
@vars = vars
end
def set(var, val)
@vars[var] = val
@rwehresmann
rwehresmann / typora_ghotic_theme_modified.css
Last active February 15, 2021 12:57
typora_ghotic_theme_modified.css
@include-when-export url(https://fonts.googleapis.com/css?family=Ubuntu:400,700,400italic,700italic);
@include-when-export url(https://fonts.googleapis.com/css?family=Raleway:600,400&subset=latin,latin-ext);
@charset "UTF-8";
@font-face {
font-family: 'TeXGyreAdventor';
font-style: normal;
font-weight: normal;
src: url(./gothic/texgyreadventor-regular.otf);
}
@rwehresmann
rwehresmann / load-content-from-after-fold.html
Created January 4, 2020 01:50
We can improve the webpage performance only loading the necessary css first (above the fold), and the rest afterwards. That result in the CSSOM finishing its load faster.
<script type="text/javascript">
const loadStylesheet = src => {
if(document.createStylesheet)
document.createStylesheet(src);
else {
const stylesheet = document.createElement('link');
stylesheet.href = src;
stylesheet.type = 'text/css';
stylesheet.rel = 'stylesheet';
document.getElementsByTagName('head')[0].appendChild(stylesheet);
class Auth0Controller < ApplicationController
def authentication
redirect_to(
"https://#{ENV.fetch('AUTH0_DOMAIN')}/authorize?" +
"client_id=#{ENV.fetch('AUTH0_CLIENT_ID')}&" +
"response_type=code&" +
"redirect_uri=#{URI.encode(auth_callback_url)}"
)
end
end
<% if current_user %>
<% if current_admin_user.present? && current_admin_user != current_user %>
<h1><%= current_admin_user.email %> is logged in as <%= current_user.email %>.</h1>
<% else %>
<h1><%= current_user.email %> is logged in.</h1>
<% end %>
<ul>
<li><%= link_to 'Admin', admin_root_path %></li>
<li><%= link_to 'Log out', auth_logout_path, method: :post %></li>