Skip to content

Instantly share code, notes, and snippets.

@GriffinHeart
GriffinHeart / no_display.rs
Created November 27, 2023 11:49
Prevent string from being leaked by accident into output
use std::fmt;
use core::fmt::Debug;
use clap::Parser;
use serde_with::{DeserializeFromStr, SerializeDisplay};
#[derive(Clone, SerializeDisplay, DeserializeFromStr)]
pub struct NoDisplay(String);
impl std::fmt::Display for NoDisplay {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
{
"meta": {
"theme": "elegant"
},
"basics": {
"name": "Hugo Ferreira de Almeida",
"label": "Software Engineer",
"picture": "",
"email": "hugofalmeida@gmail.com",
"phone": "(+81) 80-2200-3766",
// Fetcher file
const handleErrors = async (...myargs) => {
const response = await originalFetch(...myargs);
if (!response.ok) {
throw Error(response.statusText);
}
return response;
};
//client side
match({ routes, location }, (error, redirectLocation, renderProps) => {
render(
<Provider store={store}>
<ContextHolder context={context}>
<Router {...renderProps} children={routes} history={Location} />
</ContextHolder>
</Provider>,
appContainer
);
//client side
const { pathname, search, hash } = window.location;
const location = `${pathname}${search}${hash}`;
match({ routes, location }, (error, redirectLocation, renderProps) => {
console.log(renderProps);
console.log(location);
render(
<Provider store={store}>
<ContextHolder context={context}>
<Router {...renderProps} children={routes} history={Location} />
class User < ActiveRecord::Base
has_many :combo_instances
end
class ComboGame < ActiveRecord::Base
has_many :combo_instances
attr_reader :game_result
validates :hits_required, presence: true
the_password = 'DO_NOT_USE_THIS_PASSWORD'
pem_key_with_password = OpenSSL::PKey::RSA.new(2048).to_pem(OpenSSL::Cipher.new('aes-256-gcm'), the_password)
loaded_key = OpenSSL::PKey::RSA.new(pem_key_with_password, the_password)
boom!
OpenSSL::PKey::RSAError: Neither PUB key nor PRIV key: nested asn1 error
from (irb):34:in `initialize'
from (irb):34:in `new'
gem 'active_model_serializers', github: 'rails-api/active_model_serializers', branch: '0-10-stable'
class Item
include Mongoid::Document
include Mongoid::Timestamps
end
def index
render json: Item.all
end
Promise = require 'bluebird'
methodB = ->
p = new Promise (resolve, reject)->
setTimeout ->
console.log 'doing methodB'
reject Error('failed b')
, 1000
p.error (e)->
console.log 'log error to methodB.log'
@GriffinHeart
GriffinHeart / promises.coffee
Last active August 29, 2015 14:06
waterfall to promises
Promise = require 'bluebird'
methodB = ->
p = new Promise (resolve, reject)->
setTimeout ->
console.log 'doing methodB'
reject 'failed b'
, 1000
p.catch (e)->
console.log 'log error to methodB.log'