Skip to content

Instantly share code, notes, and snippets.

@abdulsattar
abdulsattar / delete-song.rb
Created January 22, 2014 21:43
Delete the currently playing song in Rhythmbox
require 'dbus'
require 'uri'
require 'shellwords'
bus = DBus::SessionBus.instance
service = bus.service('org.gnome.Rhythmbox3')
object = service.object("/org/mpris/MediaPlayer2")
object.introspect
interface = object['org.mpris.MediaPlayer2.Player']
metadata = interface['Metadata']

Contact Manager

  1. Add new contacts. Should ask for name, email, phone number, address.
  2. List all contacts.(Display it prettily)
  3. Search all contacts and display if the search key matches anything (name/email/phone number/address). Display a serial number beside each search result.
  4. Edit a contact based on the serial number above.
  5. Delete a contact based on the serial number above.
@abdulsattar
abdulsattar / deploy.rb
Created January 5, 2014 16:31
Mina deploy script
require 'mina/bundler'
require 'mina/rails'
require 'mina/git'
require 'mina/rbenv' # for rbenv support. (http://rbenv.org)
# require 'mina/rvm' # for rvm support. (http://rvm.io)
# Basic settings:
# domain - The hostname to SSH to.
# deploy_to - Path to deploy into.
# repository - Git repo to clone from. (needed by mina/git)
@abdulsattar
abdulsattar / presence_validator.rb
Last active December 31, 2015 14:38
Rails like presence validator
module PresenceValidator
attr_reader :errors
def self.included(base)
base.extend(ClassMethods)
end
private
def validate
@errors = []
options = self.class.options

Hello World

This is a test to:

public int SumOfSquares()
{
int sum=0;
for(int i=1; i<=100; i++)
sum += i;
return sum;
}