Skip to content

Instantly share code, notes, and snippets.

Avatar
👨‍💻
Shipping Code... Day & Night 🚀

Miłosz Osiński mosinski

👨‍💻
Shipping Code... Day & Night 🚀
View GitHub Profile
@mosinski
mosinski / Coverage Badges
Last active Oct 30, 2021
Coverage Badges
View Coverage Badges
Coverage Badges
View settings.rb
coś takiego:
# frozen_string_literal: true
class Shop::Settings
ALL_TERMINAL_LOCKERS_OPEN_ENABLED = "ALL_TERMINAL_LOCKERS_OPEN_ENABLED"
API_GATEWAY_NAME = "api_gateway_name"
ASSISTANCE_ENABLED = "ASSISTANCE_ENABLED"
CHECK_IN_FREE_LOCKER_ENABLED = "CHECK_IN_FREE_LOCKER_ENABLED"
CHECK_IN_MAILER_ENABLED = "CHECK_IN_MAILER_ENABLED"
CUSTOMER_CAR_SERVICE_SMS_ENABLED = "CUSTOMER_CAR_SERVICE_SMS_ENABLED"
View Jenkins.md
curl -u Jenkins:Jenkins -H "Content-Type: application/json" -X POST http://localhost:7990/rest/build-status/1.0/commits/$GIT_COMMIT -d '{"state":"INPROGRESS","key": "'$BUILD_TAG'","name": "Jenkins-'$BUILD_DISPLAY_NAME'", "url": "'$BUILD_URL'/consoleText","description": "Changes by '$GIT_COMMITTER_EMAIL'"}'

#!/bin/sh
cd ${WORKSPACE}
SUCCESS=true

gem install bundler --no-rdoc --no-ri || SUCCESS=false
bundle install || SUCCESS=false
bundle exec rake db:create || SUCCESS=false
View gist:b6c80416c45722bbca4400b5d7cc59eb
$cropper_width = $data['additional_product_information']['cropper_width'];
$cropper_height = $data['additional_product_information']['cropper_height'];
$cropper_x = $data['additional_product_information']['cropper_x'];
$cropper_y = $data['additional_product_information']['cropper_y'];
$filename = $data['additional_product_information']['thumbnail_url'];
header('Content-type: image/jpg');
header('Content-Disposition: attachment; filename='.$src);
$image = imagecreatefromjpeg($filename);
$crop = imagecreatetruecolor($cropper_width,$cropper_height);
imagecopy ( $crop, $image, 0, 0, $cropper_x, $cropper_y, $cropper_width, $cropper_height );
View gist:55cefacb9c9bcb0c2ca0
def index
puts '!!!!!!'
if current_user.sportsman?
@time_range = Date.today.at_beginning_of_month-6.days..Date.today.at_end_of_month+6.days
@trainings = Training.includes(:trainings_executions).where(start_date: @time_range, trainings_executions: {sportsman_id: current_user.id}).order(:start_time)
else
date = params[:start_date] ? params[:start_date].to_date : Date.today
@time_range = date.at_beginning_of_week..date.at_end_of_week
@training = Training.new
if current_user.coach?
View PG::Error: ERROR: new encoding (UTF8) is incompatible
======= Prolbem =================================================================================================================
I have installed : ruby-2.0.0,postgres-9.2 , now in rails app when I execute:
rake db:create , command I get:
PG::InvalidParameterValue: ERROR: new encoding (UTF8) is incompatible with the encoding of the template database (SQL_ASCII)
HINT: Use the same encoding as in the template database, or use template0 as template.
: CREATE DATABASE "my_db_name" ENCODING = 'unicode'.......
=================================================================================================================================
@mosinski
mosinski / only_numbers.js
Last active Aug 29, 2015
input allow only numbers
View only_numbers.js
$(function() {
$('input[type=number]').keydown(function (e) {
var key = e.which || e.keyCode;
if (!e.shiftKey && !e.altKey && !e.ctrlKey &&
// numbers
key >= 48 && key <= 57 ||
// Numeric keypad
key >= 96 && key <= 105 ||
// comma, period and minus, . on keypad
View gist:2409aa1ff1890e2f1b15
puts "Podaj tekst:"
t = gets.chomp.split(//)
puts "Podaj wzorzec:"
p = gets.chomp.split(//)
n, m = t.length, p.length
pPos, iPos = 0, 0
while iPos < n
View gist:f3c12bc1b0bc97a6b522
#!/usr/bin/ruby
require 'active_support/all'
@a = Array(1..ARGV[0].to_i)
def funkcja1(i)
if index = @a.index(i)
temp = @a.take(index).combination(2).to_a.delete_if { |a| a.sum != i }
@a.delete(i) if temp.empty?
puts "Funkcja1 i: #{i}"
View zad3
def PERM(n)
puts "#{@my_array[1..-1].inspect}"
for i in 1..(1..n).inject(:*)
a = 0
loop do
if a > 1 && a < n+1
temp = @temp_array[a]
if a - temp > 1
@temp_array[a] = temp + 1;
@my_array[B(a,temp+1)], @my_array[a] = @my_array [a], @my_array[B(a,temp+1)]