text:
" width="0.3937" layer="16"/>
<wire x1="66.6242" y1="34.4043" x2="67.1703" y2="34.4043" width="0.3937" layer="1"/>
<wire x1="66.0781" y1="34.9504" x2="66.6242" y2="34.4043" width="0.3937" layer="1"/>
<wire x1="65.80505" y1="34.9504" x2="66.0781" y2="34.9504" width="0.3937" layer="1"/>
<wire x1="64.9859" y1="35.76955" x2="65.80505" y2="34.9504" width="0.3937" layer="1"/>
<wire x1="64.71285" y1="35.76955" x2="64.9859" y2="35.76955" width="0.3937" layer="1"/>
<wire x1="63.62065" y1="34.67735" x2="64.71285" y2="35.76955" width="0.3937" layer="1"/>
<wire x1="63.07455" y1="34.67735" x2="63.62065" y2="34.67735" width="0.3937" layer="1"/>
<wire x1="62.2554" y1="33.8582" x2="63.07455" y2="34.67735" width="0.3937" layer="1"/>
<wire x1="60.6171" y1="33.8582" x2="62.2554" y2="33.8582" width="0.3937" layer="1"/>
<wire x1="60.34405" y1="34.13125" x2="60.6171" y2="33.8582" width="0.3937" layer="1"/>
<wire x1="59.79795" y1="34.13125" x2="60.34405" y2="34.13125" width="0.3937" layer="1"/>
<wire x1="67.1703" y1="34.4043" x2="67.31" y2="34.29" width="0.3937" layer="1"/>
<wire x1="59.79795" y1="34.13125" x2="59.69" y2="34.29" width="0.3937" layer="1"/>
<wire x1="38.227" y1="2.7305" x2="39.3192" y2="2.7305" width="0.3937" layer="1"/>
<wire x1="36.86175" y1="4.09575" x2="38.227" y2="2.7305" width="0.3937" layer="1"/>
<wire x1="36.86175" y1="10.3759" x2="36.86175" y2="4.09575" width="0.3937" layer="1"/>
<wire x1="37.6809" y1="11.19505" x2="36.86175" y2="10.3759" width="0.3937" layer="1"/>
<wire x1="37.6809" y1="12.5603" x2="37.6809" y2="11.19505" width="0.3937" layer="16"/>
<wire x1="39.04615" y1="13.92555" x2="37.6809" y2="12.5603" width="0.3937" layer="16"/>
<wire x1="46.4185" y1="13.92555" x2="39.04615" y2="13.92555" width="0.3937" layer="16"/>
<wire x1="50.2412" y1="17.74825" x2="46.4185" y2="13.92555" width="0.3937" layer="16"/>
<wire x1="52.69865" y1="17.74825" x2="50.2412" y2="17.74825" width="0.3937" layer="16"/>
<wire x1="56.52135" y1="21.57095" x2="52.69865" y2="17.74825" width="0.3937" layer="16"/>
<wire x1="56.52135" y1="24.0284" x2="56.52135" y2="21.57095" width="0.3937" layer="16"/>
<wire x1="56.52135" y1="31.94685" x2="56.52135" y2="24.0284" width="0.3937" layer="1"/>
<wire x1="58.4327" y1="33.8582" x2="56.52135" y2="31.94685" width="0.3937" layer="1"/>
<wire x1="58.70575" y1="33.8582" x2="58.4327" y2="33.8582" width="0.3937" layer="1"/>
<wire x1="58.9788" y1="34.13125" x2="58.70575" y2="33.8582" width="0.3937" layer="1"/>
<wire x1="59.5249" y1="34.13125" x2="58.9788" y2="34.13125" width="0.3937" layer="1"/>
<wire x1="39.3192" y1="2.7305" x2="39.37" y2="2.54" width="0.3937" layer="1"/>
<wire x1="59.5249" y1="34.13125" x2="59.69" y2="34.29" width="0.3937" layer="1"/>
<via x="37.6809" y="11.19505" extent="1-16" drill="0.35"/>
<via x="56.52135" y="24.0284" extent="1-16" drill="0.35"/>
</signal>
<signal name="PD1">
<contactref element="SV1" pad="23"/>
<contactref element="U1" pad="3"/>
<contactref element="SV4" pad="5"/>
<wire x1="72.35825" y1="39.3192" x2="73.45045" y2="39.3192" width="0.3937" layer="1"/>
<wire x1="69.3547" y1="36.31565" x2="72.35825" y2="39.3192" width="0.3937" layer="1"/>
<wire x1="69.3547" y1="34.67735" x2="69.3547" y2="36.31565" width="0.3937" layer="1"/>
<wire x1="67.7164" y1="33.03905" x2="69.3547" y2="34.67735" width="0.3937" layer="1"/>
<wire x1="66.89725" y1="33.03905" x2="67.7164" y2="33.03905" width="0.3937" layer="1"/>
<wire x1="65.532" y1="31.6738" x2="66.89725" y2="33.03905" width="0.3937" layer="1"/>
<wire x1="64.9859" y1="31.6738" x2="65.532" y2="31.6738" width="0.3937" layer="1"/>
<wire x1="73.45045" y1="39.3192" x2="73.66" y2="39.37" width="0.3937" layer="1"/>
<wire x1="64.9859" y1="31.6738" x2="64.77" y2="31.75" width="0.3937" layer="1"/>
<wire x1="57.8866" y1="31.94685" x2="52.15255" y2="31.94685" width="0.3937" layer="16"/>
<wire x1="58.4327" y1="32.49295" x2="57.8866" y2="31.94685" width="0.3937" layer="16"/>
<wire x1="58.70575" y1="32.49295" x2="58.4327" y2="32.49295" width="0.3937" layer="1"/>
<wire x1="59.25185" y1="33.03905" x2="58.70575" y2="32.49295" width="0.3937" layer="1"/>
<wire x1="60.34405" y1="33.03905" x2="59.25185" y2="33.03905" width="0.3937" layer="1"/>
<wire x1="60.89015" y1="32.49295" x2="60.34405" y2="33.03905" width="0.3937" layer="1"/>
<wire x1="61.43625" y1="33.03905" x2="60.89015" y2="32.49295" width="0.3937" layer="1"/>
<wire x1="62.8015" y1="33.03905" x2="61.43625" y2="33.03905" width="0.3937" layer="1"/>
<wire x1="64.16675" y1="31.6738" x2="62.8015" y2="33.03905" width="0.3937" layer="1"/>
<wire x1="64.71285" y1="31.6738" x2="64.16675" y2="31.6738" width="0.3937" layer="1"/>
<wire x1="52.15255" y1="31.94685" x2="52.07" y2="31.75" width="0.3937" layer="16"/>
<wire x1="64.71285" y1="31.6738" x2="64.77" y2="31.75" width="0.3937" layer="1"/>
<via x="58.4327" y="32.49295" extent="1-16" drill="0.35"/>
</signal>
<signal name="PC3">
<contactref element="SV1" pad="24"/>
<contactref element="U1" pad="26"/>
<wire x1="66.0781" y1="31.94685" x2="67.1703" y2="31.94685" width="0.3937" layer="16"/>
<wire x1="64.9859" y1="33.03905" x2="66.0781" y2="31.94685" width="0.3937" layer="16"/>
<wire x1="64.4398" y1="33.03905" x2="64.9859" y2="33.03905" width="0.3937" layer="16"/>
<wire x1="63.3476" y1="31.94685" x2="64.4398" y2="33.03905" width="0.3937" layer="16"/>
<wire x1="59.79795" y1="31.94685" x2="63.3476" y2="31.94685" width="0.3937" layer="16"/>
<wire x1="67.1703" y1="31.94685" x2="67.31" y2="31.75" width="0.3937" layer="16"/>
<wire x1="59.79795" y1="31.94685" x2="59.69" y2="31.75" width="0.3937" layer="16"/>
</signal>
<signal name="PD2">
<contactref element="SV1" pad="21"/>
<contactref element="U1" pad="4"/>
<wire x1="64.16675" y1="29.21635" x2="64.71285" y2="29.21635" width="0.3937" layer="1"/>
<wire x1="60.34405" y1="25.39365" x2="64.16675" y2="29.21635" width="0.3937" layer="1"/>
<wire x1="59.25185" y1="25.39365" x2="60.34405" y2="25.39365" width="0.3937" layer="1"/>
<wire x1="58.4327" y1="26.2128" x2="59.25185" y2="25.39365" width="0.3937" layer="1"/>
<wire x1="58.15965" y1="26.2128" x2="58.4327" y2="26.2128" width="0.3937" layer="1"/>
<wire x1="54.88305" y1="26.2128" x2="58.15965" y2="26.2128" width="0.3937" layer="16"/>
<wire x1="52.15255" y1="28.9433" x2="54.88305" y2="26.2128" width="0.3937" layer="16"/>
<wire x1="64.71285" y1="29.21635" x2="64.77" y2="29.21" width="0.3937" layer="1"/>
<wire x1="52.15255" y1="28.9433" x2="52.07" y2="29.21" width="0.3937" layer="16"/>
<via x="58.15965" y="26.2128" extent="1-16" drill="0.35"/>
</signal>
<signal name="PC2">
<contactref element="SV1" pad="22"/>
<contactref element="U1" pad="25"/>
<wire x1="66.35115" y1="29.21635" x2="67.1703" y2="29.21635" width="0.3937" layer="16"/>
<wire x1="65.25895" y1="30.30855" x2="66.35115" y2="29.21635" width="0.3937" layer="16"/>
<wire x1="60.89015" y1="30.30855" x2="65.25895" y2="30.30855" width="0.3937" layer="16"/>
<wire x1="59.79795" y1="29.21635" x2="60.89015" y2="30.30855" width="0.3937" layer="16"/>
<wire x1="67.1703" y1="29.21635" x2="67.31" y2="29.21" width="0.3937" layer="16"/>
<wire x1="59.79795" y1="29.21635" x2="59.69" y2="29.21" width="0.3937" layer="16"/>
</signal>
<signal name="PD3">
<contactref element="SV1" pad="19"/>
<contactref element="U1" pad="5"/>
<wire x1="61.43625" y1="26.48585" x2="64.71285" y2="26.48585" width="0.3937" layer="16"/>
<wire x1="60.34405" y1="25.39365" x2="61.43625" y2="26.48585" width="0.3937" layer="16"/>
<wire x1="53.24475" y1="25.39365" x2="60.34405" y2="25.39365" width="0.3937" layer="16"/>
<wire x1="52.15255" y1="26.48585" x2="53.24475" y2="25.39365" width="0.3937" layer="16"/>
<wire x1="64.71285" y1="26.48585" x2="64.77" y2="26.67" width="0.3937" layer="16"/>
<wire x1="52.15255" y1="26.48585" x2="52.07" y2="26.67" width="0.3937" layer="16"/>
</signal>
<signal name="PC1">
<contactref element="SV1" pad="20"/>
<contactref element="U1" pad="24"/>
<wire x1="66.35115" y1="26.7589" x2="67.1703" y2="26.7589" width="0.3937" layer="16"/>
<wire x1="65.25895" y1="27.8511" x2="66.35115" y2="26.7589" width="0.3937" layer="16"/>
<wire x1="60.89015" y1="27.8511" x2="65.25895" y2="27.8511" width="0.3937" layer="16"/>
<wire x1="59.79795" y1="26.7589" x2="60.89015" y2="27.8511" width="0.3937" layer="16"/>
<wire x1="67.1703" y1="26.7589" x2="67.31" y2="26.67" width="0.3937" layer="16"/>
<wire x1="59.79795" y1="26.7589" x2="59.69" y2="26.67" width="0.3937" layer="16"/>
</signal>
<signal name="PD4">
<contactref element="SV1" pad="17"/>
<contactref element="U1" pad="6"/>
<wire x1="61.43625" y1="24.0284" x2="64.71285" y2="24.0284" width="0.3937" layer="16"/>
<wire x1="60.34405" y1="22.9362" x2="61.43625" y2="24.0284" width="0.3937" layer="16"/>
<wire x1="58.70575" y1="22.9362" x2="60.34405" y2="22.9362" width="0.3937" layer="16"/>
<wire x1="56.7944" y1="24.84755" x2="58.70575" y2="22.9362" width="0.3937" layer="16"/>
<wire x1="52.69865" y1="24.84755" x2="56.7944" y2="24.84755" width="0.3937" layer="16"/>
<wire x1="52.15255" y1="24.30145" x2="52.69865" y2="24.84755" width="0.3937" layer="16"/>
<wire x1="64.71285" y1="24.0284" x2="64.77" y2="24.13" width="0.3937" layer="16"/>
<wire x1="52.15255" y1="24.30145" x2="52.07" y2="24.13" width="0.3937" layer="16"/>
</signal>
<signal name="PC0">
<contactref element="SV1" pad="18"/>
<contactref element="U1" pad="23"/>
<wire x1="66.35115" y1="24.30145" x2="67.1703" y2="24.30145" width="0.3937" layer="16"/>
<wire x1="65.25895" y1="25.39365" x2="66.35115" y2="24.30145" width="0.3937" layer="16"/>
<wire x1="61.1632" y1="25.39365" x2="65.25895" y2="25.39365" width="0.3937" layer="16"/>
<wire x1="59.79795" y1="24.0284" x2="61.1632" y2="25.39365" width="0.3937" layer="16"/>
<wire x1="67.1703" y1="24.30145" x2="67.31" y2="24.13" width="0.3937" layer="16"/>
<wire x1="59.79795" y1="24.0284" x2="59.69" y2="24.13" width="0.3937" layer="16"/>
</signal>
<signal name="AREF">
<contactref element="SV1" pad="14"/>
<contactref element="C4" pad="1"/>
<contactref element="C5" pad="1"/>
<contactref element="U1" pad="21"/>
<wire x1="66.35115" y1="19.1135" x2="67.1703" y2="19.1135" width="0.3937" layer="16"/>
<wire x1="65.25895" y1="20.2057" x2="66.35115" y2="19.1135" width="0.3937" layer="16"/>
<wire x1="60.89015" y1="20.2057" x2="65.25895" y2="20.2057" width="0.3937" layer="16"/>
<wire x1="59.79795" y1="19.1135" x2="60.89015" y2="20.2057" width="0.3937" layer="16"/>
<wire x1="67.1703" y1="19.1135" x2="67.31" y2="19.05" width="0.3937" layer="16"/>
<wire x1="59.79795" y1="19.1135" x2="59.69" y2="19.05" width="0.3937" layer="16"/>
<wire x1="49.42205" y1="38.227" x2="48.32985" y2="38.227" width="0.3937" layer="16"/>
<wire x1="51.8795" y1="40.68445" x2="49.42205" y2="38.227" width="0.3937" layer="16"/>
<wire x1="53.5178" y1="40.68445" x2="51.8795" y2="40.68445" width="0.3937" layer="16"/>
<wire x1="54.61" y1="41.77665" x2="53.5178" y2="40.68445" width="0.3937" layer="16"/>
<wire x1="48.32985" y1="38.227" x2="48.26" y2="38.1" width="0.3937" layer="16"/>
<wire x1="54.61" y1="41.77665" x2="54.61" y2="41.91" width="0.3937" layer="16"/>
<wire x1="58.15965" y1="19.1135" x2="59.5249" y2="19.1135" width="0.3937" layer="1"/>
<wire x1="55.7022" y1="21.57095" x2="58.15965" y2="19.1135" width="0.3937" layer="1"/>
<wire x1="55.7022" y1="40.13835" x2="55.7022" y2="21.57095" width="0.3937" layer="1"/>
<wire x1="54.61" y1="41.23055" x2="55.7022" y2="40.13835" width="0.3937" layer="1"/>
<wire x1="54.61" y1="41.91" x2="54.61" y2="41.23055" width="0.3937" layer="1"/>
<wire x1="59.5249" y1="19.1135" x2="59.69" y2="19.05" width="0.3937" layer="1"/>
</signal>
<signal name="PB6">
<contactref element="SV1" pad="11"/>
<contactref element="U1" pad="9"/>
<contactref element="SV2" pad="7"/>
<wire x1="40.4114" y1="10.3759" x2="39.59225" y2="10.3759" width="0.3937" layer="16"/>
<wire x1="41.5036" y1="11.4681" x2="40.4114" y2="10.3759" width="0.3937" layer="16"/>
<wire x1="44.7802" y1="11.4681" x2="41.5036" y2="11.4681" width="0.3937" layer="16"/>
<wire x1="49.6951" y1="16.383" x2="44.7802" y2="11.4681" width="0.3937" layer="16"/>
<wire x1="51.8795" y1="16.383" x2="49.6951" y2="16.383" width="0.3937" layer="16"/>
<wire x1="39.59225" y1="10.3759" x2="39.37" y2="10.16" width="0.3937" layer="16"/>
<wire x1="51.8795" y1="16.383" x2="52.07" y2="16.51" width="0.3937" layer="16"/>
<wire x1="61.43625" y1="16.65605" x2="64.71285" y2="16.65605" width="0.3937" layer="16"/>
<wire x1="60.34405" y1="17.74825" x2="61.43625" y2="16.65605" width="0.3937" layer="16"/>
<wire x1="53.5178" y1="17.74825" x2="60.34405" y2="17.74825" width="0.3937" layer="16"/>
<wire x1="52.15255" y1="16.383" x2="53.5178" y2="17.74825" width="0.3937" layer="16"/>
<wire x1="64.71285" y1="16.65605" x2="64.77" y2="16.51" width="0.3937" layer="16"/>
<wire x1="52.15255" y1="16.383" x2="52.07" y2="16.51" width="0.3937" layer="16"/>
</signal>
<signal name="PB7">
<contactref element="SV1" pad="9"/>
<contactref element="U1" pad="10"/>
<contactref element="SV2" pad="8"/>
<wire x1="44.50715" y1="10.3759" x2="42.0497" y2="10.3759" width="0.3937" layer="16"/>
<wire x1="48.0568" y1="13.92555" x2="44.50715" y2="10.3759" width="0.3937" layer="16"/>
<wire x1="51.8795" y1="13.92555" x2="48.0568" y2="13.92555" width="0.3937" layer="16"/>
<wire x1="42.0497" y1="10.3759" x2="41.91" y2="10.16" width="0.3937" layer="16"/>
<wire x1="51.8795" y1="13.92555" x2="52.07" y2="13.97" width="0.3937" layer="16"/>
<wire x1="64.16675" y1="13.92555" x2="64.71285" y2="13.92555" width="0.3937" layer="1"/>
<wire x1="63.07455" y1="15.01775" x2="64.16675" y2="13.92555" width="0.3937" layer="1"/>
<wire x1="60.34405" y1="15.01775" x2="63.07455" y2="15.01775" width="0.3937" layer="16"/>
<wire x1="60.071" y1="15.2908" x2="60.34405" y2="15.01775" width="0.3937" layer="16"/>
<wire x1="53.24475" y1="15.2908" x2="60.071" y2="15.2908" width="0.3937" layer="16"/>
<wire x1="52.15255" y1="14.1986" x2="53.24475" y2="15.2908" width="0.3937" layer="16"/>
<wire x1="64.71285" y1="13.92555" x2="64.77" y2="13.97" width="0.3937" layer="1"/>
<wire x1="52.15255" y1="14.1986" x2="52.07" y2="13.97" width="0.3937" layer="16"/>
<via x="63.07455" y="15.01775" extent="1-16" drill="0.35"/>
</signal>
<signal name="PB5">
<contactref element="SV1" pad="10"/>
<contactref element="U1" pad="19"/>
<contactref element="SV3" pad="5"/>
<wire x1="68.53555" y1="12.83335" x2="73.45045" y2="12.83335" width="0.3937" layer="16"/>
<wire x1="67.44335" y1="13.92555" x2="68.53555" y2="12.83335" width="0.3937" layer="16"/>
<wire x1="73.45045" y1="12.83335" x2="73.66" y2="12.7" width="0.3937" layer="16"/>
<wire x1="67.44335" y1="13.92555" x2="67.31" y2="13.97" width="0.3937" layer="16"/>
<wire x1="63.3476" y1="14.1986" x2="59.79795" y2="14.1986" width="0.3937" layer="16"/>
<wire x1="64.4398" y1="15.2908" x2="63.3476" y2="14.1986" width="0.3937" layer="16"/>
<wire x1="66.0781" y1="15.2908" x2="64.4398" y2="15.2908" width="0.3937" layer="16"/>
<wire x1="67.1703" y1="14.1986" x2="66.0781" y2="15.2908" width="0.3937" layer="16"/>
<wire x1="59.79795" y1="14.1986" x2="59.69" y2="13.97" width="0.3937" layer="16"/>
<wire x1="67.1703" y1="14.1986" x2="67.31" y2="13.97" width="0.3937" layer="16"/>
</signal>
<signal name="PD5">
<contactref element="SV1" pad="7"/>
<contactref element="U1" pad="11"/>
<wire x1="64.16675" y1="11.4681" x2="64.71285" y2="11.4681" width="0.3937" layer="1"/>
<wire x1="63.07455" y1="10.3759" x2="64.16675" y2="11.4681" width="0.3937" layer="1"/>
<wire x1="60.34405" y1="10.3759" x2="63.07455" y2="10.3759" width="0.3937" layer="16"/>
<wire x1="60.071" y1="10.10285" x2="60.34405" y2="10.3759" width="0.3937" layer="16"/>
<wire x1="53.24475" y1="10.10285" x2="60.071" y2="10.10285" width="0.3937" layer="16"/>
<wire x1="52.15255" y1="11.19505" x2="53.24475" y2="10.10285" width="0.3937" layer="16"/>
<wire x1="64.71285" y1="11.4681" x2="64.77" y2="11.43" width="0.3937" layer="1"/>
<wire x1="52.15255" y1="11.19505" x2="52.07" y2="11.43" width="0.3937" layer="16"/>
<via x="63.07455" y="10.3759" extent="1-16" drill="0.35"/>
</signal>
<signal name="PB4">
<contactref element="SV1" pad="8"/>
<contactref element="U1" pad="18"/>
<contactref element="SV3" pad="6"/>
<wire x1="70.993" y1="15.01775" x2="73.45045" y2="15.01775" width="0.3937" layer="16"/>
<wire x1="69.62775" y1="13.6525" x2="70.993" y2="15.01775" width="0.3937" layer="16"/>
<wire x1="69.62775" y1="13.1064" x2="69.62775" y2="13.6525" width="0.3937" layer="1"/>
<wire x1="67.98945" y1="11.4681" x2="69.62775" y2="13.1064" width="0.3937" layer="1"/>
<wire x1="67.44335" y1="11.4681" x2="67.98945" y2="11.4681" width="0.3937" layer="1"/>
<wire x1="73.45045" y1="15.01775" x2="73.66" y2="15.24" width="0.3937" layer="16"/>
<wire x1="67.44335" y1="11.4681" x2="67.31" y2="11.43" width="0.3937" layer="1"/>
<wire x1="63.3476" y1="11.19505" x2="59.79795" y2="11.19505" width="0.3937" layer="16"/>
<wire x1="64.4398" y1="10.10285" x2="63.3476" y2="11.19505" width="0.3937" layer="16"/>
<wire x1="66.0781" y1="10.10285" x2="64.4398" y2="10.10285" width="0.3937" layer="16"/>
<wire x1="67.1703" y1="11.19505" x2="66.0781" y2="10.10285" width="0.3937" layer="16"/>
<wire x1="59.79795" y1="11.19505" x2="59.69" y2="11.43" width="0.3937" layer="16"/>
<wire x1="67.1703" y1="11.19505" x2="67.31" y2="11.43" width="0.3937" layer="16"/>
<via x="69.62775" y="13.6525" extent="1-16" drill="0.35"/>
</signal>
<signal name="PD6">
<contactref element="SV1" pad="5"/>
<contactref element="U1" pad="12"/>
<wire x1="61.43625" y1="8.7376" x2="64.71285" y2="8.7376" width="0.3937" layer="16"/>
<wire x1="60.34405" y1="7.6454" x2="61.43625" y2="8.7376" width="0.3937" layer="16"/>
<wire x1="53.24475" y1="7.6454" x2="60.34405" y2="7.6454" width="0.3937" layer="16"/>
<wire x1="52.15255" y1="8.7376" x2="53.24475" y2="7.6454" width="0.3937" layer="16"/>
<wire x1="64.71285" y1="8.7376" x2="64.77" y2="8.89" width="0.3937" layer="16"/>
<wire x1="52.15255" y1="8.7376" x2="52.07" y2="8.89" width="0.3937" layer="16"/>
</signal>
<signal name="PB3">
<contactref element="SV1" pad="6"/>
<contactref element="U1" pad="17"/>
<contactref element="SV3" pad="7"/>
<wire x1="72.6313" y1="17.74825" x2="73.45045" y2="17.74825" width="0.3937" layer="1"/>
<wire x1="70.4469" y1="15.56385" x2="72.6313" y2="17.74825" width="0.3937" layer="1"/>
<wire x1="70.4469" y1="11.74115" x2="70.4469" y2="15.56385" width="0.3937" layer="1"/>
<wire x1="67.44335" y1="8.7376" x2="70.4469" y2="11.74115" width="0.3937" layer="1"/>
<wire x1="73.45045" y1="17.74825" x2="73.66" y2="17.78" width="0.3937" layer="1"/>
<wire x1="67.44335" y1="8.7376" x2="67.31" y2="8.89" width="0.3937" layer="1"/>
<wire x1="60.34405" y1="8.7376" x2="59.79795" y2="8.7376" width="0.3937" layer="1"/>
<wire x1="61.43625" y1="7.6454" x2="60.34405" y2="8.7376" width="0.3937" layer="1"/>
<wire x1="65.25895" y1="7.6454" x2="61.43625" y2="7.6454" width="0.3937" layer="1"/>
<wire x1="66.6242" y1="9.01065" x2="65.25895" y2="7.6454" width="0.3937" layer="1"/>
<wire x1="67.1703" y1="9.01065" x2="66.6242" y2="9.01065" width="0.3937" layer="1"/>
<wire x1="59.79795" y1="8.7376" x2="59.69" y2="8.89" width="0.3937" layer="1"/>
<wire x1="67.1703" y1="9.01065" x2="67.31" y2="8.89" width="0.3937" layer="1"/>
</signal>
<signal name="PD7">
<contactref element="SV1" pad="3"/>
<contactref element="U1" pad="13"/>
<contactref element="SV2" pad="5"/>
<wire x1="40.4114" y1="7.37235" x2="39.59225" y2="7.37235" width="0.3937" layer="1"/>
<wire x1="41.23055" y1="6.5532" x2="40.4114" y2="7.37235" width="0.3937" layer="1"/>
<wire x1="42.0497" y1="6.5532" x2="41.23055" y2="6.5532" width="0.3937" layer="1"/>
<wire x1="42.86885" y1="5.73405" x2="42.0497" y2="6.5532" width="0.3937" layer="1"/>
<wire x1="43.96105" y1="6.82625" x2="42.86885" y2="5.73405" width="0.3937" layer="1"/>
<wire x1="51.06035" y1="6.82625" x2="43.96105" y2="6.82625" width="0.3937" layer="1"/>
<wire x1="51.3334" y1="6.5532" x2="51.06035" y2="6.82625" width="0.3937" layer="1"/>
<wire x1="51.8795" y1="6.5532" x2="51.3334" y2="6.5532" width="0.3937" layer="1"/>
<wire x1="39.59225" y1="7.37235" x2="39.37" y2="7.62" width="0.3937" layer="1"/>
<wire x1="51.8795" y1="6.5532" x2="52.07" y2="6.35" width="0.3937" layer="1"/>
<wire x1="64.4398" y1="6.28015" x2="64.71285" y2="6.28015" width="0.3937" layer="1"/>
<wire x1="61.98235" y1="3.8227" x2="64.4398" y2="6.28015" width="0.3937" layer="1"/>
<wire x1="61.98235" y1="3.00355" x2="61.98235" y2="3.8227" width="0.3937" layer="1"/>
<wire x1="60.6171" y1="1.6383" x2="61.98235" y2="3.00355" width="0.3937" layer="1"/>
<wire x1="58.9788" y1="1.6383" x2="60.6171" y2="1.6383" width="0.3937" layer="1"/>
<wire x1="55.42915" y1="5.18795" x2="58.9788" y2="1.6383" width="0.3937" layer="1"/>
<wire x1="53.79085" y1="5.18795" x2="55.42915" y2="5.18795" width="0.3937" layer="1"/>
<wire x1="52.69865" y1="6.28015" x2="53.79085" y2="5.18795" width="0.3937" layer="1"/>
<wire x1="52.15255" y1="6.28015" x2="52.69865" y2="6.28015" width="0.3937" layer="1"/>
<wire x1="64.71285" y1="6.28015" x2="64.77" y2="6.35" width="0.3937" layer="1"/>
<wire x1="52.15255" y1="6.28015" x2="52.07" y2="6.35" width="0.3937" layer="1"/>
</signal>
<signal name="PB2">
<contactref element="SV1" pad="4"/>
<contactref element="U1" pad="16"/>
<contactref element="SV3" pad="3"/>
<wire x1="68.2625" y1="7.37235" x2="73.45045" y2="7.37235" width="0.3937" layer="16"/>
<wire x1="67.44335" y1="6.5532" x2="68.2625" y2="7.37235" width="0.3937" layer="16"/>
<wire x1="73.45045" y1="7.37235" x2="73.66" y2="7.62" width="0.3937" layer="16"/>
<wire x1="67.44335" y1="6.5532" x2="67.31" y2="6.35" width="0.3937" layer="16"/>
<wire x1="63.3476" y1="6.5532" x2="59.79795" y2="6.5532" width="0.3937" layer="16"/>
<wire x1="64.4398" y1="7.6454" x2="63.3476" y2="6.5532" width="0.3937" layer="16"/>
<wire x1="66.0781" y1="7.6454" x2="64.4398" y2="7.6454" width="0.3937" layer="16"/>
<wire x1="67.1703" y1="6.5532" x2="66.0781" y2="7.6454" width="0.3937" layer="16"/>
<wire x1="59.79795" y1="6.5532" x2="59.69" y2="6.35" width="0.3937" layer="16"/>
<wire x1="67.1703" y1="6.5532" x2="67.31" y2="6.35" width="0.3937" layer="16"/>
</signal>
<signal name="PB0">
<contactref element="SV1" pad="1"/>
<contactref element="U1" pad="14"/>
<contactref element="SV2" pad="6"/>
<wire x1="40.68445" y1="7.37235" x2="41.77665" y2="7.37235" width="0.3937" layer="16"/>
<wire x1="39.59225" y1="6.28015" x2="40.68445" y2="7.37235" width="0.3937" layer="16"/>
<wire x1="39.04615" y1="6.28015" x2="39.59225" y2="6.28015" width="0.3937" layer="16"/>
<wire x1="38.227" y1="5.461" x2="39.04615" y2="6.28015" width="0.3937" layer="16"/>
<wire x1="38.227" y1="4.64185" x2="38.227" y2="5.461" width="0.3937" layer="16"/>
<wire x1="39.04615" y1="3.8227" x2="38.227" y2="4.64185" width="0.3937" layer="16"/>
<wire x1="51.8795" y1="3.8227" x2="39.04615" y2="3.8227" width="0.3937" layer="16"/>
<wire x1="41.77665" y1="7.37235" x2="41.91" y2="7.62" width="0.3937" layer="16"/>
<wire x1="51.8795" y1="3.8227" x2="52.07" y2="3.81" width="0.3937" layer="16"/>
<wire x1="61.1632" y1="3.54965" x2="64.71285" y2="3.54965" width="0.3937" layer="16"/>
<wire x1="60.071" y1="2.45745" x2="61.1632" y2="3.54965" width="0.3937" layer="16"/>
<wire x1="53.24475" y1="2.45745" x2="60.071" y2="2.45745" width="0.3937" layer="16"/>
<wire x1="52.15255" y1="3.54965" x2="53.24475" y2="2.45745" width="0.3937" layer="16"/>
<wire x1="64.71285" y1="3.54965" x2="64.77" y2="3.81" width="0.3937" layer="16"/>
<wire x1="52.15255" y1="3.54965" x2="52.07" y2="3.81" width="0.3937" layer="16"/>
</signal>
<signal name="PB1">
<contactref element="SV1" pad="2"/>
<contactref element="U1" pad="15"/>
<wire x1="66.35115" y1="3.8227" x2="67.1703" y2="3.8227" width="0.3937" layer="16"/>
<wire x1="65.25895" y1="4.9149" x2="66.35115" y2="3.8227" width="0.3937" layer="16"/>
<wire x1="60.89015" y1="4.9149" x2="65.25895" y2="4.9149" width="0.3937" layer="16"/>
<wire x1="59.79795" y1="3.8227" x2="60.89015" y2="4.9149" width="0.3937" layer="16"/>
<wire x1="67.1703" y1="3.8227" x2="67.31" y2="3.81" width="0.3937" layer="16"/>
<wire x1="59.79795" y1="3.8227" x2="59.69" y2="3.81" width="0.3937" layer="16"/>
</signal>
<signal name="PC62">
<contactref element="SV4" pad="6"/>
<contactref element="C6" pad="2"/>
<contactref element="R3" pad="1"/>
<wire x1="48.32985" y1="27.8511" x2="48.32985" y2="21.844" width="0.3937" layer="16"/>
<wire x1="50.2412" y1="29.76245" x2="48.32985" y2="27.8511" width="0.3937" layer="16"/>
<wire x1="50.2412" y1="38.227" x2="50.2412" y2="29.76245" width="0.3937" layer="16"/>
<wire x1="52.15255" y1="40.13835" x2="50.2412" y2="38.227" width="0.3937" layer="16"/>
<wire x1="56.52135" y1="40.13835" x2="52.15255" y2="40.13835" width="0.3937" layer="16"/>
<wire x1="58.15965" y1="41.77665" x2="56.52135" y2="40.13835" width="0.3937" layer="16"/>
<wire x1="48.32985" y1="21.844" x2="48.26" y2="21.59" width="0.3937" layer="16"/>
<wire x1="58.15965" y1="41.77665" x2="58.42" y2="41.91" width="0.3937" layer="16"/>
<wire x1="62.52845" y1="42.0497" x2="73.45045" y2="42.0497" width="0.3937" layer="16"/>
<wire x1="61.43625" y1="43.1419" x2="62.52845" y2="42.0497" width="0.3937" layer="16"/>
<wire x1="59.5249" y1="43.1419" x2="61.43625" y2="43.1419" width="0.3937" layer="16"/>
<wire x1="58.4327" y1="42.0497" x2="59.5249" y2="43.1419" width="0.3937" layer="16"/>
<wire x1="73.45045" y1="42.0497" x2="73.66" y2="41.91" width="0.3937" layer="16"/>
<wire x1="58.4327" y1="42.0497" x2="58.42" y2="41.91" width="0.3937" layer="16"/>
</signal>
</signals>
</board>
</drawing>
<compatibility>
<note version="8.2" severity="warning">
Since Version 8.2, EAGLE supports online libraries. The ids
of those online libraries will not be understood (or retained)
with this version.
</note>
<note version="8.3" severity="warning">
Since Version 8.3, EAGLE supports URNs for individual library
assets (packages, symbols, and devices). The URNs of those assets
will not be understood (or retained) with this version.
</note>
<note version="8.3" severity="warning">
Since Version 8.3, EAGLE supports the association of 3D packages
with devices in libraries, schematics, and board files. Those 3D
packages will not be understood (or retained) with this version.
</note>
</compatibility>
</eagle>


