This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| message.body.gsub(/https*:\/\/[a-zA-z0-9\-\.]*.[a-zA-Z]{2,4}\/[a-zA-Z0-9\/_.?=&;]*/){ |match| "<a href='#{match}' target='\_blank'>#{match}</a>" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Alarm | |
| def initialize(alarm_time,music = "/mount/data2/Songs/11.Mazhathullikal.mp3") | |
| @alarm_time = alarm_time | |
| @music = music | |
| @run = true | |
| end | |
| def its_time | |
| system("vlc #{@music} --volume 512") | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| doubled_array = [1,2,3,4].map{ |i| i*2 } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| a = [1,2,3,4] | |
| b = Array.new | |
| a.each do | |
| b << a * 2 | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def isLeapYear(yearVar) | |
| if (yearVar % 4 == 0) | |
| if (yearVar % 100 == 0) | |
| if(yearVar % 400 == 0) | |
| return true | |
| end | |
| return false | |
| end | |
| return true | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'csv' | |
| CSV.open("file_name.csv",'w") do |csv| | |
| csv << "what,ever,you,want,to,give,as,input" | |
| csv << "its,easy" | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| sudo apt-get install graphicsmagick-libmagick-dev-compat libmagickwand-dev | |
| sudo gem install rmagick | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| before_filter :check_and_redirect | |
| protected | |
| def check_and_redirect | |
| if current_user.user_level = "Admin" | |
| user = 'admin' | |
| landing_page = 'index' | |
| else | |
| user = 'user' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| before_filter :check_and_redirect | |
| protected | |
| def check_and_redirect | |
| if current_user.user_level = "Admin" | |
| redirect_to controller: 'admin', action: 'index' | |
| else | |
| redirect_to controller: 'user', action: 'index' | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import httplib | |
| c=httplib.HTTPConnection('localhost:9002') | |
| headers = {"Content-type": "text/xml;charset=UTF-8", "Accept": "text/xml"} | |
| params = """<ENVELOPE> | |
| <HEADER> | |
| <TALLYREQUEST>Export Data</TALLYREQUEST> | |
| </HEADER> | |
| <BODY> | |
| <EXPORTDATA> | |
| <REQUESTDESC> |