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 launched_for?(account) | |
@store.smembers(account_wise_key(account)).map(&:to_sym) | @store.smembers(everyone_key).map(&:to_sym) | |
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
def toggle_for_account(feature, account, launch = true) | |
method = launch ? :sadd : :srem | |
@store.send(method, account_wise_key(account), feature) | |
@store.send(method, feature_wise_key(feature), account) | |
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
# Opening the gates to everyone, or the general availability | |
LaunchParty.launch(feature: :custom_translations) | |
# Stop panicking and quickly roll back the feature from everyone | |
LaunchParty.rollback(feature: :custom_translations) |
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
# Launching a feature to an account | |
account.launch(:custom_translations) | |
# Checking if the feature has been launched | |
account.launched?(:custom_translations) | |
# Reverting the feature from an account | |
account.rollback(:custom_translations) | |
# Listing all the features turned on for the account |
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 names_and_emails_from_multiple_addresses(addresses) | |
if addresses.is_a? String | |
addresses = addresses.split(/,|;/) | |
end | |
addresses = addresses.collect do |address| | |
next if address.blank? | |
address = address.gsub('"','').gsub("'",'') | |
matches = address.strip.scan(/(\w[^<\>]*)<(\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,10}\b)\>\z|\A<!--?((\b[A-Z0-9._%+-]+)@[A-Z0-9.-]+\.[A-Z]{2,10}\b)-->?\z/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
#Converting seconds into HH::MM format | |
def get_time_in_hours seconds | |
Time.at(seconds).utc.strftime("%H:%M") | |
end | |
#Converting Time in HH:MM format or in decimal format into seconds | |
def convert_duration(duration) | |
if duration =~ /^([0-9]|0[0-9]|1[0-9]|2[0-3]):[0-5][0-9]$/ | |
time_pieces = duration.split(":") | |
hours = time_pieces[0].to_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
/** | |
* jQuery MD5 hash algorithm function | |
* | |
* <code> | |
* Calculate the md5 hash of a String | |
* String $.md5 ( String str ) | |
* </code> | |
* | |
* Calculates the MD5 hash of str using the » RSA Data Security, Inc. MD5 Message-Digest Algorithm, and returns that hash. | |
* MD5 (Message-Digest algorithm 5) is a widely-used cryptographic hash function with a 128-bit hash value. MD5 has been employed in a wide variety of security applications, and is also commonly used to check the integrity of data. The generated hash is also non-reversable. Data cannot be retrieved from the message digest, the digest uniquely identifies the data. |
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
<?php | |
define('FRESHDESK_SHARED_SECRET','____Place your Single Sign On Shared Secret here_____'); | |
define('FRESHDESK_BASE_URL','http://{{your-account}}.freshdesk.com/'); //With Trailing slashes | |
function getSSOUrl($strName, $strEmail) { | |
$timestamp = time(); | |
$to_be_hashed = $strName . FRESHDESK_SHARED_SECRET . $strEmail . $timestamp; | |
$hash = hash_hmac('md5', $to_be_hashed, FRESHDESK_SHARED_SECRET); | |
return FRESHDESK_BASE_URL."login/sso/?name=".urlencode($strName)."&email=".urlencode($strEmail)."×tamp=".$timestamp."&hash=".$hash; | |
} |
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
$('#agefrom').live('change',function() { | |
var age_from = parseInt($('#agefrom').val()); | |
var age_to = parseInt($('#ageto').val()); | |
if (age_to < age_from) { | |
$('#ageto option:selected').removeAttr('selected'); | |
if (age_from < 99) { | |
$('#ageto option[value="'+ String(age_from + 1) + '"]').attr('selected','selected'); | |
} else { |