text:
Q: Creating htaccess file For Redirects I created a ".htaccess" file to redirect the website visitors from an old page (example.com) to a new page (example.org). The challenge is that I want to redirect most old pages to a specific url address. As I read I can do it with the following code:
Redirect 301 /10parami.htm https://www.example.org/de/

This works fine for the more than 200 pages which I want to redirect. But to make sure that all other pages are also redirected to the new domain, I added the following code. If I add this code in the ".htaccess" file, it redirects all my old pages to the starting page of the new domain. But this is not what I want. I want to redirect the more than 200 old pages to a specific page on the new domain. The problem is, when I combine the more than 200 redirects with the following code, you are always directed to the starting page of the new domain:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^example.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.example.com$
RewriteRule ^(.*)$ https://example.org/$1 [R=301,L]

In the attachment I added the ".htaccess" file. The more than 200 redirects work perfectly if I delete the addition code "RewriteEngine On …". But I need to make sure that all other pages are also redirected to the new domain, so that I need the additional code.
Is anybody able to fix it?
my htaccess:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^example.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.example.com$
RewriteRule ^(.*)$ https://example.org/$1 [R=301,L]
    Redirect 301 /prayong_accomodation_files/prayong_accomodation.htm https://www.example.org/plan-a-visit/
Redirect 301 /prayong_deutsch_files/watprayong-index.html https://www.example.org
Redirect 301 /selberueben_files/index.htm https://www.example.org
Redirect 301 /10parami.htm https://www.example.org/de/buddhismus/
Redirect 301 /11benefits.htm https://www.example.org/blog/teachings-11-benefits-of-practicing-metta/
Redirect 301 /16predictions.htm https://www.example.org/blog/teachings-16-predictions-of-the-buddha-acharn-veeranon/
Redirect 301 /16upakilesa.htm https://www.example.org/blog/16-defilements-upakilesa/
Redirect 301 /16voraussagen.html https://www.example.org/de/die-sechzehn-vorhersagen-des-buddha-von-phra-khru-palat-veeranon-verananto/3338/
Redirect 301 /4autoritaeten.htm https://www.example.org/de/a-iv-180-die-vier-grossen-autoritaeten/3302/
Redirect 301 /4edlewahrheiten.htm https://www.example.org/de/die-vier-edlen-wahrheiten/3245/
Redirect 301 /4nobletruths.htm https://www.example.org/blog/heart-teachings-of-the-buddha-the-four-noble-truths/
Redirect 301 /5khanda_eng.htm https://www.example.org/blog/heart-teachings-of-the-buddha-five-aggregates-of-existence/
Redirect 301 /5recollectionschant.html https://www.example.org/blog/5-frequent-recollections/
Redirect 301 /5regeln.htm https://www.example.org/de/die-fuenf-buddhistischen-regeln/
Redirect 301 /8fachpfad.htm https://www.example.org/de/der-edle-achtfache-pfad/3261/
Redirect 301 /8foldpath.htm https://www.example.org/blog/heart-teachings-of-the-buddha-the-noble-eightfold-path/
Redirect 301 /8precepts.htm https://www.example.org/blog/buddhist-ethic-principles-the-eight-precepts/
Redirect 301 /8regeln.htm https://www.example.org/de/die-acht-buddhistischen-regeln/3257/
Redirect 301 /8regelnannahme.htm https://www.example.org/de/das-nehmen-der-acht-moralregeln/3259/
Redirect 301 /acaryabuddharakkhita-metta.html https://www.example.org/de/metta-meditation-von-acarya-buddharakkhita/3390/
Redirect 301 /acharn-mun.html https://www.example.org/blog/teachings-of-the-most-venerable-phra-acharn-mun-walking-meditation/
Redirect 301 /acharnphet-deutsch.html https://www.example.org/de/buddhismus/
Redirect 301 /acharnphet-english_17-31-34.html https://www.example.org/mc-brigitte-buddhist-teachings/
Redirect 301 /acharnphet-english.html https://www.example.org/mc-brigitte-buddhist-teachings/
Redirect 301 /acharnphet-index.html https://www.example.org/mc-brigitte-buddhist-teachings/
Redirect 301 /activities.htm https://www.example.org/events/
Redirect 301 /aidstemple.htm https://www.example.org/donations/aids-temple-wat-phra-bat-nam-phu-lopburi/
Redirect 301 /akammaniya.htm https://www.example.org/blog/teachings-akammaniya-numerical-sayings-anguttara-nikhaya/
Redirect 301 /aktivitaeten.htm https://www.example.org/de/vipassana-meditations-retreats-termine/
Redirect 301 /allgembuddhismus.htm https://www.example.org/de/buddhismus-alles-was-man-wissen-sollte/
Redirect 301 /angulimala.htm https://www.example.org/de/angulimala-paritta/3315/
Redirect 301 /aplien-leben.htm https://www.example.org/de/kurzer-lebenslauf-von-phra-ajahn-plien-panyapatipo/3379/
Redirect 301 /aplien11resultate-d.htm https://www.example.org/de/buddhismus/
Redirect 301 /aplien4brahmavihara-d.htm https://www.example.org/de/die-vier-goettlichen-verweilungszustaende-gleichmut-upekkha-von-phra-acharn-plien/3374/
Redirect 301 /aplienkaruna-d.htm https://www.example.org/de/die-vier-goettlichen-verweilungszustaende-karuna-oder-mitgefuehl-von-phra-acharn-plien/3370/
Redirect 301 /aplienmetta-d.htm https://www.example.org/de/die-vier-goettlichen-verweilungszustaende-freundlichkeit-metta-als-unterstuetzung-fuer-die-welt-von-phra-acharn-plien/3365/
Redirect 301 /aplienmudita-d.htm https://www.example.org/de/die-vier-goettlichen-verweilungszustaende-mitfreude-mudita-von-phra-acharn-plien/3372/
Redirect 301 /aplienupekkha-d.htm https://www.example.org/de/die-vier-goettlichen-verweilungszustaende-gleichmut-upekkha-von-phra-acharn-plien/3374/
Redirect 301 /arbeitsmeditation.html https://www.example.org/de/buddhismus/
Redirect 301 /asahalapuja.htm https://www.example.org/blog/buddhist-holidays-asahala-puja-day/
Redirect 301 /ballad.htm https://www.example.org/blog/teachings-of-the-most-venerable-phra-acharn-mun-the-ballad-of-liberation-from-the-khandhas/
Redirect 301 /basic.htm https://www.example.org/blog/teachings-the-basic-method-of-meditation-by-acharn-brahmavamso/
Redirect 301 /bewusstsein.htm https://www.example.org/de/bewusst-sein-anweisungen-von-acharn-sangwahn/3352/
Redirect 301 /biolpoo.htm https://www.example.org/blog/teachings-biography-of-the-ven-phra-acharn-sangwahn-khemako/
Redirect 301 /bojjhanga.htm https://www.example.org/de/bojjhanga-die-sieben-erleuchtungsglieder/3300/
Redirect 301 /buddhadasa_index.html https://www.example.org/blog/teachings-of-ven-acharn-buddhadasa-bhikkhu-no-religion/
Redirect 301 /buddhaonpain.htm https://www.example.org/blog/teachings-dealing-with-pain-samyutta-nikhaya/
Redirect 301 /buddharakmetta-d.htm https://www.example.org/de/metta-meditation-von-acarya-buddharakkhita/3390/
Redirect 301 /buddhism.htm https://www.example.org/mc-brigitte-buddhist-teachings/
Redirect 301 /buddhway.htm https://www.example.org/blog/teachings-buddhist-way-ven-acharn-lee/
Redirect 301 /chantindex.htm https://www.example.org/mc-brigitte-buddhist-teachings/
Redirect 301 /chanting.html https://www.example.org/mc-brigitte-buddhist-teachings/
Redirect 301 /childprotection-index.html https://www.example.org/donations/gurudakshina-the-practice-of-giving-back/
Redirect 301 /childprotection.html https://www.example.org/donations/gurudakshina-the-practice-of-giving-back/
Redirect 301 /compassionayya.htm https://www.example.org/blog/teachings-loving-kindness-meditation-compassion-a-guided-meditation-by-ven-ayya-khema/
Redirect 301 /concentration.htm https://www.example.org/blog/teachings-experiencing-concentration-by-acharn-sanong-katapunyo/
Redirect 301 /contact.htm https://www.example.org/contact/
Redirect 301 /dailysati.htm https://www.example.org/blog/mindfulness-in-daily-life/
Redirect 301 /dailyteaching.htm https://www.example.org/vipassana-retreat-thailand/
Redirect 301 /dana_deutsch.htm https://www.example.org/de/dana/3294/
Redirect 301 /dealpain.htm https://www.example.org/blog/teachings-using-meditation-to-deal-with-pain-illness-and-death-by-thanissaro-bhikkhu/
Redirect 301 /december12-pic_index.html https://www.example.org/events/
Redirect 301 /deciding.htm https://www.example.org/mc-brigitte-deciding-to-become-a-nun/
Redirect 301 /deredle-unedle.htm https://www.example.org/de/a-iv-180-die-vier-grossen-autoritaeten-2/3304/
Redirect 301 /deutsch-index.html https://www.example.org/de
Redirect 301 /deutschindex.htm https://www.example.org/de
Redirect 301 /dhammamtvh.htm https://www.example.org/blog/teachings-dhamma-talk-given-during-a-retreat-by-ven-mettavihari-bhikkhu/
Redirect 301 /dhammaotherlanguages.html https://www.example.org/
Redirect 301 /dhammapada.htm https://www.example.org/blog/dhammapada-the-path-of-virtue/
Redirect 301 /dhammateachings.html https://www.example.org/mc-brigitte-buddhist-teachings/
Redirect 301 /dhutanga.htm https://www.example.org/blog/sangha-what-is-dhutanga-practice/
Redirect 301 /dhutangadeutsch.htm https://www.example.org/de/buddhismus/
Redirect 301 /download_deutsch.htm https://www.example.org/de/buddhismus/
Redirect 301 /download_english.htm https://www.example.org/mc-brigitte-buddhist-teachings/
Redirect 301 /downloads.htm https://www.example.org/de/buddhismus/
Redirect 301 /dreamsource.htm https://www.example.org/blog/sangha-four-sources-of-dreams/
Redirect 301 /einfuehrung.htm https://www.example.org/de/einfuehrung-in-die-meditation-von-brigitte-schrottenbacher/3396/
Redirect 301 /einstein.htm https://www.example.org/mc-brigitte-buddhist-teachings/
Redirect 301 /emotionen.htm https://www.example.org/de/das-entwickeln-von-rechter-konzentration-in-der-meditation-belehrung-vom-ehrwuerdigen-phra-acharn-putt/3342/
Redirect 301 /english-index.html https://www.example.org/
Redirect 301 /englishindex.htm https://www.example.org/
Redirect 301 /erklaerungen.htm https://www.example.org/de/buddhismus/
Redirect 301 /eveningchant.htm https://www.example.org/blog/evening-chanting-usual-version-in-other-temples/
Redirect 301 /events.html https://www.example.org/events/
Redirect 301 /feiertage.htm https://www.example.org/de/die-drei-buddhistischen-feiertage/3306/
Redirect 301 /flood-details.html https://www.example.org/donations/monthly-support-for-nuns-in-thailand-and-bhutan/
Redirect 301 /flood-index.html https://www.example.org/donations/monthly-support-for-nuns-in-thailand-and-bhutan/
Redirect 301 /flut-abrechnung.html https://www.example.org/de/donations/thailand-flut-hilfe-projekt-2011/
Redirect 301 /fuenfgruppen.htm https://www.example.org/de/die-fuenf-gruppen-des-anhaftens-pancakkhandho/3263/
Redirect 301 /gallery_index.htm https://www.example.org/vipassana-retreat-thailand/
Redirect 301 /happycouple.htm https://www.example.org/blog/teachings-how-to-live-a-happy-couple-life-acharn-veeranon/
Redirect 301 /helpnepal.html https://www.example.org/donations/keeping-the-ancient-buddhist-library/
Redirect 301 /impressum.htm https://www.example.org/contact/
Redirect 301 /index.html https://www.example.org/
Redirect 301 /index_info.htm https://www.example.org/
Redirect 301 /info_index.htm https://www.example.org/
Redirect 301 /kalamasutta.htm https://www.example.org/blog/teachings-kalama-sutta/
Redirect 301 /karma_index.html https://www.example.org/mc-brigitte-buddhist-teachings/
Redirect 301 /keinereligion.htm https://www.example.org/de/keine-religion-von-buddhadasa-bhikkhu/
Redirect 301 /keyliber.htm https://www.example.org/blog/teachings-key-to-liberation-ven-phra-acharn-chah/
Redirect 301 /kinderschutzprojekt.html https://www.example.org/de/donations/medikamentenspende-des-oesterreichischen-roten-kreuzes-fuer-beduerftige-in-thailand-projekt-ist-abgeschlossen/
Redirect 301 /knowletgo.htm https://www.example.org/blog/teachings-know-and-let-go-ven-phra-acharn-sangwahn-khemako/
Redirect 301 /konten.html https://www.example.org/donation-programs/
Redirect 301 /konzentrationerleben.htm https://www.example.org/de/konzentration-erleben-von-acharn-sanong-katapunyo/3388/
Redirect 301 /lehrreden.htm https://www.example.org/de/buddhismus/
Redirect 301 /leichterkoerper.htm https://www.example.org/de/leichter-koerper-leichter-geist-anleitung-zur-meditation-vom-ehrwuerdigen-phra-acharn-sangwahn-khemmako/3350/
Redirect 301 /letztepruefung.htm https://www.example.org/de/buddhismus/
Redirect 301 /liebenyanaponika-d.htm https://www.example.org/de/liebe-metta-von-nyanaponika-mahathera-gekuerzte-fassungddd/3409/
Redirect 301 /lifeteachingbuddhadasa.htm https://www.example.org/mc-brigitte-buddhist-teachings/
Redirect 301 /link-d.htm https://www.example.org/de/buddhismus/
Redirect 301 /link-d.html https://www.example.org/de/buddhismus/
Redirect 301 /linkenglish.htm https://www.example.org/mc-brigitte-buddhist-teachings/
Redirect 301 /linkenglish.html https://www.example.org/mc-brigitte-buddhist-teachings/
Redirect 301 /loykrathong.html https://www.example.org/mc-brigitte-buddhist-teachings/
Redirect 301 /lpootuad_engl.html https://www.example.org/blog/teaching-of-ven-luang-poo-tuad/
Redirect 301 /lpsim.htm https://www.example.org/blog/teachings-words-of-the-most-venerable-luang-por-sim-bhikkhu/
Redirect 301 /maechee_index.html https://www.example.org/mc-brigitte/
Redirect 301 /makeupyourmind.htm https://www.example.org/blog/teachings-make-up-your-mind-acharn-tippakorn/
Redirect 301 /makhapuja.htm https://www.example.org/blog/buddhist-holidays-makhapuja-day/
Redirect 301 /map-index.html https://www.example.org/plan-a-visit/
Redirect 301 /mapprayong.htm https://www.example.org/plan-a-visit/
Redirect 301 /mcbrigitte.html https://www.example.org/mc-brigitte/
Redirect 301 /mcbrigitte_indexdeutsch.html https://www.example.org/de/mc-brigitte/
Redirect 301 /meditationvideo.htm https://www.example.org/de/buddhismus/
Redirect 301 /meinleben.htm https://www.example.org/de/mc-brigitte-entscheidung-nonne-zu-werden/
Redirect 301 /metta-d.htm https://www.example.org/de/metta-sutta/3318/
Redirect 301 /mettachant.htm https://www.example.org/blog/metta/
Redirect 301 /mettakreise.htm https://www.example.org/de/metta-meditation-in-5-abschnitten-mettakreise/3381/
Redirect 301 /mettasutta-d.htm https://www.example.org/de/metta-sutta-sutta-der-allguete-von-sri-gnanawimala-maha-thero-auszug-aus-das-licht-der-lehre/3392/
Redirect 301 /mitbringen.html https://www.example.org/de/planung-vipassana-meditations-retreats/
Redirect 301 /monatskurse.html https://www.example.org/de/vipassana-meditations-retreat-in-thailand/
Redirect 301 /monthly-retreats.html https://www.example.org/events/
Redirect 301 /monthly-schedule.html https://www.example.org/vipassana-retreat-thailand/
Redirect 301 /morningchant.htm https://www.example.org/blog/morning-chanting-usual-version-in-other-temples/
Redirect 301 /mylife.htm https://www.example.org/mc-brigitte-my-life-as-a-buddhist-nun/
Redirect 301 /neujahrskurs_deutsch.html https://www.example.org/de/vipassana-meditations-retreats-termine/
Redirect 301 /news.html https://www.example.org/blog-classic-2-columns/
Redirect 301 /newyearchant.html https://www.example.org/mc-brigitte-buddhist-teachings/
Redirect 301 /newyearsretreat_english.html https://www.example.org/events/
Redirect 301 /newyearsretreat_index.html https://www.example.org/events/
Redirect 301 /nibbana.htm https://www.example.org/de/nibbana-die-beschreibung-des-unbeschreiblichen/
Redirect 301 /noreligion.htm https://www.example.org/blog/teachings-of-ven-acharn-buddhadasa-bhikkhu-no-religion/
Redirect 301 /noretreats.html https://www.example.org/events/
Redirect 301 /noteaching.html https://www.example.org/events/
Redirect 301 /noticingsumedho.htm https://www.example.org/blog/teachings-noticing-space-by-acharn-sumedho/
Redirect 301 /originalface.htm https://www.example.org/mc-brigitte-buddhist-teachings/
Redirect 301 /ourmindisnofriend.html https://www.example.org/mc-brigitte-buddhist-teachings/
Redirect 301 /ourmindisnotourfriend.html https://www.example.org/mc-brigitte-buddhist-teachings/
Redirect 301 /overviewmetta.htm https://www.example.org/blog/teachings-overview-of-loving-kindness-meditation/
Redirect 301 /P1_Dana_.htm https://www.example.org/de/der-weg-der-paramita/3265/
Redirect 301 /pancakammatthana.htm https://www.example.org/blog/teachings-panca-kammatthana-ven-phra-acharn-sangwahn-khemako/
Redirect 301 /Parami_adhitthana.htm https://www.example.org/blog/teachings-panca-kammatthana-ven-phra-acharn-sangwahn-khemako/
Redirect 301 /Parami_khanti.htm https://www.example.org/de/khanti-parami/3276/
Redirect 301 /Parami_metta.htm https://www.example.org/de/metta-parami/3282/
Redirect 301 /Parami_nekkhamma.htm https://www.example.org/de/nekkhamma-parami/3269/
Redirect 301 /Parami_panna.htm https://www.example.org/de/panna-parami/3272/
Redirect 301 /Parami_sacca.htm https://www.example.org/de/sacca-parami/3278/
Redirect 301 /Parami_sila.htm https://www.example.org/de/sila-parami/3267/
Redirect 301 /Parami_upekkha.htm https://www.example.org/de/upekkha-parami/3286/
Redirect 301 /Parami_viriya.htm https://www.example.org/de/viriya-parami/3274/
Redirect 301 /Paramita_Weg.htm https://www.example.org/de/der-weg-der-paramita/3265/
Redirect 301 /paticcasamuppada.htm https://www.example.org/blog/teachings-paticcasamuppada-dependent-origination/
Redirect 301 /pavarana.html https://www.example.org/events/
Redirect 301 /pic_socialproject.htm https://www.example.org/donation-programs/
Redirect 301 /pics-floodrelief.html https://www.example.org/donations/monthly-support-for-nuns-in-thailand-and-bhutan/
Redirect 301 /picsfeb17.html https://www.example.org/events/
Redirect 301 /practising.htm https://www.example.org/blog/teachings-practicing-insight-on-your-own-teachings-by-ven-acharn-thawee-baladhammo/
Redirect 301 /prayong_accomodation.htm https://www.example.org/plan-a-visit/
Redirect 301 /prayong_beschreibung.htm https://www.example.org/de/tempel-wat-prayong/
Redirect 301 /prayong_dailyschedule.htm https://www.example.org/vipassana-retreat-thailand/
Redirect 301 /prayong_deutsch.htm https://www.example.org/de/tempel-wat-prayong/
Redirect 301 /prayong_english.htm https://www.example.org/temple-wat-prayong/
Redirect 301 /prayong_gallery.htm https://www.example.org/de/tempel-wat-prayong/
Redirect 301 /prayong_lehrmethode.htm https://www.example.org/de/vipassana-meditations-retreat-in-thailand/
Redirect 301 /prayong_location.htm https://www.example.org/temple-wat-prayong/
Redirect 301 /prayong_method.htm https://www.example.org/vipassana-retreat-thailand/
Redirect 301 /prayong_tagesablauf.htm https://www.example.org/de/tempel-wat-prayong/
Redirect 301 /prayong_unterkunft.htm https://www.example.org/de/tempel-wat-prayong/
Redirect 301 /py-directions.html https://www.example.org/temple-wat-prayong/
Redirect 301 /py-directions_eng.html https://www.example.org/temple-wat-prayong/
Redirect 301 /py-directionsthai.html https://www.example.org/de/tempel-wat-prayong/
Redirect 301 /py-eveningchant.html https://www.example.org/blog/evening-chanting-usual-version-in-other-temples/
Redirect 301 /py-map-routeeng.html https://www.example.org/de/tempel-wat-prayong/
Redirect 301 /py-morningchant.html https://www.example.org/blog/morning-chanting-wat-prayong/
Redirect 301 /pydeutsch_index.html https://www.example.org/de/planung-vipassana-meditations-retreats/
Redirect 301 /raphael-english.html https://www.example.org/mc-brigitte-buddhist-teachings/
Redirect 301 /raum.htm https://www.example.org/de/das-wahrnehmen-von-raum-von-acharn-sumedho/3383/
Redirect 301 /realhome.htm https://www.example.org/blog/teachings-our-real-home-ven-phra-acharn-chah/
Redirect 301 /realworld_index.html https://www.example.org/de/buddhismus/
Redirect 301 /recollection.htm https://www.example.org/blog/recollection-of-the-32-parts-of-the-body/
Redirect 301 /reinheit.htm https://www.example.org/de/reinheit-und-klarblick-von-acharn-thawee-baladhammo/3336/
Redirect 301 /relief.htm https://www.example.org/blog/teachings-relief-of-suffering-ven-acharn-lee/
Redirect 301 /retreats.html https://www.example.org/events/
Redirect 301 /rose.htm https://www.example.org/de/eine-rose-zum-anstecken-nach-thich-nhat-hanhs-a-rose-for-your-pocket/3394/
Redirect 301 /satipatthana.htm https://www.example.org/blog/teachings-satipatthana-vipassana-by-venerable-mahasi-sayadaw/
Redirect 301 /seeing.htm https://www.example.org/blog/teachings-seeing-the-mind-by-ven-luang-por-putt/
Redirect 301 /selberueben.htm https://www.example.org/de/selber-klarblick-ueben-ein-leitfaden-fuer-achtsamkeit-von-phra-acharn-thawie-baladhammo/3325/
Redirect 301 /shortinstruction.htm https://www.example.org/blog/a-short-meditation-instruction/
Redirect 301 /soc-medizin.html https://www.example.org/de/donations/medikamentenspende-des-oesterreichischen-roten-kreuzes-fuer-beduerftige-in-thailand-projekt-ist-abgeschlossen/
Redirect 301 /soc-pic-index.html https://www.example.org/de/soziale-projekte/
Redirect 301 /socialproject-acnr.html https://www.example.org/donation-programs/
Redirect 301 /socialprojects.htm https://www.example.org/donation-programs/
Redirect 301 /socialprojects_index.htm https://www.example.org/donation-programs/
Redirect 301 /sozial-medikamente.html https://www.example.org/de/donations/medikamentenspende-des-oesterreichischen-roten-kreuzes-fuer-beduerftige-in-thailand-projekt-ist-abgeschlossen/
Redirect 301 /sozialeprojekte.htm https://www.example.org/de/soziale-projekte/
Redirect 301 /thefiveprecepts.htm https://www.example.org/blog/buddhist-ethic-principles-explaining-the-five-precepts/
Redirect 301 /tilakkhana.htm https://www.example.org/blog/heart-teachings-of-the-buddha-ti-lakkhana-three-characteristics-of-existence/
Redirect 301 /tobring.html https://www.example.org/plan-a-visit/
Redirect 301 /tucco.htm https://www.example.org/blog/teachings-tucco-pothila-ven-phra-acharn-chah/
Redirect 301 /ultimatetest.htm https://www.example.org/mc-brigitte-buddhist-teachings/
Redirect 301 /utteranceslpoo.htm https://www.example.org/blog/teachings-utterances-of-the-ven-phra-acharn-sangwahn-khemako/
Redirect 301 /values.htm https://www.example.org/blog/teachings-human-values-ven-acharn-lee/
Redirect 301 /velama.htm https://www.example.org/blog/teachings-velama-sutta-anguttara-nikhaya/
Redirect 301 /venchah.html https://www.example.org/blog/teachings-key-to-liberation-ven-phra-acharn-chah/
Redirect 301 /venchob.htm https://www.example.org/blog/the-story-of-venerable-acharn-chob/
Redirect 301 /venlee.html https://www.example.org/blog/teachings-buddhist-way-ven-acharn-lee/
Redirect 301 /vensangwahn.html https://www.example.org/blog/teachings-know-and-let-go-ven-phra-acharn-sangwahn-khemako/
Redirect 301 /ventip.html https://www.example.org/blog/teachings-make-up-your-mind-acharn-tippakorn/
Redirect 301 /venveeranon.html https://www.example.org/blog/teachings-16-predictions-of-the-buddha-acharn-veeranon/
Redirect 301 /vesak.htm https://www.example.org/blog/buddhist-holidays-vesak-day/
Redirect 301 /videos.html https://www.example.org/de/buddhismus/
Redirect 301 /vipassanamtvhri.htm https://www.example.org/de/vipassana-meditation-vom-ehrwuerdigen-phra-kru-kraisavilasa-metthavihari/3340/
Redirect 301 /wahreszhause.htm https://www.example.org/de/unser-wahres-zuhause-eine-lehrrede-gegeben-am-sterbebett-einer-laienanhaengerin-von-acharn-chah/3348/
Redirect 301 /walking-amun.html https://www.example.org/blog/teachings-of-the-most-venerable-phra-acharn-mun-walking-meditation/
Redirect 301 /watprayong-deutsch.html https://www.example.org/de/tempel-wat-prayong/
Redirect 301 /watprayong-english.html https://www.example.org/temple-wat-prayong/
Redirect 301 /watprayong-french.html https://www.example.org/temple-wat-prayong/
Redirect 301 /watprayong-index.html https://www.example.org/temple-wat-prayong/
Redirect 301 /watprayong_english.html https://www.example.org/temple-wat-prayong/
Redirect 301 /whatismeditation.htm https://www.example.org/blog/teachings-what-is-meditation-acharn-tippakorn/
Redirect 301 /wissenloslassen.htm https://www.example.org/de/wissen-und-loslassen-lehrreden-von-phra-acharn-sangwahn/3363/

A:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^example.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.example.com$
RewriteRule ^(.*)$ https://example.org/$1 [R=301,L]

These mod_rewrite directives are processed first, regardless of whether you put them before or after your Redirect directives. Redirect belongs to mod_alias and so are processed independently.
The above RewriteRule also redirects to the same URL-path on the target domain. eg. example.com/<foo> to example.org/<foo>. However, you stated that you wanted to redirect to "to a specific URL". For this you will need to use a RedirectMatch directive (also part of mod_alias).

*

*Delete the mod_rewrite directives above.

*Add a single RedirectMatch after all your Redirect directives:
RedirectMatch 301 ^/ https://www.example.org/<specific-url>

All other URLs, that don't match the Redirect directives that precede it will be redirected to the specific URL as stated.
You will need to clear your browser cache before testing.


text:
Q: IKVM jar to dll issues I'm having hard times trying to convert my .jar library in .dll and make it working by IKVM framework.
I wrote a Java library that works fine since it has been tested succesfully in several java projects, but I strongly need the .dll for .NET.
When I launch the command:
ikvm -jar mylib.jar

everything is ok (I also tried with a Main file to be sure: it works).
But, when I type:
ikvmc -target:library mylib.jar

I got a lot of warnings but still it creates the .dll file. It is important to say that ALL the warnings are related to libraries that I DO NOT use in my project, but I am pretty sure are in the packages I imported in Maven that are essential to me.
I don't know if the true problem is in this step since I read online to ignore those warnings, but to be sure I post a little bit of the output:
warning IKVMC0100: Class "junit.framework.TestCase" not found
warning IKVMC0100: Class "javax.servlet.http.HttpServlet" not found
warning IKVMC0100: Class "javax.servlet.ServletOutputStream" not found
warning IKVMC0100: Class "org.junit.Assert" not found
warning IKVMC0100: Class "junit.framework.TestSuite" not found
warning IKVMC0100: Class "org.apache.tools.ant.taskdefs.MatchingTask" not   found

