20 thoughts on “Today I Learned (TIL)”

  1. https://unix.stackexchange.com/a/217371

    You can just use:

    rm /var/lib/apt/lists/*
    This will remove the package lists. No repositories will be deleted, they are configured in the config file in /etc/apt/sources.list. All that can happen is that tools like apt-cache cannot get package information unless you updated the package lists. Also apt-get install will fail with E: Unable to locate package , because no information is available about the package.

    Then just run:

    apt-get update
    to rewrite those lists and the command will work again.

    Anyway, it’s recommended to run apt-get update before installing anything.

  2. https://stackoverflow.com/questions/992069/ace-vs-boost-vs-poco

    I really want to vote for Doug Schmidt and respect all the work he's done, but to be honest I find ACE mildly buggy and hard to use. I think that library needs a reboot. It's hard to say this, but I'd shy away from ACE for now unless there is a compelling reason to use TAO, or you need a single code base to run C++ on both Unix variants and Windows. TAO is fabulous for a number of difficult problems, but the learning curve is intense, and there's a reason CORBA has a number of critics. I guess just do your homework before making a decision to use either.

    If you are coding in C++, boost is in my mind a no-brainer. I use a number of the low level libraries and find them essential. A quick grep of my code reveals shared_ptr, program_options, regex, bind, serialization, foreach, property_tree, filesystem, tokenizer, various iterator extensions, alogrithm, and mem_fn. These are mostly low-level functionality that really ought to be in the compiler. Some boost libraries are very generic; it can be work to get them to do what you want, but it's worthwhile.

    Poco is a collection of utility classes that provide functionality for some very concrete common tasks. I find the libraries are well-written and intuitive. I don't have to spend much time studying documentation or writing silly test programs. I'm currently using Logger, XML, Zip, and Net/SMTP. I started using Poco when libxml2 irritated me for the last time. There are other classes I could use but haven't tried, e.g. Data::MySQL (I'm happy with mysql++) and Net::HTTP (I'm happy with libCURL). I'll try out the rest of Poco eventually, but that's not a priority at this point.
    https://stackoverflow.com/a/18413961

  3. http://www.tsm-resources.com/alists/pow2.html

    2^–2 1/4
    2^–1 1/2
    2^0 1
    2^1 2
    2^2 4
    2^3 8
    2^4 16
    2^5 32
    2^6 64
    2^7 128
    2^8 256
    2^9 512
    2^10 1024
    2^11 2048
    2^12 4096
    2^13 8192
    2^14 16384
    2^15 32768
    2^16 65536
    2^17 131072
    2^18 262144
    2^19 524288
    2^20 1048576
    2^21 2097152
    2^22 4194304
    2^23 8388608
    2^24 16777216
    2^25 33554432
    2^26 67108864
    2^27 134217728
    2^28 268435456
    2^29 536870912
    2^30 1073741824
    2^31 2147483648
    2^32 4294967296
    2^33 8589934592
    2^34 17179869184
    2^35 34359738368
    2^36 68719476736
    2^37 137438953472
    2^38 274877906944
    2^39 549755813888
    2^40 1099511627776
    2^41 2199023255552
    2^42 4398046511104
    2^43 8796093022208
    2^44 17592186044416
    2^45 35184372088832
    2^46 70368744177664
    2^47 140737488355328
    2^48 281474976710656
    2^49 562949953421312
    2^50 1125899906842624
    2^51 2251799813685248
    2^52 4503599627370496
    2^53 9007199254740992
    2^54 18014398509481984
    2^55 36028797018963968
    2^56 72057594037927936
    2^57 144115188075855872
    2^58 288230376151711744
    2^59 576460752303423488
    2^60 1152921504606846976
    2^61 2305843009213693952
    2^62 4611686018427387904
    2^63 9223372036854775808
    2^64 18446744073709551616
    2^65 36893488147419103232
    2^66 73786976294838206464
    2^67 147573952589676412928
    2^68 295147905179352825856
    2^69 590295810358705651712
    2^70 1180591620717411303424
    2^71 2361183241434822606848
    2^72 4722366482869645213696
    2^73 9444732965739290427392
    2^74 18889465931478580854784
    2^75 37778931862957161709568
    2^76 75557863725914323419136
    2^77 151115727451828646838272
    2^78 302231454903657293676544
    2^79 604462909807314587353088
    2^80 1208925819614629174706176
    2^81 2417851639229258349412352
    2^82 4835703278458516698824704
    2^83 9671406556917033397649408
    2^84 19342813113834066795298816
    2^85 38685626227668133590597632
    2^86 77371252455336267181195264
    2^87 154742504910672534362390528
    2^88 309485009821345068724781056
    2^89 618970019642690137449562112
    2^90 1237940039285380274899124224
    2^91 2475880078570760549798248448
    2^92 4951760157141521099596496896
    2^93 9903520314283042199192993792
    2^94 19807040628566084398385987584
    2^95 39614081257132168796771975168
    2^96 79228162514264337593543950336
    2^97 158456325028528675187087900672
    2^98 316912650057057350374175801344
    2^99 633825300114114700748351602688
    2^100 1267650600228229401496703205376
    2^101 2535301200456458802993406410752
    2^102 5070602400912917605986812821504
    2^103 10141204801825835211973625643008
    2^104 20282409603651670423947251286016
    2^105 40564819207303340847894502572032
    2^106 81129638414606681695789005144064
    2^107 162259276829213363391578010288128
    2^108 324518553658426726783156020576256
    2^109 649037107316853453566312041152512
    2^110 1298074214633706907132624082305024
    2^111 2596148429267413814265248164610048
    2^112 5192296858534827628530496329220096
    2^113 10384593717069655257060992658440192
    2^114 20769187434139310514121985316880384
    2^115 41538374868278621028243970633760768
    2^116 83076749736557242056487941267521536
    2^117 166153499473114484112975882535043072
    2^118 332306998946228968225951765070086144
    2^119 664613997892457936451903530140172288
    2^120 1329227995784915872903807060280344576
    2^121 2658455991569831745807614120560689152
    2^122 5316911983139663491615228241121378304
    2^123 10633823966279326983230456482242756608
    2^124 21267647932558653966460912964485513216
    2^125 42535295865117307932921825928971026432
    2^126 85070591730234615865843651857942052864
    2^127 170141183460469231731687303715884105728
    2^128 340282366920938463463374607431768211456
    2^129 680564733841876926926749214863536422912
    2^130 1361129467683753853853498429727072845824
    2^131 2722258935367507707706996859454145691648
    2^132 5444517870735015415413993718908291383296
    2^133 10889035741470030830827987437816582766592
    2^134 21778071482940061661655974875633165533184
    2^135 43556142965880123323311949751266331066368
    2^136 87112285931760246646623899502532662132736
    2^137 174224571863520493293247799005065324265472
    2^138 348449143727040986586495598010130648530944
    2^139 696898287454081973172991196020261297061888
    2^140 1393796574908163946345982392040522594123776
    2^141 2787593149816327892691964784081045188247552
    2^142 5575186299632655785383929568162090376495104
    2^143 11150372599265311570767859136324180752990208
    2^144 22300745198530623141535718272648361505980416
    2^145 44601490397061246283071436545296723011960832
    2^146 89202980794122492566142873090593446023921664
    2^147 178405961588244985132285746181186892047843328
    2^148 356811923176489970264571492362373784095686656
    2^149 713623846352979940529142984724747568191373312
    2^150 1427247692705959881058285969449495136382746624
    2^151 2854495385411919762116571938898990272765493248
    2^152 5708990770823839524233143877797980545530986496
    2^153 11417981541647679048466287755595961091061972992
    2^154 22835963083295358096932575511191922182123945984
    2^155 45671926166590716193865151022383844364247891968
    2^156 91343852333181432387730302044767688728495783936
    2^157 182687704666362864775460604089535377456991567872
    2^158 365375409332725729550921208179070754913983135744
    2^159 730750818665451459101842416358141509827966271488
    2^160 1461501637330902918203684832716283019655932542976
    2^161 2923003274661805836407369665432566039311865085952
    2^162 5846006549323611672814739330865132078623730171904
    2^163 11692013098647223345629478661730264157247460343808
    2^164 23384026197294446691258957323460528314494920687616
    2^165 46768052394588893382517914646921056628989841375232
    2^166 93536104789177786765035829293842113257979682750464
    2^167 187072209578355573530071658587684226515959365500928
    2^168 374144419156711147060143317175368453031918731001856
    2^169 748288838313422294120286634350736906063837462003712
    2^170 1496577676626844588240573268701473812127674924007424
    2^171 2993155353253689176481146537402947624255349848014848
    2^172 5986310706507378352962293074805895248510699696029696
    2^173 11972621413014756705924586149611790497021399392059392
    2^174 23945242826029513411849172299223580994042798784118784
    2^175 47890485652059026823698344598447161988085597568237568
    2^176 95780971304118053647396689196894323976171195136475136
    2^177 191561942608236107294793378393788647952342390272950272
    2^178 383123885216472214589586756787577295904684780545900544
    2^179 766247770432944429179173513575154591809369561091801088
    2^180 1532495540865888858358347027150309183618739122183602176
    2^181 3064991081731777716716694054300618367237478244367204352
    2^182 6129982163463555433433388108601236734474956488734408704
    2^183 12259964326927110866866776217202473468949912977468817408
    2^184 24519928653854221733733552434404946937899825954937634816
    2^185 49039857307708443467467104868809893875799651909875269632
    2^186 98079714615416886934934209737619787751599303819750539264
    2^187 196159429230833773869868419475239575503198607639501078528
    2^188 392318858461667547739736838950479151006397215279002157056
    2^189 784637716923335095479473677900958302012794430558004314112
    2^190 1569275433846670190958947355801916604025588861116008628224
    2^191 3138550867693340381917894711603833208051177722232017256448
    2^192 6277101735386680763835789423207666416102355444464034512896
    2^193 12554203470773361527671578846415332832204710888928069025792
    2^194 25108406941546723055343157692830665664409421777856138051584
    2^195 50216813883093446110686315385661331328818843555712276103168
    2^196 100433627766186892221372630771322662657637687111424552206336
    2^197 200867255532373784442745261542645325315275374222849104412672
    2^198 401734511064747568885490523085290650630550748445698208825344
    2^199 803469022129495137770981046170581301261101496891396417650688
    2^200 1606938044258990275541962092341162602522202993782792835301376
    2^201 3213876088517980551083924184682325205044405987565585670602752
    2^202 6427752177035961102167848369364650410088811975131171341205504
    2^203 12855504354071922204335696738729300820177623950262342682411008
    2^204 25711008708143844408671393477458601640355247900524685364822016
    2^205 51422017416287688817342786954917203280710495801049370729644032
    2^206 102844034832575377634685573909834406561420991602098741459288064
    2^207 205688069665150755269371147819668813122841983204197482918576128
    2^208 411376139330301510538742295639337626245683966408394965837152256
    2^209 822752278660603021077484591278675252491367932816789931674304512
    2^210 1645504557321206042154969182557350504982735865633579863348609024
    2^211 3291009114642412084309938365114701009965471731267159726697218048
    2^212 6582018229284824168619876730229402019930943462534319453394436096
    2^213 13164036458569648337239753460458804039861886925068638906788872192
    2^214 26328072917139296674479506920917608079723773850137277813577744384
    2^215 52656145834278593348959013841835216159447547700274555627155488768
    2^216 105312291668557186697918027683670432318895095400549111254310977536
    2^217 210624583337114373395836055367340864637790190801098222508621955072
    2^218 421249166674228746791672110734681729275580381602196445017243910144
    2^219 842498333348457493583344221469363458551160763204392890034487820288
    2^220 1684996666696914987166688442938726917102321526408785780068975640576
    2^221 3369993333393829974333376885877453834204643052817571560137951281152
    2^222 6739986666787659948666753771754907668409286105635143120275902562304

  4. PuTTY serial communication

    The settings you need are "Local echo" and "Line editing" under the "Terminal" category on the left.

    To get the characters to display on the screen as you enter them, set "Local echo" to "Force on".

    To get the terminal to not send the command until you press Enter, set "Local line editing" to "Force on".

    https://stackoverflow.com/a/4999313

  5. .REG

    Windows Registry Editor Version 5.00

    [HKEY_CLASSES_ROOT\*\shell\CopyToClientScript]
    @=”Copy to Client”
    “Icon”=”%SystemRoot%\\System32\\shell32.dll,71″

    [HKEY_CLASSES_ROOT\*\shell\CopyToClientScript\command]
    @=”\”C:\\DevTools\\copy_to_client.bat\” \”%1\””


  6. Commit c:\program files\TortoiseSVN\bin\tortoiseproc.exe /command:commit /path:"$(SolutionDir)" /notempfile $(SolutionDir)
    Update c:\program files\TortoiseSVN\bin\tortoiseproc.exe /command:update /path:"$(SolutionDir)" /notempfile $(SolutionDir)
    History c:\program files\TortoiseSVN\bin\tortoiseproc.exe /command:log /path:"$(ItemPath)" /notempfile $(ItemDir)
    Diff c:\program files\TortoiseSVN\bin\tortoiseproc.exe /command:diff /path:"$(ItemPath)" /notempfile $(ItemDir)
    Blame c:\program files\TortoiseSVN\bin\tortoiseproc.exe /command:blame /path:"$(ItemPath)" /notempfile $(ItemDir)
    Revert c:\program files\TortoiseSVN\bin\tortoiseproc.exe /command:revert /path:"$(SolutionDir)" /notempfile $(SolutionDir)
    Modifications c:\program files\TortoiseSVN\bin\tortoiseproc.exe /command:repostatus /path:"$(SolutionDir)" /notempfile $(SolutionDir)
    Edit Conflicts c:\program files\TortoiseSVN\bin\tortoiseproc.exe /command:conflicteditor /path:"$(ItemPath)" /notempfile $(ItemDir)
    Resolve c:\program files\TortoiseSVN\bin\tortoiseproc.exe /command:resolve /path:"$(ItemPath)" /noquestion /notempfile $(ItemDir)
    Repository c:\program files\TortoiseSVN\bin\tortoiseproc.exe /command:repobrowser /path:"$(SolutionDir)" /notempfile $(SolutionDir)
    Project History c:\program files\TortoiseSVN\bin\tortoiseproc.exe /command:log /path:"$(SolutionDir)" /notempfile $(SolutionDir)
    Add Solution c:\program files\TortoiseSVN\bin\tortoiseproc.exe /command:import /path:"$(SolutionDir)" /notempfile $(SolutionDir)
    Branch/Tag c:\program files\TortoiseSVN\bin\tortoiseproc.exe /command:copy /path:"$(SolutionDir)" /notempfile $(SolutionDir)
    Settings c:\program files\TortoiseSVN\bin\tortoiseproc.exe /command:settings /path:"$(SolutionDir)" /notempfile $(SolutionDir)

  7. Chrome extension notification shows only once

    Since you’re using a fixed notification ID, it’s updated instead of creating a new one.

    If the notification is not closed but hidden in the Chrome notification center, it will not be shown again.

    Your options include:

    Not using a fixed ID (pass “” as ID)
    This will cause both the old and the new notifications to remain until dismissed. Probably not what you want.

    Closing the old notification just before showing a new one.
    This works well, but is visually jarring if your old notification did not yet disappear. However, you may actually want this effect if you want to emphasize “this is new information”

    Using a priority change trick to re-show the notification.
    This works best, but is “hacky”. We can only hope Chrome API will improve to do this natively.

    https://stackoverflow.com/a/27315860

  8. #Error: sources for android api 27 not found Android Studio:

    Windows: File -> Settings (ctrl+alt+s) -> Appearance & Behavior -> System Settings -> Android SDK.

    Mac: Android Studio -> Preferences (cmd + ,) -> Appearance & Behavior -> System Settings -> Android SDK.

    Click on Edit on the right of the Android SDK location. Click Next all the way through the wizard and this should fix the problem.

    https://stackoverflow.com/a/37283886

  9. TIL how to use Holder Pattern.

    All View objects have getTag() and setTag() methods. These allow you to associate an arbitrary object with the widget. What the holder pattern is use that “tag” to hold and object that, in turn, holds each of the child widgets of interest. By attaching that holder to the row View, every time we use the row, we already have access to the child widgets we care about, without having to call findViewById() again.

    #android

Leave a Reply