idx int64 0 24.9k | question stringlengths 68 4.14k | target stringlengths 9 749 |
|---|---|---|
12,500 | def set_model ( vr_combo ) self . model = Gtk :: ListStore . new ( String ) vr_combo . selections . each { | s | r = self . model . append ; r [ 0 ] = s } self . text_column = 0 end | This sets the renderer s editable property to true and makes it save the edited value to the model . When a user edits a row in the ListView the value isn t automatically saved by Gtk . This method groups both actions together so setting edit_save = true allows both editing and saving of the field . |
12,501 | def refresh ( flags = { } ) @root = flags [ :root ] if flags [ :root ] open_folders = flags [ :open_folders ] ? flags [ :open_folders ] : get_open_folders ( ) model . clear @root_iter = add_file ( @root , nil ) open_folders ( [ @root_iter [ :path ] ] ) open_folders ( open_folders ) end | FileTreeView creates a TreeView of files with folders and icons . Often you should subclass this class for a particular use . |
12,502 | def open_folders ( folder_paths ) model . each do | model , path , iter | if folder_paths . include? ( iter [ id ( :path ) ] ) fill_folder ( iter ) end end end | Opens a list of folders . |
12,503 | def add_file ( filename , parent = @root_iter ) my_path = File . dirname ( filename ) model . each do | model , path , iter | return if iter [ id ( :path ) ] == filename parent = iter if iter [ id ( :path ) ] == my_path end fn = filename . gsub ( "\\" , "/" ) parent [ id ( :empty ) ] = false unless parent . nil? child ... | Adds a file to the tree under a given parent iter . |
12,504 | def generate ( params = { } ) params = { :type => random_gender , :frequency => :common , :with_surname => true } . merge ( params ) if ! ( params [ :min_freq ] || params [ :max_freq ] ) params [ :min_freq ] , params [ :max_freq ] = frequency_values ( params [ :frequency ] ) else params [ :min_freq ] = params [ :min_fr... | generate a name using the supplied parameter hash |
12,505 | def random_sort ( set ) set . order do if set . class . name !~ / /i random . function else rand . function end end end | randomly sort a result set according to the data adapter class |
12,506 | def get_name ( src , min_freq = 0 , max_freq = 100 ) tmp = random_sort ( @db [ src . to_sym ] . filter { ( freq >= min_freq ) & ( freq <= max_freq ) } ) tmp . count > 0 ? tmp . first [ :name ] : nil end | query the db for a name |
12,507 | def top ( options = { } , & block ) params = { } if options [ :game ] params [ :game ] = options [ :game ] end period = options [ :period ] || :week if ! [ :week , :month , :all ] . include? ( period ) raise ArgumentError , 'period' end params [ :period ] = period . to_s return @query . connection . accumulate ( :path ... | Get the list of most popular videos based on view count . |
12,508 | def for_channel ( channel , options = { } ) if channel . respond_to? ( :name ) channel_name = channel . name else channel_name = channel . to_s end params = { } type = options [ :type ] || :highlights if ! type . nil? if ! [ :broadcasts , :highlights ] . include? ( type ) raise ArgumentError , 'type' end params [ :broa... | Get the videos for a channel most recently created first . |
12,509 | def following ( options = { } , & block ) name = CGI . escape ( @name ) return @query . connection . accumulate ( :path => "users/#{name}/follows/channels" , :json => 'follows' , :sub_json => 'channel' , :create => -> hash { Channel . new ( hash , @query ) } , :limit => options [ :limit ] , :offset => options [ :offset... | Get the channels the user is currently following . |
12,510 | def load_fixtures ( resource , file ) if block_given? Dir . mktmpdir ( "rspec-puppet-augeas" ) do | dir | prepare_fixtures ( dir , resource , file ) yield dir end else dir = Dir . mktmpdir ( "rspec-puppet-augeas" ) prepare_fixtures ( dir , resource , file ) dir end end | Copies test fixtures to a temporary directory If file is nil copies the entire augeas_fixtures directory If file is a hash it copies the value from augeas_fixtures to each key path |
12,511 | def apply ( resource , logs ) logs . clear Puppet :: Util :: Log . newdestination ( Puppet :: Test :: LogCollector . new ( logs ) ) Puppet :: Util :: Log . level = 'debug' confdir = Dir . mktmpdir oldconfdir = Puppet [ :confdir ] Puppet [ :confdir ] = confdir [ :require , :before , :notify , :subscribe ] . each { | p |... | Runs a particular resource via a catalog and stores logs in the caller s supplied array |
12,512 | def followers ( options = { } , & block ) name = CGI . escape ( @name ) return @query . connection . accumulate ( :path => "channels/#{name}/follows" , :json => 'follows' , :sub_json => 'user' , :create => -> hash { User . new ( hash , @query ) } , :limit => options [ :limit ] , :offset => options [ :offset ] , & block... | Get the users following this channel . |
12,513 | def find ( options ) raise ArgumentError , 'options' if options . nil? raise ArgumentError , 'name' if options [ :name ] . nil? params = { :query => options [ :name ] , :type => 'suggest' } if options [ :live ] params . merge! ( :live => true ) end return @query . connection . accumulate ( :path => 'search/games' , :pa... | Get a list of games with names similar to the specified name . |
12,514 | def idempotent @logs_idempotent = [ ] root = load_fixtures ( resource , { "." => "#{@root}/." } ) oldroot = resource [ :root ] resource [ :root ] = root @txn_idempotent = apply ( resource , @logs_idempotent ) FileUtils . rm_r root resource [ :root ] = oldroot @txn_idempotent end | Run the resource a second time against the output dir from the first |
12,515 | def all ( options = { } , & block ) return @query . connection . accumulate ( :path => 'streams' , :json => 'streams' , :create => -> hash { Stream . new ( hash , @query ) } , :limit => options [ :limit ] , :offset => options [ :offset ] , & block ) end | Get all currently live streams sorted by descending viewer count . |
12,516 | def find ( options , & block ) check = options . dup check . delete ( :limit ) check . delete ( :offset ) raise ArgumentError , 'options' if check . empty? params = { } channels = options [ :channel ] if channels if ! channels . respond_to? ( :map ) raise ArgumentError , ':channel' end params [ :channel ] = channels . ... | Get streams for a specific game for a set of channels or by other criteria sorted by descending viewer count . |
12,517 | def apk_file build_path = Souyuz . project . options [ :output_path ] assembly_name = Souyuz . project . options [ :assembly_name ] Souyuz . cache [ :build_apk_path ] = "#{build_path}/#{assembly_name}.apk" "#{build_path}/#{assembly_name}.apk" end | android build stuff to follow .. |
12,518 | def package_path build_path = Souyuz . project . options [ :output_path ] assembly_name = Souyuz . project . options [ :assembly_name ] if File . exist? "#{build_path}/#{assembly_name}.ipa" package_path = build_path else package_path = Dir . glob ( "#{build_path}/#{assembly_name} *" ) . sort . last end package_path end | ios build stuff to follow .. |
12,519 | def attr_configurable_single * args , & block trans = attr_configurable_wrap lambda { | v | v . is_a? ( Array ) ? v . first : v } , block attr_configurable ( * args , & trans ) end | Creates a group readable and writeable attributes that can be set by a URI query parameter sharing the same name a property of a URI or a default value . The value of this attribute will be transformed by invoking the given block if one has been provided . If the attributes created by this method are assigned an Array ... |
12,520 | def attr_configurable_arr * args , & block trans = attr_configurable_wrap lambda { | v | Array ( v ) } , block attr_configurable ( * args , & trans ) end | Creates a group readable and writeable attributes that can be set by a URI query parameter sharing the same name a property of a URI or a default value . The value of this attribute will be transformed by invoking the given block if one has been provided . If the attributes created by this method are assigned a value t... |
12,521 | def attr_configurable_int * args , & block trans = attr_configurable_wrap lambda { | v | v . to_i } , block attr_configurable_single ( * args , & trans ) end | Creates readable and writeable attributes that are automatically converted into integers . |
12,522 | def method_missing ( method , * args , & block ) string_method = method . to_s if raw_hash . key? ( string_method ) return self [ string_method ] elsif raw_hash . key? ( string_method . downcase ) return self [ string_method . downcase ] end if string_method =~ / / string_method = string_method . snakecase end index = ... | Allows method - like access to the hash using camelcase field names . |
12,523 | def blocks RelationProxy . new ( self , Block , [ Operations :: Create , Operations :: List , Operations :: Delete ] ) do def from_response ( response , client ) response [ 'url' ] ||= "#{base.url}#{resource_type.url}/#{response['user_id']}" super end def create ( attributes , client = self . client ) response = client... | Returns the users blocked by this user |
12,524 | def identity SingletonRelationProxy . new ( self , Layer :: Identity ) do def from_response ( response , client ) response [ 'url' ] ||= "#{base.url}#{resource_type.url}" super end def create ( attributes , client = self . client ) client . post ( url , attributes ) fetch end def delete ( client = self . client ) clien... | Returns the identity object for this user |
12,525 | def messages RelationProxy . new ( self , Message , [ Operations :: Create , Operations :: Paginate , Operations :: Find , Operations :: Delete , Operations :: Destroy ] ) end | Returns the conversations messages |
12,526 | def contents RelationProxy . new ( self , Content , [ Operations :: Create , Operations :: Find ] ) do def create ( mime_type , file , client = self . client ) response = client . post ( url , { } , { 'Upload-Content-Type' => mime_type , 'Upload-Content-Length' => file . size } ) attributes = response . merge ( 'size' ... | Allows creating and finding of the conversation s rich content |
12,527 | def delete ( options = { } ) options = { mode : :my_devices } . merge ( options ) client . delete ( url , { } , { params : options } ) end | Deletes the conversation removing it from the user s devices by default |
12,528 | def execute ( opts = { } , & block ) parse_options self . options . merge! ( opts ) @verify_options_hook . call ( self . options ) if @verify_options_hook if options . include? ( :kill ) self . stop else self . stop if options . include? ( :restart ) if options [ :group ] gid = options [ :group ] . is_a? ( Integer ) ? ... | Executes the runner based on options |
12,529 | def stop ( kill_arg = nil ) if self . daemon_running? kill_pid ( kill_arg || options [ :kill ] ) if until_true ( MAX_START_TRIES ) { self . daemon_stopped? } FileUtils . rm options [ :pid_path ] log "Daemonized process killed after term." else log "Failed to kill daemonized process" if options [ :force ] kill_pid ( kil... | Stops a daemonized process |
12,530 | def daemon_running? return false unless File . exist? ( options [ :pid_path ] ) Process . kill 0 , File . read ( options [ :pid_path ] ) . to_i true rescue Errno :: ESRCH false end | Returns running for the daemonized process self . daemon_running? |
12,531 | def handle_pack ( pack_type , io_in , io_out , opts = { } ) args = %w{ --stateless-rpc } if opts . fetch ( :advertise_refs , false ) io_out . write ( advertisement_prefix ( pack_type ) ) args << '--advertise-refs' end args << repository_path . to_s command ( pack_type . sub ( / / , '' ) , args , io_in , io_out ) end | Process the pack file exchange protocol . |
12,532 | def command ( cmd , args , io_in , io_out , dir = nil ) cmd = [ git_path , cmd ] + args opts = { :err => :close } opts [ :chdir ] = dir unless dir . nil? cmd << opts IO . popen ( cmd , 'r+b' ) do | pipe | while ! io_in . nil? && chunk = io_in . read ( READ_SIZE ) do pipe . write ( chunk ) end pipe . close_write while c... | Runs the Git utilty with the given subcommand . |
12,533 | def route path_info = Rack :: Utils . unescape ( request . path_info ) . gsub ( %r{ } , '/' ) ROUTES . each do | path_matcher , verb , handler | path_info . match ( path_matcher ) do | match | @repository_uri = match [ 1 ] @request_verb = verb return method_not_allowed unless verb == request . request_method return bad... | Routes requests to appropriate handlers . Performs request path cleanup and several sanity checks prior to attempting to handle the request . |
12,534 | def handle_pack ( pack_type ) @pack_type = pack_type unless request . content_type == "application/x-#{@pack_type}-request" && valid_pack_type? && authorized? return no_access end headers = { 'Content-Type' => "application/x-#{@pack_type}-result" } exchange_pack ( headers , request_io_in ) end | Processes pack file exchange requests for both push and pull . Ensures that the request is allowed and properly formatted . |
12,535 | def info_refs @pack_type = request . params [ 'service' ] return no_access unless authorized? if @pack_type . nil? git . update_server_info send_file ( git . file ( 'info/refs' ) , 'text/plain; charset=utf-8' , hdr_nocache ) elsif valid_pack_type? headers = hdr_nocache headers [ 'Content-Type' ] = "application/x-#{@pac... | Processes requests for the list of refs for the requested repository . |
12,536 | def send_file ( streamer , content_type , headers = { } ) return not_found if streamer . nil? headers [ 'Content-Type' ] = content_type headers [ 'Last-Modified' ] = streamer . mtime . httpdate [ 200 , headers , streamer ] end | Produces a Rack response that wraps the output from the Git adapter . |
12,537 | def exchange_pack ( headers , io_in , opts = { } ) Rack :: Response . new ( [ ] , 200 , headers ) . finish do | response | git . handle_pack ( pack_type , io_in , response , opts ) end end | Opens a tunnel for the pack file exchange protocol between the client and the Git adapter . |
12,538 | def bad_uri? ( path ) invalid_segments = %w{ . .. } path . split ( '/' ) . any? { | segment | invalid_segments . include? ( segment ) } end | Determines whether or not _path_ is an acceptable URI . |
12,539 | def search_endpoint_url ( params ) params [ :prefix ] || params [ :prefix ] = false append = '' if params [ :translations ] append = "/translations=#{params[:translations]}" params . delete ( :translations ) end "#{append}?#{create_query_string(params, '&')}" end | The search endpoint has a slightly different url structure |
12,540 | def report ( file , inline_mode = true ) raise "Please specify file name." if file . empty? raise "No checkstyle file was found at #{file}" unless File . exist? file errors = parse ( File . read ( file ) ) send_comment ( errors , inline_mode ) end | Report checkstyle warnings |
12,541 | def report_by_text ( text , inline_mode = true ) raise "Please specify xml text." if text . empty? errors = parse ( text ) send_comment ( errors , inline_mode ) end | Report checkstyle warnings by XML text |
12,542 | def call ( env ) request = Rack :: Request . new ( env ) assign_device_type ( request ) status , headers , body = @app . call ( env ) response = Rack :: Response . new ( body , status , headers ) response_callback ( request , response ) [ status , headers , body ] end | Create a new instance of this rack middleware . |
12,543 | def authenticate ( opts = { } , & block ) block ||= lambda do | params | config [ :auth_credentials ] . each do | key , value | begin params [ key ] = value rescue NameError => e raise NameError . new ( "Unknown param name '#{key}'" ) end end end response = auth_service . request ( config [ :auth_service ] [ :request ]... | Create a new Session instance . |
12,544 | def sample_range ( range , seed = nil ) srand seed if seed rand * ( range . end - range . begin ) + range . begin end | Choose a random value from within the given range optionally seeded by seed . |
12,545 | def receive_stream_data ( data ) begin @buffer . extract ( data ) . each do | line | parse_stream_line ( line ) end @stream = '' rescue => e receive_error ( "#{e.class}: " + [ e . message , e . backtrace ] . flatten . join ( "\n\t" ) ) close_connection return end end | Called every time a chunk of data is read from the connection once it has been opened and after the headers have been processed . |
12,546 | def oauth_header uri = uri_base + @options [ :path ] . to_s oauth = { :consumer_key => @options [ :oauth ] [ :consumer_key ] , :consumer_secret => @options [ :oauth ] [ :consumer_secret ] , :token => @options [ :oauth ] [ :access_key ] , :token_secret => @options [ :oauth ] [ :access_secret ] } data = [ 'POST' , 'PUT' ... | URL and request components |
12,547 | def params flat = { } @options [ :params ] . merge ( :track => @options [ :filters ] ) . each do | param , val | next if val . to_s . empty? || ( val . respond_to? ( :empty? ) && val . empty? ) val = val . join ( "," ) if val . respond_to? ( :join ) flat [ param . to_s ] = val . to_s end flat end | Normalized query hash of escaped string keys and escaped string values nil values are skipped |
12,548 | def add_file ( files , params = { } ) params [ :files ] = Hash [ files . map { | f | [ f [ :dest ] || raise ( ArgumentError , "'`:dest`' is required" ) , :: File . open ( f [ :source ] || raise ( ArgumentError , "'`:source` is required'" ) ) ] } ] params [ :titles ] = Hash [ files . map { | f | [ f [ :dest ] , f [ :tit... | Add new file to Crowdin project . |
12,549 | def update_file ( files , params = { } ) params [ :files ] = Hash [ files . map { | f | dest = f [ :dest ] || raise ( ArgumentError , "'`:dest` is required'" ) source = :: File . open ( f [ :source ] || raise ( ArgumentError , "'`:source` is required'" ) ) source . define_singleton_method ( :original_filename ) do dest... | Upload fresh version of your localization file to Crowdin . |
12,550 | def upload_translation ( files , language , params = { } ) params [ :files ] = Hash [ files . map { | f | [ f [ :dest ] || raise ( ArgumentError , "`:dest` is required" ) , :: File . open ( f [ :source ] || raise ( ArgumentError , "`:source` is required" ) ) ] } ] params [ :language ] = language request ( :method => :p... | Upload existing translations to your Crowdin project . |
12,551 | def request ( params , & block ) params [ :query ] . reject! { | _ , value | value . nil? } if params [ :query ] case params [ :method ] when :post query = @connection . options . merge ( params [ :query ] || { } ) @connection [ params [ :path ] ] . post ( query ) { | response , _ , _ | @response = response } when :get... | Create a new API object using the given parameters . |
12,552 | def call ( env ) req = Rack :: Request . new ( env ) [ 200 , { 'Content-Type' => 'application/json' } , [ dispatch_action ( req ) ] ] rescue Heartcheck :: Errors :: RoutingError [ 404 , { 'Content-Type' => 'application/json' } , [ 'Not found' ] ] end | Sets up the rack application . |
12,553 | def dispatch_action ( req ) controller = ROUTE_TO_CONTROLLER [ req . path_info ] fail Heartcheck :: Errors :: RoutingError if controller . nil? Logger . info "Start [#{controller}] from #{req.ip} at #{Time.now}" controller . new . index . tap do | _ | Logger . info "End [#{controller}]\n" end end | Find a controller to espefic path and call the index method |
12,554 | def paginate ( key , options = { } ) type = RedisPagination . redis . type ( key ) case type when 'list' RedisPagination :: Paginator :: ListPaginator . new ( key , options ) when 'zset' RedisPagination :: Paginator :: SortedSetPaginator . new ( key , options ) when 'none' RedisPagination :: Paginator :: NonePaginator ... | Retrieve a paginator class appropriate for the + key + in Redis . + key + must be one of + list + or + zset + otherwise an exception will be raised . |
12,555 | def call ( env ) req = Rack :: Request . new ( env ) controller = Heartcheck :: App :: ROUTE_TO_CONTROLLER [ req . path_info ] if controller && ( result = cache . result ( controller ) ) [ 200 , { 'Content-type' => 'application/json' } , [ result ] ] else @app . call ( env ) end end | Creates an instance of the middleware |
12,556 | def rx ( corner ) case corner when :tl ; reg_off when :tr ; page_width - reg_crop - reg_off when :br ; page_width - reg_crop - reg_off when :bl ; reg_off end end | iterationless x registration |
12,557 | def qnum_xy ( q ) [ item_x ( q ) . mm - qnum_width - qnum_margin , item_y ( q ) . mm ] end | Coordinates at which to place item numbers |
12,558 | def marked_letters return if not_registered marked_choices . map do | q | q . map { | cho | ( 65 + cho ) . chr } end end | The set of letters marked on the response sheet . At this time only the latin sequence A B C ... is supported . |
12,559 | def redirect_to_digest_version ( env ) url = URI ( computed_asset_host || @request . url ) url . path = "#{@prefix}/#{digest_path}" headers = { 'Location' => url . to_s , 'Content-Type' => Rack :: Mime . mime_type ( :: File . extname ( digest_path ) ) , 'Pragma' => 'no-cache' , 'Cache-Control' => 'no-cache; max-age=0' ... | Sends a redirect header back to browser |
12,560 | def register each_corner { | c | @rm [ c ] = rm_centroid_on c } @rm . all? { | k , v | v [ :status ] == :ok } end | find the XY coordinates of the 4 registration marks plus the stdev of the search area as quality control |
12,561 | def rm_centroid_on ( corner ) c = @grom . rm_crop_area ( corner ) p = @mack . rm_patch ( c , @grom . rm_blur , @grom . rm_dilate ) n = NPatch . new ( p , c . w , c . h ) cx , cy , sd = n . centroid st = ( cx < 2 ) or ( cy < 2 ) or ( cy > c . h - 2 ) or ( cx > c . w - 2 ) status = st ? :edgy : :ok return { x : cx + c . ... | returns the centroid of the dark region within the given area in the XY coordinates of the entire image |
12,562 | def headers_for_env ( env ) return "" if env . blank? parameters = filter_parameters ( env ) headers = [ ] headers << "Method: #{env['REQUEST_METHOD']}" headers << "URL: #{env['REQUEST_URI']}" if env [ 'REQUEST_METHOD' ] . downcase != "get" headers << "Parameters:\n#{pretty_hash(parameters.except(:controll... | Log Request headers from Rack env |
12,563 | def exclude? ( path ) exclude . include? ( path ) || exclude . include? ( path . split ( METHOD_SEPARATOR ) . first ) end | Checks if given path is in exclude list |
12,564 | def measure ( config ) reduce ( MeasurementSet . new ) do | set , document | set . merge ( Document . measure ( document , config ) ) end end | Measure documents using given config |
12,565 | def for_rule ( rule_class ) key = rule_class . to_s [ NAMESPACE_PREFIX . length .. - 1 ] if key RuleConfig . new ( @rules . fetch ( key . to_sym , { } ) ) else fail InvalidRule , "every rule must begin with #{NAMESPACE_PREFIX}" end end | Initializes new config |
12,566 | def defaults = ( options ) @threshold = options . fetch ( :threshold , 100 ) @verbose = options . fetch ( :verbose , true ) @path = options . fetch ( :path , 'lib/**/*.rb' ) @require_exact_threshold = options . fetch ( :require_exact_threshold , true ) @rules = options . fetch ( :rules , { } ) self . output = 'measurem... | Sets default options |
12,567 | def compare_small_comparators ( other ) return true if @size > SMALL_FILE || other . size > SMALL_FILE return true if small_comparator . nil? || other . small_comparator . nil? small_comparator . call == other . small_comparator . call end | If files are small and both nodes have a comparator we can call an extra provided block to verify equality . This allows |
12,568 | def define_calculated_statistic ( name , & block ) method_name = name . to_s . gsub ( " " , "" ) . underscore + "_stat" @statistics ||= { } @statistics [ name ] = method_name ( class << self ; self ; end ) . instance_eval do define_method ( method_name ) do | filters | @filters = filters yield end end end | Defines a statistic using a block that has access to all other defined statistics |
12,569 | def statistics ( filters = { } , except = nil ) ( @statistics || { } ) . inject ( { } ) do | stats_hash , stat | stats_hash [ stat . first ] = send ( stat . last , filters ) if stat . last != except stats_hash end end | Calculates all the statistics defined for this AR class and returns a hash with the values . There is an optional parameter that is a hash of all values you want to filter by . |
12,570 | def add_to_search_list list = FFI :: MemoryPointer . new ( :pointer ) status = Sec . SecKeychainCopySearchList ( list ) Sec . check_osstatus ( status ) ruby_list = CF :: Base . typecast ( list . read_pointer ) . release_on_gc . to_ruby ruby_list << self unless ruby_list . include? ( self ) status = Sec . SecKeychainSet... | Add the keychain to the default searchlist |
12,571 | def import ( input , app_list = [ ] ) input = input . read if input . is_a? IO trusted_apps = get_trusted_apps ( app_list ) access_buffer = FFI :: MemoryPointer . new ( :pointer ) status = Sec . SecAccessCreate ( path . to_cf , trusted_apps , access_buffer ) Sec . check_osstatus status access = CF :: Base . typecast ( ... | Imports item from string or file to this keychain |
12,572 | def path out_buffer = FFI :: MemoryPointer . new ( :uchar , 2048 ) io_size = FFI :: MemoryPointer . new ( :uint32 ) io_size . put_uint32 ( 0 , out_buffer . size ) status = Sec . SecKeychainGetPath ( self , io_size , out_buffer ) Sec . check_osstatus ( status ) out_buffer . read_string ( io_size . get_uint32 ( 0 ) ) . f... | Returns the path at which the keychain is stored |
12,573 | def unlock! password = nil if password password = password . encode ( Encoding :: UTF_8 ) status = Sec . SecKeychainUnlock self , password . bytesize , password , 1 else status = Sec . SecKeychainUnlock self , 0 , nil , 0 end Sec . check_osstatus status end | Unlocks the keychain |
12,574 | def password return @unsaved_password if @unsaved_password out_buffer = FFI :: MemoryPointer . new ( :pointer ) status = Sec . SecItemCopyMatching ( { Sec :: Query :: ITEM_LIST => CF :: Array . immutable ( [ self ] ) , Sec :: Query :: SEARCH_LIST => [ self . keychain ] , Sec :: Query :: CLASS => self . klass , Sec :: Q... | Fetches the password data associated with the item . This may cause the user to be asked for access |
12,575 | def save! ( options = { } ) if persisted? cf_dict = update else cf_dict = create ( options ) self . ptr = cf_dict [ Sec :: Value :: REF ] . to_ptr self . retain . release_on_gc end @unsaved_password = nil update_self_from_dictionary ( cf_dict ) cf_dict . release self end | Attempts to update the keychain with any changes made to the item or saves a previously unpersisted item |
12,576 | def propfind ( path , * options ) headers = { 'Depth' => '1' } if ( options [ 0 ] == :acl ) body = '<?xml version="1.0" encoding="utf-8" ?><D:propfind xmlns:D="DAV:"><D:prop><D:owner/>' + '<D:supported-privilege-set/><D:current-user-privilege-set/><D:acl/></D:prop></D:propfind>' else body = options [ 0 ] end if ( ! bod... | Perform a PROPFIND request |
12,577 | def cd ( url ) new_uri = @uri . merge ( url ) if new_uri . host != @uri . host || new_uri . port != @uri . port || new_uri . scheme != @uri . scheme raise Exception , "uri must have same scheme, host and port" end @uri = new_uri end | Change the base URL for use in handling relative paths |
12,578 | def get ( path , & block ) path = @uri . merge ( path ) . path body = @handler . request_returning_body ( :get , path , @headers , & block ) body end | Get the content of a resource as a string |
12,579 | def put ( path , stream , length ) path = @uri . merge ( path ) . path res = @handler . request_sending_stream ( :put , path , stream , length , @headers ) res . body end | Stores the content of a stream to a URL |
12,580 | def put_string ( path , str ) path = @uri . merge ( path ) . path res = @handler . request_sending_body ( :put , path , str , @headers ) res . body end | Stores the content of a string to a URL |
12,581 | def move ( path , destination ) path = @uri . merge ( path ) . path destination = @uri . merge ( destination ) . to_s headers = { 'Destination' => destination } res = @handler . request ( :move , path , nil , headers . merge ( @headers ) ) res . body end | Send a move request to the server . |
12,582 | def proppatch ( path , xml_snippet ) path = @uri . merge ( path ) . path headers = { 'Depth' => '1' } body = '<?xml version="1.0"?>' + '<d:propertyupdate xmlns:d="DAV:">' + xml_snippet + '</d:propertyupdate>' res = @handler . request ( :proppatch , path , body , headers . merge ( @headers ) ) Nokogiri :: XML . parse ( ... | Do a proppatch request to the server to update properties on resources or collections . |
12,583 | def unlock ( path , locktoken ) headers = { 'Lock-Token' => '<' + locktoken + '>' } path = @uri . merge ( path ) . path res = @handler . request ( :unlock , path , nil , headers . merge ( @headers ) ) end | Send an unlock request to the server |
12,584 | def exists? ( path ) path = @uri . merge ( path ) . path headers = { 'Depth' => '1' } body = '<?xml version="1.0" encoding="utf-8"?><DAV:propfind xmlns:DAV="DAV:"><DAV:allprop/></DAV:propfind>' begin res = @handler . request ( :propfind , path , body , headers . merge ( @headers ) ) rescue return false end return ( res... | Returns true if resource exists on server . |
12,585 | def keychain out = FFI :: MemoryPointer . new :pointer status = Sec . SecKeychainItemCopyKeychain ( self , out ) Sec . check_osstatus ( status ) CF :: Base . new ( out . read_pointer ) . release_on_gc end | Returns the keychain the item is in |
12,586 | def sleep ( timeout = nil ) unlock begin timeout ? Kernel . sleep ( timeout ) : Kernel . sleep ensure lock end end | Releases the lock and sleeps timeout seconds if it is given and non - nil or forever . |
12,587 | def insert_right ( right , opts = { } ) ipc_space = opts [ :ipc_space ] || @ipc_space port_name = opts [ :port_name ] || @port mach_port_insert_right ( ipc_space . to_i , port_name . to_i , @port , right ) end | Insert + right + into another ipc space . The current task must have sufficient rights to insert the requested right . |
12,588 | def send_right ( right , remote_port ) msg = SendRightMsg . new msg [ :header ] . tap do | h | h [ :remote_port ] = remote_port . to_i h [ :local_port ] = PORT_NULL h [ :bits ] = ( MsgType [ right ] | ( 0 << 8 ) ) | 0x80000000 h [ :size ] = 40 end msg [ :body ] [ :descriptor_count ] = 1 msg [ :port ] . tap do | p | p [... | Send + right + on this Port to + remote_port + . The current task must already have the requisite rights allowing it to send + right + . |
12,589 | def receive_right msg = ReceiveRightMsg . new mach_msg ( msg , 2 , 0 , msg . size , port , MSG_TIMEOUT_NONE , PORT_NULL ) self . class . new :port => msg [ :port ] [ :name ] end | Create a new Port by receiving a port right message on this port . |
12,590 | def destroy ( opts = { } ) task = opts [ :task ] || ipc_space || mach_task_self semaphore_destroy ( task . to_i , port ) end | Create a new Semaphore . |
12,591 | def suit ( glyph = false ) case @suit when 1 glyph ? CLUB . black . bold : 'Clubs' when 2 glyph ? DIAMOND . red : 'Diamonds' when 3 glyph ? HEART . red : 'Hearts' when 4 glyph ? SPADE . black . bold : 'Spades' end end | Returns the suit of the card . |
12,592 | def has_tags? ( object , target_tags ) target_tags . all? { | target_tag | tags = object . tags tags = tags . collect { | tag | tag . name } unless Gem . loaded_specs [ 'cuke_modeler' ] . version . version [ / / ] tags . include? ( target_tag ) } end | Creates a new filter Returns whether or not the object has the target tags |
12,593 | def content_match? ( content ) if pattern . is_a? ( String ) content . any? { | thing | thing == pattern } else content . any? { | thing | thing =~ pattern } end end | Creates a new filter Returns whether or not the content matches the pattern |
12,594 | def execute ( input , negate ) method = negate ? :reject : :select input . send ( method ) do | object | type_count ( object ) . send ( comparison . operator , comparison . amount ) end end | Creates a new filter Not a part of the public API . Subject to change at any time . Filters the input models so that only the desired ones are returned |
12,595 | def get_doi_ra ( doi ) prefix = validate_prefix ( doi ) return nil if prefix . blank? url = "https://doi.org/ra/#{prefix}" result = Maremma . get ( url ) result . body . dig ( "data" , 0 , "RA" ) end | get DOI registration agency |
12,596 | def search ( domain , params = { } ) EmailHunter :: Search . new ( domain , self . key , params ) . hunt end | Domain search API |
12,597 | def finder ( domain , first_name , last_name ) EmailHunter :: Finder . new ( domain , first_name , last_name , self . key ) . hunt end | Email Finder API |
12,598 | def raw r = string . present? ? string . strip : nil return r unless ( from == "datacite" && r . present? ) doc = Nokogiri :: XML ( string , nil , 'UTF-8' , & :noblanks ) node = doc . at_css ( "identifier" ) node . content = doi . to_s . upcase if node . present? && doi . present? doc . to_xml . strip end | replace DOI in XML if provided in options |
12,599 | def get_authors ( authors ) Array . wrap ( authors ) . map { | author | get_one_author ( author ) } . compact end | parse array of author strings into CSL format |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.