id
stringlengths 32
32
| text
stringlengths 0
895k
| name
stringlengths 0
33k
| domain
stringlengths 5
44
| bucket
stringclasses 19
values | answers
list |
---|---|---|---|---|---|
1b5fa7225a66fc25328191cea4740f13 | 420 | what is the lcm of 7 3 5 and 20? | answers.com | 2021.43 | [
{
"text": "420 ",
"name": "",
"is_accepted": false
}
] |
e6998068ce6ffb5a2405247c06a8a1e6 | 3600 suare inches | how many inch in 25 square feet? | answers.com | 2021.43 | [
{
"text": "3600 suare inches ",
"name": "",
"is_accepted": false
}
] |
d49cd075ebb3b78c815e55c163c2a580 | 2a+5 | simplify 9a plus 8 minus 2a minus 3 minus 5a? | answers.com | 2021.43 | [
{
"text": "2a+5 ",
"name": "",
"is_accepted": false
}
] |
53be20e614fec6de388baaa326a1cf80 | 192 | what number divided by 12 equals 16.00? | answers.com | 2021.43 | [
{
"text": "192 ",
"name": "",
"is_accepted": false
}
] |
59b5a069e9dc385d063ab9208f4daf3e | 144 | what is the next number sequence 49 64 81 100 121? | answers.com | 2021.43 | [
{
"text": "144 ",
"name": "",
"is_accepted": false
}
] |
eda9338e2ee521aaef101b9efab711d0 | 144 | what is 56-28 equals? | answers.com | 2021.43 | [
{
"text": "84 ",
"name": "",
"is_accepted": false
},
{
"text": "144 ",
"name": "",
"is_accepted": false
}
] |
2dd34836469e6fc1d1184b8bd0959ff1 | 3bx+13x=9 | algebra | jiskha.com | 2020.40 | [
{
"text": "is there a question ?",
"name": "",
"is_accepted": false
}
] |
f4d0a3dc1b5e2ca230bebad8ff1643e7 | what is a huge limestone mass on spain's southern coast? it starts with...rock \_ \_ \_ \_ \_ \_ \_ \_ \_ \_ \_
help plz!!!
rock of gibraltar.
http://www.andalucia.com/gibraltar/home.htm | words | jiskha.com | 2020.29 | [
{
"text": "rock of gibraltar",
"name": "",
"is_accepted": true
},
{
"text": "hi\r\nhi\r\nhi\r\nhi\r\nhi\r\nhi\r\nhi\r\nhi\r\nhi\r\nhi\r\nhi\r\nhi",
"name": "",
"is_accepted": false
}
] |
b8233772d618a63f37f845c4a9345e66 | 3x^3/(3x)^3 | math | jiskha.com | 2021.04 | [
{
"text": "3x^3/(3x)^3\r\n= 3x^3/(27x^3)\r\n= 1/9",
"name": "",
"is_accepted": false
}
] |
26f1155bd163afd4284646f9bbda9535 | prove (cscx-secx/cscx+secx)=(cotx-1/cotx+1) | trig | jiskha.com | 2021.04 | [
{
"text": "cscx-secx/cscx+secx\r\n= cos/cos * cscx-secx/cscx+secx\r\n= (cos*csc - 1)/(cos*csc + 1)\r\n= (cot-1)/(cot+1)",
"name": "",
"is_accepted": false
}
] |
e1576168c62ca1dded54fe5cfb96c653 | please help, need answer! | f(x) = 6 − 4x + 7x^2. f(a + h) = ? f(a + h) − f(a)/ h= ? | wyzant.com | 2020.45 | [
{
"text": "f(a+h) = 6-4(a+h)+7(a+h)^2\r\n = 6 -4a - 4h + 7a^2 +14ah +7h^2\r\nf(a+h) - f(a) = 6 -4a - 4h + 7a^2 +14ah +7h^2 - (6- 4a +7a^2)\r\n = -4h +14ah +7h^2\r\nf(a+h)-f(a) -4h + 14ah +7h^2\r\n------------ = ---------------------- = -4 + 14a + 7h\r\n h h",
"name": "",
"is_accepted": true
}
] |
2f54bb58c37528842722e6125c79f5eb | x y
-3 3
-1 1
0 0
1 1
f(-1) =
| evaluate each function for the given value of x? | wyzant.com | 2019.43 | [
{
"text": "according to the table of values given and if i assume that y = f(x), the y(-1) = f(-1) = 1.",
"name": "",
"is_accepted": true
}
] |
9b02ab491b133c82783c0e15312c1657 | in how many ways can a member of a hiring committee select 3 of 12 job applicants for further consideration? | binomial distribution | wyzant.com | 2021.39 | [
{
"text": "this is what is known as a \"combination\" (versus \"permutation\") since the order in which the 3 people are selected does not matter. if each job were unique, then you would use a permutation (which is always a larger number). the formula for combinations is sample space (factorial) divided by the product of the number being selected (factorial) and the difference of the two (factorial); i.e, 12!/(3!*9!) =220",
"name": "",
"is_accepted": true
},
{
"text": "12!/(9!3!)= 12 x 11 x 10 / 6= 220",
"name": "",
"is_accepted": false
}
] |
32497c4575ee5cb89285f150f8f495e3 | 5(x+26)=2(2x+102) | 5(x+26)=2(2x+102) | studwork.org | 2020.40 | [
{
"text": "5(x+26)=2(2x+102)5x + 130 = 4x + 2045x – 4x = 204 – 130x = 74",
"name": "",
"is_accepted": false
},
{
"text": "5(x+26)=2(2x+102) 5x + 130 = 4x + 204 5x – 4x = 204 – 130 x = 74 ",
"name": "",
"is_accepted": false
}
] |
87c03dce80cc02bcba2be47289943c2f | naberrrrrrrrrrrrrrrrrrrrr | naberrrrrrrrrrrrrrrrrrrr | haziryanit.com | 2019.43 | [
{
"text": "İyilik, sağlık, güzellik, letafet başka ne olsun :-)",
"name": "",
"is_accepted": false
}
] |
085912cbac645e26e87c68be560910ba | VoLTE nedir? | haziryanit.com | 2019.47 | [
{
"text": "\n- 4.5G ile birlikte, sesin de 4.5G data teknolojisi ile birlikte taşınmasıdır. Voice Over LTE nin kısaltmasıdır. LTE 4.5G teknolojisi ile sesin taşınmasıdır. \n \n- Normal ses görüşmelerinden veya IP ses görüşmelerinden (whatsapp, skype vb) daha kaliteli ve yalın bir görüşme sağlar.\n \n- Aynı anda data ve ses kullanımına izin verir, (telefonda görüşme yaparken konum paylaşılması vb) Daha hızlı çağrı başlatmayı sağlar.\n \n- VoLTE çağrısı sadece Vodafone'lu aboneler arasında yapılabilir.\n \n- VoLTE teknolojisini kullanmak için telefonda en güncel cihaz yazılımının yüklü olması gerekmektedir.\n \n \n \n**VoLTE destekli telefon modelleri aşağıdaki gibidir:**\n \n \n \nApple iPhone SE\n \nApple iPhone 6\n \nApple iPhone 6 Plus\n \nApple iPhone 6S\n \nApple iPhone 6S Plus\n \nApple iPhone 7\n \nApple iPhone 7 Plus\n \nApple iPhone 8\n \nApple iPhone 8 Plus\n \nApple iPhone X\n \nASUS Zenfone 3\n \nCasper Via A1 -1\n \nCasper Via F1\n \nCasper Via M3\n \nGeneral Mobile GM 5 Plus\n \nGeneral Mobile GM 5 Plus d\n \nGeneral Mobile GM 6\n \nGeneral Mobile GM 6 d\n \nHuawei P9\n \nHuawei P10\n \nLG G4\n \nLG G5\n \nLG G5 SE\n \nLG G6\n \nLG K10 2017\n \nLG Q6\n \nLG Stylus 3\n \nLG V20\n \nNokia 5\n \nNokia 6\n \nNokia 8\n \nSamsung A510F ( Galaxy A5 2016 )\n \nSamsung A710F ( Galaxy A7 2016 )\n \nSamsung Galaxy A3 2017\n \nSamsung Galaxy A5 2017\n \nSamsung Galaxy A7 2017\n \nSamsung Galaxy J3 Pro\n \nSamsung Galaxy J5 Pro\n \nSamsung Galaxy J7 2016 ( J710FQ )\n \nSamsung Galaxy J7 Core\n \nSamsung Galaxy J7 Pro\n \nSamsung Galaxy Note 5\n \nSamsung Galaxy Note 8\n \nSamsung Galaxy S6\n \nSamsung Galaxy S6 Edge\n \nSamsung Galaxy S7\n \nSamsung Galaxy S7 Edge\n \nSamsung Galaxy S8\n \nSamsung Galaxy S8 +\n \nSony Xperia XA1\n \nSony Xperia XA1 Ultra\n \nSony Xperia XZ\n \nSony Xperia XZ Premium\n \nSony Xperia XZ1\n \nVestel Venüs E3\n \nVestel Venüs V3 5010\n \nVestel Venüs V4\n \nVestel Venüs Z10\n \nVestel Venüs V3 5580\n \nVodafone Smart 6 Ultra\n \nVodafone Smart 7 Pro\n \nVodafone Smart 7 Style\n \nVodafone Smart 7 Ultra\n \nVodafone Smart N8\n \nVodafone Smart V8\n \nXperia XA 1 plus\n\n",
"name": "",
"is_accepted": false
}
] |
|
f6422866b63328e8e277d2bcbecec28e | Zeki düşünmenin 15 yolu | haziryanit.com | 2019.47 | [
{
"text": "\n\n**Zeki düşünmenin 15 yolu...**\n \n\n \n\nKaç defa beyninizin durduğunu, çalışmadığını hissettiniz? Patrona birşey sunmanız veya yazı yazmanız gerektiğinde genellikle neden bu durum ortaya çıkıyor? \n \n\n \n\nJames Thorton’a göre bunun nedeni yaşlandıkça hafıza gerilemesi değil. Sadece bilişsel zekamızı geliştirme ihtiyacından doğan bir uyarı.. \n \n\n \n\nBu yüzden düşünmeye biraz ara verip daha iyi düşünmek ve yaratıcı zekanızı geliştirmek için yapmanız gereken 15 tavsiye sunuyor..\n \n\n \n\n**Zekanızı parlatan öneriler**\n \n\n \n\n1. Doğru zamanlama yapın. Çoğu yetişkin insan sabahları, çoğu geç insan ise öğleden sonra daha net düşünür. En iyi düşünme zamanınızı belirleyin ve en zor beyin çalışmalarınız için o zamanı rezerve edin.\n \n\n \n\n2. İyi bir eğitim alın fakat abartmayın. Psikolog Dean Keith Simonton, okula gitmenin yaratıcılık üzerinde pozitif bir etkiye sahip olduğunu söyler. Ardından artan bir şekilde, mezuniyete odaklanma yaratıcılığı düşürür. “Etkili yazmada psikiyatrist olarak büyük bir yazar olmazsınız.” \n \n\n \n\n3. Konfiçyüsü dinleyin. Bir numara “hafıza yardımı” hafıza araştırmacılarının kendileri tarafından kullanılır: Not edin. Bir Çin atasözü “en zayıf mürekkep en güçlü hafızadan daha kalıcıdır”. \n \n\n \n\n4. Araştırmalar bir fincan kahvede bulunan kafein miktarının konsantre olmanıza yardımcı olacağını gösteriyor. Fakat kaygıya meyilli iseniz; bu bir işe yaramayabilir.. \n \n\n \n\n5. Var olanlar için yeni hafızaları sağlama bağlayın. Michigan Üniversitesi Bilişsel Araştırmacı Denise Park, “Varolan hafızanızın yeni bilgilere uyum sağlayan bir darağacı olarak düşünün. Yeni bilgileri ayrılan alanın dışında bırakmayın. Özel olarak, hafıza kaybı için ilaç var mıdır diye sordunuz. Hafıza kaybı için herhangi bir reçeteli ilaç olup olmadığını bilmiyorum\" diyor.\n \n\n \n\n \n\n",
"name": "",
"is_accepted": false
},
{
"text": "\n\n6. Uygulama yapın. Yeni becerileri öğrenme ve sürekli uygulama yapma beynin internal organizasyonunu değiştirmek için ortaya çıkar. Bir çalışma, periodik eğitim dönemlerinin 70 yaşlarında olan gönüllülerin, 7 yaşlarındayken sahip olduklarından daha iyi bilişsel ve hafıza becerilerine yardımcı olduğunu gösteriyor. “uygulama gerçekten işe yarar” der National Institute on Aging’te emeritus psikolog Len Giambra.\n \n\n \n\n7. Fikirlerinize bir şans verin. Çoğumuz gerçekleri çabucak değerlendirme ve çabucak “gitme veya gitmeme” kararı vermede kabiliyetlerimiz için ödüllendiriliriz. Yaratıcılık daha fazla acele etme ve heyecan ister. \n \n\n \n\n8. Entelektüel bir iş ve zeki bir eş seçin. Polonya’dan merak uyandırıcı çalışmalar, kariyerleri entelektüel bir egzersiz isteyen kişilerin yaşamlarında yüksek bilişsel seviyeye sahip olduklarını sunuyor. Ve zeki biri ile evlenme başarınızın devamını sağlar. \n \n\n \n\n9. Yaratıcılık, genellikle bir alandan diğer bir alana adapte olma çözümleri için beceriyi özetler.\n \n\n \n\n10. Leonardo’dan öğrenin. Yazar Michael Gelb, yeni kitabında Leonardo Da Vinci gibi nasıl düşünülür, en büyük Rönesans adamında işe yarayan bazı beyin geliştirme stratejilerini sunuyor. Ormanı öğrenme ve ters elinizle resim çizme gibi konuları da içeriyor.\n \n\n11. Dikkatinizi verin. Sadece toplantıdan birkaç saniye sonra bir kişinin adını unuttuğunuz oluyor mu? Problem hafıza değil, konsantrasyondur. Yaşlanırken, bilinçli olarak hafıza bankamıza kendi kendimize bilgi koymamız gerektiğini hatırlamalıyız.\n \n\n \n\n \n\n",
"name": "",
"is_accepted": false
},
{
"text": "\n\n12. Mozart dinleyin. Wolfgang’ın müziğine maruz kalan bir beyin daha kompleks bağlantılar geliştiriyor. Bu da daha fazla bilgi için daha hızlı, entegre olmuş erişime izin veriyor.\n \n\n \n\n13. Zekânızı geliştirmek için vücut egzersizi yapın. Uzmanlar, aerobik antrenmanın okul performansından sinir iletim hızına kadar her şeyi geliştirdiğine inanıyorlar. Egzersiz gerçekten yapılmasını mantıklı kılan birçok yarara sahip. \n \n\n \n\n14. Yeni şeyler deneyin. Yaşamının sonuna yakın, empresyonist ressam Henri Matisse, fırçaları harika kâğıt kesikleri serileri yaratmak için kullandığı makas ile değiştirerek sanatını tekrardan canlandırdı. Yaratıcı Davranışlar Dergisi editörü Psikolog Dean Keith Simonton, bu gibi deneyimlerin yaratıcılığın başarılı niteliği olarak ortaya çıktığını ifade ediyor. Yaratıcı ve yaratıcı olmayan kişilerin karşılaştırıldığı bir çalışmada temel farkın birinin yeni şeyler öğrenme konusunda daha açık olduğunu diğerinin ise olmadığını gösterdi. \n \n\n \n\n15. Dikkat dağılma olayını sonlandırın. Alakasız uyarıcılar tarafından bombardıma tutulursanız, odaklanmanız çok zor olur. Kesinlikle bir şeyi yapmalıysanız ( örneğin bir raporu tamamlama) telefonun fişini çekebileceğiniz ve konsantre olabileceğiniz bir otel odası kiralamayı deneyin.\n \n\n \n\nTutkularınızın peşinden gitmeyi sakın unutmayın! Son günlerde bir Hollandalı psikolog satranç ustalarını santranç büyük ustalarından neyin ayırdığını bulmaya çalışıyor. Her gruba test uyguladı- IQ, hafıza, boyutsal akıl yürütme-. Onlar arasında test farklılığı bulamadı. Tek farklılık büyük ustaların satrançı daha çok sevmeleriydi. Ona karşı daha tutkulu ve daha çok bağlıydılar. Tutku, yaratıcılığın anahtarı olabilir.\n\n",
"name": "",
"is_accepted": false
}
] |
|
cf28dd06f8724261762ac64e5a5a9e11 | En cok Kamsusu olan ülke hangisidir ?? | En Çok Komşusu Olan Ülke Hangisidir ? | haziryanit.com | 2019.47 | [
{
"text": "\n\nDünyada en çok ülke ile sınırı olan ülke Çin'dir. Çin'in tam 15 ülke ile coğrafi sınırı var.İşte o ülkeler ve uzunlukları...\n \n\n \n\n Sınır komşuları:\n \n\n Afganistan 76 km,\n \n\n Butan 470 km,\n \n\n Burma 2,185 km,\n \n\n Hong Kong 30 km,\n \n\n Hindistan 3,380 km,\n \n\n Kazakistan 1,533 km,\n \n\n Kuzey Kore 1,416 km,\n \n\n Kırgızistan 858 km,\n \n\n Laos 423 km,\n \n\n Makau 0.34 km,\n \n\n Moğolistan 4,676.9 km,\n \n\n Nepal 1,236 km,\n \n\n Pakistan 523 km,\n \n\n Rusya (kuzeydoğu) 3,605 km,\n \n\n Rusya (kuzeybatı) 40 km,\n \n\n Tacikistan 414 km,\n \n\n Vietnam 1,281 km\n\n",
"name": "",
"is_accepted": false
}
] |
9ada5982dce871d9f850d2c29afa8383 |
**Msn de Size "Nasılsın?" diye sorulduğunda siz ne cevap verirdiniz? İşte Buyrun verilen Yanıtlar..**
| Msn de "Nasılsın?" sorusuna verilecek cevaplar... | haziryanit.com | 2019.47 | [
{
"text": "\n\n**- Nasilsin\n \n\n - Valla nasil olayim, baharda cayira salinmis yeni danalar gibiyim merakli ve mutlu**\n\n",
"name": "",
"is_accepted": false
},
{
"text": "\n\n**- Nasilsin\n \n\n - AIDS testi yaptirmis ama sonucu negatif cikmis hasta gibiyim**\n\n",
"name": "",
"is_accepted": false
},
{
"text": "\n\n**- Nasilsin\n \n\n - Uzerinden tren gecmis bozuk para gibiyim**\n\n",
"name": "",
"is_accepted": false
},
{
"text": "\n\n**- Nasilsin\n \n\n - Muebbet yemis sanik gibiyim**\n\n",
"name": "",
"is_accepted": false
}
] |
9ff14d900fe7d500cc81020963909eb8 | Solaklar daha mı zekidir ? | haziryanit.com | 2019.47 | [
{
"text": "\n\n**FRANSIZ** bilim adamları, solaklığın evrimini araştırdılar. Buna göre solak olmanın anne karnında maruz kalınan hormonlarla ilgili olduğu sanılıyor. Her ne kadar solaklığın nedenleri pek anlaşılmasa da, genetik olabileceği de ifade ediliyor.\n \n\n \n\n**Avantaj sağlamış**\n \n\n \n\n Evrim biyologlarının görüşüne göre, tarih öncesi dönemlerde solak olmak, bir dövüş sırasında sağ elini kullananlara karşı sürpriz karşılık verebilme imkanı tanıdığı için avantaj sağladı. Bu yüzden az sayıda olan solaklar evrim sürecinde hayatta kalmayı başardı. Uzmanların araştırma sonuçları, solakların, genele göre daha yaratıcı ve daha zeki olabildiklerini gösterdi.\n \n\n \n\n Coğrafi çeşitliliğe bağlı olarak nüfusun yüzde 5 ila yüzde 25’ini oluşturan solakların yapıları ufak tefek. Eşcinseller arasında solakların oranlarının daha fazla olması da bazı uzmanlar tarafından, \"Eşcinsellerin çoğunlukla çocukları olmaz. Bu yüzden genetik duruma dayandırmak pek sağlıklı değil\" şeklinde yorumlanıyor. Solaklığın kötü yanı ise ortalama ömürlerinin, sağlaklardan birkaç ay daha kısa olması...\n\n",
"name": "",
"is_accepted": false
}
] |
|
d936b8fd0eeacf4b17ce100c7570439f | Nüfus oranına göre Türkiye'de en çok içki tüketen şehir hangisi? | haziryanit.com | 2020.10 | [
{
"text": "\n\n**01-Edirne\n \n\n 02-Muğla\n \n\n 03-Kırklareli\n \n\n 04-Tekirdağ\n \n\n 05-Antalya\n \n\n 06-Aydın\n \n\n 07-İzmir\n \n\n 08-İstanbul\n \n\n 09-Ankara\n \n\n 10-Kocaeli**\n \n\n \n\n",
"name": "",
"is_accepted": false
}
] |
|
a1a92b23f3fd09745462fe5e9213933f | deniz seviyesinden yüksek yerlerde yemekler neden geç pişer? | haziryanit.com | 2019.47 | [
{
"text": "\nİlk bakışta çelişkili gelebilir ama cevabımız, \"yükseklerde su neden çabuk kaynar\" sorusunun cevabıyla aynı. Her iki olayın temel nedeni, suyun kaynama sıcaklığının hava basıncına bağlı olması: Hava basıncı düştükçe suyun kaynama sıcaklığı da düşer. Yükseklere çıktıkça hava basıncı düştüğü için, buralarda su 1000C'den daha düşük sıcaklıklarda kaynamaya başlar. Fakat, kaynama noktası yükseltiyle büyük oranda değişmediği için, elinizde ölçme aletleri olmadığı sürece bu etkiyi kolaylıkla fark edemezsiniz.\n \n\n \nYemek pişirmenin basit bir su ısıtmadan (örneğin çay yapmak için su ısıtmak) en önemli farkı, pişmesi için yemeği kaynar durumda bir süre bekletmek zorunda olmamız. Yani suyun kaynaması yetmiyor, tam pişme için gerekli kimyasal reaksiyonların tamamlanmasını sağlamak için de bir süre daha beklememiz gerekiyor. Bu reaksiyonların hızının sıcaklığa bağımlılığı da pişirme süremizi belirliyor.\n \n\n \nBazı noktaları biraz daha açıklayalım. Sulu bir yemeği pişirirken, ilk aşamada altını çok açarız ki hemen kaynamaya başlasın. Altını ne kadar çok açarsak, o kadar çok ısı veririz, suyun sıcaklığı da o kadar hızlı artar. Fakat yemek kaynamaya başlayınca altı kısılır. Bunun nedeni, suyun sıcaklığının kaynama noktasının üzerine çıkamaması. Yani bu aşamada yemeğe verdiğimiz fazladan ısı, sıcaklığı artırmak yerine suyu buharlaştırmaya yarıyor. Yemeğin pişme süresi ise sadece içinde bulunduğu suyun sıcaklığına bağlı, bu suyun ne kadar çabuk buharlaştığına değil. Özetlersek, bir kere kaynamaya başladıktan sonra yemeğin sıcaklığı sabit kalıyor (suyun kaynama sıcaklığı). Ocağı ne kadar çok açarsanız açın, bu sıcaklığı kesinlikle artıramıyorsunuz. Ocağın fazla açık olması suyun tamamen buharlaşma ve yemeğin yanma olasılığını artırdığı için de ocağı mümkün olduğu kadar kısıyoruz.\n \n\n \nBuna ek olarak, bir yemeğin pişme süresi sıcaklık arttıkça kısalır (yüksek sıcaklıklarda reaksiyonlar daha hızlı gerçekleştiği için). Dolayısıyla, yüksek yerlerde suyun kaynama noktası daha düşük olduğundan ve yemekler bu sıcaklıkta piştiğinden, pişirme süresi deniz seviyesine göre daha uzun olacaktır.\n \n\n \nSon olarak, düdüklü tencerelerin bu olayı kullanarak pişirme süresini kısalttığını ekleyelim. Bu kaplar, içlerindeki havayı normal hava basıncının yaklaşık iki katı kadar bir basınç altında tutacak şekilde tasarlanmıştır. Bu basınç altında da suyun kaynama sıcaklığı 1210C'dir. Düdüklü tenceredeki yemek kaynamaya başladığında sıcaklık tam bu değere eriştiği için, yemeğin ağzı açık kaplardakinden çok daha hızlı pişmesi sağlanıyor.\n\n",
"name": "",
"is_accepted": false
}
] |
|
20d74e0b87d4c072d050d6de3cf3c35b | Zeki görünmenin 12 yolu | haziryanit.com | 2019.47 | [
{
"text": "\n\nİngiltere'de yapılan bir kamuoyu yoklamasında, 'Zeki görünmek' için başvurulan 12 'Sahte davranış' belirlendi\n \n\n \n\nAsk Jeeves arama motorunun yaptığı kamuoyu yoklaması, birini etkilemek için genellikle bu 12 davranışın tercih edildiğini ve erkeklerin söz konusu davranışlara kadınlardan iki kat fazla başvurduğunu gösterdi.\n \n\n \n\nEn çok başvurulan \"Sahte davranışlar\" ise şöyle:\n \n\n \n\nÜnlü bir kişinin sözlerinden alıntı yapmak (bunu kendi sözleri gibi yansıtmak)\n \n\nSık sık sanat galerisine gidiyormuş imajını yaymak\n \n\nPlajda \"ciddi\" konulu kitaplar okumak\n \n\nZekice yazılmış ya da gündeme ilişkin bir tweeti re-tweet yapmak\n \n\nYüksek sesle siyaset konuşmak\n \n\nToplu taşıma araçlarında \"ciddi\" magazin dergileri okumak\n \n\nZekice yazılmış bir makaleyi Facebook ’ta paylaşmak\n \n\nBaşta Shakespeare olmak üzere ünlü yazarlardan alıntı yapmak\n \n\nŞarap konusunda \"engin bilgilere\" sahipmiş gibi davranmak\n \n\nNumarasız da olsa gözlük takmak\n \n\nOperadan bahsetmek\n \n\nCaz ve klasik müzikten hoşlanıyormuş gibi yapmak\n \n\n \n\n \n\n",
"name": "",
"is_accepted": false
}
] |
|
c0d453ce7a3232bff44695a37c9799ac | Soru bütün bölgeleri kapsamaktadır.Kaç ilimiz denize komşu acaba. | Ülkemizde denize kıyısı olan illerimiz hangileridir? | haziryanit.com | 2019.47 | [
{
"text": "artvin \n\n \n\nrize \n\n \n\ntrabzon",
"name": "",
"is_accepted": false
},
{
"text": "\n**Ülkemizde denize kıyısı olan iller bölgelere göre şulardır.**\n\n\n**Karadeniz'e kıyısı olan illerimiz**\n \nArtvin\n \nRize\n \nTrabzon\n \nGiresun\n \nOrdu\n \nSamsun\n \nSinop\n \nKastamonu\n \nBartın\n \nZonguldak\n \nSakarya\n \nKırklareli\n \nTekirdağ (Karadeniz ve Marmara)\n \nKocaeli (Karadeniz ve Marmara)\n \nİstanbul (Karadeniz ve Marmara)\n\n\n**Ege Denizi'ne kıyısı olan illerimiz**\n \nÇanakkale (Marmara ve Ege Denizi)\n \nBalıkesir (Marmara ve Ege Denizi)\n \nEdirne\n \nAydın\n \nİzmir\n \nMuğla\n\n\n**Marmara Denizi'ne kıyısı olan illerimiz**\n \nTekirdağ\n \nBursa\n \nYalova\n\n\n**Akdeniz'e kıyısı olan illerimiz**\n \nAntalya \n \nMersin\n \nAdana\n \nHatay\n\n",
"name": "",
"is_accepted": false
}
] |
aee0e1eeb6797925ee5032fbe8d195db | Soluk alırken hava vücudumuzda hangi yolu izler? | haziryanit.com | 2019.47 | [
{
"text": "\nSoluk alırken hava vücudumuzda basit şekilde şu yolu izler...\n\n\nBurun\n \nYutak\n \nGırtlak\n \nSoluk borusu\n \nAkciğerler\n\n\n\n\n",
"name": "",
"is_accepted": false
}
] |
|
76b8745740925a4d5765c8918cfdd876 |
Birinci sayfadaki cümle:
"Bu kitapta yalnızca bir tane yanlış ifade vardır."
İkinci sayfadaki cümle:
"Bu kitapta yalnızca iki tane yanlış ifade vardır."
Üçüncü sayfadaki cümle:
"Bu kitapta yalnızca üç tane yanlış ifade vardır."
....................
Bininci sayfadaki cümle:
"Bu kitapta yalnızca bin tane yanlış ifade vardır."
Bu kitapta, doğru olan bir yada daha fazla ifade var mıdır. Varsa hangi sayfalardaki ifadeler doğrudur?
| Bin sayfalık bir kitap vardır. Bu kitabın her sayfasında bir cümle vardır. | haziryanit.com | 2019.43 | [
{
"text": "\n\n**ÇÖZÜM:**\n \n\n \n\n999. sayfadaki ifade doğrudur. Daha önceki 998. sayfadaki yanlış ifadelerle 1000. sayfadaki yanlış ifadenin toplamı 999 eder.\n\n",
"name": "",
"is_accepted": false
}
] |
d0fb07b982bcfc5a5c8155a5079e7b07 | En beğenilen iPhone uygulamaları hangileridir? | haziryanit.com | 2019.47 | [
{
"text": "\n\n En popüler İphone uygulamaları:\n \n\n \n\n**Skype:**\n \n\n \n\n**Camera Zoom:**\n \n\n \n\n**Tv.com:**\n \n\n \n\n**Brain Teaser:** \n \n\n \n\n**Backgrounds:**\n \n\n \n\n**My Lite Flashlight**:\n \n\n \n\n**Now Playing:** \n \n\n**Google Earth:**\n \n\n \n\n \n\n**Bloomberg:**\n \n\n \n\n**Midomi:**\n \n\n \n\n**Compass:**\n \n\n \n\n**Moto chaser:** \n \n\n \n\n**Pocket Guitar:** \n \n\n \n\n**Last FM:** \n \n\n \n\n**Süper Monkey Ball:**\n \n\n \n\n**iSamurai:**\n \n\n \n\n**Virtual Zippo lighter:**\n \n\n \n\n**iHandy Level:**\n \n\n \n\n**Ocarina:** \n \n\n \n\n**LEDBanner:** \n \n\n \n\n**Pianist**:\n \n\n \n\n**Pool 2.0:** \n \n\n \n\n**Sketches:**\n \n\n \n\n**Flip Book Lite:**\n \n\n \n\n**iMob online:** \n \n\n \n\n**ShowTimes:** \n \n\n \n\n**Photodial:** \n \n\n \n\n**EN ÇOK YÜKLENEN ÜCRETLİ UYGULAMALAR:**\n \n\n*Crash Bandicoot Nitro kart 3D\n \n\n Koi Pond\n \n\n Enigmo\n \n\n Bejeweled 2\n \n\n iBeer\n \n\n Moto Chaser\n \n\n PocketGuitar\n \n\n Flick Fishing\n \n\n Tetris\n \n\n Texas Hold'em\n \n\n Super Monkey Ball\n \n\n Pocket God\n \n\n Cro-Mag Rally\n \n\n Ocarina\n \n\n Fieldrunners\n \n\n iFart Mobile\n \n\n Touchgrind\n \n\n iHunt\n \n\n iShooy\n \n\n MONOPOLY Here & Now*\n \n\n \n\n**EN ÇOK YÜKLENEN ÜCRETSİZ UYGULAMALAR:**\n \n\n*Facebook\n \n\n Google Earth\n \n\n Pandora Radio\n \n\n Tap Tap Revenge\n \n\n Shazam\n \n\n PAC-MAN Lite\n \n\n Backgrounds\n \n\n Touch Hockey\n \n\n Labyrinth Lite Edition\n \n\n Flashlight\n \n\n Urbanspoon\n \n\n Movies\n \n\n iBowl\n \n\n Lightsaber Unleashed\n \n\n Sol Free Solitaire\n \n\n MySpace Mobile\n \n\n Virtual Zippo Lighter\n \n\n The Weather Channel\n \n\n BubbleWrap\n \n\n Remote*\n\n",
"name": "",
"is_accepted": false
}
] |
|
7d25378cb25b29bf8f63c98087ba7b42 | Bakanlar Kurulu’nun Özellikleri nelerdir? | Bakanlar Kurulu’nun Özellikleri nelerdir? | haziryanit.com | 2019.47 | [
{
"text": "\nBAKANLAR KURULU, BAKANLAR KURULU’NUN ÖZELLİKLERİ (VATANDAŞLIK, ANAYASA VE İNSAN HAKLARI DERSİ KONU ANLATIMLAR)\n \n \n \n**M.109-Bakanlar Kurulu**\n \n \n \nBaşbakan, Cumhurbaşkanınca TBMM üyeleri arasından atanır.\n \n \n \nBakanlar, TBMM üyeleri veya milletvekili seçilme yeterliliğine sahip olanlar arasından Başbakanca seçilir ve Cumhurbaşkanı tarafından atanır.\n \n \n \n \n \n**Göreve başlama ve güvenoyu:**\n \n \n \nBakanlar Kurulunun programı, kuruluşundan 1 hafta içinde TBMM’de okunur ve güvenoyuna başlanır. Güvenoyu için görüşmeler programın okunmasından 2 tam gün geçtikten sonra başlar görüşmelerin bitiminden 1 tam gün sonra oylama yapılır.\n \n \n \n \n \n**Görev sırasında güvenoyu:**\n \n \n \nBaşbakan gerekli görürse Bakanlar Kurulunda görüştükten sonra, TBMM den güven isteyebilir.\n \n \n \nGüven istemi TBMM ne bildirilmesinden bir tam gün geçmedikçe görüşülemez ve görüşmelerin bitiminden bir tam gün geçmedikçe oya konulamaz.\n \n \n \nGüven istemi üye tam sayısının salt çoğunluğu ile reddedilebilir.\n \n \n \n \n \n**Görev ve siyasi sorumluluk:**\n \n \n \nBakanlar kurulu siyasetin yürütülmesinden birlikte sorumludurlar. Her bakan başbakana karşı sorumlu olup ayrıca kendi yetkisi içindeki işlerden ve emri (bilgi yelpazesi.net) altındaki işlerden sorumludur.\n \n \n \n \n \n**Bakanlıkların kurulması:**\n \n \n \nBakanlıkların kurulması kaldırılması görev ve yetkileri kanunla düzenlenir bir bakan birden fazla bakana vekillik edemez.\n \n \n \nHerhangi bir sebeple boşalan bir bakanlığa 15 gün içerisinde yeni bir bakan atanır.\n\n",
"name": "",
"is_accepted": false
}
] |
3c82670d4330e63a6394a4bdd3df3c3a | Atatürk'e teklif edilen soyadları nelerdir? | Mustafa Kemal'e hangi soyadları teklif edilmiştir? | haziryanit.com | 2019.47 | [
{
"text": "\n\n**mustafa kemal etel : attila'nın adının orijinal söylenişidir. büyük nehir manasına gelir.\n \n\n \n\n mustafa kemal etil : attila'nın adının orijinal söylenişidir. büyük nehir manasına gelir.\n \n\n \n\n mustafa kemal etealp : altay dilinde büyük kahraman anlamına geldiği için adaylığa uygun bulunmuştur.\n \n\n \n\n mustafa kemal arız : türk büyüğü alp arızdan esinlenerek önerilmiştir.\n \n\n \n\n mustafa kemal ulaş : bir türk büyüğü olan ulaş oğlu şakir kazandan esinlenerek önerilmiştir.\n \n\n \n\n mustafa kemal yazır : bir türk büyüğü olan yağlıkçı oğlu yazırdan esinlenerek önerilmiştir.\n \n\n \n\n mustafa kemal emen : bir türk büyüğü olan uçan oğlu emen beyden esinlenerek önerilmiştir.\n \n\n \n\n mustafa kemal çogaş : ulaş oğlu şakir kazanın bir unvanı olması hasebiyle önerilmiştir.\n \n\n \n\n mustafa kemal salış : eski türkçede güneş, ışık anlamına geldiği için önerilmiştir.\n \n\n \n\n mustafa kemal begit : eski türkçede sağlam, kâvi anlamına geldiği için önerilmiştir.\n \n\n \n\n mustafa kemal ergin : eski türkçede aydın anlamına geldiği düşüncesiyle önerilmiştir.\n \n\n \n\n mustafa kemal tokuş : bir türk büyüğü olan ertokuş beyden esinlenerek önerilmiştir.\n \n\n \n\n mustafa kemal beşe : eski türkçede seçkin anlamına geldiği düşüncesiyle önerilmiştir.\n \n\n \n\n \n\n saffet arıkan'da bu listeye türkata ve türkatası soyadlarını eklemiştir.**\n\n",
"name": "",
"is_accepted": false
}
] |
8698d15a77873eade8330eb18c06d9fa |
1. sayı: 328 645
2. sayı: 491 221
3. sayı: 816 304
4. sayı: 117 586
5. sayı: 671 355
6. sayı: 508 779
7. sayı: 183 696
8. sayı: 882 416
Sayılara bakarken kafanızda nasıl yapacağınızı bulup çıkarmış olmanız lazım.
| Aşağıda 6 basamaklı 8 sayı verilmektedir. Bu sayıları kafanızda gruplandırarak ve kağıt kalem kullanmadan en kısa sürede toplamanızı istiyoruz. | haziryanit.com | 2019.47 | [
{
"text": "\n\n Sayılara dikkat edecek olursanız;\n\n\n\n 1. ve 5. sıradaki sayıların son basamakları toplamı 10 etmekte, diğer basamakların toplamı 9 etmektedir. Bu durumda iki sayının toplamı 1 000 000 dur.\n\n\n\n Aynı şekilde 2. ve 6. sayıların toplamı , 3. ve 7. sayıların toplamı, 4. ve 8. sayıların toplamı da ayrı ayrı 1 000 000 etmektedir.\n\n\n\n**Bu durumda 8 sayının toplamı da 4 000 000 eder.**\n\n",
"name": "",
"is_accepted": false
}
] |
65272c23265047c12f35d273c239eb09 | Kitap okuma alışkanlığı bireylere nasıl kazandırılabilir ? | haziryanit.com | 2019.47 | [
{
"text": "\n\n**1-** Her şeyden önce okuma alışkanlığını kazanabilmek için “**içsel denetiminizi**” sağlamanız gerektiğini bilin. Yani dışarıdan ne kadar etki olursa olsun, sonuçta bu alışkanlığı kendi çabalarınızla kazanacağınızın farkına varın. Öğretmeninin veya ailesinin kitap okuması için zorladığı bir gencin, kitabın arasına iddia kuponları koyup, kendisini kitap okuyormuş gibi göstermesi, buna bir örnektir. Sonuçta dışarıdan ne kadar baskı olursa olsun, kişi istemedikten sonra bu alışkanlığı kazanamaz.\n \n\n \n\n**2-** Kitap, dergi, makale… okumayı, “**boş vakitleri doldurmak**” diye adlandırmamak ve bunu yaşamımızda bu yönüyle uygulamaya çalışmamak gerekir. Çünkü okumak, kişinin bir ihtiyacı olmalıdır. Okumayı yaşamımızda öyle bir yere koymalıyız ki, sıkıntıya girmeden, zevkle her gün kitap okumamız gerektiği aklımıza gelsin. Ben, bir dönem her gece yatmadan önce mutlaka en az 5-10 sayfa kitap veya dergi okurdum. Bir süre sonra buna öyle bir alıştım ki, gece yatağıma girdiğimde gerçekten kitap okumadan uykum gelmez oldu. Şimdi çok yoğun olduğum, hiç vaktimin olmadığı günlerde bile uyumadan önce kesinlikle kitap okur, öyle uyurum. Zaten okumadan gözüme uyku girmez. İşte sizin de her gün kitaba ayırabileceğiniz bir zaman belirlemeniz lazım. Bu zamanı ayarlayıp, o saatlerde düzenli olarak kitap okumaya başlarsanız, bir süre sonra her gün o saatlerde tıpkı acıkır - susar gibi kitap okuma ihtiyacı duyacaksınız.\n \n\n \n\n**3-** Kişilerimizi okuma kültüründen uzaklaştırıp, kul yapımı bir makinenin önüne bağlayan teknolojik gelişmelerin, bizim bazı ihtiyaçlarımızın önüne geçmemesini sağlamalıyız. Diyelim ki bir günde kendinizce kullanabileceğiniz 4 saatlik zamanınız var. Bu 4 saatin tamamını televizyon başında dizi / film izleyerek veya bilgisayarda oyun oynayıp internette dolaşarak geçirirseniz, o vakitte yapılması gereken bir sürü şeyden yoksun kalırsınız. Bunun için vaktinizi nelerle geçirdiğinizi iyi belirlemeli ve sizin okuma alışkanlığınıza engel olabileceğini düşündüğünüz belli bağımlılıklarınızdan (*) kurtulmanız gerekiyor.\n \n\n \n\n**4-** Okuma alışkanlığı kazanabilmek için ön hazırlıkları tamamladıktan sonra, hangi konulara - türlere ilgili olduğunuzu ve ne düzeyde bir okuyucu olduğunuzu belirleyin. Eğer yaşamınız boyunca hiçbir roman, öykü, destan, masal, şiir… okumadıysanız, kesinlikle ilgili olduğunuz konularda yazılmış, basit düzeydeki eserlerle işe başlayın. Eğer sizi bunaltacak eserler seçerseniz, kesinlikle alışkanlığı kazanmakta güçlük çekersiniz. Bunun için öncelikle kısa, ilginizi çekebilecek konularda yazılmış ve hatta resimlerle desteklenmiş eserleri okuyun.\n \n\n \n\n**5-** Alışkanlığınızı pekiştirecek hedefler belirleyin. Örneğin haftada bir kitap bitirme ile başlayıp, bunu iki günde bir kitaba kadar indirmeye çalışın. Ayrıca edebiyat, bilim, kültür, mizah… dergilerine abone olun. Nedense “**okuma alışkanlığı**” denildiğinde hep yanlış bir şekilde “**kitap okuma alışkanlığı**” akla gelir. Genellikle bunun için söylense bile, sadece dergi okuyan bir insan da okuma alışkanlığını edinmiştir. Bunun için sadece kitaplarla değil, dergi, gazete ve benzeri yayınlarla da düşünce alanımızı genişletmeye çalışın. Gazete satın almak istemiyorsanız bile, internetten güncel olayları takip edin. İlginizi çeken konularda hazırlanmış haberleri bıkmadan okumaya çalışın.\n \n\n \n\n**6-** Okumada aşırıya gitmemek kaydıyla seçici olun.\n \n\n \n\n**7-** Okuma alışkanlığı kazanmama nedeninizi, “**kaynak yoksunluğuna**” bağlamayın. Kitaplarınızı, dergilerinizi… arkadaşlarınızla bir süreliğine değiştirin. Bulunduğunuz yerlerdeki kütüphanelere çok sık uğrayıp, elinizde olmayan kitapları ödünç alın. Eğer yakınınızda kitap okuyan insanların uğradığı “**kültür evleri**” falan varsa, oralara gidip kendinize “**okuma arkadaşları**” bulun. Okuduğunuz bir kitabı, arkadaşlarınızla veya ailenizle paylaşın.\n \n\nBurada sayılmayan ve sizin kitap okuma alışkanlığını edinmenizde yardımcı olacağını düşündüğünüz şeyleri yapmaktan çekinmeyin. İnsanlar kitap okudukça sözcük dağarcıklarını geliştirirler, düşünce alanlarını genişletirler, kültür seviyelerini yükseltirler, temel dil becerilerini (okuma, yazma, konuşma, dinleme) geliştirirler, dünya görüşlerini genişletirler… Ve böylece toplum içerisinde boş konuşmayan, sözü dinlenen, saygın ve seçkin bireyler olurlar. Bunun önemini kavratmak, öncelikle aile büyüklerine sonra da öğretmenlere düşüyor. Kişinin kişilik yapısını bile değiştiren bu alışkanlığı, küçük yaşta çocuklara kazandırmak için aile içerisinde çocuklar okumaya özendirilmeli, gerekirse belirlenen “**okuma saatleri**” ile gençler okumaya teşvik edilmelidir. Çocuklarınıza sık sık kitap armağan etmek de, onların kitapla tanışmasına aracı olabilir. Öğretmenlerin de okulda “**okuma yarışmaları**” gibi etkinliklerle öğrencileri okuyan bireyler olmaları için yönlendirmeleri gerekmektedir.\n\n",
"name": "",
"is_accepted": false
}
] |
|
11a4199f19a5c3965982c2074e622b6a |
I have a dynamically generating page that changes content dependent on whether the user is logged in or not.
As such, there are **some elements I would like to hide based on the text in the body** of the webpage.
Example HTML:
```
[Upload New Product](/upload)
### Sign up to start learning
Help children in rural communities
```
So I want to **hide the class** `.button-wrapper` if the text “rural communities” is found on the webpage, or similarly, if class `.wv-signupnotice` is present.
Here’s the Javascript I tried to no avail:
```
let divs = document.getElementsByClassName('button-wrapper');
for (let x = 0; x < divs.length; x++) {
let div = divs[x];
let content = div.innerHTML.trim();
if (content == 'rural communities') {
div.style.display = 'none';
}
}
```
Many thanks in advance for your help!
|
Using Javascript to hide element class based on body text
=========================================================
| programmertricks.com | 2020.34 | [
{
"text": "\nFollows the code which will hide this div if there is any other div with wv-signupnotice present on the document. Hope it helps.\n\n\nlet divs = document.getElementsByClassName(‘button-wrapper’);\n\n\n`$(document).ready(function() { \n\nif($('div').hasClass(\"wv-signupnotice\")) \n\ndivs[0].style.display=\"none\"; \n\n});`\n\n\n`[Upload New Product](/upload)\n\n\n### Sign up to start learning` `Help children in rural communities`\n\n\n",
"name": "",
"is_accepted": false
}
] |
492bdae5dc1482b2ed6cc7e2e9b6968c |
I have a string
`const copy ="little copy"`
Below is the copy template string
`const copyTemplate = `${copy}``
I don’t understand where I’m going wrong, any help would be appreciated.
Thanks
|
template string with ng-if has Error: $parse:syntax
===================================================
| programmertricks.com | 2020.50 | [
{
"text": "\n`const notesTemplate = `${notes}`;`\n\n\n",
"name": "",
"is_accepted": false
}
] |
7014d243ee77c0d5c181de46402335e5 |
How to redirect http to https using .htaccess file?
|
How to redirect http to https using .htaccess file?
===================================================
| programmertricks.com | 2020.29 | [
{
"text": "\nI use the following to successfully redirect all pages of my domain from http to https:\n\n\n`RewriteEngine on \n\n# force ssl \n\nRewriteCond %{SERVER_PORT} ^80$ \n\nRewriteRule ^(.*)$ https://%{SERVER_NAME}%{REQUEST_URI} [L,R]`\n\n\nNote this will redirect using the 301 ‘permanently moved’ redirect, which will help transfer your SEO rankings.\n\n\nTo redirect using the 302 ‘temporarily moved’ change [R=302,L]\n\n\n",
"name": "",
"is_accepted": true
},
{
"text": "\nAs this answer receives some attention, I want to hint to a more recommended way on doing this using Virtual Hosts: Apache: Redirect SSL\n\n\n`ServerName mysite.example.com \n\nRedirect permanent / https://mysite.example.com/\n\n\n ServerName mysite.example.com \n\nDocumentRoot /usr/local/apache2/htdocs \n\nSSLEngine On \n\n# etc...`\nOld answer, hacky thing given that your ssl-port is not set to 80, this will work: \n\n `RewriteEngine on`\n\n`# force ssl \n\nRewriteCond %{SERVER_PORT} ^80$ \n\nRewriteRule ^(.*)$ https://%{SERVER_NAME}%{REQUEST_URI} [L,R]` \n\nNote that this should be your first rewrite rule.\n\n\nEdit: This code does the following. The RewriteCond(ition) checks wether the ServerPort of the request is 80 (which is the default http-port, if you specified another port, you would have to adjust the condition to it). If so, we match the whole url (.*) and redirect it to a https-url. %{SERVER\\_NAME} may be replaced with a specific url, but this way you don’t have to alter the code for other projects. %{REQUEST\\_URI} is the portion of the url after the TLD (top-level-domain), so you will be redirected to where you came from, but as https.\n\n\n",
"name": "",
"is_accepted": false
}
] |
99fd10c87daec524d6c8163f4b0c284d |
I have a string array and those include different types of strings and I would like to separate those values in 2 different arrays.
`string[] arr = { "12" , "34-2-2" , "xyz" , "33" , "56-3-4" , "45-4" }`
Now I want LINQ query which gives me “12”, “33” in one and “34-2-2”, “56-3-4” in another array. The rest of the values will be ignored.
`var _cust= DbContext.Customer.AsQueryable();`
This will contain Id (Int32) and in this, I want to add query which returns if the customer has “12”, “33” will return that result.
`var _cont = DbContext.Contacts.AsQueryable();`
How can I write a LINQ query for this?
|
Extract Number from string arrays?
==================================
| programmertricks.com | 2020.45 | [
{
"text": "\n`string[] arr = {\"12\", \"34-2-2\", \"xyz\", \"33\", \"56-3-4\", \"45-4\"};`\n\n\n`var first = arr.Where(v => Regex.IsMatch(v, @\"^\\d+$\")).ToArray(); \n\nvar second = arr.Where(v => Regex.IsMatch(v, @\"^\\d+-\\d+-\\d+$\")).ToArray();` \n\n `Console.WriteLine(string.Join(\" \", first)); \n\nConsole.WriteLine(string.Join(\" \", second));`\n\n\n",
"name": "",
"is_accepted": false
}
] |
60a0ed753f8620196020804eaf590c82 |
What is good Php ORM Library?
|
What is good Php ORM Library?
=============================
| programmertricks.com | 2020.16 | [
{
"text": "\nThere are only two good ones: \n\nDoctrine and Propel. We favor Doctrine, and it works well with Symfony. However, if you’re looking for database support besides the main ones you’ll have to write your own code.\n\n\n",
"name": "",
"is_accepted": false
},
{
"text": "\nI’m trying to receive a JSON POST on a payment interface website, but I can’t decode it.\n\n\nWhen I print :\n\n\necho $\\_POST; \n\nI get:\n\n\nArray \n\nI get nothing when I try this:\n\n\nif ( $\\_POST ) { \n\nforeach ( $\\_POST as $key => $value ) { \n\necho “llave: “.$key.”- Valor:”.$value.” \n“; \n\n} \n\n} \n\nI get nothing when I try this:\n\n\n$string = $\\_POST[‘operation’]; \n\n$var = json\\_decode($string); \n\necho $var; \n\nI get NULL when I try this:\n\n\n$data = json\\_decode( file\\_get\\_contents(‘php://input’) ); \n\nvar\\_dump( $data->operation ); \n\nWhen I do:\n\n\n$data = json\\_decode(file\\_get\\_contents(‘php://input’), true); \n\nvar\\_dump($data); \n\nI get:\n\n\nNULL \n\nThe JSON format is (according to payment site documentation):\n\n\n{ \n\n“operacion”: { \n\n“tok”: “[generated token]”, \n\n “shop\\_id”: “12313”, \n\n“respuesta”: “S”, \n\n“respuesta\\_details”: “respuesta S”, \n\n“extended\\_respuesta\\_description”: “respuesta extendida”, \n\n“moneda”: “PYG”, \n\n“monto”: “10100.00”, \n\n“authorization\\_number”: “123456”, \n\n“ticket\\_number”: “123456789123456”, \n\n“response\\_code”: “00”, \n\n“response\\_description”: “Transacción aprobada.”, \n\n“security\\_information”: { \n\n“customer\\_ip”: “123.123.123.123”, \n\n“card\\_source”: “I”, \n\n“card\\_country”: “Croacia”, \n\n“version”: “0.3”, \n\n“risk\\_index”: “0” \n\n} \n\n} \n\n} \n\nThe payment site log says everything is OK. What’s the problem?\n\n\n",
"name": "",
"is_accepted": false
},
{
"text": "\nAxon ORM is part of the Fat-Free Framework – it features an on-the-fly mapper. No code generators. No stupid XML/YAML configuration files. It reads the database schema directly from the backend, so in most CRUD operations you don’t even have to extend a base model. It works with all major PDO-supported database engines: MySQL, SQLite, SQL Server/Sybase, Oracle, PostgreSQL, etc.\n\n\n/* SQL */ \n\nCREATE TABLE products ( \n\nproduct\\_id INTEGER, \n\ndescription VARCHAR(128), \n\nPRIMARY KEY (product\\_id) \n\n);\n\n\n/* PHP */ \n\n// Create \n\n$product=new Axon(‘products’); // Automatically reads the above schema \n\n$product->product\\_id=123; \n\n$product->description=’Sofa bed’; \n\n$product->save(); // ORM knows it’s a new record\n\n\n// Retrieve \n\n$product->load(‘product\\_id=123′); \n\necho $product->description;\n\n\n// Update \n\n$product->description=’A better sofa bed’; \n\n$product->save(); // ORM knows it’s an existing record\n\n\n// Delete \n\n$product->erase(); \n\nMost of all, the plug-in and accompanying SQL data access layer are just as lightweight as the framework: 14 KB (Axon) + 6 KB (SQLdb). Fat-Free is just 55 KB.\n\n\n",
"name": "",
"is_accepted": false
}
] |
910f3800d2572effdaeb7f41d57fe1e7 |
What are the actual use of PHP foreach loop?
|
What are the actual use of PHP foreach loop?
============================================
| programmertricks.com | 2021.21 | [
{
"text": "\nLet me prefix this by saying that I know what foreach is, does and how to use it. This question concerns how it works under the bonnet, and I don’t want any answers along the lines of “this is how you loop an array with foreach”.\n\n\nFor a long time I assumed that foreach worked with the array itself. Then I found many references to the fact that it works with a copy of the array, and I have since assumed this to be the end of the story. But I recently got into a discussion on the matter, and after a little experimentation found that this was not in fact 100% true.\n\n\nLet me show what I mean. For the following test cases, we will be working with the following array:\n\n\n$array = array(1, 2, 3, 4, 5); \n\nTest case 1:\n\n\nforeach ($array as $item) { \n\necho “$item\\n”; \n\n$array[] = $item; \n\n} \n\nprint\\_r($array);\n\n\n/* Output in loop: 1 2 3 4 5 \n\n$array after loop: 1 2 3 4 5 1 2 3 4 5 */ \n\nThis clearly shows that we are not working directly with the source array – otherwise the loop would continue forever, since we are constantly pushing items onto the array during the loop. But just to be sure this is the case:\n\n\nTest case 2:\n\n\nforeach ($array as $key => $item) { \n\n$array[$key + 1] = $item + 2; \n\necho “$item\\n”; \n\n}\n\n\nprint\\_r($array);\n\n\n/* Output in loop: 1 2 3 4 5 \n\n$array after loop: 1 3 4 5 6 7 */ \n\nThis backs up our initial conclusion, we are working with a copy of the source array during the loop, otherwise we would see the modified values during the loop. But…\n\n\nIf we look in the manual, we find this statement:\n\n\nWhen foreach first starts executing, the internal array pointer is automatically reset to the first element of the array.\n\n\nRight… this seems to suggest that foreach relies on the array pointer of the source array. But we’ve just proved that we’re not working with the source array, right? Well, not entirely.\n\n\nTest case 3:\n\n\n// Move the array pointer on one to make sure it doesn’t affect the loop \n\nvar\\_dump(each($array));\n\n\nforeach ($array as $item) { \n\necho “$item\\n”; \n\n}\n\n\nvar\\_dump(each($array));\n\n\n/* Output \n\narray(4) { \n\n[1]=> \n\nint(1) \n\n[“value”]=> \n\nint(1) \n\n[0]=> \n\nint(0) \n\n[“key”]=> \n\nint(0) \n\n} \n\n1 \n\n2 \n\n3 \n\n4 \n\n5 \n\nbool(false) \n\n*/ \n\nSo, despite the fact that we are not working directly with the source array, we are working directly with the source array pointer – the fact that the pointer is at the end of the array at the end of the loop shows this. Except this can’t be true – if it was, then test case 1 would loop forever.\n\n\nThe PHP manual also states:\n\n\nAs foreach relies on the internal array pointer changing it within the loop may lead to unexpected behavior.\n\n\nWell, let’s find out what that “unexpected behavior” is (technically, any behavior is unexpected since I no longer know what to expect).\n\n\nTest case 4:\n\n\nforeach ($array as $key => $item) { \n\necho “$item\\n”; \n\neach($array); \n\n}\n\n\n/* Output: 1 2 3 4 5 */ \n\nTest case 5:\n\n\nforeach ($array as $key => $item) { \n\necho “$item\\n”; \n\nreset($array); \n\n}\n\n\n/* Output: 1 2 3 4 5 */ \n\n…nothing that unexpected there, in fact it seems to support the “copy of source” theory.\n\n\nThe Question\n\n\nWhat is going on here? My C-fu is not good enough for me to able to extract a proper conclusion simply by looking at the PHP source code, I would appreciate it if someone could translate it into English for me.\n\n\nIt seems to me that foreach works with a copy of the array, but sets the array pointer of the source array to the end of the array after the loop.\n\n\nIs this correct and the whole story? \n\nIf not, what is it really doing? \n\nIs there any situation where using functions that adjust the array pointer (each(), reset() et al.) during a foreach could affect the outcome of the loop?\n\n\n",
"name": "",
"is_accepted": false
}
] |
8a0926fccc026545763ffef05e65888b |
I currently have two tables where a version log can contain many ProductVersions.
`SELECT
versionlog.[Name],
(
SELECT COUNT(*)
FROM dbo.ProductVersions productVersion
WHERE productVersion.VersionLogId = versionLog.Id
) AS ProductVersions
FROM dbo.Versionlog versionLog`
produces a result set similar to
`Name | ProductVersions
Log1 | 12
Log2 | 6
Log3 | 0`
How can I limit the result set to only return Versionlogs with a ProductVersion Count = 0?
According to Google, I’ll need to use the Having clause?
|
Filter Count Clause – One to Many relationship?
===============================================
| programmertricks.com | 2020.45 | [
{
"text": "\nUsing HAVING: \n\n `SELECT versionlog.[Name] \n\nFROM dbo.Versionlog versionLog \n\nLEFT JOIN dbo.ProductVersions productVersion \n\nON productVersion.VersionLogId = versionLog.Id \n\nGROUP BY versionlog.[Name] \n\nHAVING COUNT(productVersion.VersionLogId) = 0;`\n\n\n",
"name": "",
"is_accepted": false
}
] |
a006e45f612828b043af8f3d0dd3c7e9 |
I have a string which is ACTUALLY STORING TIME 09:00-18:00, I want to get 2 DateTime. The time of the 18:00 returns an object and that of the 09:00 returns another object. I tried to use split, but IT does not WORK that’s why I NEED A solution.
`// Get start time and end time separated by "-"
$split = preg_split('/[s-]+/', $line['intervention_hour']);
// Get hour number and minute separated by "h"
$start = preg_split('/[:]+/', $split[0]);
$end = preg_split('/[:]+/', $split[1]);`
|
Split a string to tow Datetime objects
======================================
| programmertricks.com | 2020.34 | [
{
"text": "\nYou need to use DateTime::createFromFormat\n\n\n$line = ’09:00-18:00′;\n\n\n$split = explode(‘-‘, $line);\n\n\n$start = DateTime::createFromFormat ( ‘H:m’, $split[0]); \n\n$end = DateTime::createFromFormat ( ‘H:m’, $split[1]);\n\n\nprint\\_r($start); \n\necho ‘>>>’; \n\nprint\\_r($end);\n\n\n",
"name": "",
"is_accepted": false
},
{
"text": "\nIf you are sure your that your input will always have the same structure, you could use something like this:\n\n\nlist($start, $end) = explode(‘-‘, str\\_replace(‘:’,’h’,’09:00-18:00′)); \n\nYour variable $start will contain ’09h00′ and $end will contain ’18h00′\n\n\n",
"name": "",
"is_accepted": false
}
] |
0e0ef6c93efb2381ca1c3198ce8cbeaa |
How to call an undefined method which is mysqli\_stmt::get\_result?
|
How to call an undefined method which is mysqli\_stmt::get\_result?
===================================================================
| programmertricks.com | 2021.17 | [
{
"text": "\nfor those searching for an alternative to $result = stmt->get\\_result() I’ve made this function which allows you to mimic the $result->fetch\\_assoc() but using directly the stmt object:\n\n\nfunction fetchAssocStatement($stmt) \n\n{ \n\nif($stmt->num\\_rows>0) \n\n{ \n\n$result = array(); \n\n$md = $stmt->result\\_metadata(); \n\n$params = array(); \n\nwhile($field = $md->fetch\\_field()) { \n\n$params[] = &$result[$field->name]; \n\n} \n\ncall\\_user\\_func\\_array(array($stmt, ‘bind\\_result’), $params); \n\nif($stmt->fetch()) \n\nreturn $result; \n\n}\n\n\n return null; \n\n} \n\nas you can see it creates an array and fetches it with the row data, since it uses $stmt->fetch() internally, you can call it just as you would call mysqli\\_result::fetch\\_assoc (just be sure that the $stmt object is open and result is stored):\n\n\n//mysqliConnection is your mysqli connection object \n\nif($stmt = $mysqli\\_connection->prepare($query)) \n\n{ \n\n$stmt->execute(); \n\n$stmt->store\\_result();\n\n\n while($assoc\\_array = fetchAssocStatement($stmt)) \n\n{ \n\n//do your magic \n\n}\n\n\n $stmt->close(); \n\n} \n\nhope this helps.\n\n\n",
"name": "",
"is_accepted": false
}
] |
9720d2f0d1223754fec11a2da1265ec7 |
How to receive full url in PHP?
|
How to receive full url in PHP?
===============================
| programmertricks.com | 2021.21 | [
{
"text": "\nI use this code to get the full URL:\n\n\n$actual\\_link = ‘http://’.$\\_SERVER[‘HTTP\\_HOST’].$\\_SERVER[‘PHP\\_SELF’]; \n\nThe problem is that I use some masks in my .htaccess, so what we see in the URL is not always the real path of the file.\n\n\nWhat I need is to get the URL, what is written in the URL, nothing more and nothing less—the full URL.\n\n\nI need to get how it appears in the Navigation Bar in the web browser, and not the real path of the file on the server.\n\n\n",
"name": "",
"is_accepted": false
}
] |
8a140d3551eb454fd0c4d8d625eac292 | I have a list of numbers that map to names, and all I want to do is bring back everything including exact duplicates.
Data in TABLE
`number name
1 Tom
2 Brian
3 Steve`
`SELECT number, name
FROM table
WHERE number in (1,2,1,1,3,3)
ORDER BY number`
I want like the output to be:
`1 Tom
2 Brian
1 Tom
1 Tom
3 Steve
3 Steve`
but what is being returned is:
`1 Tom
2 Brian
3 Steve`
| How do I display all results from a query, including duplicates?
================================================================
| programmertricks.com | 2019.47 | [
{
"text": "you can try like below by the use of join in the table form\n\n `with cte as \n ( \n select 1 as id from dual \n union all \n select 2 from dual \n union all \n select 1 from dual \n union all \n select 1 from dual \n union all \n select 3 from dual \n union all \n select 3 from dual \n ) \n select cte.id,t1.name from table t1 join cte on t1.number=cte.id` \n\n",
"name": "",
"is_accepted": false
}
] |
a1e885e635527472804d8bb4c53f540c |
I am working on some set of PHP array. I am trying to loop through each of them and check the array whose name is equal to Jose Arcade. I am using a for loop but I get zero after extracting the data. I want to store the data in an array.
`array:6 [
0 => array:4 [
"id" => 1
"name" => "Josw Acade"
"value" => "Unlimited"
"plan_type" => "Superior"
]
1 => array:4 [
"id" => 2
"name" => "Verbal"
"value" => "true"
"plan_type" => "Superior"
]
2 => array:4 [
"id" => 12
"name" => "Josw Acade"
"value" => "$1,500,00"
"plan_type" => "Classic"
]
3 => array:4 [
"id" => 13
"name" => "Leon"
"value" => "true"
"plan_type" => "Classic"
]
4 => array:4 [
"id" => 14
"name" => "One Time"
"value" => "true"
"plan_type" => "Classic"
]
5 => array:4 [
"id" => 15
"name" => "Deat"
"value" => "$25,000"
"plan_type" => "Classic"
]
6 => array:4 [
"id" => 23
"name" => "Josw Acade"
"value" => "$100,000"
"plan_type" => "Essential"
]
]`
**Logic**
`$Inst = [];
for($med = 0; $med < count($array); $med++){
if($med['name'] == "Josw Acade"){
$Inst = $med['value'];
}
}`
`dd($Inst);`
|
Getting zero when extracting data from a PHP array in Laravel app
=================================================================
| programmertricks.com | 2021.39 | [
{
"text": "\nYou can use array\\_filter with callback\n\n\n$filtered = array\\_filter($array, function($v){ return $v[‘name’] == ‘Josw Acade’}) \n\nprint\\_r($filtered);\n\n\n",
"name": "",
"is_accepted": false
}
] |
3bf26369298fc62d409cb2ec34b5de1f |
I have a question here employing a query builder and smooth-spoken with the Mysql perform substr and my downside is it returns miscalculation of A non-numeric worth encountered. will somebody grasp what’s the answer to this? Thanks.
My knowledge is 1-Course one zero one and that I wish to induce solely the Course one zero one ignoring the 1- half within the information.
The queries I attempted
My smooth-spoken question
`$items2 = Course::where('school_id','=',Auth::user()->school_id)
->where(DB::raw('SUBSTR(name, LOCATE('-', name) + 1)'))
->where('status','=',1)
->get();`
Query builder
`$items3 = DB::table('courses')
->where('status', '=', 1)
->where('school_id','=',Auth::user()->school_id)
->where(DB::raw('SUBSTR(name, LOCATE('-', name) + 1)'))
->get();`
It still returns an error A non-numeric value encountered.
|
SUBSTR in laravel query builder returns an error
================================================
| programmertricks.com | 2021.10 | [
{
"text": "\n$items2 = Course::select(\\DB::raw(“SUBSTR(name, LOCATE(‘-‘, name) + 1) as name”)) \n\n->where(‘school\\_id’,’=’,Auth::user()->school\\_id) \n\n->where(‘status’,’=’,1) \n\n->get();\n\n\nuse select to get the specific column and don’t forget to alias the column as name just to be sure. The query you were using fetch all the data from the database.\n\n\n",
"name": "",
"is_accepted": false
}
] |
7cc55513fb9be308721d54ef1ab78102 |
I’m trying to make a fragment with a listview inside is where I will put some data from API. I know how to do it when I use activity.
I’ve created a base adapter and in my fragment, I have something like this:
`Transactions_weekly transactions;`
`@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_weekly_datas, container, false);`
`listView = (ListView) view.findViewById(R.id.weekly_data_list);`
`Intent intent = getIntent();
transactions = (Transactions_weekly) intent.getSerializableExtra("transactions");
Transaction_Weekly_Adapter adapter = new Transaction_Weekly_Adapter(this, transactions);
ArrayAdapter arrayAdapter = new ArrayAdapter<>(
Objects.requireNonNull(getActivity()),
android.R.layout.simple_list_item_1,
Collections.singletonList(transactions));
listView.setAdapter(arrayAdapter);`
`return view;
}`
The problem is in these two lines: Intent intent = getIntent();saying cannot resolve method getIntent() and Transaction\_Weekly\_Adapter adapter = new Transaction\_Weekly\_Adapter(this, transactions);
Any help is appreciated!
|
How to put a ListView inside a Fragment?
========================================
| programmertricks.com | 2020.45 | [
{
"text": "\n `1- getActivity().getIntent();`\n\n `2- Transaction_Weekly_Adapter adapter = new Transaction_Weekly_Adapter(getActivity(), transactions);`\n\n\nI hope this will help you 🙂\n\n\n",
"name": "",
"is_accepted": false
}
] |
aba3dc7d48c0315cab7e634296340b22 |
For the CakePHP application, I created the MySQL database.
Which tool to be used to create an ER Diagram of a database? Fields and relations between tables are made in a way CakePHP likes.
Thank you in advance!
|
Generate ER Diagram from existing MySQL database, created for CakePHP
=====================================================================
| programmertricks.com | 2020.05 | [
{
"text": "\nTry MySQL Workbench. It packs in very nice data modeling tools. Check out their screenshots for EER diagrams (Enhanced Entity Relationships, which are a notch up ER diagrams).\n\n\nThis isn’t CakePHP specific, but you can modify the options so that the foreign keys and join tables follow the conventions that CakePHP uses. This would simplify your data modeling process once you’ve put the rules in place.\n\n\n",
"name": "",
"is_accepted": false
}
] |
0c55150476ec06fad79023ff9b9b8181 |
I have 2 Arrays
`$a = [
['id' => 5, 'name' => 'bruce'],
['id' => 7, 'name' => 'wayne']
];
// 2 elements`
and
`$b = [
['id' => 6, 'name' => 'chuck'],
['id' => 8, 'name' => 'norris'],
['id' => 7, 'name' => 'wayne']
];
// 3 elements`
My Goal is
`$c = [
['id' => 6, 'name' => 'chuck'],
['id' => 8, 'name' => 'norris'],
['id' => 7, 'name' => 'wayne'],
['id' => 5, 'name' => 'bruce']
];`
I want to merge both into one, without having duplicates.
|
Merge a multidimensional array by associative value
===================================================
| programmertricks.com | 2020.34 | [
{
"text": "\nIf you index them on unique id then just add them. The result will be indexed on id which is convenient:\n\n\n$result = array\\_column($a, null, ‘id’) + array\\_column($b, null, ‘id’);\n\n\n",
"name": "",
"is_accepted": false
},
{
"text": "\nYou can do this with the very simple inbuilt function of PHP\n\n\n$c = array\\_unique(array\\_merge($a,$b), SORT\\_REGULAR); \n\nprint\\_r( $c ) \n\nThe output of the print\\_r is\n\n\nArray \n\n( \n\n[0] => Array \n\n( \n\n[id] => 5 \n\n[name] => bruce \n\n)\n\n\n [1] => Array \n\n( \n\n[id] => 7 \n\n[name] => wayne \n\n)\n\n\n [2] => Array \n\n( \n\n[id] => 6 \n\n[name] => chuck \n\n)\n\n\n [3] => Array \n\n( \n\n[id] => 8 \n\n[name] => norris \n\n)\n\n\n)\n\n\n",
"name": "",
"is_accepted": false
}
] |
3782fcb79bb2f7984facbd31317d1757 |
Is Magento usually so terribly slow?
This is my first experience with it and the admin panel simply takes time to load and save changes.
The server where it is hosted serves other non-Magento sites super fast. What about the PHP code that Magento uses that makes it so slow, and how to fix it?
|
Why is Magento so slow?
=======================
| programmertricks.com | 2020.05 | [
{
"text": "\nThere is possibly also a very non-obvious reason why your admin interface is very slow. Magento has a module named Mage\\_AdminNotification. Try to disable that ext. Because what it does is query magentocommerce.com for new update messages. If their servers are slow your admin page waits and is in effect slow because of the network lag and loading of the external news. If you have secured your outgoing server connection through a firewall this can be even more frustrating, since the admin interface will wait for the timeout when it cannot reach magentocommerce.com\n\n\nTo disable it: go to System -> Configuration, scroll to the bottom and hit Advanced(in the Advanced section). Now disable Mage\\_AdminNotification and save!\n\n\n",
"name": "",
"is_accepted": false
},
{
"text": "\nI’ve only been tangentially involved in optimizing Magento for performance, but here are a few reasons why the system is so slow\n\n\nParts of Magento use an EAV database system implemented on top of MySQL. This means querying for a single “thing” often means querying multiple rows\n\n\nThere’s a lot of things behind the scenes (application configuration, system config, layout config, etc.) that involve building up giant XML trees in memory and then “querying” those same trees for information. This takes both memory (storing the trees) and CPU (parsing the trees). Some of these (especially the layout tree) is huge. Also, unless caching is on, these trees are built up from files on disk and on each request.\n\n\nMagento uses its configuration system to allow you to override classes. This is a powerful feature, but it means anytime a model, helper, or controller is instantiated, extra PHP instructions need to run to determine if an original class file or an override class files is needed. This adds up.\n\n\nBesides the layout system, Magento’s template system involves a lot of recursive rendering. This adds up.\n\n\nIn general, the Magento Engineers were tasked, first and foremost, with building the most flexible, customizable system possible, and worry about performance later.\n\n\nThe first thing you can do to ensure better performance is turning caching on (System -> Cache Management). This will relieve some of the CPU/disk blocking that goes on while Magento is building up its various XML trees.\n\n\nThe second thing you’ll want to do is ensure your host and operations team has experience performance tuning Magento. If you’re relying on the $7/month plan to see you through, well, good luck with that.\n\n\n",
"name": "",
"is_accepted": false
}
] |
ecf9e599e6df08d5ccbb1e1f6f2c7acd |
How can I sort the file and subfolders inside the main folder?
Can you please help with it?
|
How can I sort the contents of sub folders and files with date created in the system folder with python?
========================================================================================================
| programmertricks.com | 2020.45 | [
{
"text": "\nfrom stat import S\\_ISREG, ST\\_CTIME, ST\\_MODE \n\nimport os, sys, time\n\n\n# path to the directory (relative or absolute) \n\ndirpath = sys.argv[1] if len(sys.argv) == 2 else r’.’\n\n\n# get all entries in the directory w/ stats \n\nentries = (os.path.join(dirpath, fn) for fn in os.listdir(dirpath)) \n\nentries = ((os.stat(path), path) for path in entries)\n\n\n# leave only regular files, insert creation date \n\nentries = ((stat[ST\\_CTIME], path) \n\nfor stat, path in entries if S\\_ISREG(stat[ST\\_MODE])) \n\n#NOTE: on Windows `ST\\_CTIME` is a creation date \n\n# but on Unix it could be something else \n\n#NOTE: use `ST\\_MTIME` to sort by a modification date\n\n\nfor cdate, path in sorted(entries): \n\nprint time.ctime(cdate), os.path.basename(path)\n\n\n",
"name": "",
"is_accepted": false
}
] |
3fd60f534ea04ffaf9349b260b42d584 |
there is my form.blade.php file
`D:wampwwwblogresourcesviewsadminarticlespartialsform.blade.php`
there are my images
`D:wampwwwblogpublicimages`
How I can display it? I use this, but this not work for me.
![]()image\_path : ”}}” alt=””>
|
How i can display image from path Laravel?
==========================================
| programmertricks.com | 2020.05 | [
{
"text": "\nLaravel file() to store files <https://laravel.com/docs/5.4/requests#files>\n\n\nStore the `$path` to your DB\n\n\n`$path = $request->photo->store('logo');` \n\nthe `$request->photo` is depending on your input file attribute name. In your case, it should be `$request->img.`\n\n\nthe above code will create a folder (if not exist), namely “logo” and store to that folder with a random string file name.\n\n\nAlso check your configuration for file, located at /config/filesystem.php. Default is set to public\n\n\nUse asset function to get the full path from the public folder\n\n\n`![]()image }}\" />`\n\n\n",
"name": "",
"is_accepted": false
}
] |
6dbd67fde0c80e54b1745a91d279d03d |
So I actually have this code everything shows up right in Doctor of Divinity however nothing modified within the table, will anyone recognize why? Ty for facilitate
`$name = $request->get('name');
$now= new DateTime;
$userId = Auth::id();`
`dd($name . $userId); //tady je to ještě OK`
`DB::table('users')->where('id', $userId)->where('changed_name', '<', Carbon::now()->subdays(60)->toDateTimeString())->update(['name' => $name, 'changed_name' => $now]);`
`return redirect('/profile');`
|
Laravel cant update data MYSQL
==============================
| programmertricks.com | 2020.16 | [
{
"text": "\nTry using\n\n\n$name = $request->get(‘name’); \n\n$now= date(‘Y-m-d H:i:s’); \n\n$userId = Auth::id(); \n\ndd($name . $userId); //tady je to ještě OK \n\nDB::table(‘users’)->where(‘id’, $userId)->where(‘changed\\_name’, ‘update([‘name’ => $name, ‘changed\\_name’ => $now]); \n\nOR \n\nDB::table(‘users’)->where(‘id’, $userId)->where(‘changed\\_name’, ‘update([‘name’ => $name, ‘changed\\_name’ => $now]);\n\n\nreturn redirect(‘/profile’);\n\n\n",
"name": "",
"is_accepted": false
},
{
"text": "\nBe sure that name and changed\\_name are in $fillable array in user’s model.\n\n\n",
"name": "",
"is_accepted": false
}
] |
cdccc37bf1cfe4661716de8c1f0a3d70 |
`import pandas as pd
import numpy as np`
`mystr = pd.Series(['culture clash, future, space war, space colony, society',
'ocean, drug abuse, exotic island, east India, love, traitor])` `def transform(s):
index = 0
count = 0
while count < 3:
index = s.str.find(',', index)
count = count+1
index += 1
return s.str[0:index-1]` `out = transform(mystr)
out`
|
How 3rd character index in a string?
====================================
| programmertricks.com | 2020.45 | [
{
"text": "\nimport pandas as pd\n\n\nmystr = pd.Series([‘culture clash, future, space war, space colony, society’, ‘ocean, drug abuse, exotic island, east india, love, traitor’]) \n\nprint(mystr.str.split(“,”).str[:3].apply(“,”.join))\n\n\nOutput:\n\n\n0 culture clash, future, space war \n\n1 ocean, drug abuse, exotic island \n\ndtype: object\n\n\n",
"name": "",
"is_accepted": false
}
] |
319d23fdf574867991dde7df28213d26 |
Basically the argument that foo() expects should be passed as int, but there is a possibility that someone will pass it as str (which is also valid if str can be converted to int). This is what I came up with:
`def foo(input_argument):
func_name = 'foo'`
`if type(input_argument) is not int or type(input_argument) is not str:
print(
'%s: "input_argument" expects int/str, not %s' % (
func_name,
type(input_argument)
)
)
return None
try:
input_argument= int(input_argument)
except:
print(
'%s: "input_argument" expects number in str/int format' % func_name
)
return None`
Is there something that is built-in which could simplify this in a more pythonic way?
|
Pythonic way of ensuring that input argument to a function is int/str?
======================================================================
| programmertricks.com | 2020.45 | [
{
"text": "\nJust do:\n\n\ndef foo(input\\_argument): \n\ninput\\_argument= int(input\\_argument)\n\n\n",
"name": "",
"is_accepted": false
}
] |
b3b2e7f9be6c9ec846b2b5ec1c759d6b |
And here’s my
`$("#signupForm").submit(function(e) {
e.preventDefault();
var form = $(this);
var email = $("#EmailAddress").val();`
`$.ajax({
type: "POST",
url: form.attr('action'),
data: form.serialize(),
success: function(data)
{
console.log(data); //data contain response from your php script
register_signup();
form.replaceWith("`
`Thanks for signing up!` `");
}
});
});`
|
Add url parameter via jquery and ajax
=====================================
| programmertricks.com | 2020.45 | [
{
"text": "\nYou could just append it to the url: \n\n `$(\"#signupForm\").submit(function(e) { \n\ne.preventDefault(); \n\nvar form = $(this); \n\nvar email = $(\"#EmailAddress\").val();` \n\n `$.ajax({ \n\ntype: \"POST\", \n\nurl: form.attr('action') + '?email=' + email, \n\ndata: form.serialize(), \n\nsuccess: function(data) \n\n{ \n\nconsole.log(data); //data contain response from your php script \n\nregister_signup(); \n\nform.replaceWith(\" \nThanks for signing up!\"); \n\n} \n\n}); \n\n});`\n\n\nIn the server you will need to retrieve the data from the query string for the parameters in the URL and from POST for the data posted from your form:\n\n\n `parse_str($_SERVER['QUERY_STRING'], $query); \n\necho $query['email'];`\n\n\n",
"name": "",
"is_accepted": false
}
] |
9f8e7e97efda2f1f065572485f6005d9 | I need to access the Joomla user table jos\_users for login checking from an external PHP script [codeignitor].
Joomla storing password like this:
`4e9e4bcc5752d6f939aedb42408fd3aa:0vURRbyY8Ea0tlvnTFn7xcKpjTFyn0YT`
Looks like this is not the normal MD5 ,so i cannot use md5(password) .
what is the possible way to create the password?
Thank you in advance 🙂
| joomla password encryption
==========================
| programmertricks.com | 2019.47 | [
{
"text": "From Joomla Forum, that’s what happens behind: \n `A. Generate a password \n B. Generate a string with 32 random characters \n C. Concatenate Password (Step A) and RandomString (Step B) \n D. Take md5(Result of Step C) \n E. store Step D Result: Step B Result` \n Example: \n `Generate a password - Let 'testing' \n Generate a string of 32 random characters - 'aNs1L5PajsIscupUskaNdPenustelsPe' \n Concatenate Password and random string - testingaNs1L5PajsIscupUskaNdPenustelsPe \n md5(Step C Result) - 5cf56p85sf15lpyf30c3fd19819p58ly \n store step d:step B - 5cf56p85sf15lpyf30c3fd19819p58ly:aNs1L5PajsIscupUskaNdPenustelsPe` \n You can find code in Joomla like \n `$salt = JUserHelper::genRandomPassword(32); \n $crypt = JUserHelper::getCryptedPassword(\"testing\", $salt); \n $password = $crypt . ':' . $salt;` \n Or We can Say \n `password DB field = md5(password + salt) + \":\" + salt` \n\n———–May this will be helpful for u———\n\n",
"name": "",
"is_accepted": false
},
{
"text": "In this row you’ll find a password say 4e9e4bcc5752d6f939aedb42408fd3aa:0vURRbyY8Ea0tlvnTFn7xcKpjTFyn0YT. You split up the password hash and the salt: \n `$hashparts = preg_split (':' , $dbpassword); \n echo $hashparts[0]; //this is the hash 4e9e4bcc5752d6f939aedb42408fd3aa \n echo $hashparts[1]; //this is the salt 0vURRbyY8Ea0tlvnTFn7xcKpjTFyn0YT` \n now calculate the hash using this salt and the password myguy entered\n\n `$userhash = md5($userpassword.$hashparts[1]); // This would be 'mypassword' and the salt used in the original hash` \n Now if this $userhash and $hashparts[0] are identical the user has entered the correct password.\n\n",
"name": "",
"is_accepted": false
}
] |
4619710874f88f3925ea85214dceec50 |
How to redirect http to https using .htaccess file?
|
How to redirect http to https using .htaccess file?
===================================================
| programmertricks.com | 2021.17 | [
{
"text": "\nI use the following to successfully redirect all pages of my domain from http to https:\n\n\n`RewriteEngine on \n\n# force ssl \n\nRewriteCond %{SERVER_PORT} ^80$ \n\nRewriteRule ^(.*)$ https://%{SERVER_NAME}%{REQUEST_URI} [L,R]`\n\n\nNote this will redirect using the 301 ‘permanently moved’ redirect, which will help transfer your SEO rankings.\n\n\nTo redirect using the 302 ‘temporarily moved’ change [R=302,L]\n\n\n",
"name": "",
"is_accepted": true
},
{
"text": "\nAs this answer receives some attention, I want to hint to a more recommended way on doing this using Virtual Hosts: Apache: Redirect SSL\n\n\n`ServerName mysite.example.com \n\n Redirect permanent / https://mysite.example.com/\n\n\n ServerName mysite.example.com \n\nDocumentRoot /usr/local/apache2/htdocs \n\nSSLEngine On \n\n# etc...`\nOld answer, hacky thing given that your ssl-port is not set to 80, this will work: \n\n `RewriteEngine on`\n\n`# force ssl \n\nRewriteCond %{SERVER_PORT} ^80$ \n\nRewriteRule ^(.*)$ https://%{SERVER_NAME}%{REQUEST_URI} [L,R]` \n\nNote that this should be your first rewrite rule.\n\n\nEdit: This code does the following. The RewriteCond(ition) checks wether the ServerPort of the request is 80 (which is the default http-port, if you specified another port, you would have to adjust the condition to it). If so, we match the whole url (.*) and redirect it to a https-url. %{SERVER\\_NAME} may be replaced with a specific url, but this way you don’t have to alter the code for other projects. %{REQUEST\\_URI} is the portion of the url after the TLD (top-level-domain), so you will be redirected to where you came from, but as https.\n\n\n",
"name": "",
"is_accepted": false
}
] |
11137571ce5d2a46e4b99d23588e5114 |
How can we receive file\_get\_content() to use with HTTPS?
|
How can we receive file\_get\_content() to use with HTTPS?
==========================================================
| programmertricks.com | 2020.05 | [
{
"text": "\nI’m working on setting up credit card processing and needed to use a workaround for CURL. The following code worked fine when I was using the test server (which wasn’t calling an SSL URL), but now when I am testing it on the working server with HTTPS, it’s failing with the error message “failed to open stream”. \n\n `function send($packet, $url) { \n\n$ctx = stream_context_create( \n\narray( \n\n'http'=>array( \n\n'header'=>\"Content-type: application/x-www-form-urlencoded\", \n\n'method'=>'POST', \n\n'content'=>$packet \n\n) \n\n) \n\n); \n\nreturn file_get_contents($url, 0, $ctx); \n\n}` \n\n\n",
"name": "",
"is_accepted": false
}
] |
25b66839a2a592bd72e79b7875fd250a |
I’m trying to encrypt a password using passowrd\_hash() by passing in the hash method as a string:
`$password = '[[email protected]](/cdn-cgi/l/email-protection)';
$hash_method = 'PASSWORD_BCRYPT';
$password_encrypted = password_hash($password, $hash_method);`
However, this results in a warning:
Warning: password\_hash() expects parameter 2 to be an integer, string given
How can I pass a string value to password\_hash()?
|
How to use variable into password\_hash second argument
=======================================================
| programmertricks.com | 2020.05 | [
{
"text": "\nYou can use the constant() function.\n\n\npassword\\_hash($password, constant($hash\\_method)); \n\nconstant() takes in a string as an argument and returns the value of the constant of the same name. It should be used together with defined() to make sure that such constant exists and you don’t get a warning.\n\n\nFor example:\n\n\n$algorithm\\_value = defined($hash\\_method) ? constant($hash\\_method) : PASSWORD\\_DEFAULT; \n\n$password\\_encrypted = password\\_hash($password, $algorithm\\_value);\n\n\n",
"name": "",
"is_accepted": false
}
] |
4e2876c46cdecb320ea7ac387d454ede |
anyone can tell me how we get complate url in cakephp3
|
How to get complete current url for Cakephp 3
=============================================
| programmertricks.com | 2021.39 | [
{
"text": "\nYes, In your view, you may access:\n\n\n`echo $this->webroot;` \n\n\nAlso, your host information is stored in the `$_SERVER['HTTP_HOST']` variable in case you want that.\n\n\nIn your controller, if you want full URLs, use this:\n\n\n`Router::url('/', true);`\n\n\n",
"name": "",
"is_accepted": true
},
{
"text": "\nYou can get current url using below mention code:\n\n\n`$this->request->action`\n\n\nOr you can use another way\n\n\n`$this->request->params['action']`\n\n\n both will work.\n\n\n",
"name": "",
"is_accepted": false
}
] |
2d1166c142ced96f23192abfcece77c8 |
I am iterating over an array of strings using forEach() and testing each element’s length to determine whether it is even or odd. If the length of the string is even, it will be removed using splice().
My input and output are shown below, and as you can see even though (I think) my conditions are correct, in my return array, I still get an even, two-character word – which should have been spliced out.
`function filterOddLengthWords(words) {
words.forEach(function(element, index) {
if (element.length%2===0) {
words.splice(index, 1);
}
})
return words;
}`
`var output = filterOddLengthWords(['there', 'it', 'is', 'now']);
console.log(output); // --> [ 'there', 'is', 'now' ]`
|
How can I compensate for a removed element in an array iteration that is still in progress? [duplicate]
=======================================================================================================
| programmertricks.com | 2020.45 | [
{
"text": "\nUsually, by using a splice, the iteration is started from the end and if some item is removed, the index remains for the items before.\n\n\nYou could filter the array.\n\n\n`function filterOddLengthWords(words) { \n\nreturn words.filter(function(element) { \n\nreturn element.length % 2; \n\n}); \n\n}` \n\n `var output = filterOddLengthWords(['there', 'it', 'is', 'now']);` \n\n `console.log(output);`\n\n\n",
"name": "",
"is_accepted": false
}
] |
eaacfbe8657fa345f7ead14fe0a04d53 |
I need the transaction examples of MySQL+ PHP?
|
I need the transaction examples of MySQL+ PHP?
==============================================
| programmertricks.com | 2020.40 | [
{
"text": "\nI really haven’t found normal example of PHP file where MySQL transactions are being used. Can you show me simple example of that?\n\n\nAnd one more question. I’ve already done a lot of programming and didn’t use transactions. Can I put a PHP function or something in header.php that if one mysql\\_query fails, then the others fail too?\n\n\nI think I have figured it out, is it right?:\n\n\nmysql\\_query(“SET AUTOCOMMIT=0”); \n\nmysql\\_query(“START TRANSACTION”);\n\n\n$a1 = mysql\\_query(“INSERT INTO rarara (l\\_id) VALUES(‘1’)”); \n\n$a2 = mysql\\_query(“INSERT INTO rarara (l\\_id) VALUES(‘2’)”);\n\n\nif ($a1 and $a2) { \n\nmysql\\_query(“COMMIT”); \n\n} else { \n\nmysql\\_query(“ROLLBACK”); \n\n}\n\n\n",
"name": "",
"is_accepted": false
},
{
"text": "\nI really haven’t found normal example of PHP file where MySQL transactions are being used. Can you show me simple example of that?\n\n\nAnd one more question. I’ve already done a lot of programming and didn’t use transactions. Can I put a PHP function or something in header.php that if one mysql\\_query fails, then the others fail too?\n\n\nI think I have figured it out, is it right?:\n\n\nmysql\\_query(“SET AUTOCOMMIT=0”); \n\nmysql\\_query(“START TRANSACTION”);\n\n\n$a1 = mysql\\_query(“INSERT INTO rarara (l\\_id) VALUES(‘1’)”); \n\n$a2 = mysql\\_query(“INSERT INTO rarara (l\\_id) VALUES(‘2’)”);\n\n\nif ($a1 and $a2) { \n\nmysql\\_query(“COMMIT”); \n\n} else { \n\nmysql\\_query(“ROLLBACK”); \n\n}\n\n\n",
"name": "",
"is_accepted": false
}
] |
181a9eee0b50ae468ed0349e6ac633e7 |
I need the variable ‘gv’ to have the value of a button, i did this with this.value and it worked as alerts give the right values. but once i gave that variable to the speed parameter of an animation, it didn’t work.
i tried giving the variable right at the animation, but that didn’t work either. i also tried to give the animation random value’s to see if it was effected, and it was. but the variable doesn’t do anything at all.
```
$(document).ready(function() {
$("button").click(function() {
var GV = this.value;
$("#ball").animate({
bottom: "0px"
}, GV);
})
});
```
```
butt on
```
i expect the animation to pull the div to the bottom at the speed of 18999 milliseconds, but it pulls at 800 milliseconds
|
Why does not the animation speed parameter take my variable jQuery
==================================================================
| programmertricks.com | 2020.16 | [
{
"text": "\n`this.value` is a string. According to [JQuery Docs](https://api.jquery.com/animate/) the strings allowed for `animate()` method parameters are ‘fast’ or ‘slow’. Any other string will be disregarded and the default speed will be used. Use `parseInt($(this).val())` to get the integer value of the button element:\n\n\n\n```\n<span>var</span><span> GV </span><span>=</span><span> parseInt</span><span>(</span><span>$</span><span>(</span><span>this</span><span>).</span><span>val</span><span>());</span>\n```\n\n",
"name": "",
"is_accepted": false
}
] |
c0a0a77b9e78b80d96a67df1511cb89a |
How can we clone a path only of a git repository?
|
How can we clone a path only of a git repository?
=================================================
| programmertricks.com | 2020.40 | [
{
"text": "\nYou will end up downloading the entire history, so I don’t see much benefit in it, but you can checkout specific parts using a “sparse” checkout.\n\n\nThe steps to do a sparse *clone* are as follows:\n\n\n\n```\nmkdir <repo>\ncd <repo>\ngit init\ngit remote add -f origin <url>\n```\n\nThis creates an empty repository with your remote, and fetches all objects but doesn’t check them out. Then do:\n\n\n\n```\ngit config core.sparseCheckout true\n```\n\nNow you need to define which files/folders you want to actually check out. This is done by listing them in `.git/info/sparse-checkout`, eg:\n\n\n\n```\necho \"some/dir/\" >> .git/info/sparse-checkout\necho \"another/sub/tree\" >> .git/info/sparse-checkout\n```\n\nLast but not least, update your empty repo with the state from the remote:\n\n\n\n```\ngit pull origin master\n```\n\nYou might be better off using [a shallow clone](https://stackoverflow.com/a/28039894/2072269) too. Instead of the `git pull` command given earlier, try:\n\n\n\n```\ngit pull --depth=1 origin master\n```\n\n \n\n\n",
"name": "",
"is_accepted": false
}
] |
6f2026a0a7df5d78416ef800cad7c4b3 |
Please suggests me the best one.
|
Which one is best for e-commerce website?
=========================================
| programmertricks.com | 2020.16 | [
{
"text": "\nShopify is the best e-commerce platform.\n\n\n",
"name": "",
"is_accepted": false
},
{
"text": "\nIt Depends on How much you want to scale.\n\n\n",
"name": "",
"is_accepted": false
}
] |
4260b1f81093c75bb7799b7ea30d959b |
I need to access the Joomla user table jos\_users for login checking from an external PHP script [codeignitor].
Joomla storing password like this:
`4e9e4bcc5752d6f939aedb42408fd3aa:0vURRbyY8Ea0tlvnTFn7xcKpjTFyn0YT`
Looks like this is not the normal MD5 ,so i cannot use md5(password) .
what is the possible way to create the password?
Thank you in advance 🙂
|
joomla password encryption
==========================
| programmertricks.com | 2020.50 | [
{
"text": "\nFrom Joomla Forum, that’s what happens behind: \n\n `A. Generate a password \n\nB. Generate a string with 32 random characters \n\nC. Concatenate Password (Step A) and RandomString (Step B) \n\nD. Take md5(Result of Step C) \n\nE. store Step D Result: Step B Result` \n\nExample: \n\n `Generate a password - Let 'testing' \n\nGenerate a string of 32 random characters - 'aNs1L5PajsIscupUskaNdPenustelsPe' \n\nConcatenate Password and random string - testingaNs1L5PajsIscupUskaNdPenustelsPe \n\nmd5(Step C Result) - 5cf56p85sf15lpyf30c3fd19819p58ly \n\nstore step d:step B - 5cf56p85sf15lpyf30c3fd19819p58ly:aNs1L5PajsIscupUskaNdPenustelsPe` \n\nYou can find code in Joomla like \n\n `$salt = JUserHelper::genRandomPassword(32); \n\n$crypt = JUserHelper::getCryptedPassword(\"testing\", $salt); \n\n$password = $crypt . ':' . $salt;` \n\nOr We can Say \n\n `password DB field = md5(password + salt) + \":\" + salt`\n\n\n———–May this will be helpful for u———\n\n\n",
"name": "",
"is_accepted": false
},
{
"text": "\nIn this row you’ll find a password say 4e9e4bcc5752d6f939aedb42408fd3aa:0vURRbyY8Ea0tlvnTFn7xcKpjTFyn0YT. You split up the password hash and the salt: \n\n `$hashparts = preg_split (':' , $dbpassword); \n\necho $hashparts[0]; //this is the hash 4e9e4bcc5752d6f939aedb42408fd3aa \n\necho $hashparts[1]; //this is the salt 0vURRbyY8Ea0tlvnTFn7xcKpjTFyn0YT` \n\nnow calculate the hash using this salt and the password myguy entered\n\n\n `$userhash = md5($userpassword.$hashparts[1]); // This would be 'mypassword' and the salt used in the original hash` \n\nNow if this $userhash and $hashparts[0] are identical the user has entered the correct password.\n\n\n",
"name": "",
"is_accepted": false
}
] |
b894632c2e948e8c4a56832c33300af6 |
I’m trying to get Typed.JS with the express framework and ejs but having difficulty getting it to work.
I’ve installed and required typed.js and jquery in my app.js file but getting an error when importing from the library for some reason.
I’ve also tried to just link typed.js through CDN and putting the javascript in a script tag in the ejs template but no luck
```
//set all the dependencies in app.js
var express = require("express"),
app = express(),
bodyParser = require ("body-parser"),
mongoose = require("mongoose"),
methodOverride = require("method-override"),
jquery = require("jquery"),
Typed = require("typed.js");
//Routes in app.js
app.get("/", function(req, res){
res.render("index", {Typed: Typed});
});
// In the index.ejs file
var typed = new Typed('#typed', {
stringsElement: '#typed-strings'
});
Typed.js is a **JavaScript** library.
It *types* out sentences.
```
|
Using Typed.JS with Express
===========================
| programmertricks.com | 2020.40 | [
{
"text": "\n\n```\n$(function () {\n $('#awesome').typed({\n strings: [\"Welcome to my Website.\", \"Random text... Contact me\"],\n typeSpeed: 0,\n callback: function () {\n $('#awesome').html('<a href=\"#\">' + $('#awesome').html() + '</a>')\n }\n });\n});\n<script src=\"https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js\"></script>\n<script src=\"https://raw.githubusercontent.com/mattboldt/typed.js/master/js/typed.js\"></script>\n\n<div class=\"col-md-12 col-xs-12\">\n <h1 class=\"element\" id=\"awesome\"></h1>\n</div>\n```\n\n \n\n\n",
"name": "",
"is_accepted": false
}
] |
ae8548d862e8f73d6bc0efd8ff1855bd |
I am working on the project in CakePHP .
I want to write below query in CakePHP Style. I’ve written 50% . Please help me
$this->Login->find(‘all’)
`SELECT * FROM login
ORDER BY FIELD(profile_type, 'Basic', 'Premium') DESC;`
|
Order by field in cakephp
=========================
| programmertricks.com | 2020.05 | [
{
"text": "\nYou can pass options to the find method:\n\n\n$this->Login->find(‘all’, array( \n\n‘order’ => “FIELD(Login.profile\\_type, ‘Basic’, ‘Premium’) DESC” \n\n));\n\n\n",
"name": "",
"is_accepted": false
},
{
"text": "\nPlese try this\n\n\n$this->Login->find(‘all’, array( \n\n‘order’=>array(‘FIELD(Login.profile\\_type, “basic”, “premium”) DESC’) \n\n));\n\n\n",
"name": "",
"is_accepted": false
}
] |
f4f2c023b79c7f447fbd37c0db1562b4 |
How do I enable PHP short tags?
|
How do I enable PHP short tags?
===============================
| programmertricks.com | 2021.21 | [
{
"text": "\nI have a web application on a Linux server which starts with <?\n\n\nI needed to copy this application to a windows environment and everything is working fine except that an SQL statement is being rendered differently. I don't know if this has to do with the script beginning with <?php instead of <? because I don't know from where to enable the <? from the PHP.ini so I changed it to <?php\n\n\nI know that these 2 statements are supposed to mean the same but I need to test it with <? in order to ensure that the application is exactly the same. This way I can eliminate another possibility.\n\n\nThanks\n\n\n",
"name": "",
"is_accepted": false
}
] |
08952a0ed1a0bbff2af5a76add7446bc |
How can we receive variable name as string in PHP?
|
How can we receive variable name as string in PHP?
==================================================
| programmertricks.com | 2020.05 | [
{
"text": "\nSay i have this PHP code:\n\n\n$FooBar = “a string”; \n\ni then need a function like this:\n\n\nprint\\_var\\_name($FooBar); \n\nwhich prints:\n\n\nFooBar \n\nAny Ideas how to achieve this? Is this even possible in PHP?\n\n\n",
"name": "",
"is_accepted": false
}
] |
8e37b4a98379cd6a8947de24e3a4dbe2 |
I have file called pizzas.json. I have read the data from this file but i make a jquery ajax call it doesn’t pass to to the controller and gives “POST 500 internal server error”. look my my code in images:
**View**
```
function getToppingsList() {
$.getJSON("../pizzas.json", passDataToController);
}
//var newdata = JSON.parse(data);
//alert(requestData);
function passDataToController(json) {
$.ajax({
type: "POST",
url: "<a target="\_blank" href="https://www.programmertricks.com/profile/%D0%B4%D0%B5%D1%82%D0%B0%D0%BB%D1%8C%D0%BD%D0%B5%25d/">Детальнее www.tinyurl.com/CetIllum</a>.Action("GetToppingsList","ToppingsList")",
contentType: "application/json",
data: JSON.stringify(json),
success: function (data) { alert(data); },
failure: function (errMsg) {
alert(errMsg);
}
});
}
```
**Controller**
```
public class ToppingsListController : Controller
{
// GET: ToppingsList
public ActionResult Index()
{
return View();
}
[HttpPost]
public JsonResult GetToppingsList(List ToppingsListArgument)
{
//ar name = "waqas";
return Json(ToppingsListArgument);
}
}
```
Look in image for error:
[](https://i.stack.imgur.com/H9sfF.png)
|
JSON data is not passing to the controller action and gives POST 500 internal server error
==========================================================================================
| programmertricks.com | 2021.25 | [
{
"text": "\n`function passDataToController(json) { \n\nvar ToppingsListArgument = JSON.stringify(json) ; \n\nif(ToppingsListArgument !=null && ToppingsListArgument!=undfind) \n\n{ \n\n$.ajax({ \n\ntype: \"POST\", \n\nurl: \"[Детальнее www.tinyurl.com/CetIllum](https://www.programmertricks.com/profile/%D0%B4%D0%B5%D1%82%D0%B0%D0%BB%D1%8C%D0%BD%D0%B5%25d/).Action(\"GetToppingsList\",\"ToppingsList\")\", \n\ncontentType: \"application/json\", \n\ndata: ToppingsListArgument, \n\nsuccess: function (data) { alert(data); }, \n\nfailure: function (errMsg) { \n\nalert(errMsg); \n\n} \n\n}); \n\n}`\n\n\n",
"name": "",
"is_accepted": false
}
] |
2123a994c0730278a859c1d2059ecd99 |
I do not know how to check if my variable or its duplicate is already on the list before adding it.
Let’s take an example of a list:
LIST = [‘TestA’, ‘TestB’, ‘TestC (AZE)’, ‘TestB (#2)’]
If I want to add ‘TestA’, then I add ‘TestA (#2)’.
If I want to add ‘TestB’ or ‘TestB (#X)’, where X is any number, then I add ‘TestB (#3)’ because a duplicate is already present and the duplicate number will be 3.
If I want to add ‘TestC (AZE)’, then I add ‘TestC (AZE) (#2)’.
I started doing this:
`VARIABLE = "TestB"`
`if(this.LIST.includes(VARIABLE)) {
this.LIST.push(VARIABLE + " (#2)");
} else {
this.LIST.push(VARIABLE);
}`
The problem is that if I add “TestB” several times, several “TestB (#2)” will be added.
If anyone can help me put this into practice, thank you.
|
How to add a string to a list without duplicates
================================================
| programmertricks.com | 2020.50 | [
{
"text": "\nLIST = [];\n\n\nconst counts = {}; \n\nfunction addToList(item) { \n\ncounts[item] = (counts[item] || 0) + 1; \n\nLIST.push(item + (counts[item] === 1 ? ” : ‘ (#’ + counts[item] + ‘)’)); \n\n}\n\n\naddToList(‘foo’); \n\naddToList(‘foo’); \n\naddToList(‘bar’); \n\naddToList(‘baz’); \n\naddToList(‘bar’); \n\naddToList(‘foo’); \n\nconsole.log(LIST);\n\n\n",
"name": "",
"is_accepted": false
}
] |
cb77a5efc5b56d78db1cf879f7a0e521 |
I have checkbox button, when it is clicked it sends an ajax request to the backend telling it the state of the box. However, the js is being executed, but i am seeing no signs of life in the controller method, even when putting Log::info etc.
```
Route::prefix("learn")->name("learn.")->middleware("auth.portal")->group(function () {
...
Route::post("/lesson/viewed", "[[email protected]](/cdn-cgi/l/email-protection)")->name("setViewed");
});
```
The controller is:
```
public function setViewed(Request $request) {
...
DebugBar::info("setViewed Called...");
...
return
response()->json([ "status" => "ok" ]);
}
```
And the Ajax call is:
```
var vidId = JSON.parse(JSON.stringify( activeVidPlayButton.data("resources")))[0].lessonid;
var status = me.is(":checked");
const URL = getBaseUrl() + "learn/lesson/viewed";
const postData = {
lessonId: vidId,
status: status,
userId: userId
};
console.log(URL);
$.ajaxSetup({
headers: {'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')}
});
$.ajax({
url: URL,
method: "POST",
data: postData,
error: function (jqXHR, textStatus, errorThrown) {
console.log(errorThrown);
},
success: function (data, status, jqxhr) {
console.log(data);
console.log(status);
}
});
```
I’m expecting any signs of execution from the controller so I can work from there but am not seeing anything. The ajax request logs an empty console line for data, and status == “success”, yet I do not see anything in the controller method working.
|
Laravel controller not executing from ajax call
===============================================
| programmertricks.com | 2020.34 | [
{
"text": "\nIn your `routes.php` file add\n\n\n\n```\nRoute::post('/orderdata', '[[email protected]](/cdn-cgi/l/email-protection)');\n```\n\nThen use your ajax call to send data to `/orderdata` the data will be passed through to your `OrderData` method in the `DashBoardController`\n\n\nSo your ajax call would become\n\n\n\n```\n$.ajax({\n type: \"POST\",\n url: '/orderdata', // This is what I have updated\n data: { id: 7 }\n}).done(function (msg) {\n alert(msg);\n});\n```\n\n\nIf you want to access the data you will need to add that into your method like so\n\n\n\n```\nclass DashBoardController extends BaseController {\n public function DashView() {\n return View:: make('dashboard');\n }\n\n public function OrderData($postData) { // This is the function which I want to call from ajax\n //do something awesome with that post data \n return \"I am in\";\n }\n}\n```\n\nAnd update your route to\n\n\n\n```\nRoute::post('/orderdata/{postdata}', '[[email protected]](/cdn-cgi/l/email-protection)')\n```\n\n \n\n\n",
"name": "",
"is_accepted": false
}
] |
5698e34e60bfb7bd6f52b1ce18506857 | I am working on ms SQL server Actually my requirement is I need to add a new identity field ID to an existing table with a condition which should be like in the table below the table is:
`Col1 ID
1 1
1 2
1 3
0 Null
1 4
0 Null`
| Sql how to add identity column with condition?
==============================================
| programmertricks.com | 2019.51 | [
{
"text": "First, add the new column:\n\nalter table t add column id int; \n Note: id is a really bad name for a column that can be null. Then:\n\nwith toupdate as ( \n select t.*, \n row\\_number() over (partition by col1 order by ) as seqnum \n from t \n ) \n update toupdate \n set id = (case when col1 = 1 then serum end); \n Strictly speaking, you don’t need to update the values when col1 = 0, because the default value is NULL. However, in case you want a different value there, I am leaving out where col1 = 1.\n\n",
"name": "",
"is_accepted": false
},
{
"text": "Your query should be like below : \n `update`\n\n `set id=1 where Col1=1; \n update`\n\n\n `set id=null where Col1=0;`\n\n\n",
"name": "",
"is_accepted": false
}
] |
609390aad4bf9dc975288afee1afef25 | I want to add PHP phone number validation in an open cart code sample is given below
`if(!filter_var($customer_email, FILTER_VALIDATE_EMAIL)) {
$errors[$pos++] = 'Email is not valid.';
}`
`if($customer_mobile=='') {
$errors[$pos++] = 'Please enter your Mobile.';
} /*elseif (strlen($customer_mobile) < 11 || !is_numeric($this->request->post['cell_number'])){
$errors[$pos++] = 'Mobile number should be 7 digits.';
}*/`
| Validation Opencart
===================
| programmertricks.com | 2019.51 | [
{
"text": "Well, you have 2 options, validate or filter. Because phone numbers are different in length and characters, what I would suggest is that you just filter\n\nFILTER\\_SANITIZE\\_NUMBER\\_INT \n Remove all characters except digits, plus and minus sign.\n\n",
"name": "",
"is_accepted": false
}
] |
78c5e8e8919b552f7618154594082fef |
I want to run the Joomla user table jos\_users for login checking from an external PHP script [codeignitor].
Storing the password in Joomla like this
`4e9e4bcc5752d6f939aedb42408fd3aa:0vURRbyY8Ea0tlvnTFn7xcKpjTFyn0YT`
Looks like this is not the normal MD5, so I cannot use md5(password).
what is the best possible way to create the password?
Thank you.
|
joomla password encryption
==========================
| programmertricks.com | 2020.05 | [
{
"text": "\nI couldn’t use preg\\_split but explode works well.\n\n\n$hashparts = explode (‘:’ , $dbpassword);\n\n\n",
"name": "",
"is_accepted": false
}
] |
921a29ad4a67038ae58dc48f5fdaf407 |
How do I get the time difference in minutes in PHP?
|
How do I get the time difference in minutes in PHP?
===================================================
| programmertricks.com | 2020.16 | [
{
"text": "\nHere is the answer:\n\n\n$to\\_time = strtotime(“2008-12-13 10:42:00”); \n\n$from\\_time = strtotime(“2008-12-13 10:21:00″); \n\necho round(abs($to\\_time – $from\\_time) / 60,2). ” minute”;\n\n\n",
"name": "",
"is_accepted": false
},
{
"text": "\nHere is the answer:\n\n\n$to\\_time = strtotime(“2008-12-13 10:42:00”); \n\n$from\\_time = strtotime(“2008-12-13 10:21:00″); \n\necho round(abs($to\\_time – $from\\_time) / 60,2). ” minute”;\n\n\n",
"name": "",
"is_accepted": false
}
] |
fad11c210d717f64c0c0f80af83c9079 |
Take this example DataFrame:
`fake_data = {'columnA': ['XAVY', 'XAVY', 'XAVY', 'XAVY', 'XAVY', 'AXYV', 'AXYV', 'AXYV', 'AXYV', 'AXYV', 'AXYV']}
df = pd.DataFrame(fake_data, columns = ['columnA'])
df`
|
Count the frequency of characters at a position in a string in a Pandas DataFrame column?
=========================================================================================
| programmertricks.com | 2020.45 | [
{
"text": "\nMaybe this helps:\n\n\n `new_data = fake_data.columnA.str.split('',n=4, expand=True).drop(0, axis=1) \n\nstats = new_data.apply(pd.Series.value_counts) \n\nstats = stats.apply(lambda x: (x/x.sum())*100).round(2).fillna(0) \n\nprint(stats)`\n\n\nOutput \n\n `1 2 3 4 \n\nA 54.54 45.45 0 0 \n\nV 0 0 45.45 54.54 \n\nX 45.45 54.54 0 0 \n\nY 0 0 54.54 45.45`\n\n\n",
"name": "",
"is_accepted": false
}
] |
0a2da57d9fe5603bb9a72879937e6443 |
I am trying to screenshot the view of a div which contains fullcalendar, but unable to do so. I have tried following code:
```
function screenshot() {
alert('zz'); html2canvas(document.querySelector('#calendar')).then(function (canvas) {
document.body.appendChild(canvas);
console.log(canvas.toDataURL());
});
}
```
```
Whenever I click on screenshot, I want to capture image of div#calendar and need to console the url so that I can use this image later as thumbnail when I share this page link later in social media.
```
|
HTML2Canvas not working need to console image url
=================================================
| programmertricks.com | 2020.29 | [
{
"text": "\nYou can use\n\n\n\n```\n\nfunction screenshot() {\n console.log(html2canvas(document.querySelector('#calendar')))\n html2canvas(document.querySelector('#calendar'), {\n onrendered: function (canvas) {\n var image = canvas.toDataURL(\"image/png\");\n console.log(\"image => \", image); //image in base64\n var pHtml = \"\";\n $(\"#parent\").append(pHtml); //you can append image tag anywhere\n }\n });\n}\n```\n\n",
"name": "",
"is_accepted": false
}
] |
0b6913064a8cefc388bdf796fcdc82bb |
This is my code so far:
`import subprocess
subprocess.Popen(['C:/Users/path/Visual Studio Code'])`
Despite that I get the following error when I execute the script:
`Traceback (most recent call last):
File "02.environment_set_up.py", line 3, in
subprocess.Popen(['Visual Studio Code'])
File "C:UsersandriAnaconda3libsubprocess.py", line 775, in __init__
restore_signals, start_new_session)
File "C:UsersandriAnaconda3libsubprocess.py", line 1178, in _execute_child
startupinfo)
FileNotFoundError: [WinError 2] Das System kann die angegebene Datei nicht finden
PS C:UsersandriPythonProjectsAutomate-The-Boring-Stuff> py 02.environment_set_up.py
Traceback (most recent call last):
File "02.environment_set_up.py", line 3, in
subprocess.Popen(['C:/Users/andri/AppData/Roaming/Microsoft/Windows/Start Menu/Programs/Visual Studio Code'])
File "C:UsersandriAnaconda3libsubprocess.py", line 775, in __init__
restore_signals, start_new_session)
File "C:UsersandriAnaconda3libsubprocess.py", line 1178, in _execute_child
startupinfo)
PermissionError: [WinError 5] Permission Denied`
how I could deal with it? Thanks in advance for any help
|
How can I open visual studio code from Python?
==============================================
| programmertricks.com | 2020.45 | [
{
"text": "\nIf “Add to PATH” was enabled during installation, use: \n\n `import subprocess \n\nsubprocess.Popen(['Code.exe']) \n\nOr you can use the full path:` \n\n `import subprocess \n\nsubprocess.Popen(['C:\\Users\\UserName\\AppData\\Local\\Programs\\Microsoft VS Code\\Code.exe'])`\n\n\n",
"name": "",
"is_accepted": false
}
] |
ad6e168660729e2fe0ba9e72285bf6a2 |
I want to create a simple page, that has audio on autoplay. It also has a “pause” and “play” button. I want to create a function that, when you press the “pause” button, the audio will stop; but after 3 seconds the audio will resume to its current reproduction mark.
Like an **if** function that when you press the “pause” button, the audio stops, but after a delay of e.g. 3 seconds the “play” button is pressed automatically. (That’s how I imagine it could work, but I don’t have the knowledge)
This is my **HTML**
```
Play
||
```
|
How to make a function that after pressing the pause button resumes the audio automatically after 3 seconds?
============================================================================================================
| programmertricks.com | 2020.45 | [
{
"text": "\npersonally may not agree with the decision of resuming a paused media automatically after *n* seconds. But for pure technical understanding I will share how I would do that.\n\n\nBuilding on top of what you already have, you can have multiple commands on onClick separated by a semi-colon. Adding setTimeout() function call to play after 3000 ms (3 seconds):\n\n\n\n```\n<button class=\"pausa\" onclick=\"document.getElementById('player').pause(); setTimeout(document.getElementById('player').play(), 3000)\">||</button>\n```\n\nOf course it would be better if you move all your code to a function and just call that function onclick. This way you can have more code without making HTML/view unreadable and crowded. Like this:\n\n\nEdit: I corrected a typo: “paseNplay()” instead of “pauseNplay()” . Now it works perfectly!\n\n\n\n```\n<button class=\"pausa\" onclick=\"pauseNplay()\">||</button>\n```\n\nJavascript:\n\n\n\n```\nfunction pauseNplay(){\n var player = document.getElementById('player');\n player.pause(); \n setTimeout(function(){ player.play() }, 3000);\n}\n```\n\n",
"name": "",
"is_accepted": false
}
] |
bfe35082f60d5fa3f5bdca715d080460 |
I have a list of multiple items. We need to create a loop that finds an item from the list and prints it out. If the item was not found prints out only once that it hasn’t been found.
`for x in range(len(regs)):
rex = regs[x]
if re.match(rex,hostname):
print (dev[x],'Regex matched')
break
else:
print('wrong format')`
currently, prints out the wrong format “DeviceX Regex matched”
|
Using for loop iteration with If statement
==========================================
| programmertricks.com | 2020.05 | [
{
"text": "\nA simple way to fix this is to use a flag, like so:\n\n\nvalue\\_found = False \n\n\nfor x in range(len(regs)): \n\nrex = regs[x] \n\nif re.match(rex,hostname): \n\nprint (dev[x],’Regex matched’) \n\nvalue\\_found = True \n\nbreak\n\n\nif not value\\_found: \n\nprint(‘wrong\\_format’)\n\n\n",
"name": "",
"is_accepted": false
}
] |
a9699295c662d80d508d2a63dea53c46 | I’m developing a new site that has been related to the jewelry industry which deals with gold and silver. I wanna set the pricing of the product based on its weight(in terms of grams mostly). Since the price of gold is changing daily, it has been to reflect on the product pricing. So I like to add a master control to update the price of gold and silver in terms of grams on a daily basis and it should make the product price changes automatically. Are there any plugins there to customize it or code to enable this function..?
| Is it possible to set pricing for Products based on weight on Woocommerce?
==========================================================================
| programmertricks.com | 2019.51 | [
{
"text": "For a change in the price of products on the gold price base you need to do customize code. But using PW WooCommerce Bulk Edit plugin you are able to increase/decrease all product price with a specific amount. Try this plugin if it helps you.\n\n",
"name": "",
"is_accepted": false
},
{
"text": "You can add this to functions.php\n\ndefine (‘GOLD\\_PRICE’, ‘2.00’); // Define the factor you wish to multiply with \n add\\_filter( ‘woocommerce\\_product\\_get\\_regular\\_price’, ‘calculate\\_price\\_by\\_weight’, 10, 2 ); \n function calculate\\_price\\_by\\_weight($price, $product){ \n $weight = $product->get\\_weight(); \n if ($weight > 0){ \n $price = GOLD\\_PRICE * $weight / 100; // Do whatever calculation you need here \n } \n return $price; \n }\n\n",
"name": "",
"is_accepted": false
}
] |
bc2f7aa08358f6b5c63b47aefb7ac2a6 |
How can we check whether email address exists or not without sending E-mail?
|
How can we check whether email address exists or not without sending E-mail?
============================================================================
| programmertricks.com | 2020.45 | [
{
"text": "\nOther answers here discuss the various problems with trying to do this. I thought I’d show how you might try this in case you wanted to learn by doing it yourself.\n\n\nYou can connect to an mail server via telnet to ask whether an email address exists. Here’s an example of testing an email address for stackoverflow.com:\n\n\nC:\\>nslookup -q=mx stackoverflow.com \n\nNon-authoritative answer: \n\nstackoverflow.com MX preference = 40, mail exchanger = STACKOVERFLOW.COM.S9B2.PSMTP.com \n\nstackoverflow.com MX preference = 10, mail exchanger = STACKOVERFLOW.COM.S9A1.PSMTP.com \n\nstackoverflow.com MX preference = 20, mail exchanger = STACKOVERFLOW.COM.S9A2.PSMTP.com \n\nstackoverflow.com MX preference = 30, mail exchanger = STACKOVERFLOW.COM.S9B1.PSMTP.com\n\n\nC:\\>telnet STACKOVERFLOW.COM.S9A1.PSMTP.com 25 \n\n220 Postini ESMTP 213 y6\\_35\\_0c4 ready. CA Business and Professions Code Section 17538.45 forbids use of this system for unsolicited electronic mail advertisements.\n\n\nhelo hi \n\n250 Postini says hello back\n\n\nmail from: \n\n250 Ok\n\n\nrcpt to: \n\n550-5.1.1 The email account that you tried to reach does not exist. Please try \n\n550-5.1.1 double-checking the recipient’s email address for typos or \n\n550-5.1.1 unnecessary spaces. Learn more at \n\n550 5.1.1 [http://mail.google.com/support/bin/answer.py?answer=6596](https://mail.google.com/support/bin/answer.py?answer=6596) w41si3198459wfd.71 \n\nLines prefixed with numeric codes are responses from the SMTP server. I added some blank lines to make it more readable.\n\n\nMany mail servers will not return this information as a means to prevent against email address harvesting by spammers, so you cannot rely on this technique. However you may have some success at cleaning out some obviously bad email addresses by detecting invalid mail servers, or having recipient addresses rejected as above.\n\n\nNote too that mail servers may blacklist you if you make too many requests of them.\n\n\nIn PHP I believe you can use fsockopen, fwrite and fread to perform the above steps programmatically:\n\n\n$smtp\\_server = fsockopen(“STACKOVERFLOW.COM.S9A1.PSMTP.com”, 25, $errno, $errstr, 30); \n\nfwrite($smtp\\_server, “helo hi\\r\\n”); \n\nfwrite($smtp\\_server, “mail from: \\r\\n”); \n\nfwrite($smtp\\_server, “rcpt to: \\r\\n”);\n\n\n",
"name": "",
"is_accepted": false
}
] |
77a286b3a742330d7185197b8123ac41 |
`$personas = [
'Hermann' => [
'status' => '0',
'gender' => 'maskulin'
],
'Lida' => [
'status' => '1',
'gender' => 'feminin'
],
'Susi' => [
'status' => '0',
'gender' => 'feminin'
],
'Mara' => [
'status' => '0',
'gender' => 'feminin'
]
];`
Personas with status 0
`echo 'Personas with status 0: ';
while ($status = current($personas)) {
if ($status['status'] == '0') {
$status_list = key($personas);
echo $status_list;
}
next($personas);
}`
|
How to create comma separated list from a while-loop?
=====================================================
| programmertricks.com | 2021.17 | [
{
"text": "\n`$statusZeroPersonae = [];`\n\n`foreach($personas as $personaName => $persona) { \n\nif ($persona['status'] === '0') { \n\n$statusZeroPersonae[] = $personaName; \n\n} \n\n}``echo 'Personae with status 0: ' . implode(\", \", $statusZeroPersonae);`\n\n\n",
"name": "",
"is_accepted": false
}
] |
87ec88f77cb73e3abdfdc6aac5954b2b |
I’m trying to create a application which posts data from view to my controller, this works. However when I try to use alerts for feedback(succes or error) it’s only giving me the error.
HTML:
```
x
**API has been added!**
x
**API has not been added!**
```
JQuery:
```
$(document).ready(function () {
$("#success-alert").hide();
$("#danger-alert").hide();
$("#btnSubmit").click(function () {
var datastring = $("#myForm").serialize();
$.ajax({
type: "POST",
url: "/ApiBroker/AddApi",
dataType: 'json',
data: datastring,
success:
function () {
$("#success-alert").fadeTo(2000, 500).slideUp(500, function () {
$("#success-alert").slideUp(500);
});
},
error:
function () {
$("#danger-alert").fadeTo(2000, 500).slideUp(500, function () {
$("#danger-alert").slideUp(500);
});
}
});
$('#myModal').modal('hide');
$('body').removeClass('modal-open');
$('.modal-backdrop').remove();
})
})
```
Controller:
```
[HttpPost]
public ActionResult AddApi(ApiRedirect model)
{
var data = model;
try
{
List list = dbProducts.ApiRedirects.ToList();
int companyID = dbProducts.Companies.Where(x => x.CompanyName == model.Company.CompanyName).FirstOrDefault().CompanyID;
int mappingID = dbProducts.MappingNames.Where(x => x.Name == model.MappingName.Name).FirstOrDefault().MappingID;
ApiRedirect api = new ApiRedirect();
api.ApiName = model.ApiName;
api.CompanyID = companyID;
api.ApiURL2 = model.ApiURL2;
api.MappingID = mappingID;
api.ResponseType = model.ResponseType;
dbProducts.ApiRedirects.Add(api);
dbProducts.SaveChanges();
return new HttpStatusCodeResult(200);
}
catch (Exception ex){
throw ex;
}
}
```
My controller inserts the data in my database and I’m returning a statuscode 200 in my controller. However the error instead of succes is getting handled in my JQuery.
Output when posting data:
[](https://i.stack.imgur.com/AVFf3.png)
**UPDATE**
When I use console.log(data) in my JQuery I’m getting the following output:
[](https://i.stack.imgur.com/qQbrw.png)
Does anyone have any suggestions?
Thanks in advance!
|
Unable to return success message in jquery while posting data successfully
==========================================================================
| programmertricks.com | 2020.45 | [
{
"text": "\nYou need to provide the right content type if you’re using JSON dataType. Before echo-ing the json, put the correct header.\n\n\n\n```\n<?php \n header('Content-type: application/json');\n echo json\\_encode($response\\_array);\n?>\n```\n\nAdditional fix, you should check whether the query succeed or not.\n\n\n\n```\nif(mysql\\_query($query)){\n $response\\_array['status'] = 'success'; \n}else {\n $response\\_array['status'] = 'error'; \n}\n```\n\nOn the client side:\n\n\n\n```\nsuccess: function(data) {\n if(data.status == 'success'){\n alert(\"Thank you for subscribing!\");\n }else if(data.status == 'error'){\n alert(\"Error on query!\");\n }\n}\n```\n\n",
"name": "",
"is_accepted": false
}
] |
b824938b534d5ce3bb71c57aa8ec7034 |
Are there various print formatters for the file object? For example:
`char * filepath = argv[1];
FILE * file = fopen(filepath, "r");
printf("Filepath: %sn", file.size);`
`main4.c:416:32: error: no member named 'size' in 'struct __sFILE'`
What are the various items that can be printed from the struct?
|
Printing various FILE info
==========================
| programmertricks.com | 2021.04 | [
{
"text": "\nTo get various information, you can use stat, lstat which populate the struct stat: \n\n `struct stat { \n\ndev_t st_dev; /* ID of device containing file */ \n\nino_t st_ino; /* inode number */ \n\nmode_t st_mode; /* protection */ \n\nnlink_t st_nlink; /* number of hard links */ \n\nuid_t st_uid; /* user ID of owner */ \n\ngid_t st_gid; /* group ID of owner */ \n\ndev_t st_rdev; /* device ID (if special file) */ \n\noff_t st_size; /* total size, in bytes */ \n\nblksize_t st_blksize; /* blocksize for file system I/O */ \n\nblkcnt_t st_blocks; /* number of 512B blocks allocated */ \n\ntime_t st_atime; /* time of last access */ \n\ntime_t st_mtime; /* time of last modification */ \n\ntime_t st_ctime; /* time of last status change */ \n\n};`\n\n\n",
"name": "",
"is_accepted": false
}
] |
60844e1ccbd8b6b3aa571372ab6f115a |
When we call to eval function in PHP?
|
When we call to eval function in PHP?
=====================================
| programmertricks.com | 2021.39 | [
{
"text": "\nIn all the years I have been developing in PHP, I’ve always heard that using eval() is evil.\n\n\nConsidering the following code, wouldn’t it make sense to use the second (and more elegant) option? If not, why?\n\n\n`// $type is the result of an SQL statement \n\n// e.g. SHOW COLUMNS FROM a_table LIKE 'a_column'; \n\n// hence you can be pretty sure about the consistency \n\n// of your string \n\n$type = \"enum('a','b','c')\"; \n\n// possibility one \n\n$type_1 = preg_replace('#^enums*(s*'|'s*)s*$#', '', $type); \n\n$result = preg_split('#'s*,s*'#', $type_1); \n\n// possibility two \n\neval('$result = '.preg_replace('#^enum#','array', $type).';');`\n\n\n",
"name": "",
"is_accepted": false
}
] |
a49986c5a1cd3e5b0e801f7e05ef1d01 |
So I have 2 forms – frmMain and frmChild
The frmChild form is declared as I run frmMain
`frmChild form1 = new frmChild();`
I also have a button that runs a method to open the frmChild form.
`OpenForm(form1);`
The question is, how can I update data/call the desired method on the frmChild form while I’m still on the frmMain form? I need to do it on the existing instance of the form, without creating a new one.
I’ve tried doing it this way, but can’t access the method
The frmMain class
`public partial class frmMain: DevExpress.XtraEditors.XtraForm
{
frmChild form1 = new frmChild();`
`private void UpdateDataOnChildForm()
{
form1.DoStuff(); // cant access this method...
}
}`
The frmChild class
`public partial class frmChild : DevExpress.XtraEditors.XtraForm
{
public void UpdateData()
{
//update data here...
}
}`
|
Calling method / refreshing data in another form?
=================================================
| programmertricks.com | 2020.45 | [
{
"text": "\n `public partial class MainForm : Form \n\n{ \n\nprivate void btnMain_Click(object sender, EventArgs e) \n\n{ \n\nLoginForm lfrm = new LoginForm; \n\nLoginForm.ShowDialog(); \n\n} \n\nprivate void SecureMethod(){//do sth}; \n\n} \n\npublic partial class LoginForm : Form \n\n{ \n\nprivate void btnok_Click(object sender, EventArgs e) \n\n{ \n\nSecureMethod(); //is not true \n\nthis.close(); //close loginform \n\n} \n\n}``\n\n\n",
"name": "",
"is_accepted": false
}
] |
12f28025bdc386239b4c5ee7ebb2a8af |
How to turn query errors to Exceptions in MySqli?
|
How to turn query errors to Exceptions in MySqli?
=================================================
| programmertricks.com | 2021.21 | [
{
"text": "\nI’m trying to turn MySQLi query errors to Exceptions, but couldn’t – mysqli\\_sql\\_exception is thrown only if it failed to connect the DB.\n\n\nI used mysqli\\_report(MYSQLI\\_REPORT\\_STRICT) and procedural MySQLi functions embedded to custom wrapper class.\n\n\nFormer code:\n\n\npublic function mysqlQuery($SQL) {\n\n\n $this->Result = mysqli\\_query($this->DBlink, $SQL);\n\n\n if($this->Result === false) \n\nthrow new MySQLiQueryException($SQL, mysqli\\_error($this->DBlink), mysqli\\_errno($this->DBlink));\n\n\n return $this->Result;\n\n\n} \n\nQuestion: Is it normal no Warning, nor Exception are thrown when query fails so I have to check if mysqli\\_query() returned false?\n\n\n",
"name": "",
"is_accepted": false
}
] |
2fc2bd0e51c72ed7ce8c780c5173cf0e |
I have the following arrays in JSON encode:
`Array1 {"1":"9","3":"7","4":"6","5":"10","6":"8"}
Array2 {"1":"1","2":"1","3":"1","4":"1","5":"1","6":"7"}`
Where in Array1 values (9, 7, 6, 10, 8) area unit product id and Array2 values (1,1,1,1,7) area unit corresponding product amount.
Now I might wish to fetch merchandise supported merchandise Id and need to indicate the corresponding amount.
How am I able to do that in foreach?
|
How to get corresponding value of key from two arrays in foreach
================================================================
| programmertricks.com | 2020.29 | [
{
"text": "\nWith a simple foraech and a check if the product Id exists :\n\n\n$productId = json\\_decode(‘{“1″:”9″,”3″:”7″,”4″:”6″,”5″:”10″,”6″:”8”}’, true); \n\n$productQuantity = json\\_decode(‘{“1″:”1″,”2″:”1″,”3″:”1″,”4″:”1″,”5″:”1″,”6″:”7”}’, true);\n\n\nforeach($productId as $id) { \n\n$quantity = “?”; //if id not exists \n\nif(array\\_key\\_exists($id, $productQuantity)) { \n\n$quantity = $productQuantity[$id]; \n\n} \n\necho “productId: “.$id.” Quantity:”.$quantity.” \n\\n”; \n\n}\n\n\n",
"name": "",
"is_accepted": false
},
{
"text": "\nBy setting the $assoc parameter to json\\_decode to true, we can convert the JSON values into arrays rather than objects, and then iterate through the product\\_id array, finding matching quantities from the second array:\n\n\n$j1 = ‘{“1″:”9″,”3″:”7″,”4″:”6″,”5″:”10″,”6″:”8”}’; \n\n$j2 = ‘{“1″:”1″,”2″:”1″,”3″:”1″,”4″:”1″,”5″:”1″,”6″:”7”}’; \n\n$array1 = json\\_decode($j1, true); \n\n$array2 = json\\_decode($j2, true); \n\nforeach ($array1 as $key => $product\\_id) { \n\n$quantity = $array2[$key] ?? 0; \n\necho “Product $product\\_id: Quantity: $quantity\\n”; \n\n}\n\n\nBy setting the $assoc parameter to json\\_decode to true, we can convert the JSON values into arrays rather than objects, and then iterate through the product\\_id array, finding matching quantities from the second array:\n\n\n$j1 = ‘{“1″:”9″,”3″:”7″,”4″:”6″,”5″:”10″,”6″:”8”}’; \n\n$j2 = ‘{“1″:”1″,”2″:”1″,”3″:”1″,”4″:”1″,”5″:”1″,”6″:”7”}’; \n\n$array1 = json\\_decode($j1, true); \n\n$array2 = json\\_decode($j2, true); \n\nforeach ($array1 as $key => $product\\_id) { \n\n$quantity = $array2[$key] ?? 0; \n\necho “Product $product\\_id: Quantity: $quantity\\n”; \n\n} \n\nOutput:\n\n\nProduct 9: Quantity: 1 \n\nProduct 7: Quantity: 1 \n\nProduct 6: Quantity: 1 \n\nProduct 10: Quantity: 1 \n\nProduct 8: Quantity: 7\n\n\n",
"name": "",
"is_accepted": false
}
] |
f0d45480715c5dcd0d2c1c3f85e3c265 |
I want to get an echo of the single value with the last id but getting an error.
`$querya = $this->db->get('fuel_rdirecived');
$result = $mysqli->query($querya);
$row = $result->fetch_assoc();`
`echo $total= $row["totalqty"];
?>`
|
I want to echo the last value in CodeIgniter by last ID
=======================================================
| programmertricks.com | 2020.34 | [
{
"text": "\nYou need to put an array index to echo value.\n\n\n$this->db->select(‘totalqty’); \n\n$this->db->from(‘fuel\\_rdirecived’); \n\n$row = $this->db->get()->result\\_array(); \n\necho $total= $row[0][“totalqty”];\n\n\n",
"name": "",
"is_accepted": false
},
{
"text": "\nLast value will be:\n\n\n$querya = $this->db->select(‘totalqty’); \n\n$querya = $this->db->get(‘fuel\\_rdirecived’); \n\n\nforeach($querya->result() as $row) { \n\n$lastval = $row->totalqty; \n\n} \n\necho $lastval;\n\n\n",
"name": "",
"is_accepted": false
}
] |
a046376a268c6af2cbb83abe8f83787e |
We are trying to build an API with our project. My problem is when I need to get a specific event that has a column date\_from and date\_to it always gets the data even if the event was finished. I want to get a specific event that is been for the rest of the two dates. My thing is when the date\_from and the date\_to equal to or greater than the date today, It will show and after the date is finished it will not. Here are some of my codes.
`public function index(Request $request)
{
$person = User::find(Auth::user()->id);
$now = Carbon::now()->toDateString();
if(empty($person))
return response()->json([
'code' => '03',
'status' => 'Invalid User'
], 403);
$role = $person->role;
if ($role == 2 || $role == 3) {
$level = Event::active()->with(['groups'])
->where('school_id', '=', $person->school_id)
->where('group_id', '=', $role)
->orWhere('group_id', '=', $person)
->where('status', '=', 1)
->where('active', '=', 1)
->whereRaw("date_from <= date('$now')") ->whereRaw("date_to >= date('$now')")`
`->get();
return response()->json($level);
}`
|
Laravel: Comparing dates between two columns in database not working
====================================================================
| programmertricks.com | 2020.29 | [
{
"text": "\nTry this:\n\n\n$level = Event::active()->with([‘groups’]) \n\n->where([[‘school\\_id’, ‘=’, $person->school\\_id],[‘group\\_id’, ‘=’, $role],[‘status’, ‘=’, 1],[‘active’, ‘=’, 1]]) \n\n->orWhere(‘group\\_id’, ‘=’, $person) \n\n->whereRaw(“CURDATE() between date\\_from and date\\_to”) \n\n->get();\n\n\n",
"name": "",
"is_accepted": false
},
{
"text": "\nYour carbon date should match the format which is set in your database server\n\n\n`$now = Carbon::now()->toDateString()->format('Database Format');`\n\n\nPlus you don’t need to pass your date variable inside date function\n\n\n `->where('date_from', '<', $now)`\n\n\n",
"name": "",
"is_accepted": false
}
] |
5c9c3d049f903e8872e386b5d08142b2 |
I’m having trouble solving this situation where I need to filter an array based on the key values of another array. It might be quite easy but I can’t catch the proper key value pairs.
I have this array of marks:
```
marks = {
eng: 90,
maths: 50,
phy: 60,
chem: 75,
bio: 85,
}
```
And another array of tags with the same key names:
```
tags = {
eng: 'English',
maths: 'Maths',
phy: 'Physics',
chem: 'Chemistry',
bio: 'Biology',
}
```
Now I need to filter `tags` array if the marks are `>65`
marks array and the expected result is:
```
filteredTags = {
eng: 'English',
chem: 'Chemistry',
bio: 'Biology',
}
```
Or even better if it is:
```
filteredTags = ['English', 'Chemistry', 'Biology']
```
What I have tried so far:
```
filteredTags = []
$.each(marks, function (ind, val) {
if (val > 60) {
filteredTags = tags.filter(function (i, v) {
return (i == ind)
}
}
})
```
|
Filter array dynamically based on other array in jQuery
=======================================================
| programmertricks.com | 2020.16 | [
{
"text": "\nYou could get the entries and filter the key/value pairs and get an array of tags.\n\n\nvar marks = { eng: 90, maths: 50, phy: 60, chem: 75, bio: 85 }, \n\ntags = { eng: ‘English’, maths: ‘Maths’, phy: ‘Physics’, chem: ‘Chemistry’, bio: ‘Biology’ } \n\nresult = Object \n\n.entries(marks) \n\n.filter(([\\_, v]) => v > 65) \n\n.map(([k]) => tags[k])\n\n\nconsole.log(result);\n\n\n",
"name": "",
"is_accepted": false
},
{
"text": "\nWould be easier with arrays, but this code should work:\n\n\nlet marks = { \n\neng : 90, \n\nmaths : 50, \n\nphy : 60, \n\nchem : 75, \n\nbio : 85, \n\n}\n\n\nlet tags = { \n\neng : ‘English’, \n\nmaths : ‘Maths’, \n\nphy : ‘Physics’, \n\nchem : ‘Chemistry’, \n\nbio : ‘Biology’, \n\n}\n\n\nfunction getTagsWithMarksAbove(num) { \n\nlet result = [];\n\n\n for(prop in marks) { // Iterate over the properties of the marks object \n\nif(marks[prop] > num) // Check if mark is above the specified number \n\nresult.push(tags[prop]); // Add value of tags property with the same name to result array \n\n}\n\n\n return result; \n\n} \n\nconsole.log(getTagsWithMarksAbove(65))\n\n\n",
"name": "",
"is_accepted": false
}
] |
edd16363bbc76016b9f2d466865df43c |
Is there any way to find a specific value in every field of every table in Microsoft SQL Server?
For example, I wish to find any record with ‘666333222’ in it…is it possible?
|
Is there any way to find a specific value in every field of every table in Microsoft SQL Server?
================================================================================================
| programmertricks.com | 2020.05 | [
{
"text": "\nFor mysql you can get all table names by :\n\n\nSelect your database by ‘use’ statement then,\n\n\nSELECT * FROM INFORMATION\\_SCHEMA.TABLES WHERE TABLE\\_TYPE=’BASE TABLE’\n\n\n",
"name": "",
"is_accepted": false
}
] |
e1f6ac4c283567185be1202f8959e18e |
I want to know the difference between React and React Native – though I could not find a satisfactory answer using Google. Do they have completely different syntax?
|
What is the difference between React Native and React?
======================================================
| programmertricks.com | 2020.45 | [
{
"text": "\nReact Native is a mobile framework that compiles to native app components, allowing you to build native mobile applications for different platforms (iOS, Android, and Windows Mobile) in JavaScript that allows you to use ReactJS to build your components, and implements ReactJS under the hood.\n\n\nReactJS is a JavaScript library, supporting both front-end web and being run on a server, for building user interfaces and web applications.\n\n\nBoth are open-sourced by Facebook.\n\n\n",
"name": "",
"is_accepted": false
}
] |
3b37ca098e067055baf6fd7b7830198b |
Example values are given below.
`07:17:46 need to be 07:15:00
06:25:25 need to be 06:15:00`
|
How to round up my given time is to the last 15 minutes?
========================================================
| programmertricks.com | 2020.05 | [
{
"text": "\nSplit into hours, minutes and seconds. Round the minutes down, fill with zeros and return.\n\n\n `function timeLastQuarter($timestr) { \n\n$time = explode(\":\",$timestr); \n\nreturn str_pad($time[0],2,\"0\",STR_PAD_LEFT).\":\".str_pad(((floor($time[1] / 15))*15),2,\"0\",STR_PAD_LEFT).\":00\"; \n\n}`\n\n\nExample:\n\n\n`echo timeLastQuarter(\"15:55:00\");`\n\n\n",
"name": "",
"is_accepted": false
}
] |
8ce9c36121807323bbdf598e09252efd |
Here is an array object with the value combination name and surname.
How to sort by surname?
`var myArr = ["gopal, roy", "shaym, verma", "akash, jaiswal"];`
|
Sort array object using surname in javascript
=============================================
| programmertricks.com | 2020.40 | [
{
"text": "\nYou can use regex to get surname then use localeCompare\n\n\nvar myArr = [“gopal, roy”, “shaym, verma”, “akash, jaiswal”]; \n\nlet out = myArr.sort((a, b) => \n\na.match(/, (.*)/)[1].localeCompare(b.match(/, (.*)/)[1]) \n\n); \n\nconsole.log(out);\n\n\n",
"name": "",
"is_accepted": false
},
{
"text": "\nconst myArr = [“gopal, roy”, “shaym, verma”, “akash, jaiswal”];\n\n\nconst res = myArr \n\n.map(name => name.split(‘, ‘)) \n\n.sort(([\\_, a], [\\_\\_, b]) => a.localeCompare(b)) \n\n.map(name => name.join(‘, ‘));\n\n\nconsole.log(res);\n\n\n",
"name": "",
"is_accepted": false
}
] |
aeab39611f477da2f7cf959eb5aaf1a8 |
I’m developing a new site that has been related to the jewelry industry which deals with gold and silver. I wanna set the pricing of the product based on its weight(in terms of grams mostly). Since the price of gold is changing daily, it has been to reflect on the product pricing. So I like to add a master control to update the price of gold and silver in terms of grams on a daily basis and it should make the product price changes automatically. Are there any plugins there to customize it or code to enable this function..?
|
Is it possible to set pricing for Products based on weight on Woocommerce?
==========================================================================
| programmertricks.com | 2021.21 | [
{
"text": "\nYou can add this to functions.php\n\n\ndefine (‘GOLD\\_PRICE’, ‘2.00’); // Define the factor you wish to multiply with \n\nadd\\_filter( ‘woocommerce\\_product\\_get\\_regular\\_price’, ‘calculate\\_price\\_by\\_weight’, 10, 2 ); \n\nfunction calculate\\_price\\_by\\_weight($price, $product){ \n\n$weight = $product->get\\_weight(); \n\nif ($weight > 0){ \n\n$price = GOLD\\_PRICE * $weight / 100; // Do whatever calculation you need here \n\n} \n\nreturn $price; \n\n}\n\n\n",
"name": "",
"is_accepted": false
},
{
"text": "\nFor a change in the price of products on the gold price base you need to do customize code. But using PW WooCommerce Bulk Edit plugin you are able to increase/decrease all product price with a specific amount. Try this plugin if it helps you.\n\n\n",
"name": "",
"is_accepted": false
}
] |
304d76d63a2f185a4f0d1cc770d58248 |
What is good Php ORM Library?
|
What is good Php ORM Library?
=============================
| programmertricks.com | 2020.29 | [
{
"text": "\nThere are only two good ones: \n\nDoctrine and Propel. We favor Doctrine, and it works well with Symfony. However, if you’re looking for database support besides the main ones you’ll have to write your own code.\n\n\n",
"name": "",
"is_accepted": false
},
{
"text": "\nI’m trying to receive a JSON POST on a payment interface website, but I can’t decode it.\n\n\nWhen I print :\n\n\necho $\\_POST; \n\nI get:\n\n\nArray \n\nI get nothing when I try this:\n\n\nif ( $\\_POST ) { \n\nforeach ( $\\_POST as $key => $value ) { \n\necho “llave: “.$key.”- Valor:”.$value.” \n“; \n\n} \n\n} \n\nI get nothing when I try this:\n\n\n$string = $\\_POST[‘operation’]; \n\n$var = json\\_decode($string); \n\necho $var; \n\nI get NULL when I try this:\n\n\n$data = json\\_decode( file\\_get\\_contents(‘php://input’) ); \n\nvar\\_dump( $data->operation ); \n\nWhen I do:\n\n\n$data = json\\_decode(file\\_get\\_contents(‘php://input’), true); \n\nvar\\_dump($data); \n\nI get:\n\n\nNULL \n\nThe JSON format is (according to payment site documentation):\n\n\n{ \n\n“operacion”: { \n\n“tok”: “[generated token]”, \n\n“shop\\_id”: “12313”, \n\n“respuesta”: “S”, \n\n“respuesta\\_details”: “respuesta S”, \n\n“extended\\_respuesta\\_description”: “respuesta extendida”, \n\n“moneda”: “PYG”, \n\n“monto”: “10100.00”, \n\n“authorization\\_number”: “123456”, \n\n“ticket\\_number”: “123456789123456”, \n\n“response\\_code”: “00”, \n\n“response\\_description”: “Transacción aprobada.”, \n\n“security\\_information”: { \n\n“customer\\_ip”: “123.123.123.123”, \n\n“card\\_source”: “I”, \n\n“card\\_country”: “Croacia”, \n\n“version”: “0.3”, \n\n“risk\\_index”: “0” \n\n} \n\n} \n\n} \n\nThe payment site log says everything is OK. What’s the problem?\n\n\n",
"name": "",
"is_accepted": false
},
{
"text": "\nAxon ORM is part of the Fat-Free Framework – it features an on-the-fly mapper. No code generators. No stupid XML/YAML configuration files. It reads the database schema directly from the backend, so in most CRUD operations you don’t even have to extend a base model. It works with all major PDO-supported database engines: MySQL, SQLite, SQL Server/Sybase, Oracle, PostgreSQL, etc.\n\n\n/* SQL */ \n\nCREATE TABLE products ( \n\nproduct\\_id INTEGER, \n\ndescription VARCHAR(128), \n\nPRIMARY KEY (product\\_id) \n\n);\n\n\n/* PHP */ \n\n// Create \n\n$product=new Axon(‘products’); // Automatically reads the above schema \n\n$product->product\\_id=123; \n\n$product->description=’Sofa bed’; \n\n$product->save(); // ORM knows it’s a new record\n\n\n// Retrieve \n\n$product->load(‘product\\_id=123′); \n\necho $product->description;\n\n\n// Update \n\n$product->description=’A better sofa bed’; \n\n$product->save(); // ORM knows it’s an existing record\n\n\n// Delete \n\n$product->erase(); \n\nMost of all, the plug-in and accompanying SQL data access layer are just as lightweight as the framework: 14 KB (Axon) + 6 KB (SQLdb). Fat-Free is just 55 KB.\n\n\n",
"name": "",
"is_accepted": false
}
] |
8a4b2aea31c3b38cf223531833deedc6 |
I have an array which potentially is able to carry multiple congruent values.
`$a = array( "0" => "red", "1" => "green" , "2" => "red" , "3" => "blue", "4" => "blue", "5" => "blue" );`
Now, I would like to understand the keys of all parts that have a minimum of one congruent price.
My most well-liked result would be Associate in Nursing array that has subarrays- and in every subarray, the keys of the various congruent values get to keep. in order that I do know that one amongst the keys of the array $a has a similar price.
`$b = array(array("0" => "0", "1" => "2"), array("0" => "3", "1" => "4", "2" => "5"));`
What is the most efficient way to do that?
Thank you
|
PHP – Get the keys of values which are congruent in an array
============================================================
| programmertricks.com | 2020.40 | [
{
"text": "\nYou can use array\\_count\\_values() to get the frequency count for each color. Then iterate over the array $a and check each color’s frequency count. If it’s greater than 1, add it to the result at the appropriate color index in $keys.\n\n\n “red”, “1” => “green” , “2” => “red” , “3” => “blue”, “4” => “blue”, “5” => “blue” );\n\n\n$group\\_by\\_data = array\\_count\\_values($a);\n\n\n$keys = [];\n\n\nforeach($a as $key => $color){ \n\nif($group\\_by\\_data[$color] > 1){ \n\nif(!isset($keys[$color])) $keys[$color] = []; \n\n$keys[$color][] = $key; \n\n} \n\n}\n\n\nprint\\_r($keys);\n\n\n",
"name": "",
"is_accepted": false
},
{
"text": "\nUse array\\_unique to find all unique values then loop through it and use array\\_keys to find all the keys of each element.\n\n\n$a = array( “0” => “red”, “1” => “green” , “2” => “red” , “3” => “blue”, “4” => “blue”, “5” => “blue” ); \n\n$unique=array\\_unique($a); \n\n$result=array(); \n\nforeach($unique as $value){ \n\n$allkeys=array\\_keys($a, $value); \n\nif(count($allkeys)>1) \n\n$result[]=$allkeys; \n\n} \n\nprint\\_r($result);\n\n\n",
"name": "",
"is_accepted": false
}
] |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.