idx
int64
0
24.9k
question
stringlengths
68
4.14k
target
stringlengths
9
749
11,400
def on_error ( obj = nil , & block ) @on_error_obj = obj @on_error = Proc . new { | handle , obj_ptr , code , description | yield self , object_for ( obj_ptr ) , code , description } Phidgets :: FFI :: Common . set_OnError_Handler ( @handle , @on_error , pointer_for ( obj ) ) true end
Sets an error handler callback function . This is called when an asynchronous error occurs . This is generally used for network errors and device hardware error messages .
11,401
def on_server_connect ( obj = nil , & block ) @on_server_connect_obj = obj @on_server_connect = Proc . new { | handle , obj_ptr | yield self , object_for ( obj_ptr ) } Phidgets :: FFI :: Common . set_OnServerConnect_Handler ( @handle , @on_server_connect , pointer_for ( obj ) ) true end
Sets a server connect handler callback function . This is called for network opened Phidgets when a connection to the PhidgetWebService has been established .
11,402
def on_sleep ( obj = nil , & block ) @on_sleep_obj = obj @on_sleep = Proc . new { | obj_ptr | yield object_for ( obj_ptr ) } Phidgets :: FFI :: Common . set_OnWillSleep_Handler ( @on_sleep , pointer_for ( obj ) ) true end
Sets a sleep handler callback function . This is called when the MacOS X is entering sleep mode .
11,403
def on_wake ( obj = nil , & block ) @on_wake_obj = obj @on_wake = Proc . new { | obj_ptr | yield object_for ( obj_ptr ) } Phidgets :: FFI :: Common . set_OnWakeup_Handler ( @on_wake , pointer_for ( obj ) ) true end
Sets a wake callback function . This is called when the MacOS X is waking up from sleep mode .
11,404
def image_resources ( resource_name , options = { } ) options = { path : "#{resource_name}/:digest(/:size)" , constraints : { size : / \d \d / } , only : [ :show ] } . merge ( options ) resources resource_name , options do get :uncropped , on : :member get :original , on : :member get :download , on : :member end end
Declares an image resource .
11,405
def on_attach ( obj = nil , & block ) @on_attach_obj = obj @on_attach = Proc . new { | handle , obj_ptr | yield handle , object_for ( obj_ptr ) } Klass . set_OnAttach_Handler ( @handle , @on_attach , pointer_for ( obj ) ) end
Sets an attach handler callback function . This is called when a Phidget is plugged into the system .
11,406
def on_detach ( obj = nil , & block ) @on_detach_obj = obj @on_detach = Proc . new { | handle , obj_ptr | yield handle , object_for ( obj_ptr ) } Klass . set_OnDetach_Handler ( @handle , @on_detach , pointer_for ( obj ) ) end
Sets a detach handler callback function . This is called when a Phidget is unplugged from the system .
11,407
def on_server_connect ( obj = nil , & block ) @on_server_connect_obj = obj @on_server_connect = Proc . new { | handle , obj_ptr | yield self , object_for ( obj_pointer ) } Klass . set_OnServerConnect_Handler ( @handle , @on_server_connect , pointer_for ( obj ) ) end
Sets a server connect handler callback function . This is used for opening the PhidgetManager remotely and is called when a connection to the server has been made .
11,408
def on_server_disconnect ( obj = nil , & block ) @on_server_disconnect_obj = obj @on_server_disconnect = Proc . new { | handle , obj_ptr | yield self , object_for ( obj_ptr ) } Klass . set_OnServerDisconnect_Handler ( @handle , @on_server_disconnect , pointer_for ( obj ) ) end
Sets a server disconnect handler callback function . This is used for opening the PhidgetManager remotely and is called when a connection to the server has been lost
11,409
def on_error ( obj = nil , & block ) @on_error_obj = obj @on_error = Proc . new { | handle , obj_ptr , code , description | yield self , object_for ( obj_ptr ) , code , description } Klass . set_OnError_Handler ( @handle , @on_error , pointer_for ( obj ) ) end
Sets a error handler callback function . This is called when an asynchronous error occurs .
11,410
def execute! exit_code = begin $stderr = @stderr $stdin = @stdin $stdout = @stdout VcoWorkflows :: CLI . start ( @argv ) 0 rescue StandardError => e b = e . backtrace b . unshift ( "#{b.shift}: #{e.message} (#{e.class})" ) @stderr . puts ( b . map { | s | "\tfrom #{s}" } . join ( "\n" ) ) 1 ensure $stderr = STDERR $std...
Allow everything fun to be injected from the outside while defaulting to normal implementations . Do the things!
11,411
def get_workflow_for_name ( name ) path = "/workflows?conditions=name=#{url_encode(name)}" response = JSON . parse ( @session . get ( path ) . body ) fail ( IOError , ERR [ :too_many_workflows ] ) if response [ 'total' ] > 1 fail ( IOError , ERR [ :no_workflow_found ] ) if response [ 'total' ] == 0 workflow_id = nil re...
Get one workflow with a specified name .
11,412
def get_execution_list ( workflow_id ) path = "/workflows/#{workflow_id}/executions/" relations = JSON . parse ( @session . get ( path ) . body ) [ 'relations' ] executions = { } relations [ 'link' ] . each do | link | next unless link . key? ( 'attributes' ) attributes = { } link [ 'attributes' ] . each { | a | attrib...
Get a list of executions for the given workflow GUID
11,413
def execute_workflow ( id , parameter_json ) path = "/workflows/#{id}/executions/" response = @session . post ( path , parameter_json ) response . headers [ :location ] . gsub ( %r{ } , '' ) . gsub ( %r{ \/ } , '' ) end
Submit the given workflow for execution
11,414
def parameters ( arguments ) Hash [ arguments . map do | name , value | type_handler = @type_handlers . fetch ( name ) type_handler . validate ( value ) [ name , type_handler . serialize ( value ) ] end ] end
Initialize a Specification
11,415
def to_s message = '' @messages . keys . sort . each do | timestamp | message << "#{Time.at(timestamp / 1000)}" message << " #{@messages[timestamp]['severity']}: #{@messages[timestamp]['user']}:" message << " #{@messages[timestamp]['short-description']}" unless @messages [ timestamp ] [ 'short-description' ] . eql? ( @...
Create an execution log object
11,416
def current_limit = ( new_current_limit ) ptr = :: FFI :: MemoryPointer . new ( :int ) Klass . setCurrentLimit ( @handle , Phidgets :: FFI :: LEDCurrentLimit [ new_current_limit ] ) new_current_limit end
Sets the board current limit for all LEDs or raises an error . Not supported on all PhidgetLEDs .
11,417
def voltage = ( new_voltage ) ptr = :: FFI :: MemoryPointer . new ( :int ) Klass . setVoltage ( @handle , Phidgets :: FFI :: LEDVoltage [ new_voltage ] ) new_voltage end
Sets the voltage level for all LEDs or raises an error . Not supported on all PhidgetLEDs .
11,418
def on_velocity_change ( obj = nil , & block ) @on_velocity_change_obj = obj @on_velocity_change = Proc . new { | device , obj_ptr , index , velocity | yield self , @steppers [ index ] , velocity , object_for ( obj_ptr ) } Klass . set_OnVelocityChange_Handler ( @handle , @on_velocity_change , pointer_for ( obj ) ) end
Sets a velocity change handler callback function . This is called when a stepper velocity changes .
11,419
def on_acceleration_change ( obj = nil , & block ) @on_acceleration_change_obj = obj @on_acceleration_change = Proc . new { | device , obj_ptr , ind , acc | yield self , axes [ ind ] , acc , object_for ( obj_ptr ) } Klass . set_OnAccelerationChange_Handler ( @handle , @on_acceleration_change , pointer_for ( obj ) ) end
Sets an acceleration change handler callback function . This is called when the acceleration of an axis changes by more than the set sensitivity .
11,420
def cropped_and_resized ( size ) normalized do | image | if record . cropped? || size != record . size image . crop ( image_sizing . crop_geometry_string ( size ) ) image . resize ( size ) end end end
Crops and resizes the image . Normalization is performed as well .
11,421
def normalized require_valid_image! process_data do | image | image . combine_options do | combined | combined . auto_orient combined . colorspace ( "sRGB" ) if needs_colorspace_conversion? yield ( combined ) if block_given? optimize ( combined ) end image . format ( format ) if needs_format_conversion? end end
Normalizes the image .
11,422
def load_config ( path ) return unless File . exist? ( path ) buf = File . read ( path ) eval ( "#{buf}" , binding , path ) end
load config file and merge up with the config tree . it will not work when the config_path is nil or the file is missed
11,423
def method_missing ( method ) method = method . to_s raise NoMethodError , "No such method: #{method}" unless @args . keys . include? method @args [ method ] end
This will return arguments as object methods .
11,424
def attributes super . merge ( { :motors => motors . size , :encoders => encoders . size , :inputs => inputs . size , :sensors => sensors . size , :ratiometric => ratiometric } ) end
The attributes of a PhidgetMotorControl
11,425
def on_current_change ( obj = nil , & block ) @on_current_change_obj = obj @on_current_change = Proc . new { | device , obj_ptr , motor , current | yield self , @motors [ motor ] , current , object_for ( obj_ptr ) } Klass . set_OnCurrentChange_Handler ( @handle , @on_current_change , pointer_for ( obj ) ) end
Sets a current change handler callback function . This is called when the current consumed by a motor changes .
11,426
def on_back_emf_update ( obj = nil , & block ) @on_back_emf_update_obj = obj @on_back_emf_update = Proc . new { | device , obj_ptr , motor , voltage | yield self , @motors [ motor ] , voltage , object_for ( obj_ptr ) } Klass . set_OnBackEMFUpdate_Handler ( @handle , @on_back_emf_update , pointer_for ( obj ) ) end
Sets a Back EMF update handler callback function . This is called at a steady rate of 16ms when BackEMF sensing is enabled .
11,427
def on_position_update ( obj = nil , & block ) @on_position_update_obj = obj @on_position_update = Proc . new { | device , obj_ptr , encoder , position | yield self , @encoders [ encoder ] , position , object_for ( obj_ptr ) } Klass . set_OnEncoderPositionUpdate_Handler ( @handle , @on_position_update , pointer_for ( o...
Sets a position update handler callback function . This event provides data about how many ticks have occured since the last update event . It is called at a steady rate of 8ms .
11,428
def on_sensor_update ( obj = nil , & block ) @on_sensor_update_obj = obj @on_sensor_update = Proc . new { | device , obj_ptr , index , value | yield self , @sensors [ index ] , value , object_for ( obj_ptr ) } Klass . set_OnSensorUpdate_Handler ( @handle , @on_sensor_update , pointer_for ( obj ) ) end
Sets a sensor update handler callback function . This is called at a steady rate of 8ms .
11,429
def ratiometric ptr = :: FFI :: MemoryPointer . new ( :int ) Klass . getRatiometric ( @handle , ptr ) ( ptr . get_int ( 0 ) == 0 ) ? false : true end
Returns the ratiometric state of the board
11,430
def pretty_print ( q ) q . instance_exec ( self ) do | obj | text "\#<#{obj.class.to_s}" group_sub { nest ( 2 ) { breakable ' ' pp obj . instance } } breakable '' text '>' end end
pretty - prints a representation this JSI to the given printer
11,431
def subscript_assign ( subscript , value ) clear_memo ( :[] , subscript ) if value . is_a? ( Base ) instance [ subscript ] = value . instance else instance [ subscript ] = value end end
assigns a subscript taking care of memoization and unwrapping a JSI if given .
11,432
def on_output_change ( obj = nil , & block ) @on_output_change_obj = obj @on_output_change = Proc . new { | device , obj_ptr , index , state | yield self , @outputs [ index ] , ( state == 0 ? false : true ) , object_for ( obj_ptr ) } Klass . set_OnOutputChange_Handler ( @handle , @on_output_change , pointer_for ( obj )...
Sets an output change handler callback function . This is called when a digital output on the PhidgetRFID board has changed .
11,433
def on_tag ( obj = nil , & block ) @on_tag_obj = obj @on_tag = Proc . new { | device , obj_ptr , tag , proto | yield self , tag . read_string , object_for ( obj_ptr ) } Klass . set_OnTag2_Handler ( @handle , @on_tag , pointer_for ( obj ) ) end
Sets a tag handler callback function . This is called when a new tag is seen by the reader . The event is only fired one time for a new tag so the tag has to be removed and then replaced before another tag gained event will fire .
11,434
def on_tag_lost ( obj = nil , & block ) @on_tag_lost_obj = obj @on_tag_lost = Proc . new { | device , obj_ptr , tag , proto | yield self , tag . read_string , object_for ( obj_ptr ) } Klass . set_OnTagLost2_Handler ( @handle , @on_tag_lost , pointer_for ( obj ) ) end
Sets a tag lost handler callback function . This is called when a tag is removed from the reader
11,435
def antenna ptr = :: FFI :: MemoryPointer . new ( :int ) Klass . getAntennaOn ( @handle , ptr ) ( ptr . get_int ( 0 ) == 0 ) ? false : true end
Returns the antenna state of the Phidget .
11,436
def led ptr = :: FFI :: MemoryPointer . new ( :int ) Klass . getLEDOn ( @handle , ptr ) ( ptr . get_int ( 0 ) == 0 ) ? false : true end
Returns the LED state .
11,437
def tag_present ptr = :: FFI :: MemoryPointer . new ( :int ) Klass . getTagStatus ( @handle , ptr ) ( ptr . get_int ( 0 ) == 0 ) ? false : true end
Returns the value indicating whether or not a tag is on the reader .
11,438
def write ( tag , protocol , lock = false ) tmp = lock ? 1 : 0 Klass . write ( @handle , tag , Phidgets :: FFI :: RFIDTagProtocol [ protocol ] , tmp ) true end
Writes to a tag .
11,439
def set_compass_correction_parameters ( new_mag_field , new_offset0 , new_offset1 , new_offset2 , new_gain0 , new_gain1 , new_gain2 , new_t0 , new_t1 , new_t2 , new_t3 , new_t4 , new_t5 ) Klass . setCompassCorrectionParameters ( @handle , new_mag_field , new_offset0 , new_offset1 , new_offset2 , new_gain0 , new_gain1 ,...
Sets correction paramaters for the magnetometer triad . This is for filtering out hard and soft iron offsets and scaling the output to match the local field strength . These parameters can be obtained from the compass calibration program provided by Phidgets Inc .
11,440
def open ( options ) password = ( options [ :password ] . nil? ? nil : options [ :password ] . to_s ) if ! options [ :server_id ] . nil? Klass . openRemote ( @handle , options [ :server_id ] . to_s , password ) else Klass . openRemoteIP ( @handle , options [ :address ] . to_s , options [ :port ] . to_i , password ) end...
Opens a PhidgetDictionary over the WebService . If you are not programming with the block method you will have to call this explicitly . This is called automatically if you are programming with the block method .
11,441
def delete ( pattern ) Klass . removeKey ( @handle , ( pattern . kind_of? ( Regexp ) ? pattern . source : pattern . to_s ) ) true end
Removes a set of keys from the dictionary
11,442
def on_connect ( obj = nil , & block ) @on_connect_obj = obj @on_connect = Proc . new { | handle , obj_ptr | @listeners . each_pair do | pattern , ( listener , proc ) | begin next if status != :connected Klass . set_OnKeyChange_Handler ( @handle , listener , pattern , proc , pointer_for ( obj ) ) sleep @handler_sleep r...
Sets a server connect handler callback function . This is called when a connection to the server has been made .
11,443
def on_disconnect ( obj = nil , & block ) @on_disconnect_obj = obj @on_disconnect = Proc . new { | handle , obj_ptr | @listeners . each_pair do | pattern , ( listener , proc ) | Klass . remove_OnKeyChange_Handler ( listener . get_pointer ( 0 ) ) sleep @handler_sleep end yield self , object_for ( obj_ptr ) } Klass . set...
Sets a server disconnect handler callback function . This is called when a connection to the server has been lost .
11,444
def on_change ( pattern = ".*" , obj = nil , & block ) pattern = ( pattern . kind_of? ( Regexp ) ? pattern . source : pattern . to_s ) @listeners [ pattern ] = [ :: FFI :: MemoryPointer . new ( :pointer ) , Proc . new { | handle , obj_ptr , key , value , reason | yield object_for ( obj_ptr ) , key , value , reason } ] ...
Adds a key listener to an opened dictionary . Note that this should only be called after the connection has been made - unlike all other events .
11,445
def remove_on_change ( pattern = ".*" ) pattern = ( pattern . kind_of? ( Regexp ) ? pattern . source : pattern . to_s ) if @listeners . has_key? ( pattern ) listener , proc = @listeners . delete ( pattern ) Klass . remove_OnKeyChange_Handler ( listener . get_pointer ( 0 ) ) sleep @handler_sleep true else nil end end
Removes a key listener
11,446
def fetched ( key ) value = self [ key ] return unless value doc = Nokogiri :: XML value doc . at ( "/bibitem/fetched" ) &. text end
Return fetched date
11,447
def action ( path , params ) response = @adapter . get ( path , params ) unless response [ 'result_code' ] == 'done' raise ResultError , response [ 'result_code' ] end self end
Perform an action request against the Pinboard API
11,448
def post ( endpoint , body , headers = { } ) headers = { accept : :json , content_type : :json } . merge ( headers ) @rest_resource [ endpoint ] . post body , headers end
Perform a REST POST operation against the specified endpoint with the given data body
11,449
def on_raw_data ( obj = nil , & block ) @on_raw_data_obj = obj @on_raw_data = Proc . new { | device , obj_ptr , raw_data , data_length | data = [ ] data_length . times { | i | data << raw_data [ i ] . get_int ( 0 ) } yield self , data , data_length , object_for ( obj_ptr ) } Klass . set_OnRawData_Handler ( @handle , @o...
Sets a raw data handler callback function . This is called whenever a new IR data is available . Data is in the form of an array of microsecond pulse values . This can be used if the user wishes to do their own data decoding or for codes that the PhidgetIR cannot automatically recognize .
11,450
def on_code ( obj = nil , & block ) @on_code_obj = obj @on_code = Proc . new { | device , obj_ptr , data , data_length , bit_count , repeat | data_string = [ ] data_length . times { | i | data_string [ i ] = data [ i ] . get_uchar ( 0 ) . to_s ( 16 ) } yield self , data_string , data_length , bit_count , repeat , objec...
Sets a code handler callback function . This is called whenever a new code is recognized .
11,451
def on_learn ( obj = nil , & block ) @on_learn_obj = obj @on_learn = Proc . new { | device , obj_ptr , int_data , data_length , code_info | data = [ ] data_length . times { | i | data [ i ] = int_data [ i ] . get_uchar ( 0 ) . to_s ( 16 ) } code_info_struct = IR_code_info . new ( code_info ) yield self , data , data_le...
Sets a learn handler callback function . This is called when a new code has been learned . This generally requires the button to be held down for a second or two .
11,452
def transmit ( data , code_info ) pdata = :: FFI :: MemoryPointer . new ( :uchar , 16 ) data_ffi = [ ] data . size . times { | i | data_ffi [ i ] = data [ i ] . to_i ( 16 ) } data_ffi = :: FFI :: MemoryPointer . new ( :uchar , 16 ) . write_array_of_uchar ( data_ffi ) Klass . Transmit ( @handle , data_ffi , code_info ) ...
Transmits a code
11,453
def transmit_raw ( data , length , carrier_frequency , duty_cycle , gap ) c_data = :: FFI :: MemoryPointer . new ( :int , data . size ) . write_array_of_int ( data ) Klass . TransmitRaw ( @handle , c_data , length . to_i , carrier_frequency . to_i , duty_cycle . to_i , gap . to_i ) true end
Transmits raw data as a series of pulses and spaces .
11,454
def last_code data_ffi = :: FFI :: MemoryPointer . new ( :uchar , 16 ) data_length = :: FFI :: MemoryPointer . new ( :int ) data_length . write_int ( 16 ) bit_count = :: FFI :: MemoryPointer . new ( :int ) Klass . getLastCode ( @handle , data_ffi , data_length , bit_count ) data = [ ] data_length . get_int ( 0 ) . time...
Gets the last code that was received .
11,455
def last_learned_code data_ffi = :: FFI :: MemoryPointer . new ( :uchar , 16 ) data_length = :: FFI :: MemoryPointer . new ( :int ) data_length . write_int ( 16 ) code_info = :: FFI :: MemoryPointer . new ( IR_code_info ) Klass . getLastLearnedCode ( @handle , data_ffi , data_length , code_info ) data = [ ] data_length...
Gets the last code that was learned .
11,456
def publish_to ( exname , message , opts = { } ) EventMachine . schedule { ex = amq . exchanges [ exname ] || raise ( "Undefined exchange name : #{exname}" ) case ex . type when :topic unless opts . has_key? :key opts [ :key ] = '*' end end ex . publish ( Serializer . instance . marshal ( message ) , opts ) } end
Publish a message to the designated exchange .
11,457
def required_parameters required = { } @input_parameters . each_value { | v | required [ v . name ] = v if v . required? } required end
Get an array of the names of all the required input parameters
11,458
def parameter ( parameter_name , parameter_value = nil ) if @input_parameters . key? ( parameter_name ) @input_parameters [ parameter_name ] . set parameter_value else $stderr . puts "\nAttempted to set a value for a non-existent WorkflowParameter!" $stderr . puts "It appears that there is no parameter \"#{parameter}\"...
Get the parameter object named . If a value is provided set the value and return the parameter object .
11,459
def execute ( workflow_service = nil ) workflow_service = @service if workflow_service . nil? fail ( IOError , ERR [ :no_workflow_service_defined ] ) if workflow_service . nil? verify_parameters @execution_id = workflow_service . execute_workflow ( @id , input_parameter_json ) end
Execute this workflow
11,460
def log ( execution_id = nil ) execution_id = @execution_id if execution_id . nil? log_json = @service . get_log ( @id , execution_id ) VcoWorkflows :: WorkflowExecutionLog . new ( log_json ) end
Return logs for the given execution
11,461
def input_parameter_json tmp_params = [ ] @input_parameters . each_value { | v | tmp_params << v . as_struct if v . set? } param_struct = { parameters : tmp_params } param_struct . to_json end
Convert the input parameters to a JSON document
11,462
def verify_parameters required_parameters . each do | name , wfparam | if wfparam . required? && ( wfparam . value . nil? || wfparam . value . size == 0 ) fail ( IOError , ERR [ :param_verify_failed ] << "#{name} required but not present." ) end end end
Verify that all mandatory input parameters have values
11,463
def default_gw_ipaddr ip = case ` ` . rstrip when 'Linux' ` ` . split ( "\n" ) [ 0 ] . split . last when 'SunOS' ` ` else raise "Unsupported platform to detect gateway IP address: #{`/bin/uname`}" end ip = ip . rstrip raise "Failed to run command lines or empty result" if ip == '' || $? . exitstatus != 0 ip end
Return the IP address assigned to default gw interface
11,464
def list response = @client . get ( '/notes/list' ) response . fetch ( 'notes' , EMPTY_ARRAY ) . map do | note_hash | NoteSummary . from_hash ( note_hash ) end end
Initialize a Notes
11,465
def get ( options = EMPTY_HASH ) parameters = Specification . new ( tag : Types :: Tags , dt : Types :: Time , url : Types :: URL , meta : Types :: Boolean ) . parameters ( options ) posts_from @client . get ( '/posts/get' , parameters ) end
Fetch one or more bookmarks
11,466
def recent ( options = EMPTY_HASH ) parameters = Specification . new ( tag : Types :: Tags , count : Types :: Integer ) . parameters ( options ) posts_from @client . get ( '/posts/recent' , parameters ) end
List the most recent bookmarks
11,467
def all ( options = EMPTY_HASH ) parameters = Specification . new ( tag : Types :: Tags , start : Types :: Integer , results : Types :: Integer , fromdt : Types :: Time , todt : Types :: Time , meta : Types :: Boolean ) . parameters ( options ) results = @client . get ( '/posts/all' , parameters ) results . map { | pos...
List all bookmarks
11,468
def suggest ( url ) parameters = Specification . new ( url : Types :: URL ) . parameters ( url : url ) Suggestion . from_array ( @client . get ( '/posts/suggest' , parameters ) ) end
List popular and recommended tags for a URL
11,469
def dates ( options = EMPTY_HASH ) parameters = Specification . new ( tag : Types :: Tags ) . parameters ( options ) response = @client . get ( '/posts/dates' , parameters ) dates_with_counts_from ( response ) end
List dates with the number of bookmarks created on each
11,470
def posts_from ( response ) response . fetch ( 'posts' , EMPTY_ARRAY ) . map do | post_hash | Post . from_hash ( post_hash ) end end
Create Post objects from posts response
11,471
def dates_with_counts_from ( response ) entries = response . fetch ( 'dates' , EMPTY_HASH ) . map do | date , count | [ Types :: Date . deserialize ( date ) , count . to_i ] end Hash [ entries ] end
Create Hash of dates to counts from dates response
11,472
def on_position_change ( obj = nil , & block ) @on_position_change_obj = obj @on_position_change = Proc . new { | device , obj_ptr , index , position | yield self , @servos [ index ] , position , object_for ( obj_ptr ) } Klass . set_OnPositionChange_Handler ( @handle , @on_position_change , pointer_for ( obj ) ) end
Sets a position change handler callback function . This is called when a the servo position has changed .
11,473
def on_position_fix_status_change ( obj = nil , & block ) @on_position_fix_status_change_obj = obj @on_position_fix_status_change = Proc . new { | device , obj_ptr , fix_status | yield self , ( fix_status == 0 ? false : true ) , object_for ( obj_ptr ) } Klass . set_OnPositionFixStatusChange_Handler ( @handle , @on_posi...
Sets an position fix status change handler callback function . This is called when the position fix status changes .
11,474
def on_position_change ( obj = nil , & block ) @on_position_change_obj = obj @on_position_change = Proc . new { | device , obj_ptr , lat , long , alt | yield self , lat , long , alt , object_for ( obj_ptr ) } Klass . set_OnPositionChange_Handler ( @handle , @on_position_change , pointer_for ( obj ) ) end
Sets position change handler callback function . This is called when the latitude longitude or altitude changes .
11,475
def on_temperature_change ( obj = nil , & block ) @on_temperature_change_obj = obj @on_temperature_change = Proc . new { | device , obj_ptr , index , temperature | yield self , @thermocouples [ index ] , temperature , object_for ( obj_ptr ) } Klass . set_OnTemperatureChange_Handler ( @handle , @on_temperature_change , ...
Sets a temperature change handler callback function . This is called when when the temperature has changed atleast by the sensitivity value that has been set .
11,476
def check_auth_params if ( Fulfil . authentication . nil? || Fulfil . authentication [ :subdomain ] . empty? || Fulfil . authentication [ :api_key ] . empty? ) raise Fulfil :: AuthenticationError , "Please set your subdomain and api key" end end
USed to check if auth is done properly before making calls
11,477
def request ( http_method , data = { } , url = "" ) final_url = @options [ :base_url ] << url begin case http_method when :get response = Curl . get ( final_url , data ) do | http | http . headers [ 'x-api-key' ] = @options [ :api_key ] http . headers [ 'Accept' ] = 'application/json' end end rescue Curl :: Err :: Host...
Issue request and get response
11,478
def get response = @client . get ( '/tags/get' ) Hash [ response . map { | tag , count | [ tag , count . to_i ] } ] end
Initialize a Tags
11,479
def delete ( tag ) parameters = Specification . new ( tag : Types :: Tags ) . parameters ( tag : tag ) @client . action ( '/tags/delete' , parameters ) self end
Delete a tag
11,480
def rename ( old , new ) parameters = Specification . new ( old : Types :: Tags , new : Types :: Tags ) . parameters ( old : old , new : new ) @client . action ( '/tags/rename' , parameters ) self end
Rename a tag
11,481
def change_privilege ( user , group = user ) Wakame . log . info ( "Changing process privilege to #{user}:#{group}" ) uid , gid = Process . euid , Process . egid target_uid = Etc . getpwnam ( user ) . uid target_gid = Etc . getgrnam ( group ) . gid if uid != target_uid || gid != target_gid if pid_file && File . exist? ...
Change privileges of the process to the specified user and group .
11,482
def to_json config = { } config [ 'url' ] = @url config [ 'username' ] = @username config [ 'password' ] = @password config [ 'verify_ssl' ] = @verify_ssl puts JSON . pretty_generate ( config ) end
Return a JSON document for this object
11,483
def on_sensor_change ( obj = nil , & block ) @on_sensor_change_obj = obj @on_sensor_change = Proc . new { | device , obj_ptr , index , value | yield self , @sensors [ index ] , value , object_for ( obj_ptr ) } Klass . set_OnSensorChange_Handler ( @handle , @on_sensor_change , pointer_for ( obj ) ) end
Sets a sensor change handler callback function . This is called when a sensor on the PhidgetInterfaceKit has changed by at least the sensitivity value that has been set for this input .
11,484
def download raise "#{@source_url} is not accessible" unless @url . valid? f = open ( @file_path , 'wb' ) count = 0 @url . net_http . request_get ( @url . path ) do | r | r . read_body do | s | @download_length += s . length f . write s if block_given? count += 1 if count % 100 == 0 yield @download_length end end end e...
downloads a given file into a specified filename . If block is given returns download progress
11,485
def dynamic_image_tag ( record_or_array , options = { } ) record = extract_dynamic_image_record ( record_or_array ) options = { alt : filename_to_alt ( record . filename ) } . merge ( options ) size = fit_size! ( record_or_array , options ) url_options = options . extract! ( * allowed_dynamic_image_url_options ) html_o...
Returns an HTML image tag for the record . If no size is given it will render at the original size .
11,486
def touch! self . check_security! self . last_activity_at = Time . now self . last_activity_ip = controller . request . ip self . last_activity_path = controller . request . path self . requests += 1 self . save! Authie . config . events . dispatch ( :session_touched , self ) true end
This method should be called each time a user performs an action while authenticated with this session .
11,487
def set_cookie! cookies [ :user_session ] = { :value => self . temporary_token , :secure => controller . request . ssl? , :httponly => true , :expires => self . expires_at } Authie . config . events . dispatch ( :session_cookie_updated , self ) true end
Sets the cookie on the associated controller .
11,488
def check_security! if controller if cookies [ :browser_id ] != self . browser_id invalidate! Authie . config . events . dispatch ( :browser_id_mismatch_error , self ) raise BrowserMismatch , "Browser ID mismatch" end unless self . active? invalidate! Authie . config . events . dispatch ( :invalid_session_error , self ...
Check the security of the session to ensure it can be used .
11,489
def invalidate! self . active = false self . save! if controller cookies . delete ( :user_session ) end Authie . config . events . dispatch ( :session_invalidated , self ) true end
Mark this session as invalid
11,490
def see_password! self . password_seen_at = Time . now self . save! Authie . config . events . dispatch ( :seen_password , self ) true end
Note that we have just seen the user enter their password .
11,491
def mark_as_two_factored! self . two_factored_at = Time . now self . two_factored_ip = controller . request . ip self . save! Authie . config . events . dispatch ( :marked_as_two_factored , self ) true end
Mark this request as two factor authoritsed
11,492
def revert_to_parent! if self . parent self . invalidate! self . parent . activate! self . parent . controller = self . controller self . parent . set_cookie! self . parent else raise NoParentSessionForRevert , "Session does not have a parent therefore cannot be reverted." end end
Revert back to the parent session
11,493
def lint_files ( files = nil ) system 'pip install --user proselint' unless proselint_installed? raise "proselint is not in the user's PATH, or it failed to install" unless proselint_installed? markdown_files = get_files files proses = { } to_disable = disable_linters || [ "misc.scare_quotes" , "typography.symbols" ] w...
Lints the globbed markdown files . Will fail if proselint cannot be installed correctly . Generates a markdown list of warnings for the prose in a corpus of . markdown and . md files .
11,494
def with_proselint_disabled ( disable_linters ) proselint_template = File . join ( File . dirname ( __FILE__ ) , 'proselintrc' ) proselintJSON = JSON . parse ( File . read ( proselint_template ) ) disable_linters . each do | linter | proselintJSON [ 'checks' ] [ linter ] = false end temp_proselint_rc_path = File . join...
Creates a temporary proselint settings file
11,495
def save ( path , options = { } ) raise PathMissing if path . nil? || path !~ / \S / Grim . processor . save ( @pdf , @index , path , options ) end
Sets up some instance variables on new instance .
11,496
def find_app_folder_in_ipa raise 'IPA is not open' unless self . open? app_folder_in_ipa = "Payload/#{File.basename(@ipa_path, File.extname(@ipa_path))}.app" mobileprovision_entry = @ipa_zipfile . find_entry ( "#{app_folder_in_ipa}/embedded.mobileprovision" ) info_plist_entry = @ipa_zipfile . find_entry ( "#{app_folder...
Find the . app folder which contains both the embedded . mobileprovision and Info . plist files .
11,497
def load_captcha ( options ) if options [ :raw64 ] options [ :raw64 ] elsif options [ :raw ] Base64 . encode64 ( options [ :raw ] ) elsif options [ :file ] Base64 . encode64 ( options [ :file ] . read ( ) ) elsif options [ :path ] Base64 . encode64 ( File . open ( options [ :path ] , 'rb' ) . read ) elsif options [ :ur...
Load a captcha raw content encoded in base64 from options .
11,498
def captcha ( captcha_id ) response = perform ( 'captcha' , captcha : captcha_id ) DeathByCaptcha :: Captcha . new ( response ) end
Retrieve information from an uploaded captcha .
11,499
def perform ( action , payload = { } ) payload . merge! ( cmd : action , version : DeathByCaptcha :: API_VERSION , username : self . username , password : self . password ) socket = create_socket ( ) socket . puts ( payload . to_json ) response = socket . read ( ) socket . close ( ) begin response = JSON . parse ( resp...
Perform a Socket communication with the DeathByCaptcha API .