Let us suppose this step is ok, now I have to import the IKVM libraries and the mylib.dll file in the References of my C# app. I did and the outcome is pretty strange: the autocomplete environment suggest me to use only 4 Java classes, ignoring the 99% of the others. I suppose that something went wrong, but it's pretty hard to me understand where and how to fix it.
Just more helpful info: I'm using Maven, Java8 (sdk 1.8) and IKVM 8.
I also tried the same with IKVM 7 and still got the same errors.
In the end, this is my pom.xml:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.fra.mylibrary</groupId>
<artifactId>MyLibrary</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>MYLIBRARY</name>

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<!-- https://mvnrepository.com/artifact/net.sourceforge.owlapi/owlapi-distribution -->
<dependencies>
    <!-- https://mvnrepository.com/artifact/net.sourceforge.owlapi/owlapi-distribution -->
    <dependency>
        <groupId>net.sourceforge.owlapi</groupId>
        <artifactId>owlapi-distribution</artifactId>
        <version>4.1.3</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/org.antlr/antlr4-runtime -->
    <dependency>
        <groupId>org.antlr</groupId>
        <artifactId>antlr4-runtime</artifactId>
        <version>4.5.3</version>
    </dependency>

    <!-- https://mvnrepository.com/artifact/org.slf4j/slf4j-simple -->
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-simple</artifactId>
        <version>1.7.21</version>
    </dependency>

    <!-- https://mvnrepository.com/artifact/org.codehaus.groovy/groovy-all -->
    <dependency>
        <groupId>org.codehaus.groovy</groupId>
        <artifactId>groovy-all</artifactId>
        <version>2.4.7</version>
    </dependency>

    <!-- https://mvnrepository.com/artifact/net.sourceforge.owlapi/jfact -->
    <dependency>
        <groupId>net.sourceforge.owlapi</groupId>
        <artifactId>jfact</artifactId>
        <version>4.0.4</version>
    </dependency>

</dependencies>

<build>
    <plugins>
        <!-- ANTLR4 -->
        <plugin>
            <groupId>org.antlr</groupId>
            <artifactId>antlr4-maven-plugin</artifactId>
            <version>4.5.3</version>
            <executions>
                <execution>
                    <goals>
                        <goal>antlr4</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
            </configuration>
        </plugin>

        <!-- Maven Assembly Plugin to create Jar -->
        <plugin>
            <artifactId>maven-assembly-plugin</artifactId>
            <executions>
                <execution>
                    <phase>package</phase>
                    <goals>
                        <goal>single</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <descriptorRefs>
                    <descriptorRef>jar-with-dependencies</descriptorRef>
                </descriptorRefs>
            </configuration>
        </plugin>

        <!-- Maven Compiler Plugin -->
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.6.0</version>
            <configuration>
                <source>1.8</source>
                <target>1.8</target>
            </configuration>
        </plugin>

    </plugins>
</build>

A: Just remove all code related to latest version of method and classes , and change it to lower version of library of java , may it work , because I have same error like this

redpajama_set_name: RedPajamaStackExchange


text:
Q: how to write block by block database records into a file in python I am extracting database records from a table and I want to write those into a file. The scenario that I have is that my table has billions of rows in it. So I cannot load all the records in one go an write them as I run out of memory. So I was doing write into the file one record at a time. My current code is:
from impala.dbapi import connect

connection = connect()
cur = connection.cursor()
sql = "<SQL Statement>"
cur.execute(sql)
write_file = open("file1.csv",'w')
write_file.write("<column header>")

row = cur.fetchone()
while row is not None:
      write_file.write("\n" + str(row)[1:-1])
      row = cur.fetchone()

write_file.close()