text:
package nix

import (
	"bytes"
	"encoding/json"
	"errors"
	"fmt"
	"io/ioutil"
	"os"
	"os/exec"
	"path"
	"path/filepath"
	"strings"
	"syscall"
	"time"

	"github.com/DBCDK/morph/healthchecks"
	"github.com/DBCDK/morph/secrets"
	"github.com/DBCDK/morph/ssh"
	"github.com/DBCDK/morph/utils"
)

type Host struct {
	HealthChecks            healthchecks.HealthChecks
	Name                    string
	NixosRelease            string
	TargetHost              string
	TargetPort              int
	TargetUser              string
	Secrets                 map[string]secrets.Secret
	BuildOnly               bool
	SubstituteOnDestination bool
	NixConfig               map[string]string
	Tags                    []string
}

type HostOrdering struct {
	Tags []string
}

type DeploymentMetadata struct {
	Description string
	Ordering    HostOrdering
}

type Deployment struct {
	Hosts []Host             `json:"hosts"`
	Meta  DeploymentMetadata `json:"meta"`
}

type NixContext struct {
	EvalCmd	string
	BuildCmd string
	ShellCmd string
	EvalMachines    string
	ShowTrace       bool
	KeepGCRoot      bool
	AllowBuildShell bool
}

type NixBuildInvocationArgs struct {
	ArgsFile string
	Attr string
	DeploymentPath string
	Names []string
	NixArgs []string
	NixBuildTargets string
	NixConfig map[string]string
	NixContext NixContext
	ResultLinkPath string
}

