This file contains 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 resolve(string) | |
string.gsub(/\d\[(.*?)\]/){|a| | |
formated = a.split("[")[1..-1].join("[") | |
if formated.include?('[') | |
resolve(formated) * a.split("[").first.to_i | |
else | |
a.split("[").last * a.split("[").first.to_i | |
end | |
}.gsub("]", "") |
This file contains 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 Matrix | |
def &(matrix) | |
Matrix.Raise ErrDimensionMismatch, "Matrix dimension mismatch" unless (row_count == matrix.row_count && column_count == matrix.column_count) | |
rows = Array.new(row_count) {|i| | |
Array.new(column_count) {|j| | |
self[i, j] & matrix[i, j] | |
} | |
} | |
new_matrix rows, matrix.column_count | |
end |
This file contains 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
function flatten(set, seen){ | |
var seen = seen ? seen : []; | |
for(var i=0; i<set.length; i++){ | |
if(Array.isArray(set[i])){ | |
flatten(set[i],seen) | |
}else{ | |
seen.push(set[i]) | |
} | |
} |
This file contains 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
# you can change the variable given_date to the date you want to be converted or run it directory form terminal like so | |
#ruby filename.rb year month day | |
#duby filename.rb 2000 1 1 | |
require "date" | |
arabic_months = { | |
1 => "Muharam", |
This file contains 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 "net/imap" | |
require "mail" | |
def connect_to_mail_server (username , password,server ="imap.google.com",post=993,ssl=true) | |
imap = Net::IMAP.new(server,port,ssl) | |
imap.login(username,password) | |
return imap | |
end | |
def get_access_to_mail_boxes imap |
This file contains 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
in angular js app | |
After sending delete request to your backend server it will be redirected by default to the otherwise url that you define to in the app.js file | |
so if you try to redirect after delete request using | |
$location.path ("URL"); | |
or | |
$scope.$apply($location.path("URL")); | |
or | |
$scope.$apply($location.path("URL")); | |
Error: $digest already in progress |