By doing this it takes a lot of time because of sequential processing of that many records one at a time. What I want to try is to write a block of records at a time (say 1 million records at a time). How can I write a block of record at a time instead of one record at a time?
NOTE: The database that I am using is impala
UPDATE: This is the profiling result from the execution of the above code
ncalls  tottime  percall  cumtime  percall filename:lineno(function)

   148032    0.162    0.000    0.563    0.000 TBinaryProtocol.py:109(writeI32)
    49344    0.077    0.000    0.261    0.000 TBinaryProtocol.py:121(writeString)
    49344    0.256    0.000  146.854    0.003 TBinaryProtocol.py:125(readMessageBegin)
    49344    0.011    0.000    0.011    0.000 TBinaryProtocol.py:145(readMessageEnd)
        1    0.000    0.000    0.000    0.000 TBinaryProtocol.py:20(<module>)
   148032    0.257    0.000  146.350    0.001 TBinaryProtocol.py:205(readI32)
    49344    0.084    0.000    0.549    0.000 TBinaryProtocol.py:220(readString)
        1    0.000    0.000    0.000    0.000 TBinaryProtocol.py:226(TBinaryProtocolFactory)
        1    0.000    0.000    0.000    0.000 TBinaryProtocol.py:236(TBinaryProtocolAccelerated)
        1    0.000    0.000    0.000    0.000 TBinaryProtocol.py:24(TBinaryProtocol)
        1    0.000    0.000    0.000    0.000 TBinaryProtocol.py:258(TBinaryProtocolAcceleratedFactory)
        1    0.000    0.000    0.000    0.000 TBinaryProtocol.py:39(__init__)
    49344    0.134    0.000    0.828    0.000 TBinaryProtocol.py:44(writeMessageBegin)
    49344    0.010    0.000    0.010    0.000 TBinaryProtocol.py:54(writeMessageEnd)
        1    0.000    0.000    0.000    0.000 TCLIService.py:2364(GetOperationStatus_args)
      155    0.000    0.000    0.000    0.000 TCLIService.py:2375(__init__)
      155    0.001    0.000    0.002    0.000 TCLIService.py:2398(write)
        1    0.000    0.000    0.000    0.000 TCLIService.py:2425(GetOperationStatus_result)
      155    0.000    0.000    0.000    0.000 TCLIService.py:2435(__init__)
      155    0.001    0.000    0.002    0.000 TCLIService.py:2438(read)
        1    0.000    0.000    0.000    0.000 TCLIService.py:2485(CancelOperation_args)
        1    0.000    0.000    0.000    0.000 TCLIService.py:2546(CancelOperation_result)
        1    0.000    0.000    2.112    2.112 TCLIService.py:259(ExecuteStatement)
        1    0.000    0.000    2.112    2.112 TCLIService.py:275(recv_ExecuteStatement)
        1    0.000    0.000    0.000    0.000 TCLIService.py:2761(write)
        1    0.000    0.000    0.000    0.000 TCLIService.py:2788(GetResultSetMetadata_result)
        1    0.000    0.000    0.000    0.000 TCLIService.py:2798(__init__)
        1    0.000    0.000    0.000    0.000 TCLIService.py:2801(read)
        1    0.000    0.000    0.000    0.000 TCLIService.py:2848(FetchResults_args)
    49186    0.030    0.000    0.030    0.000 TCLIService.py:2859(__init__)
    49186    0.171    0.000    0.418    0.000 TCLIService.py:2882(write)
        1    0.000    0.000    0.000    0.000 TCLIService.py:2909(FetchResults_result)
    49186    0.047    0.000    0.047    0.000 TCLIService.py:2919(__init__)
    49186    0.195    0.000   93.752    0.002 TCLIService.py:2922(read)
      155    0.001    0.000    0.114    0.001 TCLIService.py:499(GetOperationStatus)
      155    0.001    0.000    0.012    0.000 TCLIService.py:507(send_GetOperationStatus)
      155    0.001    0.000    0.101    0.001 TCLIService.py:515(recv_GetOperationStatus)
        1    0.000    0.000    0.002    0.002 TCLIService.py:589(GetResultSetMetadata)
        1    0.000    0.000    0.000    0.000 TCLIService.py:597(send_GetResultSetMetadata)
        1    0.000    0.000    0.002    0.002 TCLIService.py:605(recv_GetResultSetMetadata)
    49186    0.145    0.000  241.626    0.005 TCLIService.py:619(FetchResults)
    49186    0.276    0.000    2.709    0.000 TCLIService.py:627(send_FetchResults)
    49186    0.318    0.000  238.771    0.005 TCLIService.py:635(recv_FetchResults)
        1    0.000    0.000    0.000    0.000 TCLIService.py:770(Processor)
        1    0.001    0.001    0.001    0.001 TCLIService.py:9(<module>)
        1    0.000    0.000    0.000    0.000 TProtocol.py:20(<module>)
        1    0.000    0.000    0.000    0.000 TProtocol.py:23(TProtocolException)
        1    0.000    0.000    0.000    0.000 TProtocol.py:39(TProtocolBase)
        1    0.000    0.000    0.000    0.000 TProtocol.py:419(TProtocolFactory)
        1    0.000    0.000    0.000    0.000 TProtocol.py:42(__init__)
  2245378    4.023    0.000  190.070    0.000 TSocket.py:103(read)
    49344    0.153    0.000    0.925    0.000 TSocket.py:123(write)
    49344    0.012    0.000    0.012    0.000 TSocket.py:137(flush)
        1    0.000    0.000    0.000    0.000 TSocket.py:141(TServerSocket)
        1    0.000    0.000    0.001    0.001 TSocket.py:20(<module>)
        1    0.000    0.000    0.000    0.000 TSocket.py:28(TSocketBase)
        1    0.000    0.000    0.000    0.000 TSocket.py:29(_resolveAddr)
        1    0.000    0.000    0.000    0.000 TSocket.py:47(TSocket)
        1    0.000    0.000    0.000    0.000 TSocket.py:50(__init__)
    49344    0.022    0.000    0.022    0.000 TSocket.py:69(isOpen)
        1    0.000    0.000    0.000    0.000 TSocket.py:72(setTimeout)
        1    0.000    0.000    0.000    0.000 TSocket.py:81(open)
        1    0.000    0.000    0.000    0.000 TTransport.py:103(TServerTransportBase)
        1    0.000    0.000    0.000    0.000 TTransport.py:116(TTransportFactoryBase)
        1    0.000    0.000    0.000    0.000 TTransport.py:123(TBufferedTransportFactory)
        1    0.000    0.000    0.000    0.000 TTransport.py:131(TBufferedTransport)
        1    0.000    0.000    0.000    0.000 TTransport.py:139(__init__)
    49344    0.057    0.000    0.079    0.000 TTransport.py:145(isOpen)
        1    0.000    0.000    0.000    0.000 TTransport.py:148(open)
   197376    0.473    0.000  145.718    0.001 TTransport.py:154(read)
   246720    0.177    0.000    0.376    0.000 TTransport.py:162(write)
    49344    0.177    0.000    1.156    0.000 TTransport.py:165(flush)
    49344    0.015    0.000    0.015    0.000 TTransport.py:173(cstringio_buf)
  2196034    8.376    0.000   57.806    0.000 TTransport.py:177(cstringio_refill)
   197376    0.389    0.000  146.149    0.001 TTransport.py:54(readAll)
       46    0.000    0.000    0.000    0.000 abc.py:89(<genexpr>)
       34    0.000    0.000    0.000    0.000 collections.py:329(<genexpr>)
        4    0.000    0.000    0.000    0.000 collections.py:353(<genexpr>)
        4    0.000    0.000    0.000    0.000 collections.py:355(<genexpr>)
        4    0.000    0.000    0.000    0.000 collections.py:38(__init__)
        1    0.000    0.000    0.000    0.000 collections.py:387(Counter)
       44    0.000    0.000    0.000    0.000 collections.py:54(__setitem__)
       28    0.000    0.000    0.000    0.000 collections.py:73(__iter__)
        3    0.000    0.000    0.000    0.000 decimal.py:3782(__init__)
       27    0.000    0.000    0.000    0.000 decimal.py:3809(<genexpr>)
       27    0.000    0.000    0.000    0.000 decimal.py:3816(<genexpr>)
    49186    0.018    0.000    0.018    0.000 hiveserver2.py:113(buffersize)
    49344    3.269    0.000 1590.514    0.032 hiveserver2.py:116(wrapper)
100680255   29.571    0.000   29.571    0.000 hiveserver2.py:122(has_result_set)
        1    0.000    0.000   39.283   39.283 hiveserver2.py:140(execute)
        1    0.000    0.000    2.112    2.112 hiveserver2.py:142(op)
        1    0.000    0.000    0.000    0.000 hiveserver2.py:146(_get_socket)
        2    0.004    0.002    0.029    0.014 hiveserver2.py:15(<module>)
        1    0.000    0.000   39.283   39.283 hiveserver2.py:154(_execute_sync)
        1    0.000    0.000    0.000    0.000 hiveserver2.py:158(_get_transport)
        1    0.000    0.000    0.000    0.000 hiveserver2.py:166(_reset_state)
        1    0.002    0.002   37.169   37.169 hiveserver2.py:175(_wait_to_finish)
        1    0.000    0.000    0.000    0.000 hiveserver2.py:187(connect_to_impala)
      154    0.000    0.000    0.000    0.000 hiveserver2.py:189(_get_sleep_interval)
 50340127   50.937    0.000 1760.004    0.000 hiveserver2.py:207(fetchone)
        1    0.000    0.000    0.001    0.001 hiveserver2.py:209(open_session)
        1    0.000    0.000    2.112    2.112 hiveserver2.py:226(execute_statement)
        1    0.000    0.000    0.002    0.002 hiveserver2.py:237(get_result_schema)
        1    0.000    0.000    0.000    0.000 hiveserver2.py:24(HiveServer2Connection)
 50340127   52.496    0.000 1693.039    0.000 hiveserver2.py:250(next)
    49186 1153.582    0.023 1584.908    0.032 hiveserver2.py:263(fetch_results)
        1    0.000    0.000    0.000    0.000 hiveserver2.py:30(__init__)
      155    0.002    0.000    0.115    0.001 hiveserver2.py:406(get_operation_status)
        1    0.000    0.000    0.001    0.001 hiveserver2.py:49(cursor)
        1    0.000    0.000    0.000    0.000 hiveserver2.py:66(HiveServer2Cursor)
        1    0.000    0.000    0.000    0.000 hiveserver2.py:71(__init__)
    49344    0.039    0.000    0.039    0.000 hiveserver2.py:76(err_if_rpc_not_ok)
    49186    0.017    0.000    0.017    0.000 hiveserver2.py:89(description)
      391    0.000    0.000    0.000    0.000 sre_parse.py:130(__getitem__)
       42    0.000    0.000    0.000    0.000 sre_parse.py:134(__setitem__)
      145    0.000    0.000    0.000    0.000 sre_parse.py:138(append)
   135/54    0.000    0.000    0.000    0.000 sre_parse.py:140(getwidth)
       12    0.000    0.000    0.000    0.000 sre_parse.py:178(__init__)
     1116    0.001    0.000    0.001    0.000 sre_parse.py:182(__next)
      308    0.000    0.000    0.000    0.000 sre_parse.py:195(match)
      983    0.000    0.000    0.002    0.000 sre_parse.py:201(get)
        1    0.000    0.000    0.000    0.000 sre_parse.py:205(tell)
      114    0.000    0.000    0.000    0.000 sre_parse.py:210(isident)
       21    0.000    0.000    0.000    0.000 sre_parse.py:216(isname)
        2    0.000    0.000    0.000    0.000 sre_parse.py:225(_class_escape)
       32    0.000    0.000    0.000    0.000 sre_parse.py:257(_escape)
    47/12    0.000    0.000    0.004    0.000 sre_parse.py:301(_parse_sub)
    52/13    0.001    0.000    0.004    0.000 sre_parse.py:379(_parse)
       12    0.000    0.000    0.000    0.000 sre_parse.py:67(__init__)
       12    0.000    0.000    0.004    0.000 sre_parse.py:675(parse)
       29    0.000    0.000    0.000    0.000 sre_parse.py:72(opengroup)
       29    0.000    0.000    0.000    0.000 sre_parse.py:83(closegroup)
       98    0.000    0.000    0.000    0.000 sre_parse.py:90(__init__)
   442674    0.315    0.000    0.315    0.000 ttypes.py:2296(__init__)
   590232    0.262    0.000    0.262    0.000 ttypes.py:2380(__init__)
  1032906    2.061    0.000    2.061    0.000 ttypes.py:2644(__init__)
    49186    0.033    0.000    0.033    0.000 ttypes.py:2786(__init__)
    49344    0.050    0.000    0.050    0.000 ttypes.py:2896(__init__)
      155    0.000    0.000    0.000    0.000 ttypes.py:5195(__init__)
      155    0.000    0.000    0.000    0.000 ttypes.py:5266(__init__)
       21    0.000    0.000    0.000    0.000 ttypes.py:540(__init__)
    49186    0.055    0.000    0.055    0.000 ttypes.py:5764(__init__)
        1    0.000    0.000    0.000    0.000 ttypes.py:5840(TFetchResultsResp)
    49186    0.044    0.000    0.044    0.000 ttypes.py:5855(__init__)
        1  286.275  286.275 2121.074 2121.074 test.py:24(func1)
        1    0.001    0.001 2121.112 2121.112 test.py:3(<module>)
       12    0.000    0.000    0.000    0.000 {_sre.compile}
       35    0.000    0.000    0.000    0.000 {_sre.getlower}
   148032    0.134    0.000    0.134    0.000 {_struct.pack}
   148032    0.107    0.000    0.107    0.000 {_struct.unpack}
  2294724    4.074    0.000    4.074    0.000 {cStringIO.StringIO}
      251    0.000    0.000    0.000    0.000 {getattr}
    99230    0.061    0.000    0.061    0.000 {isinstance}
    24/13    0.000    0.000    0.000    0.000 {issubclass}
55672069/55672017    7.519    0.000    7.519    0.000 {len}
    49351    0.061    0.000    0.061    0.000 {max}
        4    0.000    0.000    0.000    0.000 {method '__contains__' of 'frozenset' objects}
       11    0.000    0.000    0.000    0.000 {method '__subclasses__' of 'type' objects}
