Skip to content

Instantly share code, notes, and snippets.

View michalwiacek's full-sized avatar
🥑
Focusing

Michał Wiącek michalwiacek

🥑
Focusing
  • Samsung R&D
  • Warsaw
View GitHub Profile
@michalwiacek
michalwiacek / get_mxers.rb
Created November 9, 2020 12:03 — forked from afair/get_mxers.rb
Ruby: lookup email MX servers for a domain
require 'resolv'
class Domain
def mxers(domain)
mxs = Resolv::DNS.open do |dns|
ress = dns.getresources(domain, Resolv::DNS::Resource::IN::MX)
ress.map { |r| [r.exchange.to_s, IPSocket::getaddress(r.exchange.to_s), r.preference] }
end
return mxs
@michalwiacek
michalwiacek / rspec_model_testing_template.rb
Created May 22, 2020 23:12 — forked from kolosek/rspec_model_testing_template.rb
Rails Rspec model testing skeleton & cheat sheet using rspec-rails, shoulda-matchers, shoulda-callbacks, and factory_girl_rails. Pretty much a brain dump of examples of what you can (should?) test in a model. Pick & choose what you like, and please let me know if there are any errors or new/changed features out there. Reddit comment thread: http…
# This is a skeleton for testing models including examples of validations, callbacks,
# scopes, instance & class methods, associations, and more.
# Pick and choose what you want, as all models don't NEED to be tested at this depth.
#
# I'm always eager to hear new tips & suggestions as I'm still new to testing,
# so if you have any, please share!
#
# @kyletcarlson
#
# This skeleton also assumes you're using the following gems:
@michalwiacek
michalwiacek / postgres_backup.sh
Created May 22, 2020 23:11 — forked from kolosek/postgres_backup.sh
Script for making automatic dumps of postgres database sorted by date
#!/bin/bash
DIR=/home/httpd/DIR_LOCATION;
DB=(DATABASE_NAME);
DATE=$(/bin/date '+%Y%m%d');
TENDAY=$(/bin/date -d'10 days ago' '+%Y%m%d');
/bin/mkdir -p $DIR/$DATE/;
for d in "${DB[@]}"
do
pg_dump -f $DIR/$DATE/$d.sql $d;
#!/bin/bash
echo 'This script will set up your Ubuntu 18.04 for Rails development.'
echo 'Press ENTER to continue with installation, press ^C to cancel.'
read
# Install required software
echo "------Installing requirements------"
sudo apt install -y curl git-core gdebi-core gdebi rar unrar gnupg2 vim

Creality Ender 3

This page describes my experience with the Creality Ender 3.

  • Tweezers missing
  • Mini USB cable missing
  • No exposed serial port to attach e.g., an ESP8266

Need to check

  • Tension of belts. Too loose = bad print quality
@michalwiacek
michalwiacek / switch-to-rbenv.md
Created January 19, 2020 14:50 — forked from traumverloren/switch-to-rbenv.md
Switch from RVM to rbenv

Switch from RVM to rbenv:

Get Rid of RVM if it's installed:

rvm implode

Cleanup your .bash_profile/.bashrc/.zshrc file to remove RVM from the path:

You should have something like this left from RVM. Delete it from the file. ``[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"```

@michalwiacek
michalwiacek / app.DockerFile
Created November 13, 2019 23:52 — forked from satendra02/app.DockerFile
docker+rails+puma+nginx+postgres (Production ready)
FROM ruby:2.3.1
# Install dependencies
RUN apt-get update -qq && apt-get install -y build-essential libpq-dev nodejs
# Set an environment variable where the Rails app is installed to inside of Docker image:
ENV RAILS_ROOT /var/www/app_name
RUN mkdir -p $RAILS_ROOT
# Set working directory, where the commands will be ran:
@michalwiacek
michalwiacek / ruby_on_rails_deployment.md
Created November 12, 2019 23:21 — forked from zentetsukenz/ruby_on_rails_deployment.md
Deploy Ruby on Rails application with Docker Compose and Capistrano with ease

Docker

Files and Folders.

|
|\_ app
|...
|\_ docker
| |
@michalwiacek
michalwiacek / devise.rb
Created August 18, 2019 18:38 — forked from seyhunak/devise.rb
Devise, Sendgrid
config/initializers/devise.rb :
config.mailer_sender = "[email protected]"
config/environments/production.rb :
config.action_mailer.default_url_options = { :host => 'your.websitedomain.com' }
ActionMailer::Base.smtp_settings = {
:address => "smtp.sendgrid.net",
:port => "25",
:authentication => :plain,
package com.company;
import java.io.*;
import java.net.*;
public class FileClient{
public static void main(String[] args){
try(
Socket socket = new Socket("localhost", 8000);//Nawiızywanie po³ıczenia z serwerem