idx int64 0 24.9k | question stringlengths 68 4.14k | target stringlengths 9 749 |
|---|---|---|
19,900 | def create_unit ( type , attributes : { } ) "#{self.class.name.split('::').first}::#{type.to_s.camelize}" . constantize . new ( options : unit_options , logger : logger ) . tap do | unit | { src : :source , dst : :destination } . each do | k , v | unit . send "#{v}=" . to_sym , attributes [ k ] unless attributes [ k ] ... | Creates a new unit object for the collection . |
19,901 | def unit_options options = { } return options unless manifest %i( root package_tool ) . each do | k | options [ k ] = manifest [ k ] unless manifest [ k ] . nil? end options end | Load basic unit options from the manifest . |
19,902 | def install_unit ( unit , type , quiet = false ) success = unit . install logger . info do "Installed #{type_name(type)}: #{unit.source} => #{unit.destination_path}" end unless quiet || ! success return true rescue Unit :: InstallFailed => e logger . fatal { "Halting install! Install attempt failed for #{type_name(type... | Installs a unit . |
19,903 | def install_unit? ( unit , type , quiet = false ) unit . install? logger . info do "Testing install for #{type_name(type)}:" " #{unit.source} => #{unit.destination_path}" end unless quiet return true rescue Unit :: InstallFailed => e logger . error { "Cannot install #{type_name(type)}: #{e}" } return false end | Checks if a unit can be installed . |
19,904 | def execute ( node , arguments ) if run_as_pseudo_tty? node . pseudo_tty command else node . run command end rescue Interrupt puts "\nExiting gracefully from interrupt\n" . warning end | In which the bcome context is a shortcut to a more complex command |
19,905 | def process_options options options = options . clone [ :left , :right ] . each do | key | if options . key? ( key ) && ! ( options [ key ] . nil? ) options [ key ] = File . expand_path options [ key ] end end options end | Creates a new Controller |
19,906 | def run if @options [ :list_assemblers ] puts @assemblerman . list_assemblers return elsif @options [ :install_assemblers ] @assemblerman . install_assemblers ( @options [ :install_assemblers ] ) return end if ( @options [ :left ] . nil? || @options [ :right ] . nil? ) logger . error "Reads must be provided with --left... | Runs the program |
19,907 | def init_settings s = Biopsy :: Settings . instance s . set_defaults libdir = File . dirname ( __FILE__ ) s . target_dir = [ File . join ( libdir , 'assemblers/' ) ] s . objectives_dir = [ File . join ( libdir , 'objectives/' ) ] logger . debug "initialised Biopsy settings" end | Initialise the Biopsy settings with defaults setting target and objectiv directories to those provided with Assemblotron |
19,908 | def write_metadata res File . open ( @options [ :output_parameters ] , 'wb' ) do | f | f . write ( JSON . pretty_generate ( res ) ) end end | Write out metadata from the optimisation run |
19,909 | def subsample_input if @options [ :skip_subsample ] logger . info "Skipping subsample step (--skip-subsample is on)" @options [ :left_subset ] = @options [ :left ] @options [ :right_subset ] = @options [ :right ] return end logger . info "Subsampling reads" seed = @options [ :seed ] seed = Time . now . to_i if seed == ... | Run the subsampler on the input reads storing the paths to the samples in the assembler_options hash . |
19,910 | def merge_assemblies res l = @options [ :left ] r = @options [ :right ] transfuse = Transfuse :: Transfuse . new ( @options [ :threads ] , false ) assemblies = res . each_value . map { | assembler | assember [ :final ] } scores = transfuse . transrate ( assemblies , l , r ) filtered = transfuse . filter ( assemblies , ... | Merge the final assemblies |
19,911 | def all_settings settings = { } instance_variables . each do | var | key = var [ 1 .. - 1 ] settings [ key ] = self . instance_variable_get ( var ) end settings end | Returns a hash of the settings |
19,912 | def draw_rectangle ( point , size , z_index , colour ) left = point . x top = point . y width = size . width height = size . height draw_quad ( left , top , colour , left + width , top , colour , left + width , top + height , colour , left , top + height , colour , z_index ) end | Simplify drawing a rectangle in a single colour . |
19,913 | def draw_simple_line ( p1 , p2 , z_index , colour ) draw_line ( p1 . x , p1 . y , colour , p2 . x , p2 . y , colour , z_index ) end | Simplify drawing a line . |
19,914 | def centred_in ( text , rect ) size = measure ( text ) Point ( ( rect . width - size . width ) / 2 , ( rect . height - size . height ) / 2 ) end | Return the co - ordnates needed to place a given string in the centre of an area both vertically and horizontally . |
19,915 | def new_brb_out_request ( meth , * args , & blck ) Thread . current [ :brb_nb_out ] ||= 0 Thread . current [ :brb_nb_out ] += 1 raise BrBCallbackWithBlockingMethodException . new if is_brb_request_blocking? ( meth ) and block_given? block = ( is_brb_request_blocking? ( meth ) or block_given? ) ? Thread . current . to_s... | Execute a request on a distant object |
19,916 | def new_brb_in_request ( meth , * args ) if is_brb_request_blocking? ( meth ) m = meth . to_s m = m [ 0 , m . size - 6 ] . to_sym idrequest = args . pop thread = args . pop begin r = ( ( args . size > 0 ) ? @object . send ( m , * args ) : @object . send ( m ) ) brb_send ( [ ReturnCode , r , thread , idrequest ] ) rescu... | Execute a request on the local object |
19,917 | def diff ( other ) require_dep! 'awesome_spawn' require_cmd! diff_cmd out = nil begin this_dir = unpack other_dir = if other . is_a? ( Polisher :: Gem ) other . unpack elsif other . is_a? ( Polisher :: Git :: Repo ) other . path else other end result = AwesomeSpawn . run ( "#{diff_cmd} -r #{this_dir} #{other_dir}" ) ou... | Return diff of content in this gem against other |
19,918 | def push_token return params [ :pushToken ] if params . include? ( :pushToken ) if request && request . body request . body . rewind json_body = JSON . parse ( request . body . read ) if json_body [ 'pushToken' ] json_body [ 'pushToken' ] end end end | Convienience method for parsing the pushToken out of a JSON POST body |
19,919 | def generate siba_file . run_this do file_path = @name . gsub / \. / , "" file_path += ".yml" file_path = siba_file . file_expand_path file_path if siba_file . file_file? ( file_path ) || siba_file . file_directory? ( file_path ) raise Siba :: Error , "Options file already exists: #{file_path}" end options_data = [ ] S... | Generates yaml options file and returns its path |
19,920 | def add_brahmic_scheme ( name , scheme ) name = name . to_sym scheme = scheme . deep_dup @schemes [ name ] = IceNine . deep_freeze ( scheme ) @brahmic_schemes . add ( name ) @scheme_names . add ( name ) scheme end | Add a Brahmic scheme to Sanscript . |
19,921 | def add_roman_scheme ( name , scheme ) name = name . to_sym scheme = scheme . deep_dup scheme [ :vowel_marks ] = scheme [ :vowels ] [ 1 .. - 1 ] unless scheme . key? ( :vowel_marks ) @schemes [ name ] = IceNine . deep_freeze ( scheme ) @roman_schemes . add ( name ) @scheme_names . add ( name ) scheme end | Add a roman scheme to Sanscript . |
19,922 | def transliterate ( data , from , to , ** opts ) from = from . to_sym to = to . to_sym return data if from == to raise SchemeNotSupportedError , from unless @schemes . key? ( from ) raise SchemeNotSupportedError , to unless @schemes . key? ( to ) data = data . to_str . dup options = @defaults . merge ( opts ) map = mak... | Transliterate from one script to another . |
19,923 | def run ( program , * arguments ) program = program . to_s arguments = arguments . map { | arg | arg . to_s } system ( program , * arguments ) end | Runs a program locally . |
19,924 | def mkdir_p ( path ) stdout , stderr , _ , _ = exec ( "mkdir -p #{path.inspect}" , :with_codes => true ) if stderr =~ / / base . say_status :permission_error , stderr , :red raise PermissionError , "unable to create directory #{path}" end end | Creates the directory at the path on the remote server |
19,925 | def validate_args ( args : { } , requested_args : [ ] , default_args : { } ) requested_args . each do | requested_arg | raise "Cell must have #{requested_arg} argument" if args [ requested_arg ] == nil end default_args . each do | key , value | args [ key ] = value if args [ key ] == nil end args end | This function is used from cells to validates arguments on constructor . |
19,926 | def command? ( command ) MakeMakefile :: Logging . instance_variable_set :@logfile , File :: NULL MakeMakefile :: Logging . quiet = true MakeMakefile . find_executable command . to_s end | Checks if command exists . |
19,927 | def find_resource ( controller ) ( controller . enclosing_resource ? controller . enclosing_resource . send ( source ) : klass ) . find controller . params [ key ] end | finds the resource on a controller using enclosing resources or resource class |
19,928 | def find_resource ( controller ) ResourcesController . raise_cant_find_singleton ( name , klass ) unless controller . enclosing_resource controller . enclosing_resource . send ( source ) end | finds the resource from the enclosing resource . Raise CantFindSingleton if there is no enclosing resource |
19,929 | def find_root Pathname . pwd . ascend do | root | config_dir = root . join ( Project :: CONFIG_DIR ) if config_dir . directory? config_file = config_dir . join ( Project :: CONFIG_FILE ) return root if config_file . file? environments_dir = config_dir . join ( Project :: ENVIRONMENTS_DIR ) return root if environments_d... | Finds the root of the project starting at the current working directory and ascending upwards . |
19,930 | def dimension_reduce ( results ) total = 0 results . each_value do | value | o = value [ :optimum ] w = value [ :weighting ] a = value [ :result ] m = value [ :max ] total += w * ( ( ( o - a ) / m ) ** 2 ) if m != 0 end Math . sqrt ( total ) / results . length end | Perform a euclidean distance dimension reduction of multiple objectives |
19,931 | def bot_post ( id , text , options = { } ) data = { :bot_id => id , :text => text } data [ :options ] = options if options . any? post ( '/bots/post' , data ) . status == 202 end | Post a message from a bot . |
19,932 | def create_bot ( name , group_id , options = { } ) data = { :bot => options . merge ( :name => name , :group_id => group_id ) } post ( '/bots' , data ) end | Create a new bot . |
19,933 | def preview_to ( recipient ) @newsletter = build_newsletter mail = build_mail mail . to = recipient . email replace_and_send_mail_safely ( mail , recipient ) end | Send a preview email |
19,934 | def send_emails mail = build_mail get_recipients do | recipient | unless EmailResponse . exists? ( email : recipient . email ) mail . to = recipient . email replace_and_send_mail_safely ( mail , recipient ) end end end | Iterate over recipients and sends emails |
19,935 | def replace_and_send_mail_safely ( mail , recipient ) html_body = mail . html_part . body . raw_source do_custom_replacements_for ( mail , recipient ) send_raw_email_safely ( mail ) mail . html_part . body = html_body end | Perform custom replacements and send the email without throwing any exception |
19,936 | def build_mail AwsSesNewsletters :: MailBuilder . new ( from : newsletter . from , subject : newsletter . subject , html_body : newsletter . html_body , images : get_images , ) . build end | Builds a Mail |
19,937 | def get_discount_payments ( cart_id ) discount_payments = Auth . configuration . payment_class . constantize . where ( :cart_id => cart_id , :discount_id . nin => [ "" , nil ] , :payment_status => 1 ) discount_payments end | will return discount_payments of this cart id with a payments_status of 1 . |
19,938 | def get_sum_of_discount_payments ( cart_id ) sum_of_discount_payments = 0 get_discount_payments ( cart_id ) . each do | dp | sum_of_discount_payments += dp . amount end sum_of_discount_payments end | will return the sum of the amounts of all successfull discount_payments . |
19,939 | def core__read_yaml ( file_path ) return unless File . exist? ( file_path ) config_file = File . read ( file_path ) return YAML . safe_load ( config_file ) . with_indifferent_access rescue nil end | This function takes a path to a yaml file and return the hash with yaml data or nil if file not exist . |
19,940 | def core__paginate_array ( array , per_page , page ) start = ( page - 1 ) * per_page array [ start , per_page ] end | This function paginate an array and return the requested page . |
19,941 | def core__add_param_to_url ( url , param_name , param_value ) uri = URI ( url ) params = URI . decode_www_form ( uri . query || "" ) << [ param_name , param_value ] uri . query = URI . encode_www_form ( params ) uri . to_s end | This function add a new GET param to an url string . |
19,942 | def targets @targets ||= Dir . glob ( File . join ( target_dir , '*.rb' ) ) . collect { | t | t . gsub ( "#{target_dir}/" , '' ) . gsub ( '.rb' , '' ) . intern } end | Targets to check |
19,943 | def load_target ( target ) raise ArgumentError , target unless targets . include? ( target ) require "polisher/adaptors/version_checker/#{target}" tm = target_module ( target ) @target_modules ||= [ ] @target_modules << tm include tm end | Load specified target |
19,944 | def activities_from_to ( query , default_from , default_to ) defaults = { "range" => { "from" => default_from , "to" => default_to } } query = defaults . deep_merge ( query ) from = query [ "range" ] [ "from" ] . to_i to = query [ "range" ] [ "to" ] . to_i if from >= to query [ "range" ] [ "from" ] = default_from query... | the default from is the beginning of the current month and the default to is the current time . |
19,945 | def activities_fields ( query ) defaults = { "only" => Object . const_get ( name ) . fields . keys } query = defaults . deep_merge ( query ) only = ( ( Object . const_get ( name ) . fields . keys & query [ "only" ] ) + [ "created_at" ] ) query [ "only" ] = only return query end | defaults for only . if it is empty or nil then it becomes all attributes otherwise it becomes the intersect of all attributes and the ones specified in the only created_at had to be added here because otherwise it throws an error saying missing_attribute in the only . I think this has something to do with the fact that... |
19,946 | def start if File . exists? CONFIG_PATH if Config . missing_configurables . size > 0 Prometheus :: ConfigCommands . new . invoke :repair else super end else Prometheus :: ConfigCommands . new . invoke :edit end end | Make sure the user has a complete config before continuing . |
19,947 | def [] ( id ) return @users [ id ] if id . start_with? '@' res = @users . find { | _ , u | u . displayname == id } res . last if res . respond_to? :last end | Initializes a new Users instance . Gets a user by ID or display name . |
19,948 | def process_power_levels ( room , data ) data . each do | id , level | get_user ( id ) . process_power_level room , level end end | Process power level updates . |
19,949 | def process_invite ( room , event ) sender = get_user ( event [ 'sender' ] ) invitee = get_user ( event [ 'state_key' ] ) invitee . process_invite room , sender , event end | Process an invite event for a room . |
19,950 | def get_user ( id ) return @users [ id ] if @users . key? id user = User . new id @users [ id ] = user broadcast ( :added , user ) user end | Get the user instance for a specified user ID . If an instance does not exist for the user one is created and returned . |
19,951 | def nested_in ( * names , & block ) options = names . extract_options! raise ArgumentError , "when giving more than one nesting, you may not specify options or a block" if names . length > 1 and ( block_given? or options . length > 0 ) if options . delete ( :polymorphic ) raise ArgumentError , "when specifying :polymor... | Specifies that this controller has a particular enclosing resource . |
19,952 | def ensure_sane_wildcard idx = specifications . length while ( idx -= 1 ) >= 0 if specifications [ idx ] == '*' raise ArgumentError , "Can only specify one wildcard '*' in between resource specifications" elsif specifications [ idx ] . is_a? ( Specification ) break end end true end | ensure that specifications array is determinate w . r . t route matching |
19,953 | def load_enclosing_resources namespace_segments . each { | segment | update_name_prefix ( "#{segment}_" ) } specifications . each_with_index do | spec , idx | case spec when '*' then load_wildcards_from ( idx ) when / \? / then load_wildcard ( $1 ) else load_enclosing_resource_from_specification ( spec ) end end end | this is the before_action that loads all specified and wildcard resources |
19,954 | def load_wildcards_from ( start ) specs = specifications . slice ( start .. - 1 ) encls = nesting_segments . slice ( enclosing_resources . size .. - 1 ) if spec = specs . find { | s | s . is_a? ( Specification ) } spec_seg = encls . index ( { :segment => spec . segment , :singleton => spec . singleton? } ) or Resources... | loads a series of wildcard resources from the specified specification idx |
19,955 | def destroy ( * args ) resource = find ( * args ) if enclosing_resource service . destroy ( * args ) resource else resource . destroy end end | find the resource If we have a resource service we call destroy on it with the reosurce id so that any callbacks can be triggered Otherwise just call destroy on the resource |
19,956 | def get_permission_name permission = CONFIGS [ :lato_core ] [ :superusers_permissions ] . values . select { | x | x [ :value ] === self . permission } return permission [ 0 ] [ :title ] if permission && ! permission . empty? end | This function return the permission name for the user . |
19,957 | def sync ( filter : nil , since : nil , full_state : false , set_presence : true , timeout : 30_000 ) options = { full_state : full_state } options [ :since ] = since if since options [ :set_presence ] = 'offline' unless set_presence options [ :timeout ] = timeout if timeout options [ :filter ] = parse_filter filter ma... | Synchronize with the latest state on the server . |
19,958 | def search ( from : nil , options : { } ) make_request ( :post , '/search' , params : { next_batch : from } , content : options ) . parsed_response end | Performs a full text search on the server . |
19,959 | def make_request ( method , path , opts = { } , & block ) path = ( opts [ :base ] || @base_uri ) + URI . encode ( path ) options = make_options opts [ :params ] , opts [ :content ] , opts [ :headers ] parse_response METHODS [ method ] . call ( path , options , & block ) end | Helper method for performing requests to the homeserver . |
19,960 | def make_options ( params , content , headers = { } ) { headers : headers } . tap do | o | o [ :query ] = @access_token ? { access_token : @access_token } : { } o [ :query ] . merge! ( params ) if params . is_a? Hash o . merge! make_body content end end | Create an options Hash to pass to a server request . |
19,961 | def make_body ( content ) key = content . respond_to? ( :read ) ? :body_stream : :body value = content . is_a? ( Hash ) ? content . to_json : content { key => value } end | Create a hash with body content based on the type of content . |
19,962 | def parse_response ( response ) case response . code when 200 response else handler = ERROR_HANDLERS [ response . code ] raise handler . first . new ( response . parsed_response ) , handler . last end end | Parses a HTTParty Response object and returns it if it was successful . |
19,963 | def parse_filter ( filter ) filter . is_a? ( Hash ) ? URI . encode ( filter . to_json ) : filter end | Parses a filter object for use in a query string . |
19,964 | def command ( index , & block ) if index . is_a? Command cmd = index else cmd = Command . new cmd . index = index cmd . instance_eval ( & block ) end @commands = { } unless @commands @flags = [ ] unless @flags if cmd . flags? @flags << cmd . flags . short if cmd . flags . short? @flags << cmd . flags . long if cmd . fl... | An application usually has multiple commands . |
19,965 | def parse @commands . each do | _ , cmd | if cmd . flags? next unless argv_index = ARGV . index ( cmd . flags . short ) || ARGV . index ( cmd . flags . long ) else next unless argv_index = ARGV . index ( cmd . index . to_s ) end cmd . given = true unless argv_index . nil? if cmd . type . nil? yield cmd if block_given? ... | Parse arguments off of ARGV . |
19,966 | def parse_cmd ( cmd , flags ) if cmd . flags? args = Raw . arguments_to ( cmd . flags . short , flags ) if args . nil? || args . empty? args = Raw . arguments_to ( cmd . flags . long , flags ) end else args = Raw . arguments_to ( cmd . index . to_s , flags ) end unless cmd . type . to_s =~ / / return nil if args . nil?... | Parse a given command with its given flags . |
19,967 | def []= ( key , value ) if config = configs [ key ] config . set ( receiver , value ) else store [ key ] = value end end | Stores a value for the key either on the receiver or in the store . |
19,968 | def merge! ( another ) configs = self . configs another . each_pair do | key , value | if config = configs [ key ] config . set ( receiver , value ) else store [ key ] = value end end self end | Merges another with self . |
19,969 | def each_pair configs . each_pair do | key , config | yield ( key , config . get ( receiver ) ) end store . each_pair do | key , value | yield ( key , value ) end end | Calls block once for each key - value pair stored in self . |
19,970 | def to_hash hash = { } each_pair do | key , value | if value . kind_of? ( ConfigHash ) value = value . to_hash end hash [ key ] = value end hash end | Equal if the to_hash values of self and another are equal . Returns self as a hash . Any ConfigHash values are recursively hashified to account for nesting . |
19,971 | def decipher_ecb ( key , input , strip_padding : true ) plain = decipher_ecb_blockwise ( CryptBuffer ( key ) , CryptBuffer ( input ) . chunks_of ( @block_size_bytes ) ) . to_crypt_buffer strip_padding ? plain . strip_padding : plain end | NOTE convert ECB encryption to AES gem or both to openssl |
19,972 | def unicipher_cbc ( direction , key_str , input_buf , iv ) method = "#{direction.to_s}_cbc_block" blocks = input_buf . chunks_of ( @block_size_bytes ) iv ||= blocks . shift . str key = CryptBuffer ( key_str ) . hex prev_block = iv . to_crypt_buffer strings = blocks . map . with_index do | block , i | ctext_block = send... | this method is used for encipher and decipher since most of the code is identical only the value of the previous block and the internal ecb method differs |
19,973 | def generate_answer ( question , top = 1 ) response = @http . post ( "#{BASE_URL}/#{@knowledgebase_id}/generateAnswer" , json : { question : question , top : top } ) case response . code when 200 response . parse [ 'answers' ] . map do | answer | Answer . new ( answer [ 'answer' ] . normalize , answer [ 'questions' ] .... | Returns the list of answers for the given question sorted in descending order of ranking score . |
19,974 | def cell ( * names ) names_list = names . first . to_s . start_with? ( 'Lato' ) ? names [ 1 .. - 1 ] : names cell_class = names . first . to_s . start_with? ( 'Lato' ) ? "#{names.first}::" : 'LatoCore::' names_list . each do | name | cell_class = "#{cell_class}#{name.capitalize}::" end "#{cell_class}Cell" . constantize... | This helper is used to create a new cell with a pretty format . |
19,975 | def require_delete_permission unless @folder . is_root? || boxroom_current_user . can_delete ( @folder ) redirect_to @folder . parent , :alert => t ( :no_permissions_for_this_type , :method => t ( :delete ) , :type => t ( :this_folder ) ) else require_delete_permissions_for ( @folder . children ) end end | Overrides require_delete_permission in ApplicationController |
19,976 | def method_call_path ( method_call_tag ) name , receiver , scope = method_call_tag . values_at ( :name , :receiver , :scope ) scope = scope . join ( "::" ) if receiver == :class scope = "Kernel" if scope . empty? new_method_path ( scope , :class , name ) elsif receiver == :instance scope = "Kernel" if scope . empty? ne... | method_call_tag is the scanner event tag emitted by ReflexiveRipper |
19,977 | def validate_address! ( addr ) ip = IPAddr . new ( addr ) unless ip . ipv4? raise NotImplementedError , 'Only IPv4 is supported by this library' end if addr . include? ( '/' ) raise ArgumentError , 'Please specify a host IP address (without mask)' end addr . to_s end | Validate that the given string is a valid IP address . |
19,978 | def cast_value ( value ) return value if value . blank? return value if form_options . is_a? Proc return field_options [ :cast ] . call ( value ) if field_options [ :cast ] . is_a? Proc case form_options [ :as ] when :bs_datetimepicker if value . is_a? String DateTime . parse ( value ) elsif value . is_a? Date value . ... | Esegue un casting dei valori rispetto al tipo di campo da utilizzare per formtastic |
19,979 | def get ( uri ) uri = Resync :: XML . to_uri ( uri ) @helper . fetch ( uri : uri ) end | Gets the content of the specified URI as a string . |
19,980 | def download_to_temp_file ( uri ) uri = Resync :: XML . to_uri ( uri ) @helper . fetch_to_file ( uri : uri ) end | Gets the content of the specified URI and saves it to a temporary file . |
19,981 | def download_to_file ( uri : , path : ) uri = Resync :: XML . to_uri ( uri ) @helper . fetch_to_file ( path : path , uri : uri ) end | Gets the content of the specified URI and saves it to the specified file overwriting it if it exists . |
19,982 | def core__get_modules_list all_gems = core__get_application_gems . keys lato_gems = [ ] all_gems . each do | name | lato_gems . push ( name ) if name . start_with? 'lato' end lato_gems end | This function returns the list of lato modules installed on main application . |
19,983 | def core__get_module_languages ( module_name ) default_languages = core__get_module_default_languages ( module_name ) application_languages = core__get_module_application_languages ( module_name ) return default_languages unless application_languages default_languages . each do | key , value | application_languages [ k... | This function load languages for a specific module . This config are generated from the merge of application languages for the module and default languages of the module . |
19,984 | def core__get_module_configs module_name default_config = core__get_module_default_configs ( module_name ) application_config = core__get_module_application_configs ( module_name ) return default_config unless application_config default_config . each do | key , value | application_config [ key ] = value unless applicat... | This function load configs for a specific module . This configs are generated from the merge of application configs for the module and default configs of the module . |
19,985 | def text ( att , value ) clear_text_field ( att ) Scoring . new ( value ) . scores . each do | word , score | metaphone = Lunar . metaphone ( word ) nest [ att ] [ metaphone ] . zadd ( score , id ) metaphones [ id ] [ att ] . sadd ( metaphone ) end fields [ TEXT ] . sadd ( att ) end | Indexes all the metaphone equivalents of the words in value except for words included in Stopwords . |
19,986 | def number ( att , value , purge = true ) if value . kind_of? ( Enumerable ) clear_number_field ( att ) value . each { | v | number ( att , v , false ) } and return end clear_number_field ( att ) if purge numbers [ att ] . zadd ( value , id ) numbers [ att ] [ value ] . zadd ( 1 , id ) numbers [ id ] [ att ] . sadd ( v... | Adds a numeric index for att with value . |
19,987 | def sortable ( att , value ) sortables [ id ] [ att ] . set ( value ) fields [ SORTABLES ] . sadd att end | Adds a sortable index for att with value . |
19,988 | def to_request ( new_input = Undefined ) new_input . equal? ( Undefined ) ? self : self . class . new ( name , env , new_input ) end | Return self or a new instance with + input + |
19,989 | def core__encode_token exp , payload exp = 1 . day . from_now unless exp payload [ :exp ] = exp . to_i JWT . encode ( payload , Rails . application . secrets . secret_key_base , 'HS256' ) end | This functon return a token with encrypted payload information . |
19,990 | def core__decode_token token begin body = JWT . decode ( token , Rails . application . secrets . secret_key_base , true , algorithm : 'HS256' ) [ 0 ] return HashWithIndifferentAccess . new body rescue => exception return nil end end | This function return the payload of a token . |
19,991 | def authenticate ( username , password , method = :plain ) execute ( MarilynRPC :: Service :: AUTHENTICATION_PATH , "authenticate_#{method}" . to_sym , [ username , password ] ) end | authenicate the client to call methods that require authentication |
19,992 | def execute ( path , method , args ) thread = Thread . current tag = "#{Time.now.to_f}:#{thread.object_id}" @semaphore . synchronize { @socket . write ( MarilynRPC :: MailFactory . build_call ( tag , path , method , args ) ) @threads [ tag ] = thread } Thread . stop mail = thread [ MAIL_KEY ] if mail . is_a? MarilynRPC... | Executes a client call blocking . To issue an async call one needs to have start separate threads . THe Native client uses then multiplexing to avoid the other threads blocking . |
19,993 | def search_by_name ( name , page_limit = 1 , page = 1 ) if page_limit > 50 page_limit = MAX_PAGE_LIMIT end results_json = @badfruit . search_movies ( name , page_limit , page ) if results_json . nil? return [ ] else return @badfruit . parse_movies_array ( JSON . parse ( results_json ) ) end end | Initialize a wrapper around the Rotten Tomatoes API specific to movies . |
19,994 | def search_by_id ( movie_id ) movie = @badfruit . get_movie_info ( movie_id , "main" ) raise 'Movie not found' if movie . nil? || movie . empty? @badfruit . parse_movie_array ( JSON . parse ( movie ) ) end | search by id |
19,995 | def search_by_alias ( alias_id , type = 'imdb' ) movie = @badfruit . get_movie_alias_info ( alias_id , type ) json = JSON . parse ( movie ) raise 'Movie not found' if ! json [ 'error' ] . nil? @badfruit . parse_movie_array ( json ) end | Search for a movie by way of a 3rd party id . |
19,996 | def dashify_string_hash ( string_hash ) output = Hash . new string_hash . each do | key , value | dashed = key . to_s . gsub ( "_" , "-" ) . to_sym output [ dashed ] = value end output end | convert to string - key not string_key |
19,997 | def committees url = Sunlight :: Base . construct_url ( "committees.allForLegislator" , { :bioguide_id => self . bioguide_id } ) if ( result = Sunlight :: Base . get_json_data ( url ) ) committees = [ ] result [ "response" ] [ "committees" ] . each do | committee | committees << Sunlight :: Committee . new ( committee ... | Get the committees the Legislator sits on |
19,998 | def get_access_token @client = TwitterOAuth :: Client . new ( :consumer_key => ConsumerKey , :consumer_secret => ConsumerSecret ) request_token = @client . request_token puts "To authenticate your client, visit the URL: #{request_token.authorize_url}" open_link request_token . authorize_url print 'Enter PIN: ' begin @c... | Prompt the user for a PIN using a request token and see if we can successfully authenticate them |
19,999 | def timeline ( * args ) load_default_token return failtown ( "Unauthorized, re-run setup!" ) unless @client && @client . authorized? home_timeline = since_id ? @client . home_timeline ( :since_id => since_id ) : @client . home_timeline if home_timeline . any? print_tweets ( home_timeline ) self . since_id = home_timeli... | Display the user s timeline |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.