1107483909  105.411    0.000  105.411    0.000 {method 'append' of 'list' objects}
        4    0.220    0.055    0.220    0.055 {method 'close' of 'file' objects}
        1    0.000    0.000    0.000    0.000 {method 'connect' of '_socket.socket' objects}
        1    0.000    0.000    0.000    0.000 {method 'disable' of '_lsprof.Profiler' objects}
        1    0.000    0.000    0.000    0.000 {method 'endswith' of 'str' objects}
    49198    0.249    0.000    0.249    0.000 {method 'extend' of 'list' objects}
    49344    0.021    0.000    0.021    0.000 {method 'getvalue' of 'cStringIO.StringO' objects}
 50340126   32.139    0.000   32.139    0.000 {method 'pop' of 'list' objects}
   246720    0.140    0.000    0.140    0.000 {method 'read' of 'cStringIO.StringI' objects}
       23    0.000    0.000    0.000    0.000 {method 'readline' of 'file' objects}
  2245378  185.259    0.000  185.259    0.000 {method 'recv' of '_socket.socket' objects}
    49344    0.764    0.000    0.764    0.000 {method 'send' of '_socket.socket' objects}
        2    0.000    0.000    0.000    0.000 {method 'setter' of 'property' objects}
        1    0.000    0.000    0.000    0.000 {method 'settimeout' of '_socket.socket' objects}
       45    0.000    0.000    0.000    0.000 {method 'split' of 'str' objects}
       11    0.000    0.000    0.000    0.000 {method 'startswith' of 'str' objects}
       45    0.000    0.000    0.000    0.000 {method 'strip' of 'str' objects}
   246720    0.198    0.000    0.198    0.000 {method 'write' of 'cStringIO.StringO' objects}
 50340130   34.491    0.000   34.491    0.000 {method 'write' of 'file' objects}
      193    0.000    0.000    0.000    0.000 {min}
        4    0.800    0.200    0.800    0.200 {open}
1057142741   84.179    0.000   84.179    0.000 {ord}
        1    0.000    0.000    0.000    0.000 {posix.getcwd}
        1    0.000    0.000    0.000    0.000 {posix.lstat}
        1    0.000    0.000    0.000    0.000 {posix.urandom}
        1    0.000    0.000    0.000    0.000 {repr}
      146    0.000    0.000    0.000    0.000 {setattr}
        2    0.000    0.000    0.000    0.000 {sys._getframe}
        3    0.000    0.000    0.000    0.000 {thread.allocate_lock}
        2    0.000    0.000    0.000    0.000 {thread.get_ident}
    49344   32.932    0.001   93.520    0.002 {thrift.protocol.fastbinary.decode_binary}
    49344    0.184    0.000    0.184    0.000 {thrift.protocol.fastbinary.encode_binary}
      154   37.048    0.241   37.048    0.241 {time.sleep}
        1    0.000    0.000    0.000    0.000 {time.strftime}
      159    0.000    0.000    0.000    0.000 {time.time}

A: If you save the output of the profiler into a file (I saved into file a) and sort it by the 2nd column tottime (the time spend in the function itself excluding called functions) and take the top 10 (not sure if giving it a head would be appropriate):
[max@supernova:~/tmp] $ sort --key=2nr a | head
    49186 1153.582    0.023 1584.908    0.032 hiveserver2.py:263(fetch_results)
        1  286.275  286.275 2121.074 2121.074 test.py:24(func1)
  2245378  185.259    0.000  185.259    0.000 {method 'recv' of '_socket.socket' objects}
1107483909  105.411    0.000  105.411    0.000 {method 'append' of 'list' objects}
1057142741   84.179    0.000   84.179    0.000 {ord}
 50340127   52.496    0.000 1693.039    0.000 hiveserver2.py:250(next)
 50340127   50.937    0.000 1760.004    0.000 hiveserver2.py:207(fetchone)
      154   37.048    0.241   37.048    0.241 {time.sleep}
 50340130   34.491    0.000   34.491    0.000 {method 'write' of 'file' objects}
    49344   32.932    0.001   93.520    0.002 {thrift.protocol.fastbinary.decode_binary}

Interpretation:

*

*The bulk of the time is spent in 49186 calls into hiveserver2.py:263(fetch_results). I am not familiar with that library, but would I check if the number of calls could be reduced. Often, there are function prologue and epilogue costs, request/response overhead and such, so by reducing the number of calls you could cut down some overheads. May be do bulk result row fetching (i.e. more than one row at a time).

*Not sure what test.py:24(func1) does but it is the 2nd hot spot in the profiler output although it is called only once. Does it do any kind of a loop?

*Next is 185.259 time units, they are spent in 2245378 calls to {method 'recv' of '_socket.socket' objects}. That number of recv calls seems excessive, probably because of using fetchone, because it looks like it sends a new request over the socket for each row.

*Next {method 'append' of 'list' objects}, not enough information where it is being called from.

*Same for {ord}.

*Next, the two entries hiveserver2.py:250(next) and hiveserver2.py:207(fetchone) account for the most of total time (the 4th column).
Considering the above interpretation, it looks like calling fetchone is quite sub-optimal.
Instead of calling fetchone I would try calling fetchall if the resultset is guaranteed to fit into available memory, otherwise fetchmany, in order to load the recordset from the database using as few requests/batches as possible.


text:
Q: What if, memory allocated using malloc is deleted using delete rather than free I came across an issue which I could not resolve.
My question is, if I used malloc to allocate memory and then memory block is delete using delete?
The general thumb rule is

If we allocate memory using malloc, it should be deleted using free.
If we allocate memory using new, it should be deleted using delete.

Now, in order to check what happens if we do the reverse, I wrote a small code.
#include<iostream>
#include<cstdio>
#include<cstdlib>

using namespace std;

class A
{
  int p=10;
public:
  int lol() {
    return p;
  }
};

int main()
{
  int *a = (int *)malloc(sizeof(int)*5);
  for(int i=0; i<4; i++) {
    a[i] = i;
    cout << a[i] << endl;
  }

  delete(a);
  // Works fine till here..

  A b;
  cout << b.lol() << endl;
  free(b); // Causes error.

  return 0;
}

The error which I get is:

error: cannot convert 'A' to 'void*' for argument '1' to 'void
free(void*)'

I am unable to understand why is this happening. Please explain.

A: The free function expects a pointer to memory allocated by malloc. The compiler is simply telling you that did not pass it a pointer, a fact that it can readily prove. I guess you meant to create an object with new and then call free on the address of that object. But you did not call new.
When you correct this you may well find the free succeeds but you should not read anything significant into any such success. You know the rules, they are clearly stated in your documentation. It is incorrect to do what you are attempting. The behaviour is undefined. There's little to be gained from an experiment like this. You won't learn anything about why the C memory management functions cannot be paired with C++ memory management functions.
The problem with your experiment is that is has no power. You can just show the outcome for one specific scenario. But these functions are designed to work across the board. How are you going to test every single possible scenario?
Never program using trial and error. You must always understand the rules and priciples behind what you do.

A: Your b variable is not a pointer, but a stack-allocated A. If you want to try this experiment, then you'd want to say
A* b = new A;
free(b);

I'm all for experimentation, but I'm not sure what you were trying to achieve here.
In C++, operator new doesn't just allocate memory, it runs constructors too. Similarly, delete runs destructors for you (taking polymorphic classes into account), as well as freeing the returned memory. On the other hand, malloc() and free() are just C library routines which (from a programmer's point of view) do nothing more than request a chunk of memory from the operating system, and then hand it back.
Now, for a simple, POD class with trivial constructors and destructors, you might be able to get away with mixing up C and C++ memory allocation, because there's nothing C++-specific to be done. But even if you do, what does it prove? It's undefined behaviour, and it probably won't work on another compiler. It might not work tomorrow.
If you use any C++ features -- inheritance, virtual functions, etc etc, it very definitely won't work, because new and delete have to do a lot more work than just allocating memory.
So please, stick to the rules! :-)

A: You didn't create b using new so you are not testing the intended hypothesis. (Also, the name of b is not a pointer.)
Anyway, malloc/new and delete/free work interchangeably only as long as their implementations are interchangeable. In simple cases and on simpler platforms this is more likely, but it's a risky bet in the long term or as a habit.
For example, the array form of new, when applied to a class with a nontrivial destructor, requires the implementation (compiler, runtime, etc.) to remember the size of the array so that delete may call the destructor for each array object. There is almost nowhere to put such information but in the dynamically allocated block itself, preceding the memory location referred to by the pointer returned by new. Passing this pointer to free would then require the memory allocator to determine the actual start of the allocation block, which it may or may not be able to do.
More generally, new and malloc may refer to completely different memory allocators. The compiler, runtime library, and OS work together to provide memory to your program. The details can change as a result of switching or upgrading any of these components.

A: When you call delete a pointer, the compiler will call the dtor of the class for you automatically, but free won't. (Also new will call ctor of the class, malloc won't.)
In you example, a char array apparently don't have a dtor, so delete does nothing but return the memory. That's why it's okay. (Or vise versa, new a char array and then free it.)
But there can still be a problem: what if new and malloc are borrowing memory from different heap manager?
Imagine that, you borrow money from people A, and return to people B later. Even if you are okay with that, have you ever consider A's feeling?
BTW, you should use delete [] pArray; to free an array allocated using new[].

A: From the documentation,
void free (void* ptr);

ptr::

Pointer to a memory block previously allocated with malloc, calloc or
  realloc.

And what you are passing is not a pointer, so it complains.
 A *b = new A();
 cout << b->lol() << endl;
 free(b); // Will Not cause error

A: No, it is not a rule of thumb that you should not mix new/free or malloc/delete.
Sure, it might be possible to use free to relinquish an allocation you obtained with new without a crash, but it is highly implementation/system specific.
Ignoring the fact that you're bypassing destructors or writing code that will corrupt memory on some systems, the more fundamental, more basic C++ consideration is really simply this:
malloc/free are global, system functions, while new and delete are operators.
struct X {
    void* operator new(size_t);
    void operator delete(void* object);
};

Sure - you can borrow a book from Amazon and return it to your local library: go there late one night and leave it on their front door step.
It's going to have undefined behavior, up to and including your getting arrested - and I'm talking about mixing new/free again here :)
Put another way: malloc and free deal with raw memory allocations, while new and delete deal with objects, and that's a very different thing.
void* p = new std::vector<int>(100);
void* q = malloc(sizeof(*q));

A: Many good reasons have already been given. I'll add one more reason: the new operator can be overriden in c++. This allows the user to specify their own memory management model if they so desire. Although this is pretty uncommon, its existence is just one more reason why malloc and new, delete and free cannot be used interchangeably. This is for the reason described by @Patz.

A: free() accepts a pointer.
You are passing an object (not a pointe) to free. That is why you are getting the error. If you make below change, your code works fine.
A *a = new A;
free(a);

Though the code above works fine, it will lead to a memory leak because free() doesn't call the destructor, which is responsible for freeing the resource(s) created by the constructor.


text:
Q: Network calling in intent service works only in debug mode Am encountering a strange problem I am trigerring an intent service every 20 sec:
with an api hit through volley
When the app is on  debug mode its working fine and am getting the result. Otherwise its not working at all
Please someone help me tto find a solution for this.
public class DataSubmissionService extends IntentService {
    @Override
    protected void onHandleIntent(Intent intent) {
        gpsTracker_gps = new GPSTracker(getApplicationContext(), Constant.GPS);
        if (Utils.isNetworkAvailable(getApplicationContext())){
            init();

        }else {
            logUtils.writeToLogFile("Network not available");
        }
    }