func (nArgs *NixBuildInvocationArgs) ToNixBuildArgs() []string {
	args := []string{
		nArgs.NixContext.EvalMachines,
		"--arg", "networkExpr", nArgs.DeploymentPath,
		"--argstr", "argsFile", nArgs.ArgsFile,
		"--out-link", nArgs.ResultLinkPath,
		"--attr", nArgs.Attr,
	}

	args = append(args, mkOptions(nArgs.NixConfig)...)

	if len(nArgs.NixArgs) > 0 {
		args = append(args, nArgs.NixArgs...)
	}

	if nArgs.NixContext.ShowTrace {
		args = append(args, "--show-trace")
	}

	if nArgs.NixBuildTargets != "" {
		args = append(args,
			"--arg", "buildTargets", nArgs.NixBuildTargets)
	}

	return args
}

func (nArgs *NixEvalInvocationArgs) ToNixInstantiateArgs() []string {
	args := []string{
		"--eval", nArgs.NixContext.EvalMachines,
		"--arg", "networkExpr", nArgs.DeploymentPath,
		"--argstr", "argsFile", nArgs.ArgsFile,
		"--attr", nArgs.Attr,
	}

	if nArgs.NixContext.ShowTrace {
		args = append(args, "--show-trace")
	}

	if nArgs.AsJSON {
		args = append(args, "--json")
	}

	if nArgs.Strict {
		args = append(args, "--strict")
	}

	if nArgs.ReadWriteMode {
		args = append(args, "--read-write-mode")
	}

	return args
}

