Skip to content

Instantly share code, notes, and snippets.

🐙
Doing stuff

Dmitriy Shcherbakan somenugget

🐙
Doing stuff
Block or report user

Report or block somenugget

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@somenugget
somenugget / mail_example_1.cs
Last active Jul 18, 2019
ASP.NET mail example 1
View mail_example_1.cs
// in the beginning of the file
using System.Net;
using System.Net.Mail;
MailAddress to = new MailAddress("elizabeth@westminster.co.uk");
MailAddress from = new MailAddress("piotr@mailtrap.com");
MailMessage message = new MailMessage(from, to);
@somenugget
somenugget / currying.rb
Last active Jan 18, 2019
Currying in Ruby
View currying.rb
# https://www.morozov.is/2019/01/11/partial-application-in-ruby.html
fun = ->(tag, text) { "<#{tag}>#{text}</#{tag}>" }
curried_fun = fun.curry
bold_fun = curried_fun.('b')
p fun.('b', 'yo') # "<b>yo</b>"
p curried_fun.('b').('yo') # "<b>yo</b>"
p bold_fun.('yo') # "<b>yo</b>"
View gist:a4a1a860eae6c5f25d05e8423421bd1b

Block creation

To create an anchor to a heading in github flavored markdown. Add - characters between each word in the heading and wrap the value in parens (#some-markdown-heading) so your link should look like so:

To create an anchor to a heading in github flavored markdown. Add - characters between each word in the heading and wrap the value in parens (#some-markdown-heading) so your link should look like so:

To create an anchor to a heading in github flavored markdown.

@somenugget
somenugget / trb_template.rb
Created Sep 9, 2018
TRB: Idea for nested operation with placeholders
View trb_template.rb
class SetUserAttributes < Trailblazer::Operation
step Model(User, :find_by)
success placeholder: :set
step :persist
def persist(options, **)
options[:model].save!
end
end
@somenugget
somenugget / create_spec.rb
Created Sep 5, 2018
TRB operation test with mocked model
View create_spec.rb
RSpec.describe Room::Create do
describe '.call' do
context 'valid params' do
subject(:result) { described_class.(params: { room: room_params }) }
let(:room_params) { { name: 'room' } }
let(:room) do
double :room, :slug= => 'slug',
:slug => 'slug',
@somenugget
somenugget / out.rb
Created Jul 20, 2018
Replace last console output
View out.rb
require 'time'
loop do
time = Time.now.to_s + "\r"
print time
$stdout.flush
sleep 1
end
View vue_pug_stylus.sublime-snippet
<snippet>
<content><![CDATA[
<template lang="pug">
$0
</template>
<script>
export default {
name: '${1:${TM_FILENAME/(.+)..+..+/$1/}}',
};
You can’t perform that action at this time.