FTP UPLOAD FILE Laravel - laravel

I try to send an excel file who was created when i refresh the page. I used the package https://github.com/harishanchu/Laravel-FTP
When i run the code bellow i get an exception like :
pathinfo() expects parameter 1 to be string, array given
I don't want to pick up a file in the storage because the system that i made will run the daily query everyday and send the file via FTP ! so i can't know the path before the file was created.
Hope someone could help me on this ! thanks a lot in advance
here the full code :
$licencies = Licencies::where('lb_assurance' , '=' , 'Lafont')
->leftJoin('activite_licencie' , 'activite_licencie.id' , '=' , 'licencies.activite_licencie_id')
->leftJoin('saisons' , 'saisons.id' , '=' , 'licencies.saison_id')
->leftJoin('pays' , 'pays.id' , '=' , 'licencies.pays_naissance_id')
->leftJoin('type_licence' , 'type_licence.id' , '=' , 'licencies.type_licence_id')
->leftJoin('structures' , 'structures.id' , '=' , 'licencies.structure_id')
->leftJoin('civilite' , 'civilite.id' , '=' , 'licencies.civilite_id')
->leftJoin('catg_licence' , 'catg_licence.id' , '=' , 'licencies.catg_licence_id')
->select('num_licence' , 'civilite.lb_civilite' , 'lb_nom' , 'lb_prenom' , 'dt_naissance' , 'pays.fr' ,'activite_licencie.lb_activite' , 'catg_licence.lb_catg_lic' , 'type_licence.lb_type' ,'saisons.lb_saison', 'lb_surclassement' , 'structures.nom_structure' , 'lb_assurance' , 'cd_dept_naissance' , 'lb_adresse' , 'tel_fix_licencie' , 'tel_port_licencie' , 'adresse_email')
->whereRaw('DATE(licencies.created_at) = CURRENT_DATE')
->get();
$licencies->map(function($licencie) {
$licencie['dt_naissance'] = \Carbon\Carbon::parse($licencie['dt_naissance'])->format('d/m/Y');
//$licencie['created_at'] = \Carbon\Carbon::parse($licencie['created_at'])->format('d/m/Y H:i:s');
return $licencie;
});
$date = Carbon::now('Europe/Paris')->format('d-m-Y H:i:s');
$file = Excel::create('Assurance Lafont - Saisie des Licences FFRXIII le : ' . $date . '' , function($excel) use ($licencies) {
$excel->sheet('Excel', function($sheet) use ($licencies)
{
$sheet->fromArray($licencies);
});
});
$directory = 'mydirectory' ;
$ftp = FTP::connection()->uploadFile($file, $directory);
dd($ftp);

Related

XPath match XML node based on particular attribute values