type NixEvalInvocationArgs struct {
	AsJSON bool
	ArgsFile string
	Attr string
	DeploymentPath string
	NixContext NixContext
	Strict bool
	ReadWriteMode bool
}

func (host *Host) GetName() string {
	return host.Name
}

func (host *Host) GetTargetHost() string {
	return host.TargetHost
}

func (host *Host) GetTargetPort() int {
	return host.TargetPort
}

func (host *Host) GetTargetUser() string {
	return host.TargetUser
}

func (host *Host) GetHealthChecks() healthchecks.HealthChecks {
	return host.HealthChecks
}

func (host *Host) GetTags() []string {
	return host.Tags
}

func (host *Host) Reboot(sshContext *ssh.SSHContext) error {

	var (
		oldBootID string
		newBootID string
	)

	oldBootID, err := sshContext.GetBootID(host)
	// If the host doesn't support getting boot ID's for some reason, warn about it, and skip the comparison
	skipBootIDComparison := err != nil
	if skipBootIDComparison {
		fmt.Fprintf(os.Stderr, "Error getting boot ID (this is used to determine when the reboot is complete): %v\n", err)
		fmt.Fprintf(os.Stderr, "This makes it impossible to detect when the host has rebooted, so health checks might pass before the host has rebooted.\n")
	}

	if cmd, err := sshContext.Cmd(host, "sudo", "reboot"); cmd != nil {
		fmt.Fprint(os.Stderr, "Asking host to reboot ... ")
		if err = cmd.Run(); err != nil {
			// Here we assume that exit code 255 means: "SSH connection got disconnected",
			// which is OK for a reboot - sshd may close active connections before we disconnect after all
			if exitErr, ok := err.(*exec.ExitError); ok {
				if status, ok := exitErr.Sys().(syscall.WaitStatus); ok && status.ExitStatus() == 255 {
					fmt.Fprintln(os.Stderr, "Remote host disconnected.")
					err = nil
				}
			}
		}

		if err != nil {
			fmt.Fprintln(os.Stderr, "Failed")
			return err
		}
	}

	fmt.Fprintln(os.Stderr, "OK")

	if !skipBootIDComparison {
		fmt.Fprint(os.Stderr, "Waiting for host to come online ")

		// Wait for the host to get a new boot ID. These ID's should be unique for each boot,
		// meaning a reboot will have been completed when the boot ID has changed.
		for {
			fmt.Fprint(os.Stderr, ".")

			// Ignore errors; there'll be plenty of them since we'll be attempting to connect to an offline host,
			// and we know from previously that the host should support boot ID's
			newBootID, _ = sshContext.GetBootID(host)

			if newBootID != "" && oldBootID != newBootID {
				fmt.Fprintln(os.Stderr, " OK")
				break
			}

			time.Sleep(2 * time.Second)
		}
	}

	return nil
}