    private void fetchinfofromTracker(GPSTracker gpsTracker) {
        latitude = String.valueOf(gpsTracker.latitude);
        Log.d(TAG, "Latitude :" + latitude);
        longitude = String.valueOf(gpsTracker.longitude);
        Log.d(TAG, "Longitude :" + longitude);

        elevation = String.valueOf(gpsTracker.altitude);
        speed = String.valueOf(gpsTracker.speed);
        accuracy = String.valueOf(gpsTracker.accuracy);
        provider = gpsTracker.provider;
        bearing = String.valueOf(gpsTracker.bearing);

        model.setLatitude(latitude);
        model.setLongitude(longitude);
        model.setAccuracy(accuracy);
        model.setProvider(provider);
        model.setBearing(bearing);
        model.setTimeStamp(getCurrentDateTime());
        // callAlarmManager();

        // logUtils.logText("GPS Values:" + "Latitude" +latitude + " Longitude" + longitude );
        if (latitude.equals("0.0")) {
            latitude = "0.0";
            longitude = "0.0";
            model.setLatitude(latitude);
            model.setLongitude(longitude);
        } else {

            Intent intent = new Intent(BROADCAST_ACTION);
            intent.putExtra("latitude", latitude);
            intent.putExtra("longitude", longitude);
            intent.putExtra("speed", speed);
            intent.putExtra("accuracy", accuracy);
            intent.putExtra("bearing", bearing);
            intent.putExtra("provider", provider);
            intent.putExtra("elevation", elevation);
            sendBroadcast(intent);

            // insertdata();
            sendToServer(model);
        }
    }

    private void sendVolleyRequest(JSONObject jsonObject) {
        try {
            logUtils.logText("Connecting to server");
            RequestQueue requestQueue = Volley.newRequestQueue(this);
            String URL = Constant.BASE_URL;
            JSONObject jsonBody = jsonObject;
            final String requestBody = jsonBody.toString();

            JsonArrayRequest getRequest = new JsonArrayRequest(Request.Method.POST, URL, null,
                new Response.Listener<JSONArray>()
                {
                    @Override
                    public void onResponse(JSONArray response) {
                        // display response
                        responseListener(response.toString(),resultCode);
                    }
                },
                new Response.ErrorListener()
                {
                    @Override
                    public void onErrorResponse(VolleyError error) {
                        Log.d("Error.Response", error.toString());
                        logUtils.writeToLogFile(error.toString());
                    }
                }
        ){
            @Override
            public String getBodyContentType() {
                return "application/json";
            }

            @Override
            public byte[] getBody() {
                try {
                    return requestBody == null ? null : requestBody.getBytes("utf-8");
                } catch (UnsupportedEncodingException uee) {
                    VolleyLog.wtf("Unsupported Encoding while trying to get the bytes of %s using %s", requestBody, "utf-8");
                    return null;
                }
            }

            @Override
            public Map<String, String> getHeaders() throws AuthFailureError {
                Map<String, String> headers = new HashMap<String, String>();
                headers.put("Accept", "application/json");
                headers.put("Content-Type", "application/json");
                return headers;
            }
        };
        getRequest.setRetryPolicy(new DefaultRetryPolicy(
                TIME_OUT,
                DefaultRetryPolicy.DEFAULT_MAX_RETRIES,
                DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));
        requestQueue.add(getRequest);
    } catch (Exception e) {
        e.printStackTrace();
    }

  public void responseListener(String res, int resultCode) {
    Log.e(TAG,res);
    //Log.e("responseFromFeecal..", res);
    //Log.e("feeResultCode", "" + resultCode);
    //Log.e("CMR", "Server response: " + res);
    int maxLogSize = 1000;
    for (int i = 0; i <= res.length() / maxLogSize; i++) {
        int start = i * maxLogSize;
        int end = (i + 1) * maxLogSize;
        end = end > res.length() ? res.length() : end;
        Log.v("lt_response", res.substring(start, end));
    }
    logUtils.logText("Server Response: " + res);
    if (res.contains("100") || (res.contains("Success"))) {
       /* Toast.makeText(getApplicationContext(), "Success" ,
                Toast.LENGTH_SHORT).show();*/
        String guidval = "";
        String status = "";
        try {
            JSONArray jsonArray = new JSONArray(res);
            JSONObject jsonObject = jsonArray.getJSONObject(0);
            JSONArray idStr = jsonObject.getJSONArray("ReceivedGuidKeys");

            JSONObject key_value = idStr.getJSONObject(0);
            String key_c = key_value.getString("key");
            guidval = key_c;
            String status_c = key_value.getString("status");
            status = status_c;
            System.out.println("Status: " + status_c + " GUIDKey: " + key_c);
        } catch (JSONException e) {
            e.printStackTrace();
            logUtils.logText(e.getMessage());
        }

        if (status.equalsIgnoreCase(Constant.FALSE)) {
            //SendtoServer(guidval, Constant.PENDINGITEM);
            logUtils.logText("Server returns false for " + guidval);
            System.out.print("Server returns false for " + guidval);
        }
    } else {
        /*DBHelper db = new DBHelper(getApplicationContext());
        db.logRecordCounts();*/
        logUtils.logText("Server failed to respond");
    }
}
}

While am working on debugging , all the time its hitting the api and giving me the perfect response


text:
Q: Error while creating EntityManagerFactory: java.lang.NoClassDefFoundError I have a problem creating entity manager factory. I'm using JPA to connect to a postgres database. The "Java_Lab_4" doesn't seem like a valid persistence Unit Name.
I've tried naming the persistence unit name org.apache.openjpa.persistence.PersistenceProviderImpl, but it didn't help.

    package model;

    import java.text.SimpleDateFormat;
    import java.math.BigDecimal;
    import java.util.Date;
    import java.util.List;
    import java.util.Properties;
    import java.util.TreeSet;
    import javax.persistence.EntityManager;
    import javax.persistence.EntityManagerFactory;
    import javax.persistence.Persistence;
    import javax.persistence.Query;

    public class Test {
        public static void main(String[] args) {

            Properties props = new Properties();

            props.put("openjpa.ConnectionURL", "jdbc:postgresql://localhost:5432/postgres");
            props.put("openjpa.ConnectionDriverName", "org.jdbc.Driver");
            props.put("openjpa.ConnectionUserName", "postgres");
            props.put("openjpa.ConnectionPassword", "stalker");
            props.put("openjpa.jdbc.SynchronizeMappings", "public");
    // the problem is here -->
            EntityManagerFactory emf = Persistence.createEntityManagerFactory("Java_Lab_4", props);
            saveEntities(emf);
            readEntities(emf);

        }

        private static void saveEntities(EntityManagerFactory emf) {
            EntityManager em = emf.createEntityManager();
            em.getTransaction().begin();

            try {

                Booking booking = new Booking();
                booking.setBooking_Code(BigDecimal.valueOf(12345.0));
                booking.setPaid("yes");
                booking.setPassenger_Code(1234);
                booking.setFlight_Code(BigDecimal.valueOf(9999));
                booking.setDate(new SimpleDateFormat("dd/MM/yyyy").parse("9/10/2019"));

                em.persist(booking);

                em.getTransaction().commit();

            } catch (Exception e) {
                e.printStackTrace();

                em.getTransaction().rollback();
            } finally {

                em.close();
            }
        }

        private static void readEntities(EntityManagerFactory emf) {
            EntityManager em;
            em = emf.createEntityManager();
            em.getTransaction().begin();

            try {

                Query query = em.createQuery("SELECT x FROM Group x");

                List<?> list = query.getResultList();

                if (!list.isEmpty()) {

                    for (Object object : list) {
                        Date date = ((Booking)list).getDate();
                        String paid = ((Booking)list).getPaid();
                        long passengerCode = ((Booking)list).getPassenger_Code();
                        BigDecimal flightCode = ((Booking)list).getFlight_Code();
                        BigDecimal bookingCode = ((Booking)list).getBooking_Code();
                        System.out.println("PassengerCode = " + passengerCode
                                + ", FlightCode = " + flightCode.toString() + ", BookingCode = "
                                + bookingCode.toString() + ", Date = " + date.toString()
                                + "Paid = " + paid);
                    }

                } else {
                    System.out.println("No booking");
                }

                em.getTransaction().commit();

            } catch (Exception e) {
                e.printStackTrace();

                em.getTransaction().rollback();
            } finally {

                em.close();
            }
        }
    }

Persistence file:

    <?xml version="1.0" encoding="UTF-8"?>
    <persistence version="2.1" xmlns="http://xmlns.jcp.org/xml/ns/persistence"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd" >
        <persistence-unit name="Java_Lab_4">
            <provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
            <class>model.Booking</class>
            <class>model.Category</class>
            <class>model.Flight</class>
            <class>model.Passenger</class>
            <class>model.Ticket</class>
        </persistence-unit>
    </persistence>

Exception in thread "main" java.lang.NoClassDefFoundError: org/jboss/logging/Logger
    at org.hibernate.jpa.HibernatePersistenceProvider.<clinit>(HibernatePersistenceProvider.java:38)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
    at java.lang.reflect.Constructor.newInstance(Unknown Source)
    at java.lang.Class.newInstance(Unknown Source)
    at javax.persistence.spi.PersistenceProviderResolverHolder$DefaultPersistenceProviderResolver.getPersistenceProviders(PersistenceProviderResolverHolder.java:117)
    at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:76)
    at model.Test.main(Test.java:26)
Caused by: java.lang.ClassNotFoundException: org.jboss.logging.Logger
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    ... 9 more

