Skip to content

Instantly share code, notes, and snippets.

View mm580486's full-sized avatar
🎯
Focusing

mohammad mahmoodi mm580486

🎯
Focusing
View GitHub Profile
@mm580486
mm580486 / remove-emoji.rb
Last active January 27, 2021 14:30
remove emoji from string - ruby
# method base
def clean_emoji(str='')
str=str.force_encoding('utf-8').encode
arr_regex=[/[\u{1f600}-\u{1f64f}]/,/[\u{2702}-\u{27b0}]/,/[\u{1f680}-\u{1f6ff}]/,/[\u{24C2}-\u{1F251}]/,/[\u{1f300}-\u{1f5ff}]/]
arr_regex.each do |regex|
str = str.gsub regex, ''
end
return str
end
# sample
@fpauser
fpauser / rbenv-install-system-wide.sh
Last active December 30, 2020 21:53 — forked from jnx/rbenv-install-system-wide.sh
rbenv single & system-wide installation for Debian (tested with Debian 7.1) & Ubuntu (tested with Ubuntu 12.04 LTS)
# Update, upgrade and install development tools:
apt-get update
apt-get -y upgrade
apt-get -y install build-essential
apt-get -y install git-core
# Install rbenv
git clone https://github.com/sstephenson/rbenv.git /usr/local/rbenv
# Add rbenv to the path:
@gabceb
gabceb / gist:5113767
Created March 8, 2013 02:27
Handling 404, 401 and 500 exceptions on Rails
class ApplicationController < ActionController::Base
unless Rails.application.config.consider_all_requests_local
#rescue_from Exception, with: :render_500
rescue_from ActionController::RoutingError, with: :render_canvas_404
rescue_from ActionController::UnknownController, with: :render_404
rescue_from AbstractController::ActionNotFound, with: :render_404
rescue_from ActiveRecord::RecordNotFound, with: :render_404
rescue_from ActiveResource::ForbiddenAccess, with: :render_403
end
@Integralist
Integralist / web-server.rb
Created June 3, 2012 10:16
Create basic Web Server in Ruby (using WEBrick)
#!/usr/bin/env ruby
require "webrick"
=begin
WEBrick is a Ruby library that makes it easy to build an HTTP server with Ruby.
It comes with most installations of Ruby by default (it’s part of the standard library),
so you can usually create a basic web/HTTP server with only several lines of code.
The following code creates a generic WEBrick server on the local machine on port 1234,