func (ctx *NixContext) GetBuildShell(deploymentPath string) (buildShell *string, err error) {

	nixEvalInvocationArgs := NixEvalInvocationArgs{
		AsJSON: true,
		Attr: "info.buildShell",
		DeploymentPath: deploymentPath,
		NixContext: *ctx,
		Strict: true,
	}

	jsonArgs, err := json.Marshal(nixEvalInvocationArgs)
	if err != nil {
		return buildShell, err
	}

	cmd := exec.Command(ctx.EvalCmd, nixEvalInvocationArgs.ToNixInstantiateArgs()...)

	var stdout bytes.Buffer
	cmd.Stdout = &stdout
	cmd.Stderr = os.Stderr

	utils.AddFinalizer(func() {
		if (cmd.ProcessState == nil || !cmd.ProcessState.Exited()) && cmd.Process != nil {
			_ = cmd.Process.Signal(syscall.SIGTERM)
		}
	})
	cmd.Env = os.Environ()
	cmd.Env = append(cmd.Env, fmt.Sprintf("MORPH_ARGS=%s", jsonArgs))
	err = cmd.Run()
	if err != nil {
		errorMessage := fmt.Sprintf(
			"Error while running `%s ..`: %s", ctx.EvalCmd, err.Error(),
		)
		return buildShell, errors.New(errorMessage)
	}

	err = json.Unmarshal(stdout.Bytes(), &buildShell)
	if err != nil {
		return nil, err
	}

	return buildShell, nil
}