My XPath expression only matches the 1st node of type Property_Maps with any attributes.
//Ingest_LDD/Property_Maps/*
I want to match a particular Property_Maps based on particular attribute values ,so I created this Xpath:
//Ingest_LDD/Property_Maps[#identifier='identifierABCD' and #title='titleABCD' and #namespace_id='namespace_idABCD' and #description='descriptionABCD' and #external_property_map_id='external_property_map_idABCD' and #external_property_map_id='external_property_map_idABCD' and #Property_Map='identifier' and #Property_Map='identifier']
Another try with # symbol:
//Ingest_LDD/Property_Maps[identifier='identifierABCD' and title='titleABCD' and namespace_id='namespace_idABCD' and description='descriptionABCD' and external_property_map_id='external_property_map_idABCD' and external_property_map_id='external_property_map_idABCD' and Property_Map='identifier' and Property_Map='identifier']
Solution syntax:
//Ingest_LDD/DD_Attribute[name='nameABCD' and version_id='version_idXYZ' and local_identifier='local_identifier2' and nillable_flag='false' and submitter_name='submitter_name2' and definition='definition8' and comment='comment5']
Solution: The issue was that the XPath query builder in Java was appending extra levels of the tree and "attribute as values" rather than attributes=values.
Further question: How can we match based on certain attributes, and get back an element and all its sub-elements to perform a recursive copy down the tree?
However, this expression is not matching or returning a result.
Sample xml:
<?xml version="1.0" encoding="UTF-8" standalone="no"?><!--(name , ldd_version_id , full_name , steward_id , namespace_id , external_property_maps_id* , comment? , last_modification_date_time , DD_Attribute* , DD_Class* , DD_Rule* , Property_Maps*)-->
<Ingest_LDD>
<name>name1</name>
<ldd_version_id>ldd_version_id1</ldd_version_id>
<full_name>full_name1</full_name>
<steward_id>steward_id1</steward_id>
<namespace_id>namespace_id1</namespace_id>
<external_property_maps_id>external_property_maps_id1</external_property_maps_id>
<external_property_maps_id>external_property_maps_id2</external_property_maps_id>
<comment>comment1</comment>
<last_modification_date_time>last_modification_date_time1</last_modification_date_time>
<!--(name , version_id , local_identifier , submitter_name , definition , abstract_flag? , element_flag? , Internal_Reference* , (DD_Association | DD_Association_External)+ , Terminological_Entry*)-->
<DD_Class>
<name>name40</name>
<version_id>version_id3</version_id>
<local_identifier>local_identifier3</local_identifier>
<submitter_name>submitter_name3</submitter_name>
<definition>definition15</definition>
<abstract_flag>false</abstract_flag>
<element_flag>false</element_flag>
<!--((lid_reference | lidvid_reference) , reference_type , comment?)-->
<Internal_Reference>
<lidvid_reference>lidvid_reference_4</lidvid_reference>
<reference_type>reference_type5</reference_type>
<comment>comment8</comment>
</Internal_Reference>
<!--((lid_reference | lidvid_reference) , reference_type , comment?)-->
<Internal_Reference>
<lidvid_reference>lidvid_reference_5</lidvid_reference>
<reference_type>reference_type6</reference_type>
<comment>comment9</comment>
</Internal_Reference>
<DD_Association_External>
<name>name41</name>
<namespace_id>namespace_id2</namespace_id>
<reference_type>reference_type7</reference_type>
<minimum_occurrences>minimum_occurrences1</minimum_occurrences>
<maximum_occurrences>maximum_occurrences1</maximum_occurrences>
</DD_Association_External>
<!--(identifier_reference+ , local_identifier* , reference_type , minimum_occurrences , maximum_occurrences , constant_value? , DD_Attribute_Reference? , DD_Class_Reference?)-->
<DD_Association>
<identifier_reference>identifier_reference1</identifier_reference>
<identifier_reference>identifier_reference2</identifier_reference>
<local_identifier>local_identifier4</local_identifier>
<local_identifier>local_identifier5</local_identifier>
<reference_type>reference_type8</reference_type>
<minimum_occurrences>minimum_occurrences2</minimum_occurrences>
<maximum_occurrences>maximum_occurrences2</maximum_occurrences>
<constant_value>constant_value1</constant_value>
<DD_Attribute_Reference>
<namespace_id>namespace_id3</namespace_id>
<name>name42</name>
</DD_Attribute_Reference>
<DD_Class_Reference>
<namespace_id>namespace_id4</namespace_id>
<name>name43</name>
</DD_Class_Reference>
</DD_Association>
<!--(name , definition , language , preferred_flag , instance_id? , External_Reference_Extended*)-->
<Terminological_Entry>
<name>name44</name>
<definition>definition16</definition>
<language>language13</language>
<preferred_flag>true</preferred_flag>
<instance_id>instance_id13</instance_id>
<!--((doi? , reference_text , description?) , (name? , url?))-->
<External_Reference_Extended>
<doi>doi25</doi>
<reference_text>reference_text25</reference_text>
<description>description25</description>
<name>name45</name>
<url>url25</url>
</External_Reference_Extended>
<!--((doi? , reference_text , description?) , (name? , url?))-->
<External_Reference_Extended>
<doi>doi26</doi>
<reference_text>reference_text26</reference_text>
<description>description26</description>
<name>name46</name>
<url>url26</url>
</External_Reference_Extended>
</Terminological_Entry>
<!--(name , definition , language , preferred_flag , instance_id? , External_Reference_Extended*)-->
<Terminological_Entry>
<name>name47</name>
<definition>definition17</definition>
<language>language14</language>
<preferred_flag>true</preferred_flag>
<instance_id>instance_id14</instance_id>
<!--((doi? , reference_text , description?) , (name? , url?))-->
<External_Reference_Extended>
<doi>doi27</doi>
<reference_text>reference_text27</reference_text>
<description>description27</description>
<name>name48</name>
<url>url27</url>
</External_Reference_Extended>
<!--((doi? , reference_text , description?) , (name? , url?))-->
<External_Reference_Extended>
<doi>doi28</doi>
<reference_text>reference_text28</reference_text>
<description>description28</description>
<name>name49</name>
<url>url28</url>
</External_Reference_Extended>
</Terminological_Entry>
</DD_Class>
<!--(name , version_id , local_identifier , submitter_name , definition , abstract_flag? , element_flag? , Internal_Reference* , (DD_Association | DD_Association_External)+ , Terminological_Entry*)-->
<DD_Class>
<name>name50</name>
<version_id>version_id4</version_id>
<local_identifier>local_identifier6</local_identifier>
<submitter_name>submitter_name4</submitter_name>
<definition>definition18</definition>
<abstract_flag>false</abstract_flag>
<element_flag>true</element_flag>
<!--((lid_reference | lidvid_reference) , reference_type , comment?)-->
<Internal_Reference>
<lidvid_reference>lidvid_reference_6</lidvid_reference>
<reference_type>reference_type9</reference_type>
<comment>comment10</comment>
</Internal_Reference>
<!--((lid_reference | lidvid_reference) , reference_type , comment?)-->
<Internal_Reference>
<lidvid_reference>lidvid_reference_7</lidvid_reference>
<reference_type>reference_type10</reference_type>
<comment>comment11</comment>
</Internal_Reference>
<DD_Association_External>
<name>name51</name>
<namespace_id>namespace_id5</namespace_id>
<reference_type>reference_type11</reference_type>
<minimum_occurrences>minimum_occurrences3</minimum_occurrences>
<maximum_occurrences>maximum_occurrences3</maximum_occurrences>
</DD_Association_External>
<!--(identifier_reference+ , local_identifier* , reference_type , minimum_occurrences , maximum_occurrences , constant_value? , DD_Attribute_Reference? , DD_Class_Reference?)-->
<DD_Association>
<identifier_reference>identifier_reference3</identifier_reference>
<identifier_reference>identifier_reference4</identifier_reference>
<local_identifier>local_identifier7</local_identifier>
<local_identifier>local_identifier8</local_identifier>
<reference_type>reference_type12</reference_type>
<minimum_occurrences>minimum_occurrences4</minimum_occurrences>
<maximum_occurrences>maximum_occurrences4</maximum_occurrences>
<constant_value>constant_value2</constant_value>
<DD_Attribute_Reference>
<namespace_id>namespace_id6</namespace_id>
<name>name52</name>
</DD_Attribute_Reference>
<DD_Class_Reference>
<namespace_id>namespace_id7</namespace_id>
<name>name53</name>
</DD_Class_Reference>
</DD_Association>
<!--(name , definition , language , preferred_flag , instance_id? , External_Reference_Extended*)-->
<Terminological_Entry>
<name>name54</name>
<definition>definition19</definition>
<language>language15</language>
<preferred_flag>true</preferred_flag>
<instance_id>instance_id15</instance_id>
<!--((doi? , reference_text , description?) , (name? , url?))-->
<External_Reference_Extended>
<doi>doi29</doi>
<reference_text>reference_text29</reference_text>
<description>description29</description>
<name>name55</name>
<url>url29</url>
</External_Reference_Extended>
<!--((doi? , reference_text , description?) , (name? , url?))-->
<External_Reference_Extended>
<doi>doi30</doi>
<reference_text>reference_text30</reference_text>
<description>description30</description>
<name>name56</name>
<url>url30</url>
</External_Reference_Extended>
</Terminological_Entry>
<!--(name , definition , language , preferred_flag , instance_id? , External_Reference_Extended*)-->
<Terminological_Entry>
<name>name57</name>
<definition>definition20</definition>
<language>language16</language>
<preferred_flag>true</preferred_flag>
<instance_id>instance_id16</instance_id>
<!--((doi? , reference_text , description?) , (name? , url?))-->
<External_Reference_Extended>
<doi>doi31</doi>
<reference_text>reference_text31</reference_text>
<description>description31</description>
<name>name58</name>
<url>url31</url>
</External_Reference_Extended>
<!--((doi? , reference_text , description?) , (name? , url?))-->
<External_Reference_Extended>
<doi>doi32</doi>
<reference_text>reference_text32</reference_text>
<description>description32</description>
<name>name59</name>
<url>url32</url>
</External_Reference_Extended>
</Terminological_Entry>
</DD_Class>
<!--(local_identifier , rule_context , rule_assign* , DD_Attribute_Reference? , DD_Class_Reference? , DD_Rule_Statement+)-->
<DD_Rule>
<local_identifier>local_identifier9</local_identifier>
<rule_context>rule_context1</rule_context>
<rule_assign>rule_assign1</rule_assign>
<rule_assign>rule_assign2</rule_assign>
<DD_Attribute_Reference>
<namespace_id>namespace_id8</namespace_id>
<name>name60</name>
</DD_Attribute_Reference>
<DD_Class_Reference>
<namespace_id>namespace_id9</namespace_id>
<name>name61</name>
</DD_Class_Reference>
<!--(rule_type , rule_test , rule_message , rule_description? , rule_value*)-->
<DD_Rule_Statement>
<rule_type>rule_type1</rule_type>
<rule_test>rule_test1</rule_test>
<rule_message>rule_message1</rule_message>
<rule_description>rule_description1</rule_description>
<rule_value>rule_value1</rule_value>
<rule_value>rule_value2</rule_value>
</DD_Rule_Statement>
<!--(rule_type , rule_test , rule_message , rule_description? , rule_value*)-->
<DD_Rule_Statement>
<rule_type>rule_type2</rule_type>
<rule_test>rule_test2</rule_test>
<rule_message>rule_message2</rule_message>
<rule_description>rule_description2</rule_description>
<rule_value>rule_value3</rule_value>
<rule_value>rule_value4</rule_value>
</DD_Rule_Statement>
</DD_Rule>
<!--(local_identifier , rule_context , rule_assign* , DD_Attribute_Reference? , DD_Class_Reference? , DD_Rule_Statement+)-->
<DD_Rule>
<local_identifier>local_identifier10</local_identifier>
<rule_context>rule_context2</rule_context>
<rule_assign>rule_assign3</rule_assign>
<rule_assign>rule_assign4</rule_assign>
<DD_Attribute_Reference>
<namespace_id>namespace_id10</namespace_id>
<name>name62</name>
</DD_Attribute_Reference>
<DD_Class_Reference>
<namespace_id>namespace_id11</namespace_id>
<name>name63</name>
</DD_Class_Reference>
<!--(rule_type , rule_test , rule_message , rule_description? , rule_value*)-->
<DD_Rule_Statement>
<rule_type>rule_type3</rule_type>
<rule_test>rule_test3</rule_test>
<rule_message>rule_message3</rule_message>
<rule_description>rule_description3</rule_description>
<rule_value>rule_value5</rule_value>
<rule_value>rule_value6</rule_value>
</DD_Rule_Statement>
<!--(rule_type , rule_test , rule_message , rule_description? , rule_value*)-->
<DD_Rule_Statement>
<rule_type>rule_type4</rule_type>
<rule_test>rule_test4</rule_test>
<rule_message>rule_message4</rule_message>
<rule_description>rule_description4</rule_description>
<rule_value>rule_value7</rule_value>
<rule_value>rule_value8</rule_value>
</DD_Rule_Statement>
</DD_Rule>
<!--(identifier , title? , namespace_id , description? , external_property_map_id* , Property_Map+)-->
<Property_Maps>
<identifier>identifier1</identifier>
<title>title1</title>
<namespace_id>namespace_id12</namespace_id>
<description>description33</description>
<external_property_map_id>external_property_map_id1</external_property_map_id>
<external_property_map_id>external_property_map_id2</external_property_map_id>
<!--(identifier? , title? , model_object_id , model_object_type , instance_id* , external_namespace_id* , description? , Property_Map_Entry+)-->
<Property_Map>
<identifier>identifier2</identifier>
<title>title2</title>
<model_object_id>model_object_id1</model_object_id>
<model_object_type>model_object_type1</model_object_type>
<instance_id>instance_id17</instance_id>
<instance_id>instance_id18</instance_id>
<external_namespace_id>external_namespace_id1</external_namespace_id>
<external_namespace_id>external_namespace_id2</external_namespace_id>
<description>description34</description>
<!--(property_map_type? , property_map_subtype? , property_name , property_value+)-->
<Property_Map_Entry>
<property_map_type>property_map_type1</property_map_type>
<property_map_subtype>property_map_subtype1</property_map_subtype>
<property_name>property_name1</property_name>
<property_value>property_value1</property_value>
<property_value>property_value2</property_value>
</Property_Map_Entry>
<!--(property_map_type? , property_map_subtype? , property_name , property_value+)-->
<Property_Map_Entry>
<property_map_type>property_map_type2</property_map_type>
<property_map_subtype>property_map_subtype2</property_map_subtype>
<property_name>property_name2</property_name>
<property_value>property_value3</property_value>
<property_value>property_value4</property_value>
</Property_Map_Entry>
</Property_Map>
<!--(identifier? , title? , model_object_id , model_object_type , instance_id* , external_namespace_id* , description? , Property_Map_Entry+)-->
<Property_Map>
<identifier>identifier3</identifier>
<title>title3</title>
<model_object_id>model_object_id2</model_object_id>
<model_object_type>model_object_type2</model_object_type>
<instance_id>instance_id19</instance_id>
<instance_id>instance_id20</instance_id>
<external_namespace_id>external_namespace_id3</external_namespace_id>
<external_namespace_id>external_namespace_id4</external_namespace_id>
<description>description35</description>
<!--(property_map_type? , property_map_subtype? , property_name , property_value+)-->
<Property_Map_Entry>
<property_map_type>property_map_type3</property_map_type>
<property_map_subtype>property_map_subtype3</property_map_subtype>
<property_name>property_name3</property_name>
<property_value>property_value5</property_value>
<property_value>property_value6</property_value>
</Property_Map_Entry>
<!--(property_map_type? , property_map_subtype? , property_name , property_value+)-->
<Property_Map_Entry>
<property_map_type>property_map_type4</property_map_type>
<property_map_subtype>property_map_subtype4</property_map_subtype>
<property_name>property_name4</property_name>
<property_value>property_value7</property_value>
<property_value>property_value8</property_value>
</Property_Map_Entry>
</Property_Map>
</Property_Maps>
<!--(identifier , title? , namespace_id , description? , external_property_map_id* , Property_Map+)-->
<Property_Maps>
<identifier>identifierABCD</identifier>
<title>titleABCD</title>
<namespace_id>namespace_idABCD</namespace_id>
<description>descriptionABCD</description>
<external_property_map_id>external_property_map_idABCD</external_property_map_id>
<external_property_map_id>external_property_map_idABCD</external_property_map_id>
<!--(identifier? , title? , model_object_id , model_object_type , instance_id* , external_namespace_id* , description? , Property_Map_Entry+)-->
<Property_Map>
<identifier>identifierABCD</identifier>
<title>title5</title>
<model_object_id>model_object_id3</model_object_id>
<model_object_type>model_object_type3</model_object_type>
<instance_id>instance_id21</instance_id>
<instance_id>instance_id22</instance_id>
<external_namespace_id>external_namespace_id5</external_namespace_id>
<external_namespace_id>external_namespace_id6</external_namespace_id>
<description>description37</description>
<!--(property_map_type? , property_map_subtype? , property_name , property_value+)-->
<Property_Map_Entry>
<property_map_type>property_map_type5</property_map_type>
<property_map_subtype>property_map_subtype5</property_map_subtype>
<property_name>property_name5</property_name>
<property_value>property_value9</property_value>
<property_value>property_value10</property_value>
</Property_Map_Entry>
<!--(property_map_type? , property_map_subtype? , property_name , property_value+)-->
<Property_Map_Entry>
<property_map_type>property_map_type6</property_map_type>
<property_map_subtype>property_map_subtype6</property_map_subtype>
<property_name>property_name6</property_name>
<property_value>property_value11</property_value>
<property_value>property_value12</property_value>
</Property_Map_Entry>
</Property_Map>
<!--(identifier? , title? , model_object_id , model_object_type , instance_id* , external_namespace_id* , description? , Property_Map_Entry+)-->
<Property_Map>
<identifier>identifierABCD</identifier>
<title>title6</title>
<model_object_id>model_object_id4</model_object_id>
<model_object_type>model_object_type4</model_object_type>
<instance_id>instance_id23</instance_id>
<instance_id>instance_id24</instance_id>
<external_namespace_id>external_namespace_id7</external_namespace_id>
<external_namespace_id>external_namespace_id8</external_namespace_id>
<description>description38</description>
<!--(property_map_type? , property_map_subtype? , property_name , property_value+)-->
<Property_Map_Entry>
<property_map_type>property_map_type7</property_map_type>
<property_map_subtype>property_map_subtype7</property_map_subtype>
<property_name>property_name7</property_name>
<property_value>property_value13</property_value>
<property_value>property_value14</property_value>
</Property_Map_Entry>
<!--(property_map_type? , property_map_subtype? , property_name , property_value+)-->
<Property_Map_Entry>
<property_map_type>property_map_type8</property_map_type>
<property_map_subtype>property_map_subtype8</property_map_subtype>
<property_name>property_name8</property_name>
<property_value>property_value15</property_value>
<property_value>property_value16</property_value>
</Property_Map_Entry>
</Property_Map>
</Property_Maps>
</Ingest_LDD>
The main mistake you're making is using #, which selects an attribute of the xml node, when actually you want to evaluate the contents of a child of the xml node. You probably want something more like this.
//Ingest_LDD/Property_Maps[identifier='identifierABCD' and title='titleABCD' and namespace_id='namespace_idABCD' and description='descriptionABCD' and external_property_map_id='external_property_map_idABCD']
As noted in the comment above, however, it's unclear what the intent of #Property_Map='identifier' and #Property_Map='identifier' is. Perhaps this was a typo?