A: There's nothing wrong the EntityManagerFactory name - but you are missing a class on the classpath.
As mentioned in the comment on your question, you're going to need to add the jboss-logging jar file to your classpath.
BUT - Hibernate has LOTs of dependencies, so if you're putting the Jars together yourself then it's going to take you a long time to get them all, and in the right versions!
You can download a zip (70Mb) which contains the dependencies needed from here:
https://hibernate.org/orm/releases/5.4/
(use the "download zip archive" button, right hand side - it's not that easy to see!)
The jars are in the "lib" folder, there's then several subfolders - for now at least I would just throw all of these onto your classpath, except for the optional folder.
If you're at all familiar with Maven or similar (Gradle, whatever), then I'd recommend using that, then most of the dependencies will be downloaded automatically, there's guidance in the question here: Maven - how to add all required dependencies for hibernate?


text:
Q: Retrieving information from another list based on the ID value that is retrieved from the first list using angularjs I am retrieving list information using angular js, now while the information is getting looped, for each list item ID, I need to retrieve information from another list where ID is look up column from the first list.
I tried the following code, but am unable to retrieve data from the second list
var myAngApp = angular.module('SharePointAngApp', []);myAngApp.controller('spCustomerController', function ($scope, $http) {

        $http({

            method: 'GET',

            url: _spPageContextInfo.webAbsoluteUrl + "/_api/web/lists/getByTitle('Questions')/items?$select=ID,Created,Description,Title,Favourites,Author/Title&$expand=Author/Title",

            headers: { "Accept": "application/json;odata=verbose" }

        }).success(function (data, status, headers, config) {
                data.d.results.forEach(function(customer) {

                var id=customer["ID"];
                customer["Description"] = customer["Description"].replace(/<(?:.|\n)*?>/gm, '');
         $http({

            method: 'GET',

            url: _spPageContextInfo.webAbsoluteUrl + "/_api/web/lists/getByTitle('Answers')/items?$select=QuestionID&$filter=QuestionID eq "+id+"",

            headers: { "Accept": "application/json;odata=verbose" }

        }).success(function (data, status, headers, config) {

            $scope.answers = data.d.results;

        }).error(function (data, status, headers, config) {

        });

        });
            $scope.customers = data.d.results;
        }).error(function (data, status, headers, config) {
        });
});

A: Lookup column information can be retrieved using $expand operator. For example:
List A has column Title, Name and List B has column Title, Name and Lookup column named LookupA (Lookup list is A). So if you are querying in B list, then your query should look like
/_api/web/lists/getbytitle('B')/items?$select=Title,Name,LookupA/Title,LookupA/Name&$expand=LookupA

LookupA will be returned as object
Find more about $expand CRUD Operation to List Using SharePoint 2013 Rest API
Use SharePoint REST Client to test/explore REST API.


text:
Q: Visual Studio Code App wont run from Applications folder The latest version of Visual Studio Code will not run ("can't be opened" is the unhelpful error) when I copy it to the applications folder.  It runs fine after unzipping to the Downloads folder, but just wont from the applications folder.
I don't think it's the security setting as that's already set to allow apps from anywhere.
OS X El Capitan on a Mid-2014 Macbook Pro

A: Moving the Visual Studio Code.app into the ~/Applications folder instead of /Applications worked for me.

A: I had this issue and I found a workaround, which may work for you...

*

*Unzip Visual Studio Code in the download folder.

*Right-click Visual Studio code, in the download folder, and select 'Open'. If you're prompted by Gatekeeper, open the application.

*From the 'Code' menu, select Preferences > User Settings.

*Once the settings files open, you can immediately close them both.

*From the 'Code' menu, select Preferences > Keyboard Shortcuts.

*As with #3, you can immediately close the files.

*Quit Visual Studio Code

*Copy the Visual Studio Code application into your Applications folder.

*Open it from Applications.

This worked for me - I have no idea why, perhaps a bug to do with accessing the preference file(s)?
Maybe this might work for you?

A: Just place distribution archive (VSCode-darwin.zip) in /Aplication folder and extract it in the same place.
Remove archive after expand.

A: That's because of the extended attribute com.apple.quarantine, you can use xattr to remove it from any downloaded app, e.g.:
xattr -d -r com.apple.quarantine "/Applications/Visual Studio Code.app"

Note: use sudo to run the above command when necessary.


text:
Q: How to reference an offsite web service from code I have a .NET code which has a web reference to a web service (eg. WebRef) which resides in a corporate intranet (CorpInt).
The problem is I do not have access to CorpInt from my development machine. And the code has references which goes like
WebRef.Customers webref = new WebRefProxy.GetCustomersService();

Is there a way in which I could get in the remote intranet site, download something like a disconnected WebRef such that I can compile and reference it on my development machine?
Or any other feasible solution?
thank you in advance.

A: You shoud try to improve your code design and implement a Service Stub, the fundamental objective of this pattern is resolve problems like your:

Removes dependence upon problematic services during testing


text:
Q: HTML ─ Python dictionary from form-subelement via CherryPy # ! /usr/bin/env python
# -*- coding: utf-8 -*-
# image_slide.py

""" Python        2.7.3
    Cherrypy      3.2.2
"""

When an HTML form is submitted to a Python function, the values are sent within one dictionary. For some subelements in an HTML form, I want to POST an additional nested dictionary, within that form dictionary. The question is, if there is an HTML tag or such a thing, which Python would interpret as opening for a new dictionary. So far I tried naming the  or an invisible <fieldset>, but of course it isn't as simple. And nested forms aren't possible either.
What I have is a form, which contains a few text inputs and a table with a selection of associated items.
_____ the entire form __________________________________________________________
|                                                                              |
|   beverage:      coffee                                                      |
|   time of day:   morning                                                     |
|   temperature:   hot                                                         |
|   color:         brown                                                       |
|   taste:         full-bodied                                                 |
|                                                                              |
|   Ingredients:                                                               |
|   ________________________________________________________________________   |
|   |                   |                   |                   |          |   |
|   |     <IMAGE_1>     |     <IMAGE_2>     |     <IMAGE_3>     |     <IMAG|   |
|   |                   |                   |                   |          |   |
|   | filename: coffee  | filename: sugar   | filename: milk    | filename:|   |
|   | x select item     | x select item     | x select item     | x select |   |
|   |___________________|___________________|___________________|__________|   |
|   |_____________________________<scrollbar>______________________________|   |
|                                                                              |
|   < OK >                                                                     |
|______________________________________________________________________________|

Following are three simple pseudo-code snippets to explain the gist.

*

*Content of one form entry:
beverages = {
    'coffee': {
        'beverage':    'coffee',
        'time of day': 'morning',
        'temperature': 'hot',
        'color':       'brown',
        'taste':       'full-bodied',
        }
    }

ingredients = {
    'coffee': [
        'coffee',
        'sugar',
        'milk',
        'cinnamon',
        ],
    }

*Top part of the form :
yield(u'''
    <form action="..." method="POST">

''')

for key, value in beverages['coffee'].items():
    yield(u'''

         {key}:
         <input type="text" name="{key}" value="{value}">

        '''.format(locals(),)

*Bottom part of the form :
""" This hole bottom part already shall be in a dictionary named 'ingredients'.
    For each loop pass, I'd like a sub-dictionary, named by its loop pass.
    I used the fictional tag <SPECIAL_SUB_DICT>, to open a new dictionary.
"""

yield(u'''

    <SPECIAL_SUB_DICT name="ingredients">

''')

for index, name in enumerate(ingredients['coffee']):
    yield(u'''

        <SPECIAL_SUB_DICT name="{index}">

        <input type="text" name="filename" value="{name}">
        <input type="check" name="chosen_one" value="{index}"> select item
        </SPECIAL_SUB_DICT>

        '''.format(locals(),)

yield(u'''

    </SPECIAL_SUB_DICT>
    <input type="submit" name="submit" value="OK">
    </form>
    ''')

Conclusion
The problem is, without some sort of <SPECIAL_SUB_DICT> tag, I can't easily rename single ingredients. For example, if I'd like to change the filename from 'milk' to 'hole cream milk'. The way I do it now is, to add the current loop pass to the input name, like this:
'<input type="text" name="filename_{index}" value="{name}"> '.format(locals(),)
Then, within the receiving function, I can check which key starts with 'filename_' and update all of them:
for key, values in kwargs:
    if key startswith('filename_'):
        ingredients['coffee'][key[9:]] = value

It would be much nicer, if I just could iterate kwargs['ingredients']:
for key, values in kwargs['ingredients'].items():
    ingredients['coffee'][key] = value[filename]

I'm asking, because a <SPECIAL_SUB_DICT> tag would be much closer to my current solution than parsing the table with Python's BeautifulSoup. And of course I want to know it. After all, with BeautifulSoup I'd probably be done by now.
EDIT 1:
This runs with the web application framework CherryPy.
Maybe there's a way it could handle such a request.
Though I dont't think, that it would offer something off-standard.
EDIT 2:
Given, that the form-dictionary starts in the URL with a question mark, I don't think a sub-dictionary is possible, because I don't know of any dictionary closing character. The closest thing I could come up with is using a hidden input named 'index', and zip() it with the text input named 'filename'. This answer, unfortunately for PHP, got me in the right direction.
'<input type="hidden" name="index" value="{index}"> '.format(locals(),)
'<input type="text" name="filename" value="{name}"> '.format(locals(),)

for key, values in zip(kwargs['index'], kwargs['filename']):
    ingredients['coffee'][key] = value

However, this wouldn't work for the delete button, which I planed to add to each ingredient. Since only the submit input can carry the index, and its value is used to display the button's unicode symbol, I again have to append the index to the name.
Then, the only thing I can think of, is a form for each ingredient and the top part of the formular, instead of one large form for everything. Though I don't know if that would be good for the performance, if the list of ingredients becomes too long.
As a visual trick comes a background image to mind, to replace the value, which then transparently, can be used according to its name. This answer and its corresponding question was helpful to get it working.
But nothing of this is an answer to my question.
I'm still missing the one solution for all inputs,
like multiple forms, just more elegant.

A: Okay, I wanted to know how this is done as well, so here you go. This only works for single-level dicts. If you want to make this recursive, I'll leave it to you.
The problem with this: <input name="foo[bar]"> is that foo[bar] is the variable name, and the brackets are converted to URL-safe entities:
[DEBUG] BODY_TEXT: foo%5Bbar%5D=input_value

CherryPy allows you to define a custom body processor by defining a callable in cherrypy.request.body.processors, which is a dictionary whose keys match the content type. This is how the cherrypy.tools.json_in() tool works, by replacing the body processor with a function that parses JSON when the request's content type is application/json.
The final part you need is how to inject your parsed dictionary (i.e. {'foo': 'bar'} into the handler method's arguments to be used just like regular POST input vars. I took it directly from the default form processor: https://github.com/cherrypy/cherrypy/blob/main/cherrypy/_cpreqbody.py#L177
So here's the tool. You need to enable it in your config, and load it in your server script, but it will take a dict-shaped set of form inputs pass the dict to your handler. It does this with a regular expression.
import re
import cherrypy
import logging
import urllib

class ImprovedFormInput(cherrypy.Tool):

    def __init__(self):
        logging.debug('ImprovedFormInput.__init__()')

        cherrypy.Tool.__init__(self, 'before_request_body', self.handle_post, priority=50)

    def handle_post(self):
        logging.debug('ImprovedFormInput.handle_post()')

        request = cherrypy.serving.request

        def impfin_processor(entity):

            raw_body = entity.fp.read()

            body_text = raw_body.decode()
            logging.debug('BODY_TEXT: %s', body_text)

            parsed = urllib.parse.parse_qs(body_text)
            logging.debug('PARSED: %s', parsed.keys())

            form_inputs = {}
            r = re.compile(r'^(\w+)\[(.+)\]$') # This pattern could be better

            for key in parsed.keys():

                m = r.match(key)
                if m is None:
                    continue

                groups = m.groups()

                pkey = groups[0]
                logging.debug('PKEY: %s', pkey)

                ckey = groups[1]
                logging.debug('CKEY: %s', ckey)

                if pkey not in form_inputs:
                    form_inputs[pkey] = {}

                form_inputs[pkey][ckey] = parsed[key]

            logging.debug('FINPUTS: %s', form_inputs)

            # https://github.com/cherrypy/cherrypy/blob/main/cherrypy/_cpreqbody.py#L177
            for key, value in form_inputs.items():
                if key in entity.params:
                    if not isinstance(entity.params[key], list):
                        entity.params[key] = [entity.params[key]]
                    entity.params[key].append(value)
                else:
                    entity.params[key] = value

        request.body.processors['application/x-www-form-urlencoded'] = impfin_processor


text:
Q: JavaScript Independent Modules I have several modules in my application and some global variables. One module may require some methods from other modules to work and also some global variables.
How can I organise my code so modules won't use methods from other modules or global variables?
//global variables needed in both of the modules.
var a, b;

//VIDEO MODULE
var VIDEO = (function() {

    //requires a method from USER MODULE:
    if(USER.has_liked_video()) {
        //do smth.
    }

    //requires some global variables

    return {}
})();

//USER MODULE
var USER = (function() {

    //requires a method from VIDEO MODULE:
    if(VIDEO.exists()) {
        //do smth.
    }

    //requires some global variables

    return {}
})();


text:
Q: How to split string column into categorical columns in pandas I have a string column containing something like this

Col1

ind1,ind2,ind3

ind1,ind5,ind3

ind2,ind3,ind5,ind4

I want to split it to the following columns:

ind_1
ind_2
ind_3
ind_4
ind_5

ind1
ind2
ind3

ind1

ind3

ind5

ind2
ind3
ind4
ind5

using .str.rsplit(',', expand=True) does not order the same strings in the same column.

A: Explode your column then pivot your dataframe:
out = df['Col1'].str.split(',').explode().reset_index()
out = (out.pivot('index', 'Col1', 'Col1').fillna('')
          .rename_axis(index=None, columns=None))
print(out)

# Output
   ind1  ind2  ind3  ind4  ind5
0  ind1  ind2  ind3
1  ind1        ind3        ind5
2        ind2  ind3  ind4  ind5

A: use df.column.str.get_dummies with seperator as ","
import pandas as pd

df = pd.DataFrame({
    "col1" : ["ind1,ind2,ind3", "ind1,ind5,ind3", "ind2,ind3,ind5,ind4"]
})
df.head()

# output
    col1
0   ind1,ind2,ind3
1   ind1,ind5,ind3
2   ind2,ind3,ind5,ind4

df  = pd.concat([df,df.col1.str.get_dummies(sep = ",")], axis =1)
df

# output
    col1                ind1    ind2    ind3    ind4    ind5
0   ind1,ind2,ind3      1       1       1       0       0
1   ind1,ind5,ind3      1       0       1       0       1
2   ind2,ind3,ind5,ind4 0       1       1       1       1

A: I think I found the solution and even return binary result:
df.join(df.Col1.str.get_dummies(',').apply(lambda x: np.where(x == 1, 1, 0))).drop(columns=['Col1'])


text:
Q: Why i cannot open file programmatically after saving it with File.WriteAllBytes I have a base64 string image, what i did is; i converted the string into an array of bytes, and saved the file. Then, i tries to access the file for bitmap purposes but the system throws an exception: The process cannot access the file because it is being used by another process. I am using File.WriteAllBytes which is mainly a synchronous function.
Byte[] bytes = Convert.FromBase64String(baseString);
File.WriteAllBytes(filePath, bytes);
Bitmap bmp = Bitmap.FromFile(filePath) as Bitmap;

I expect to open the file without facing any problem since WriteAllBytes method is synchronous

A:
Why i cannot open file programmatically after saving it with File.WriteAllBytes

If you get "The process cannot access the file because it is being used by another process" and you know you don't have any open file handles, then the culprit is typically an Antivirus program.  Could also be something like a backup or file sync service, but less likely.


text:
Q: Javascript Angular / Firebase auto keys has "-" remove or add own I am working on an angular 2 / firebase project.
I have this function which adds a new record to firebase:
addItem(newTitle: string, newText: string) {
    this.items.push({ title: newTitle, text: newText });
  }

This will add something like this to the firebase database:
1st it creates a unique id/key:
-KkztvsKvtqCfoFlpdFc

  title: mytitle

  text: mytext here

I have a problem with the key it add. It starts with a -
So I either need a way to generate my own unique id/key or get firebase to not add the -
How can I do this?

A: The algorithm for generating push ids is described here: firebase.googleblog.com/2015/02/the-2120-ways-to-ensure-unique_68.html. The code is shown in this gist.
You can easily take the - our of the dictionary (PUSH_CHARS) and generate keys without them.


text:
Q: ¿Por qué al realizar una petición ajax no llega a complete:function? Estoy teniendo un caso en el cual al realizar una petición y tener el resultado correcto no llega al apartado de complete: function (), lo cual me bloquearia mi pantalla para continuar con el funcionamiento normal
Este es mi código:
        async: false,
        url: url,
        data: JSON.stringify(datosActivacion),
        type: "POST",
        dataType: "json",
        contentType: "application/json; charset=utf-8",
        success: function (result) {
            if (result.estatus === "success") {
                $("#mdlCodigoConfirmacion").modal("toggle");
            } else if (result.estatus === "errorS") {
                var resE = JSON.parse(result.response);
                if (resE.message === "Límite de intentos alcanzado.") {
                    mostarModalSoloAceptar(resE.message + ". Espere 15 minutos para un nuevo intento de activacion");
                } else {
                    mostarModalSoloAceptar(resE.message);
                }
            }
            else {
                mostarModalSoloAceptar(result.response);
            }
        },
        error: function () {
            waitingDialog.hide();
            mostarModalSoloAceptar("Error al intentar conectar al servidor");
        },
        complete: function () {
            waitingDialog.hide();
        }
    });```


text:
Q: Howto configure Runtime Version which builds Resources.Designer.cs in Visual Studio 2010 I've somehow screwed up my visual stuio 2010  installation. (I installed and uninstalled the Visual Studio 11 Developer Preview)
If i now build a simple forms project where a form has "localizable=true", i got the following error:
Could not load file or assembly 'System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.

The reason is the Runtime version which creates the Properties\Resources.Designer.cs.
In my case it is Runtime Version:4.0.30319.17020 instead of Runtime Version: 4.0.30319.239.
Where can in configure the version used to create those Designer files in visual studio?

A: I found a solution for this problem:
I uninstalled the following tools

*

*Microsoft .NET Framework 4.5 Client Profile Developer Preview

*Microsoft .NET Framework 4.5 Developer Preview Multi-Targeting Pack

*Microsoft .NET Framework 4.5 Extended Developer Preview

Then i've reinstalled Visual Studio 2010.
After this, i don't get any errors related to the resource version.
btw: this also solved a problem when building a solution with msbuild 4.0 for target version 3.5.
The error message i got:
C:\Windows\Microsoft.NET\Framework\v3.5\Microsoft.Data.Entity.target(50,5): error MSB4044: The "EntityClean" task was not given a value for the required parameter "ResourceOutputPath"

And this disappeared after removing the 4.5 stuff and reinstalling VS2010


text:
Q: Exchange ERC20 token with other ERC20 token I have 2 ERC20 tokens. The contract are designed as standard ERC20. Here are the 2 tokens to take as an example -
AUDC --> Contract address: (0xContractAUDC)
         Wallet Address:   (0xWalletAUDC)
DAI  --> Contract address: (0xContractDAI)
         Wallet Address:   (0xWalletDAI)

I want to transfer some DAI from wallet 0xWalletDAI to 0xWalletAUDC to receive converted AUDC in return (I have private keys of both the wallets).
Looking for some help to know how this can be implemented. I would try to be helpful with more information if needed.
I am using ethers.js v4.0 to interact with blockchain.

A: I found out the solution to implement this using ethers.js -
const ethers = require('ethers');

let provider = ethers.getDefaultProvider();

// WALLETS
const DAIUserWalletObj = new ethers.Wallet(DAIUserPrivateKey, provider);
const AUDCWalletObj = new ethers.Wallet(AUDCPrivateKey, provider);

//CONTRACTS
const contractDAI = new ethers.Contract(DAIContractAddress, DAIContractABI, provider);
constractDAI = contractDAI.connect(DAIUserWalletObj);
const contractAUDC = new ethers.Contract(AUDCContractAddress, AUDCContractABI, provider);
contractAUDC = contractAUDC.connect(AUDCWalletObj);

let overRide = { gasLimit: 7500000 }
let numDAITokens = 20;  // Just for example
let numOfAUDCTokens = 40; // Just for example
const receipt1 = await contractDAI.transfer(AUDCContractAddress, numDAITokens, overRide);
const receipt2 = await contractAUDC.transfer(DAIUserWalletAddress, numOfAUDCTokens, overRide);
console.log(receipt1);
console.log(receipt2);

A: If these are ERC20 tokens then you will need to do the accounting yourself.
I would suggest that you have separate contracts handling this.
Here is an example which can be re-purposed to work with your use case.
The idea is to send one ERC20 token to a contract which performs the exchange calculation, and then moves funds from one token to another.
If the exchange rate from DAI to AUD does not fluctuate then you can have this exchange rate as a constant in the contract. Most likely this will fluctuate though, in which case exchanging will be a bit more complicated.
Decentralized exchanges like UniSwap handle the exchanges automatically using an algorithm that uses the available liquidity as input. Doing something like this is a pretty involved process.
The other alternative is you to have an approve function that can be invoked by a specific signer. This signer could be a centralized service that is part of the exchange workflow.
Alternatively you can use oracles to regularly update the exchange rates between two tokens but this is going to cost gas and unless you have a lot of volume might not be the most cost effective option.


text:
Q: Laravel Show Form Button on Textbox Value Do any of you jquery/Laravel Pros know if it's possible to hide or show a submit button based on a textbox field value?
I have a Laravel (4.2) form that I'm working on and I want to hide the submit button until a textbox value reaches 0, then show the button so users can submit it.
I figured its a jquery script maybe, never done that before thus why I'm asking for help.
{{ HTML::col(3,3,3,3) }}
{{ Form::formGroup() }}
{{ Form::label('Remainder', 'Remainder Balance') }}
{{ Form::text('Remainder', $value , ['class' => 'form-control', 'data-fv-notempty' => 'false', 'readonly']) }}
{{ Form::closeFormGroup() }}
{{ HTML::closeCol() }}
{{ HTML::closeRow() }}

{{ HTML::row() }}
    {{ HTML::col(12,12,12,12) }}
        {{ Form::submit('Submit', array('class' => "btn btn-submit btn-lg")) }}
    {{ HTML::closeCol() }}
{{ HTML::closeRow() }}
{{ Form::closeFormGroup() }}
{{ Form::close() }}

Thanks in advance everyone, I greatly appreciate it.

A: First you should give these things an id.
{{ Form::text('Remainder', $value , ['id' => 'remainder', 'class' => 'form-control', 'data-fv-notempty' => 'false', 'readonly']) }}

{{ Form::submit('Submit', array('id' => 'myFormSubmit', 'class' => "btn btn-submit btn-lg")) }}

$(document).ready(function() {
    $('#remainder').change(function() {
        if ($(this).val() == 0) {
            $('#myFormSubmit').show();
        } else {
            $('#myFormSubmit').hide();
        }
    });
});

If you are programatically changing the text box (your wording about it "reaching" 0 makes me suspect this might be the case), that change event won't fire so you will also need to do $('#remaidner').trigger('change');


text:
Q: CakePHP Upload Plugin - Field 'photo_dir' doesn't have a default value I am trying to set up an old cakePHP application in a new hosting and all of sudden am getting this error on the shared godaddy hosting. It works fine in the old hosting. Its been 2 years i have worked on CakePHP and dont seem to understand why this is coming. I am using the following upload plugin cakephp-upload
Error: SQLSTATE[HY000]: General error: 1364 Field 'photo_dir' doesn't have a default value
SQL Query: INSERT INTO `prayag_cms`.`galleries` (`branch_id`, `name`, `album_id`, `display_photo`, `modified`, `created`) VALUES (0, 'Photo', 1, 'CpLMQ28WYAEOnow.jpg_large.jpg', '2016-12-06 10:17:14', '2016-12-06 10:17:14')

This is my confirguration
public $actsAs = array(
            'Containable',
    'Upload.Upload' => array(
        'display_photo' => array(
            'fields' => array(
                'dir' => 'photo_dir'
            ),
                            'thumbnailSizes' => array(
                'small' => '250x250',
            ),
                            'thumbnailMethod' => 'php',
                            'path' => '{ROOT}webroot{DS}img{DS}{model}{DS}',
        ),

    )
);

Controller:
public function admin_add() {
    if ($this->request->is('post')) {
        $this->Gallery->create();
        if ($this->Gallery->save($this->request->data)) {
            $this->Session->setFlash(__('The gallery has been saved.'), 'admin/flash_success');
            return $this->redirect(array('action' => 'index'));
        } else {
            $this->Session->setFlash(__('The gallery could not be saved. Please, try again.'), 'admin/flash_error');
        }
    }
    $branches = $this->Gallery->Branch->find('list');
    $albums = $this->Gallery->Album->find('list');
    $this->set(compact('branches', 'albums'));
}

A: It's may be happening for folder not exist(webroot/img/users[model]) or not have enough permission to create new folder or access folder.

*

*for this reason photo is not uploaded

*if photo is not uploaded then photo_dir assigned NULL

*But your database field doesn't accept NULL value

*Then you get those errors

hope your problem will be solved


text:
Q: Getting Environment Variable in windows batch file echo %PATH% will print the enviroment variable PATH. But I want to assign the environment variable to a batch variable first and then get the value of the environment variable. Is it possible?
Something as follows:
set myvar=PATH
echo %myvar%

The above code will echo "PATH". But I want to get the enviroment variable PATH

A: try with :

set myvar=PATH
call echo %%myvar%%

or with delayed expansion (it should work faster):
@echo off
set myvar=PATH
setlocal enableDelayedExpansion
echo !%myvar%!

Why you can use directly set set "myvar=%PATH%" ?