Skip to content

Instantly share code, notes, and snippets.

View trushkevich's full-sized avatar

Anton Trushkevich trushkevich

View GitHub Profile
@medfreeman
medfreeman / Dockerfile
Last active September 6, 2023 20:32
docker / mongo replicaSet
ARG MONGO_VERSION
FROM mongo:${MONGO_VERSION}
RUN mkdir -p /data/keyfile
RUN openssl rand -base64 741 > /data/keyfile/keyfile
RUN chown -R mongodb:mongodb /data/keyfile
RUN chmod 600 /data/keyfile/keyfile
@0xjac
0xjac / private_fork.md
Last active May 6, 2024 13:25
Create a private fork of a public repository

The repository for the assignment is public and Github does not allow the creation of private forks for public repositories.

The correct way of creating a private frok by duplicating the repo is documented here.

For this assignment the commands are:

  1. Create a bare clone of the repository. (This is temporary and will be removed so just do it wherever.)

git clone --bare git@github.com:usi-systems/easytrace.git

@achmadns
achmadns / activate-rabbitmqadmin.sh
Created March 7, 2016 07:26
Activate rabbitmqadmin
#/bin/bash
# these action should be run with sudo level
# activate management plugin first
rabbitmq-plugins enable rabbitmq_management
# restart the rabbitmq-server
service rabbitmq-server restart
# download the rabbitmqadmin script locally
@maxivak
maxivak / readme.md
Last active August 5, 2019 08:47
Install TinyMCE editor 4 with Elfinder file manager in Rails 4 app

TinyMCE with file manager

This post shows how to use TinyMCE 4.1 WYSIWYG text editor in a Rails 4 application for editing content in a textarea field.

TinyMCE is a powerful online WYSIWYG editor with many plugins.

If you want to insert an image by selecting it from images stored on server or upload an image to server, then you need to have a file manager with tinyMCE. TinyMCE comes with a file manager which is not free.

elFinder is an open-source file manager which can be easily integrated with tinyMCE 4.1.

@eyecatchup
eyecatchup / hsvToRgb.js
Last active March 7, 2021 23:32
HSV to RGB color conversion - JavaScript-Port from the excellent java algorithm by Eugene Vishnevsky at http://www.cs.rit.edu/~ncs/color/t_convert.html
/**
* HSV to RGB color conversion
*
* H runs from 0 to 360 degrees
* S and V run from 0 to 100
*
* Ported from the excellent java algorithm by Eugene Vishnevsky at:
* http://www.cs.rit.edu/~ncs/color/t_convert.html
*/
function hsvToRgb(h, s, v) {
@peter
peter / carrierwave-file-size-limit-example.rb
Created March 7, 2014 09:17
Checking and Limiting File Size of Uploaded Files with Carrierwave
# NOTE: There must be a better way to do this - help appreciated!
###############################################################
# uploaded_file.rb - utility class
###############################################################
class UploadedFile
def self.size(file)
uploaded?(file) ? file.size : nil
end
@mrbrdo
mrbrdo / rails_group_count.rb
Last active June 6, 2018 11:29
Rails ActiveRecord / ActiveRelation grouped count as integer (sum of counts for each group). Tested on Postgres This can be used for Kaminari too (speeds up total_pages and total_count considerably).
module ActiveRecordGroupCount
extend ActiveSupport::Concern
module ExtensionMethods
def count(*args)
scope = except(:select).select("1")
query = "SELECT count(*) AS count_all FROM (#{scope.to_sql}) x"
ActiveRecord::Base.connection.execute(query).first.try(:[], "count_all").to_i
end
end
@andrewpthorp
andrewpthorp / coderay.css
Created March 11, 2013 13:02
A CodeRay theme to get GitHub style code coloring.
.CodeRay {
background-color: #efefef;
font-family: Monaco, "Courier New", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", monospace;
color: #000;
margin-bottom: 14px;
}
.CodeRay pre {
margin: 0px;
padding: 1em;
@KartikTalwar
KartikTalwar / Documentation.md
Last active April 13, 2024 23:09
Rsync over SSH - (40MB/s over 1GB NICs)

The fastest remote directory rsync over ssh archival I can muster (40MB/s over 1gb NICs)

This creates an archive that does the following:

rsync (Everyone seems to like -z, but it is much slower for me)

  • a: archive mode - rescursive, preserves owner, preserves permissions, preserves modification times, preserves group, copies symlinks as symlinks, preserves device files.
  • H: preserves hard-links
  • A: preserves ACLs
@datenimperator
datenimperator / Gemfile
Created September 7, 2012 18:55
Sinatra, sprockets, compass, bootstrap-sass playing together
source :rubygems
gem 'shotgun', :group=>:development
gem 'rack-cache'
gem 'sinatra', :require => 'sinatra/base'
gem 'sinatra-support'
gem 'haml'