func (ctx *NixContext) EvalHosts(deploymentPath string, attr string) (string, error) {
	attribute := "nodes." + attr

	nixEvalInvocationArgs := NixEvalInvocationArgs{
		AsJSON: false,
		Attr: attribute,
		DeploymentPath: deploymentPath,
		NixContext: *ctx,
		Strict: true,
	}

	jsonArgs, err := json.Marshal(nixEvalInvocationArgs)
	if err != nil {
		return "", err
	}

	cmd := exec.Command(ctx.EvalCmd, nixEvalInvocationArgs.ToNixInstantiateArgs()...)

	utils.AddFinalizer(func() {
		if (cmd.ProcessState == nil || !cmd.ProcessState.Exited()) && cmd.Process != nil {
			_ = cmd.Process.Signal(syscall.SIGTERM)
		}
	})

	cmd.Stdout = os.Stdout
	cmd.Stderr = os.Stderr
	cmd.Env = os.Environ()
	cmd.Env = append(cmd.Env, fmt.Sprintf("MORPH_ARGS=%s", jsonArgs))
	err = cmd.Run()
	return deploymentPath, err
}

func (ctx *NixContext) GetMachines(deploymentPath string) (deployment Deployment, err error) {

	nixEvalInvocationArgs := NixEvalInvocationArgs{
		AsJSON: true,
		Attr: "info.deployment",
		DeploymentPath: deploymentPath,
		NixContext: *ctx,
		Strict: true,
	}

	jsonArgs, err := json.Marshal(nixEvalInvocationArgs)
	if err != nil {
		return deployment, err
	}

	cmd := exec.Command(ctx.EvalCmd, nixEvalInvocationArgs.ToNixInstantiateArgs()...)

	var stdout bytes.Buffer
	cmd.Stdout = &stdout
	cmd.Stderr = os.Stderr

	utils.AddFinalizer(func() {
		if (cmd.ProcessState == nil || !cmd.ProcessState.Exited()) && cmd.Process != nil {
			_ = cmd.Process.Signal(syscall.SIGTERM)
		}
	})
	cmd.Env = os.Environ()
	cmd.Env = append(cmd.Env, fmt.Sprintf("MORPH_ARGS=%s", jsonArgs))
	err = cmd.Run()
	if err != nil {
		errorMessage := fmt.Sprintf(
			"Error while running `%s ..`: %s", ctx.EvalCmd, err.Error(),
		)
		return deployment, errors.New(errorMessage)
	}

	err = json.Unmarshal(stdout.Bytes(), &deployment)
	if err != nil {
		return deployment, err
	}

	return deployment, nil
}

