Skip to content

Instantly share code, notes, and snippets.

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

Hello World

This is a test to:

@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
@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)

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 / 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']
@abdulsattar
abdulsattar / timelogger.md
Last active August 29, 2015 13:56
Timelogger

Develop a timelogger. It should allow you to record time spent doing a task and give you a summary of all the tasks you did on a given day/week.

Here's how it will work, you say timelogger <taskname>. <taskname> is the task you just did. You should store the current timestamp and the <taskname>. So, the time you spent on <taskname> is the difference between times of <taskname> and previous task. You won't count the amount of time for the very first task.

E.g.

$ timelogger arrived
$ timelogger coffee
$ timelogger school_one

Javascript event handler task

We decided to give you a small practice assignment about javascript event handlers. You need to create a very simple task manager:

  1. A list of tasks should be displayed.
  2. Every task should have a checkbox.
  3. The text of the task should be displayed in an input textbox.
  4. When you check the textbox, it must change the strike the task out. (See text-decoration: strike-through css property).
  5. When you click enter in a textbox, it must create a new task beneath the task currently being edited.
  6. When you press Ctrl+Enter, it must mark that task as completed. (Similar to checking the checkbox)
  7. When you press Ctrl+Backspace, delete the task.
@abdulsattar
abdulsattar / version
Created September 1, 2014 05:50
Complete VIM version
VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Jan 2 2014 19:39:47)
Included patches: 1-52
Modified by pkg-vim-maintainers@lists.alioth.debian.org
Compiled by buildd@
Huge version with GTK2-GNOME GUI. Features included (+) or not (-):
+acl +farsi +mouse_netterm +syntax
+arabic +file_in_path +mouse_sgr +tag_binary
+autocmd +find_in_path -mouse_sysmouse +tag_old_static
+balloon_eval +float +mouse_urxvt -tag_any_white
+browse +folding +mouse_xterm +tcl

Keybase proof

I hereby claim:

  • I am abdulsattar on github.
  • I am abdulsattar (https://keybase.io/abdulsattar) on keybase.
  • I have a public key whose fingerprint is 1C47 C754 0E53 16B6 1E2B 2D14 0809 9006 45E8 4429

To claim this, I am signing this object: