Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env ruby
# coding: utf-8
def header(s)
s = "⦿ #{s}"
puts
puts s
puts '=' * s.size
end

WhoIsPopularToday.com Integeration Guide

Who? needs some information to be able to index news:

  • news title
  • creation date in country timezone
  • URL to original article page

There are some optional information that could be benefecial for

Overview

This project consists of web services that is deployed with capistrano and docker-compose on a single server, and a set of interfaces, like a browser extension

Services

@emad-elsaid
emad-elsaid / natega.rb
Last active July 12, 2017 19:40 — forked from a7madM/natega.rb
require 'uri'
require 'net/http'
require 'pp'
require 'json'
seat_number = 427_300 # write start seat number
count = 10
(seat_number..seat_number + count).each do |seat|
url = URI('http://natega.youm7.com/Home/GetResultStage1/')
@emad-elsaid
emad-elsaid / graph.rb
Created July 9, 2017 20:54
graph a file as bars in terminal, or from standard input
#!/usr/bin/env ruby
# usage : graph file
# usage : cat file | graph
# file lines are casted to float so it has to start with a number
MAX_LENGTH = 80
BAR_CHAR = '|'.freeze
data = ARGV.empty? ? STDIN.read.lines : File.read(ARGV.first).lines
@emad-elsaid
emad-elsaid / unused-git-keep.sh
Last active July 4, 2017 15:30
It gets .keep files and count number of files in each directory that has .keep file, Unneeded git keep files will have a number greater than 1 in front of them
#!/usr/bin/env bash
for f in `git ls-files | grep "\..*keep"`; do
echo -n $f
git ls-files `dirname $f` | wc -l
done
#!/usr/bin/env ruby
require 'optparse'
options = {}
OptionParser.new do |opts|
opts.banner = 'Usage: ruby-methods-stats [options]... [file]...'
opts.on(
'-h',
'--help',
class User < ActiveRecord::Base
self.roles
@roles ||= %w(admin moderator contributor)
end
end
# > User.roles
# => ["admin", "moderator", "contributor"]
#!/usr/bin/env ruby
if ['--help', '-h'].include?(ARGV[0]) || ARGV.size != 2
puts <<-EOT
Make web application shortcut
Usage: makewebapp <name> <URL>
EOT
exit
end
@emad-elsaid
emad-elsaid / 90-custom-kbd.conf
Last active May 1, 2017 16:34
X11 config file to convert capslock to control, and swap left control with left alt (mac style kbd) /etc/X11/xorg.conf.d/90-custom-kbd.conf
Section "InputClass"
Identifier "keyboard defaults"
MatchIsKeyboard "on"
Option "XKbOptions" "caps:lctrl,ctrl:swap_lalt_lctl"
EndSection