func (ctx *NixContext) BuildMachines(deploymentPath string, hosts []Host, nixArgs []string, nixBuildTargets string) (resultPath string, err error) {
	tmpdir, err := ioutil.TempDir("", "morph-")
	if err != nil {
		return "", err
	}
	utils.AddFinalizer(func() {
		os.RemoveAll(tmpdir)
	})

	hostNames := []string{}
	for _, host := range hosts {
		hostNames = append(hostNames, host.Name)
	}

	resultLinkPath := filepath.Join(path.Dir(deploymentPath), ".gcroots", path.Base(deploymentPath))
	if ctx.KeepGCRoot {
		if err = os.MkdirAll(path.Dir(resultLinkPath), 0755); err != nil {
			ctx.KeepGCRoot = false
			fmt.Fprintf(os.Stderr, "Unable to create GC root, skipping: %s", err)
		}
	}
	if !ctx.KeepGCRoot {
		// create tmp dir for result link
		resultLinkPath = filepath.Join(tmpdir, "result")
	}

	buildShell, err := ctx.GetBuildShell(deploymentPath)

	if err != nil {
		errorMessage := fmt.Sprintf(
			"Error getting buildShell.",
		)
		return resultPath, errors.New(errorMessage)
	}

	argsFile := tmpdir + "/morph-args.json"
	NixBuildInvocationArgs := NixBuildInvocationArgs{
		ArgsFile: argsFile,
		Attr: "machines",
		DeploymentPath: deploymentPath,
		Names: hostNames,
		NixArgs: nixArgs,
		NixBuildTargets: nixBuildTargets,
		NixConfig: hosts[0].NixConfig,
		NixContext: *ctx,
		ResultLinkPath: resultLinkPath,
	}

	jsonArgs, err := json.Marshal(NixBuildInvocationArgs)
	if err != nil {
		return "", err
	}

	err = ioutil.WriteFile(argsFile, jsonArgs, 0644)
	if err != nil {
		return "", err
	}

	var cmd *exec.Cmd
	if ctx.AllowBuildShell && buildShell != nil {

		shellArgs := strings.Join(append([]string{ctx.BuildCmd}, NixBuildInvocationArgs.ToNixBuildArgs()...), " ")
		cmd = exec.Command(ctx.ShellCmd, *buildShell, "--pure", "--run", shellArgs)
	} else {
		cmd = exec.Command(ctx.BuildCmd, NixBuildInvocationArgs.ToNixBuildArgs()...)

	}

	// show process output on attached stdout/stderr
	cmd.Stdout = os.Stderr
	cmd.Stderr = os.Stderr
	utils.AddFinalizer(func() {
		if (cmd.ProcessState == nil || !cmd.ProcessState.Exited()) && cmd.Process != nil {
			_ = cmd.Process.Signal(syscall.SIGTERM)
		}
	})

	cmd.Env = os.Environ()
	cmd.Env = append(cmd.Env, fmt.Sprintf("MORPH_ARGS=%s", jsonArgs))
	cmd.Env = append(cmd.Env, fmt.Sprintf("MORPH_ARGS_FILE=%s", argsFile))
	err = cmd.Run()

	if err != nil {
		errorMessage := fmt.Sprintf(
			"Error while running `%s ...`: See above.", cmd.String(),
		)
		return resultPath, errors.New(errorMessage)
	}

	resultPath, err = os.Readlink(resultLinkPath)
	if err != nil {
		return "", err
	}

	return
}

func mkOptionsFromHost(host Host) []string {
	return mkOptions(host.NixConfig)
}

func mkOptions(nixConfig map[string]string) []string {
	var options = make([]string, 0)
	for k, v := range nixConfig {
		options = append(options, "--option")
		options = append(options, k)
		options = append(options, v)
	}
	return options
}

func GetNixSystemPath(host Host, resultPath string) (string, error) {
	return os.Readlink(filepath.Join(resultPath, host.Name))
}

func GetNixSystemDerivation(host Host, resultPath string) (string, error) {
	return os.Readlink(filepath.Join(resultPath, host.Name+".drv"))
}

func GetPathsToPush(host Host, resultPath string) (paths []string, err error) {
	path1, err := GetNixSystemPath(host, resultPath)
	if err != nil {
		return paths, err
	}

	paths = append(paths, path1)

	return paths, nil
}

func Push(ctx *ssh.SSHContext, host Host, paths ...string) (err error) {
	utils.ValidateEnvironment("ssh")

	var userArg = ""
	var keyArg = ""
	var sshOpts = []string{}
	var env = os.Environ()
	if host.TargetUser != "" {
		userArg = host.TargetUser + "@"
	} else if ctx.DefaultUsername != "" {
		userArg = ctx.DefaultUsername + "@"
	}
	if ctx.IdentityFile != "" {
		keyArg = "?ssh-key=" + ctx.IdentityFile
	}
	if ctx.SkipHostKeyCheck {
		sshOpts = append(sshOpts, fmt.Sprintf("%s", "-o StrictHostkeyChecking=No -o UserKnownHostsFile=/dev/null"))
	}
	if host.TargetPort != 0 {
		sshOpts = append(sshOpts, fmt.Sprintf("-p %d", host.TargetPort))
	}
	if ctx.ConfigFile != "" {
		sshOpts = append(sshOpts, fmt.Sprintf("-F %s", ctx.ConfigFile))
	}
	if len(sshOpts) > 0 {
		env = append(env, fmt.Sprintf("NIX_SSHOPTS=%s", strings.Join(sshOpts, " ")))
	}

	options := mkOptionsFromHost(host)
	for _, path := range paths {
		args := []string{
			"--to", userArg + host.TargetHost + keyArg,
			path,
		}
		args = append(args, options...)
		if host.SubstituteOnDestination {
			args = append(args, "--use-substitutes")
		}

		cmd := exec.Command(
			"nix-copy-closure", args...,
		)
		cmd.Env = env

		cmd.Stdout = os.Stderr
		cmd.Stderr = os.Stderr
		err = cmd.Run()

		if err != nil {
			return err
		}
	}

	return nil
}

license: MIT

repository: DBCDK/morph

license_type: permissive

repo_name: DBCDK/morph

branch_name: refs/heads/master

gha_license_id: MIT

gha_language: Go

extension: go


text:
SECTION = "x11/utils"
DESCRIPTION = "Matchbox panel"
LICENSE = "GPL"
DEPENDS = "libmatchbox x11 xext xpm"
RDEPENDS = "libmatchbox matchbox-common"

SRC_URI = "ftp://ftp.handhelds.org/matchbox/sources/matchbox-panel/${PV}/matchbox-panel-${PV}.tar.bz2"
S = "${WORKDIR}/matchbox-panel-${PV}"

inherit autotools pkgconfig gettext

EXTRA_OECONF = "--enable-small-icons"
#		--enable-dnotify
#		--enable-startup-notification

repository: Terentyev/familiar-linux

repo_name: Terentyev/familiar-linux

extension: bb


text:
package crypto

import (
	"crypto/tls"
	"crypto/x509"
	"encoding/pem"
	"fmt"
)

type DefaultTlsValidator struct {
	cert string
	url  string
}

type TlsValidator interface {
	ValidateCert() error
	HasSelfSignedCert() (bool, error)
}

func NewTlsValidator(cert, url string) TlsValidator {
	return &DefaultTlsValidator{
		cert: cert,
		url:  url,
	}
}

// HasSelfSignedCert determines whether the url is using self-signed certs or not
func (tv *DefaultTlsValidator) HasSelfSignedCert() (bool, error) {
	conf := &tls.Config{
		InsecureSkipVerify: false,
	}

	_, err := tls.Dial("tcp", tv.url+":443", conf)
	if err != nil {
		// If the error is x509.UnknownAuthorityError, this means the url is using self-signed certs
		if err.Error() == (x509.UnknownAuthorityError{}).Error() {
			return true, nil
		}
		return false, err
	}
	return false, nil
}

