Skip to content

Instantly share code, notes, and snippets.

View khalilovcmd's full-sized avatar
🏠
Working from home

Tarek Khalil khalilovcmd

🏠
Working from home
View GitHub Profile
module Rendering
module Slack
module Processors
class EnhancedProcessor < ::SlackMarkdown::Processor
def filters
@filters ||= [
::SlackMarkdown::Filters::ConvertFilter,
::SlackMarkdown::Filters::MultipleQuoteFilter,
::SlackMarkdown::Filters::QuoteFilter,
{
"attachments": [
{
"color": "#36a64f",
"pretext": "Some pretext",
"author_name": "Jasmine Jaume",
"text": "Some text",
"image_url": "http://example-website.com/image.jpg"
}
]
document = ::Nokogiri::HTML::fragment(text)
document.search("h1,h2,h3").each do |header|
 header.replace("*#{header.text}*")
end
module Rendering
module Parts
class Note < Reply
include ::Services::Slack::Rendering::Mixins::TeammateAuthor
def attachment_color
ATTACHMENT_COLOR
end
def fallback
class PartRenderer < Renderer
PART_MAPPING = {
"note" => ::Services::Slack::Rendering::Parts::Note,
....
....
....
}
def render(context)
PART_MAPPING[part_type].new(context).render
module Rendering
class MessageRenderer
class SlackMessage; end
class SlackAttachment; end
class SlackAttachmentField; end
class SlackAttachmentAction; end
def initialize(context = Context.new)
end
@khalilovcmd
khalilovcmd / logger.js
Last active July 8, 2019 14:18 — forked from rtgibbons/logger.js
Logger Library with winston
var winston = require('winston');
var fs = require('fs');
// check if directory exist
if (!fs.existsSync('logs')) {
fs.mkdirSync('logs'); // create new directory
}
// Set up logger
var customColors = {
@khalilovcmd
khalilovcmd / lodashify.js
Created December 19, 2015 15:20
to import lodash into chrome dev tools console
var el = document.createElement('script');
el.src = "https://raw.githubusercontent.com/lodash/lodash/3.10.1/lodash.min.js";
el.type = "text/javascript";
document.head.appendChild(el)
@khalilovcmd
khalilovcmd / server-density.sh
Last active December 16, 2015 11:21
installing server density redis plugin on a linux machine (server density agent version 1)
# download sd-agent v1.4.1, then run .sh
wget https://raw.githubusercontent.com/serverdensity/sd-agent/master/install.sh
chmod +x install.sh
./install.sh -a xxxxxxx -k xxxxxxxxxxxxxxxxxxxxxxxxxxx
# python and pip need to be installed
pip install redis
# edit sd-agent config file
vi /etc/sd-agent/config.cfg
@khalilovcmd
khalilovcmd / heroku-getting-started.sh
Last active December 9, 2015 11:12
installing heroku, and getting started
# download heroku
wget -O- https://toolbelt.heroku.com/install-ubuntu.sh | sh
# login to heroku
heroku login
# create heroku-git link (adding a heroku remote)
heroku create
# pushing a commit to heroku