Batch changing and replacing file extension in subdirs

I want to batch-change files which lie in subdirs. The extension of the existing files is *.ada.npp. I would like to change it to *.ada. The thing is there are files already existing with the desired extension *.ada. Those files need to be replaced.
I tried with mmv and mv extensively but was not successfull (see below).
mmv -rd ';*.npp' '\#1'
$ mmv -rd ';*.npp' '\#1'
mechanisation/nav_kernel/acdc_alignment.1.ada.npp , mechanisation/nav_kernel/acdc_types.1.ada.npp , mechanisation/nav_ke
rnel/acdc_types.2.ada.npp , mechanisation/nav_kernel/ahrs_manager.1.ada.npp , mechanisation/nav_kernel/ahrs_manager.2.ad
a.npp , mechanisation/nav_kernel/aim_augmentation.1.ada.npp , mechanisation/nav_kernel/aim_augmentation.2.ada.npp , mech
anisation/nav_kernel/aim_types.1.ada.npp , mechanisation/nav_kernel/aim_types.2.ada.npp , mechanisation/nav_kernel/analy
tic_platform.1.ada.npp , mechanisation/nav_kernel/analytic_platform.2.ada.npp , mechanisation/nav_kernel/earth_model.1.a
da.npp , mechanisation/nav_kernel/earth_model.2.ada.npp , mechanisation/nav_kernel/ecef_conversions.1.ada.npp , mechanis
ation/nav_kernel/ecef_conversions.2.ada.npp , mechanisation/nav_kernel/egm_2008_gravity_model.1.ada.npp , mechanisation/
nav_kernel/egm_2008_gravity_model.2.ada.npp , mechanisation/nav_kernel/fast_strapdown_manager.1.ada.npp , mechanisation/
nav_kernel/fast_strapdown_manager.2.ada.npp , mechanisation/nav_kernel/geoid.1.ada.npp , mechanisation/nav_kernel/geoid.
2.ada.npp , mechanisation/nav_kernel/gps_toolbox.1.ada.npp , mechanisation/nav_kernel/gps_toolbox.2.ada.npp , mechanisat
ion/nav_kernel/gravity_augmentation.1.ada.npp , mechanisation/nav_kernel/gravity_augmentation.2.ada.npp , mechanisation/
nav_kernel/gyrocompass.1.ada.npp , mechanisation/nav_kernel/gyrocompass.2.ada.npp , mechanisation/nav_kernel/heading_irs
_slew.1.ada.npp , mechanisation/nav_kernel/heading_irs_slew.2.ada.npp , mechanisation/nav_kernel/inertial_data_processin
g.1.ada.npp , mechanisation/nav_kernel/inertial_data_processing.2.ada.npp , mechanisation/nav_kernel/inertial_measuremen
t_pipe.1.ada.npp , mechanisation/nav_kernel/inertial_measurement_pipe.2.ada.npp , mechanisation/nav_kernel/input_validat
ion.1.ada.npp , mechanisation/nav_kernel/input_validation.2.ada.npp , mechanisation/nav_kernel/integrity_monitor.1.ada.n
pp , mechanisation/nav_kernel/integrity_monitor.2.ada.npp , mechanisation/nav_kernel/irs_manager.1.ada.npp , mechanisati
on/nav_kernel/irs_manager.2.ada.npp , mechanisation/nav_kernel/magvar.1.ada.npp , mechanisation/nav_kernel/magvar.2.ada.
npp , mechanisation/nav_kernel/main_manager.1.ada.npp , mechanisation/nav_kernel/main_manager.2.ada.npp , mechanisation/
nav_kernel/main_manager_fast.1.ada.npp , mechanisation/nav_kernel/main_manager_fast.2.ada.npp , mechanisation/nav_kernel
/main_manager_slow.1.ada.npp , mechanisation/nav_kernel/main_manager_slow.2.ada.npp , mechanisation/nav_kernel/motion_se
nsor.1.ada.npp , mechanisation/nav_kernel/motion_sensor.2.ada.npp , mechanisation/nav_kernel/navigation.1.ada.npp , mech
anisation/nav_kernel/navigation.2.ada.npp , mechanisation/nav_kernel/output_preparation.1.ada.npp , mechanisation/nav_ke
rnel/output_preparation.2.ada.npp , mechanisation/nav_kernel/output_preparation_fast.1.ada.npp , mechanisation/nav_kerne
l/output_preparation_fast.2.ada.npp , mechanisation/nav_kernel/pressure_altitude_augmentation.1.ada.npp , mechanisation/
nav_kernel/pressure_altitude_augmentation.2.ada.npp , mechanisation/nav_kernel/satellites_bookkeeper.1.ada.npp , mechani
sation/nav_kernel/satellites_bookkeeper.2.ada.npp , mechanisation/nav_kernel/sea_alignment.1.ada.npp , mechanisation/nav
_kernel/sea_alignment.2.ada.npp , mechanisation/nav_kernel/stationary_heading_stabilization.1.ada.npp , mechanisation/na
v_kernel/stationary_heading_stabilization.2.ada.npp , mechanisation/nav_kernel/strapdown_ecef.1.ada.npp , mechanisation/
nav_kernel/strapdown_ecef.2.ada.npp , mechanisation/nav_kernel/true_airspeed_augmentation.1.ada.npp , mechanisation/nav_
kernel/true_airspeed_augmentation.2.ada.npp , mechanisation/nav_kernel/zero_velocity_augmentation.1.ada.npp , mechanisat
ion/nav_kernel/zero_velocity_augmentation.2.ada.npp -> mechanisation/nav_kernel/#1 : collision.
Nothing done.
Use find.
find . -name '*.ada.npp' -exec sh -c '
for f; do
mv -- "$f" "${f%.npp}"
done' _ {} +
This loop will do what you need. Launch it from the top level directory where you want to start your search
IFS="
";for F in `find . -name "*.ada.npp"`;do B1=`echo "$F" | sed 's/.ada.npp$//'`;mv -- "$F" "$B1.ada";done