// ValidateCert parses the cert, ensures that the cert format is valid and verifies that the cert is valid for the url
func (tv *DefaultTlsValidator) ValidateCert() error {
	// Validates that the cert format is valid
	block, _ := pem.Decode([]byte(tv.cert))
	if block == nil {
		return fmt.Errorf("failed to parse certificate PEM")
	}
	providedCert, err := x509.ParseCertificate(block.Bytes)
	if err != nil {
		return fmt.Errorf("failed to parse certificate: %v", err)
	}

	roots := x509.NewCertPool()
	roots.AddCert(providedCert)
	opts := x509.VerifyOptions{
		DNSName: tv.url,
		Roots:   roots,
	}

	// Verifies that the cert is valid
	_, err = providedCert.Verify(opts)
	if err != nil {
		return fmt.Errorf("failed to verify certificate: %v", err)
	}
	return nil
}

repository: blogtheristo/eks-anywhere

repo_name: blogtheristo/eks-anywhere

branch_name: refs/heads/main


text:
package mongotrace

import (
	"context"
	"fmt"
	"strings"
	"sync"

	"go.opencensus.io/trace"
	"gopkg.in/DataDog/dd-trace-go.v1/ddtrace/ext"

	"go.mongodb.org/mongo-driver/bson"
	"go.mongodb.org/mongo-driver/event"
)

type spanKey struct {
	ConnectionID string
	RequestID    int64
}

type monitor struct {
	sync.Mutex
	spans map[spanKey]*trace.Span
	cfg   *config
}

func (m *monitor) Started(ctx context.Context, evt *event.CommandStartedEvent) {
	hostname, port := peerInfo(evt)
	b, _ := bson.MarshalExtJSON(evt.Command, false, false)
	ctx, span := trace.StartSpan(ctx, evt.CommandName, trace.WithSampler(m.cfg.sampler))
	span.AddAttributes(trace.StringAttribute(ext.DBInstance, evt.DatabaseName),
		trace.StringAttribute(ext.DBStatement, string(b)),
		trace.StringAttribute(ext.DBType, "mongo"),
		trace.StringAttribute(ext.PeerHostname, hostname),
		trace.StringAttribute(ext.PeerPort, port),
	)
	key := spanKey{
		ConnectionID: evt.ConnectionID,
		RequestID:    evt.RequestID,
	}
	m.Lock()
	m.spans[key] = span
	m.Unlock()
}

func (m *monitor) Succeeded(ctx context.Context, evt *event.CommandSucceededEvent) {
	m.Finished(&evt.CommandFinishedEvent, nil)
}

func (m *monitor) Failed(ctx context.Context, evt *event.CommandFailedEvent) {
	m.Finished(&evt.CommandFinishedEvent, fmt.Errorf("%s", evt.Failure))
}

func (m *monitor) Finished(evt *event.CommandFinishedEvent, err error) {
	key := spanKey{
		ConnectionID: evt.ConnectionID,
		RequestID:    evt.RequestID,
	}
	m.Lock()
	span, ok := m.spans[key]
	if ok {
		delete(m.spans, key)
	}
	m.Unlock()
	if !ok {
		return
	}
	if err != nil {
		span.AddAttributes(trace.StringAttribute("error.msg", err.Error()))
	}
	span.End()
}

// NewMonitor creates a new mongodb event CommandMonitor.
func NewMonitor(opts ...Option) *event.CommandMonitor {
	cfg := new(config)
	defaults(cfg)
	for _, opt := range opts {
		opt(cfg)
	}
	m := &monitor{
		spans: make(map[spanKey]*trace.Span),
		cfg:   cfg,
	}
	return &event.CommandMonitor{
		Started:   m.Started,
		Succeeded: m.Succeeded,
		Failed:    m.Failed,
	}
}

func peerInfo(evt *event.CommandStartedEvent) (hostname, port string) {
	hostname = evt.ConnectionID
	port = "27017"
	if idx := strings.IndexByte(hostname, '['); idx >= 0 {
		hostname = hostname[:idx]
	}
	if idx := strings.IndexByte(hostname, ':'); idx >= 0 {
		port = hostname[idx+1:]
		hostname = hostname[:idx]
	}
	return hostname, port
}

repository: entropyx/mongo-opencensus

repo_name: entropyx/mongo-opencensus


text:
import { Controller, Post, Body, ValidationPipe, ParseIntPipe, Get, Param, Query, Patch, Delete, UseGuards } from '@nestjs/common';
import { CreateClipDto } from './dto/create-clip.dto';
import { ClipsService } from './clips.service';
import { Clip } from './clip.entity';
import { GetClipFilterDto } from './dto/get-clip-filter.dto';
import { UpdateClipDto } from './dto/update-clip.dto';
import { AuthGuard } from '@nestjs/passport';

@Controller('clips')
export class ClipsController {

    //depenency inject service
    constructor(private clipService: ClipsService) { }

    @Post()
    createClip(@Body('channel_id', ParseIntPipe) channel_id: number, @Body(ValidationPipe) createClipDto: CreateClipDto, ): Promise<Clip> {
        return this.clipService.createClip(createClipDto, channel_id);
    }

    @Get(':id')
    @UseGuards(AuthGuard())
    getClipById(@Param('id', ParseIntPipe) id: number): Promise<Clip> {
        return this.clipService.getClipById(id);
    }

    /*
    For this hanlder we can either get all clips in the database with the route
    /clips

    or

    We get clips based on the search criteria (see get-clip-filter.dto) as a query for example
    /clips?text=failure
    */

    @Get()
    @UseGuards(AuthGuard())
    getAllClips(@Query(ValidationPipe) getClipFilterDto: GetClipFilterDto): Promise<Clip[]> {
        return this.clipService.getClips(getClipFilterDto);
    }

    /*
    This handler will update a clip text transciption (revised_text column)
    We send the clip id in the url as a parameter, but the revised_text in http body
    as a key-value pair
    */
    @Patch(':id/revised_text')
    @UseGuards(AuthGuard())
    updateClipText(@Param('id', ParseIntPipe) id: number, @Body(ValidationPipe) updateClipDto: UpdateClipDto): Promise<Clip> {
        return this.clipService.updateClipText(id, updateClipDto);
    }

    /*
    This handler will delete a clip by id
    The clip id will be in the url as a paramater
    */
    @Delete('/:id')
    @UseGuards(AuthGuard())
    deleteClipById(@Param('id', ParseIntPipe) id: number): Promise<void> {
       return this.clipService.deleteClipById(id);
    }

}

repository: cottojon/scribe

repo_name: cottojon/scribe

gha_language: CSS

extension: ts


text:
#include "No.h"
#include <iostream>

using namespace std;

class ListaEncad
{
private:
    No *primeiro;
    No *ultimo;
    int n;
public:
    ListaEncad(/* args */);
    ~ListaEncad();

    void insereFinal(int val);
    void removeFinal();

    bool listaVazia();

    /*
    Essa função tem o objetivo de inserir um valor depois de um no cujo valor e dado por X. Se o valor X nao for encontrado,
    a operação não deve inserir o valor e deve imprimir uma mensagem de erro.
    */
    void insereAposValorX(int x, int valor);

    void imprime();
};

url: https://raw.githubusercontent.com/lucaslgr/estrutura-de-dados-cplusplus/434dc93a743586543be784fa626ea910705e638e/Exercícios Slide 3 (Listas)/Lista Simplesmente Encadeada com Descritor 2.0/ListaEncad.h

repository: lucaslgr/estrutura-de-dados-cplusplus

repo_name: lucaslgr/estrutura-de-dados-cplusplus

extension: h