Skip to content

Instantly share code, notes, and snippets.

View satblip's full-sized avatar

Louis Borsu satblip

View GitHub Profile
@emad-elsaid
emad-elsaid / chat.rb
Created March 1, 2014 13:18
creating simple network chat using ruby
require 'sinatra' # gem install sinatra --no-rdoc --no-ri
set :port, 3000
set :environment, :production
html = <<-EOT
<html><head><style>
#text{width:100%; font-size: 15px; padding: 5px; display: block;}
</style></head><body>
<input id="text" placeholder="Write then press Enter."/>
<div id="chat"></div>
@emad-elsaid
emad-elsaid / github.rb
Created March 5, 2014 12:53
post to gist
#!/usr/bin/env ruby
# Credits to :
# http://stackoverflow.com/questions/16365553/creating-gist-from-a-ruby-script
# i modified the script alittle bit to read files from params
require 'net/http'
require 'json'
uri = URI("https://api.github.com/gists")
@emad-elsaid
emad-elsaid / imagize.rb
Created March 12, 2014 12:47
highlight code and convert it to image using ruby
#!/usr/bin/env ruby
require 'pygmentize' # gem install pygmentize
require 'selenium-webdriver' # gem install selenium-webdriver
exit unless code_path = ARGV.shift
file_path = File.absolute_path 'code.html'
image_path = File.absolute_path 'code_image.png'
code = Pygmentize.process File.read(code_path), :ruby
html = <<-EOT
@emad-elsaid
emad-elsaid / gist-download.rb
Created March 14, 2014 13:01
Download your latest 30 Github Gists to local directory
#!/usr/bin/env ruby
require 'open-uri'
require 'json'
print 'Github Username: '
username = gets.chomp
# get gists
puts 'Downloading gists list'
gists_str = open("https://api.github.com/users/#{username}/gists").read
@emad-elsaid
emad-elsaid / matrix.rb
Created March 16, 2014 14:28
Create Matrix Like screen using Ruby
#!/usr/bin/env ruby
require 'gosu' # gem install gosu
$width, $height = 200, 200
$number_of_v_lines,$number_of_h_lines = 10, 10
$chars = ('a'..'z').to_a
class Entity
def initialize(x,y,vel, win)
@pos, @vel = {x:x, y:y}, vel
# IMPORTANT: this example is potentially out of date. The latest version can be found here: https://github.com/papertrail/remote_syslog2/blob/master/examples/remote_syslog.ebextensions.config
# See http://help.papertrailapp.com/kb/hosting-services/aws-elastic-beanstalk/
# Usage:
# - replace <VERSION> with the version of remote_syslog2 you want to use. Example: .../download/v0.14/remote_syslog_linux_amd64.tar.gz
# - replace <YOUR-TRACKED-FILES> with the files you want to monitor for new log lines. Example: - /var/log/httpd/access_log
# - replace <YOUR-APP-NAME> with the name of the application
# - replace <YOUR-LOG-DESTINATION> and <YOUR-PORT-NUMBER> with the values shown under log destinations: https://papertrailapp.com/account/destinations
sources:
@emad-elsaid
emad-elsaid / gmail2tumblr.rb
Created March 6, 2014 12:19
gmail to tumblr posting script
#!/usr/bin/env ruby
require 'mail' # gem install mail --no-document
# Credit to :
# http://stackoverflow.com/questions/12884711/how-to-send-email-via-smtp-with-rubys-mail-gem
def ask question
print "#{question} ? : "
$stdin.gets.chomp!
end
@chrisgilbert
chrisgilbert / gist:58f57c82f74162ed5c0f
Last active June 25, 2021 19:17
Run Ansible or Ansible-Playbook from Rundeck
#!/bin/bash
# Interpret whether the input needs to go to ansible, or ansible-playbook and run appropriately
# First update the git repos for each project
/usr/bin/update-git-repos
export ANSIBLE_FORCE_COLOR=1
export ANSIBLE_RETRY_FILES_ENABLED=False
@Iristyle
Iristyle / gist:5005653
Created February 21, 2013 15:53
Configure HAProxy for userlists

Create SHA512 passwords

# make sure to use a leading space so that the command is not stored in your bash history!!
 mkpasswd -m sha-512 password1
# generates -> $6$yMgsow58.g/Z$mBjHfdVzqcF/LN.iwV23Eyqg.yGPTsp9pOwaStsJ6c4I4zL7BhucVVAkv5guf7OVRr8Pw0mHF4NrWBRCG5ci7/
 mkpasswd -m sha-512 password2
# generates -> $6$RZ86vRkQ$aRKN1HOsk6bDHBbMhS7jSo/p1NGFl4PvwY3KpU.72i./LvITi41nL84EkxOFXl.6Bmhynj/L7pYbfF0rUHtOB0
@emad-elsaid
emad-elsaid / monitor-size.rb
Last active November 22, 2021 15:51
monitor directories sizes and take an action if one of them exceeded
#!/usr/bin/env ruby
seconds_to_wait = 1*60*60 # 1 hour
$directories_to_watch = {
'/Users/blaze/Desktop/folder1' => 1*1024, #bytes
'/Users/blaze/Desktop/folder2' => 1*1024 #bytes
}
def alert_size_exceeded directory, size
# you can replace this by an sending an email