Laravel Function at Scheduler

I have a laravel 5.2 project and i want to run laravel scheduler by specified time from database data, so i create schedule kernel like this :
protected function schedule( Schedule $schedule )
{
// Run proposal schedule to generate albums
$proposals = Proposal::whereStatus( true )->whereGenerated( false )->get();
foreach ( $proposals as $key => $proposal ) {
$time = date( 'i G ', strtotime( $proposal->duedate ) );
$send_date = date( $time . 'j n * Y', strtotime( $proposal->created_at . ' + ' . $proposal->timeout . ' days' ) );
$schedule->call( function() use( $proposal ) {
$proposal->generateAlbums();
} )->cron( $send_date );
}
}
And it's work fine, until i reset my migration and try to migrate from the begining, i got an error like this
SQLSTATE[42P01]: Undefined table: 7 ERROR: relation "proposals" does not exist
So i think it's not good if i place my code there, right??
where should i place my code for this??
Or it's already right and what i need just to check if database table are exists or not??
I need best solution to code just the way laravel provide..
You can check if table exists or not by
if (Schema::hasTable('proposals')) {
//Your code which needs to execute
}

Pig CLI getting stuck with ">>" symbol prompting for input

I'd like to understand what is wrong with below Pig code. The last time of below code cause Pig CLI getting stuck with ">>" prompting for input but regardless of what I enter, it continued to prompt.
newServiceIdMapping = load '/idn/home/data/new/ServiceIdMapping_test.csv' USING PigStorage(',') AS (market : chararray , serviceId : chararray , rm : chararray , serviceChannel : chararray , team : chararray , pm : chararray , tl : chararray , gh : chararray );
newServiceIdMappingUpd = FOREACH newServiceIdMapping GENERATE (serviceId,rm , (pm == '' ? tl : pm) As pm1 );
Exclude the brackets after GENERATE.
newServiceIdMapping = load '/idn/home/data/new/ServiceIdMapping_test.csv' USING PigStorage(',') AS (market : chararray , serviceId : chararray , rm : chararray , serviceChannel : chararray , team : chararray , pm : chararray , tl : chararray , gh : chararray );
newServiceIdMappingUpd = FOREACH newServiceIdMapping GENERATE serviceId,rm , (pm == '' ? tl : pm) as pm1 ;

How to convert windows-1256 to utf-8 in lua?

I need to convert Arabic text from windows-1256 to utf-8 how can I do that? any help?
thanks
Try lua-iconv, which binds iconv to Lua.
local win2utf_list = [[
0x00 0x0000 #NULL
0x01 0x0001 #START OF HEADING
0x02 0x0002 #START OF TEXT
-- Download full text from
-- http://www.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/WINDOWS/CP1256.TXT
0xFD 0x200E #LEFT-TO-RIGHT MARK
0xFE 0x200F #RIGHT-TO-LEFT MARK
0xFF 0x06D2 #ARABIC LETTER YEH BARREE
]]
local win2utf = {}
for w, u in win2utf_list:gmatch'0x(%x%x)%s+0x(%x+)' do
local c, t, h = tonumber(u,16), {}, 128
while c >= h do
t[#t+1] = 128 + c%64
c = math.floor(c/64)
h = h > 32 and 32 or h/2
end
t[#t+1] = 256 - 2*h + c
win2utf[w.char(tonumber(w,16))] =
w.char((table.unpack or unpack)(t)):reverse()
end
local function convert_to_utf8(win_string)
return win_string:gsub('.', win2utf)
end
Windows-1256 is one of the character-sets designed as an 8-bit overlay of ASCII. It therefore has 256 characters, each encoded as one byte.
UTF-8 is an encoding of the Unicode character-set. Being "universal", it works out that it is a superset of the Windows-1256 character-set. So, there is no loss of information by having to use "substitution characters" in place of ones that aren't members of the character-set.
Conversion is a simple matter of transforming the Windows-1256 byte for each character to the corresponding UTF-8 bytes. A lookup table is an easy way to do it.
local encoding = {
-- table maps the one byte Windows-1256 encoding for a character to a Lua string with the UTF-8 encoding for the character
"\000" , "\001" , "\002" , "\003" , "\004" , "\005" , "\006" , "\007" ,
"\008" , "\009" , "\010" , "\011" , "\012" , "\013" , "\014" , "\015" ,
"\016" , "\017" , "\018" , "\019" , "\020" , "\021" , "\022" , "\023" ,
"\024" , "\025" , "\026" , "\027" , "\028" , "\029" , "\030" , "\031" ,
"\032" , "\033" , "\034" , "\035" , "\036" , "\037" , "\038" , "\039" ,
"\040" , "\041" , "\042" , "\043" , "\044" , "\045" , "\046" , "\047" ,
"\048" , "\049" , "\050" , "\051" , "\052" , "\053" , "\054" , "\055" ,
"\056" , "\057" , "\058" , "\059" , "\060" , "\061" , "\062" , "\063" ,
"\064" , "\065" , "\066" , "\067" , "\068" , "\069" , "\070" , "\071" ,
"\072" , "\073" , "\074" , "\075" , "\076" , "\077" , "\078" , "\079" ,
"\080" , "\081" , "\082" , "\083" , "\084" , "\085" , "\086" , "\087" ,
"\088" , "\089" , "\090" , "\091" , "\092" , "\093" , "\094" , "\095" ,
"\096" , "\097" , "\098" , "\099" , "\100" , "\101" , "\102" , "\103" ,
"\104" , "\105" , "\106" , "\107" , "\108" , "\109" , "\110" , "\111" ,
"\112" , "\113" , "\114" , "\115" , "\116" , "\117" , "\118" , "\119" ,
"\120" , "\121" , "\122" , "\123" , "\124" , "\125" , "\126" , "\127" ,
"\226\130\172", "\217\190" , "\226\128\154", "\198\146" , "\226\128\158", "\226\128\166", "\226\128\160", "\226\128\161",
"\203\134" , "\226\128\176", "\217\185" , "\226\128\185", "\197\146" , "\218\134" , "\218\152" , "\218\136" ,
"\218\175" , "\226\128\152", "\226\128\153", "\226\128\156", "\226\128\157", "\226\128\162", "\226\128\147", "\226\128\148",
"\218\169" , "\226\132\162", "\218\145" , "\226\128\186", "\197\147" , "\226\128\140", "\226\128\141", "\218\186" ,
"\194\160" , "\216\140" , "\194\162" , "\194\163" , "\194\164" , "\194\165" , "\194\166" , "\194\167" ,
"\194\168" , "\194\169" , "\218\190" , "\194\171" , "\194\172" , "\194\173" , "\194\174" , "\194\175" ,
"\194\176" , "\194\177" , "\194\178" , "\194\179" , "\194\180" , "\194\181" , "\194\182" , "\194\183" ,
"\194\184" , "\194\185" , "\216\155" , "\194\187" , "\194\188" , "\194\189" , "\194\190" , "\216\159" ,
"\219\129" , "\216\161" , "\216\162" , "\216\163" , "\216\164" , "\216\165" , "\216\166" , "\216\167" ,
"\216\168" , "\216\169" , "\216\170" , "\216\171" , "\216\172" , "\216\173" , "\216\174" , "\216\175" ,
"\216\176" , "\216\177" , "\216\178" , "\216\179" , "\216\180" , "\216\181" , "\216\182" , "\195\151" ,
"\216\183" , "\216\184" , "\216\185" , "\216\186" , "\217\128" , "\217\129" , "\217\130" , "\217\131" ,
"\195\160" , "\217\132" , "\195\162" , "\217\133" , "\217\134" , "\217\135" , "\217\136" , "\195\167" ,
"\195\168" , "\195\169" , "\195\170" , "\195\171" , "\217\137" , "\217\138" , "\195\174" , "\195\175" ,
"\217\139" , "\217\140" , "\217\141" , "\217\142" , "\195\180" , "\217\143" , "\217\144" , "\195\183" ,
"\217\145" , "\195\185" , "\217\146" , "\195\187" , "\195\188" , "\226\128\142", "\226\128\143", "\219\146"
}
--
encoding.convert = function(str)
assert(type(str) == "string", "Parameter 1 must be a string")
local result = {}
for i = 1, string.len(str) do
table.insert(result, encoding[string.byte(str,i)+1])
end
return table.concat(result)
end
assert(encoding.convert("test1") == "test1", "test1 failed")
Refs:
Joel Spolsky, The Absolute Minimum Every Software Developer Absolutely, Positively Must Know About Unicode and Character Sets (No Excuses!)
Roberto Ierusalimschy, Creating Strings Piece by Piece
Generally, convert from a code page (character set) to another. Must use a map table.
Which like: http://www.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/WINDOWS/CP1256.TXT, from CP1256 to Unicode.
Then convert from Unicode to Utf8 (encode/decode method works between Unicode & UTF-8 , without a big map).

Resources