Subin's Blog https://subinsb.com/ Recent content on Subin's Blog Hugo en-us Mon, 09 Feb 2026 00:00:00 +0530 Popular baby names of Kerala 1920 - 2007 https://subinsb.com/popular-baby-names-kerala/ Sun, 08 Feb 2026 00:00:00 +0530 https://subinsb.com/popular-baby-names-kerala/ <p>After the <a href="https://subinsb.com/simple-analysis-of-kerala-place-names/">place name analysis</a>, I was curious about human names of Kerala. Name of a person is dependent on the time of their birth. When I was in school, there were 4 Vishnus, and some 3 or 4 Aishwaryas among 200 students.</p> <p>Why did a name become popular? Who started the trend? When was it trending? When did it become &quot;unfashionable&quot;? Good questions to ask for a name.</p> <h2 id="data">Data</h2> <p>To do this, we need names. The only public data available for this is the voters list. I've been working on this project on and off for the past 1.5 years. Collecting the data was the most difficult part.</p> <p>I've collected names from the 5 corporations of Kerala: Thiruvananthapuram, Kollam, Kochi, Thrissur, Kozhikode, Kannur.</p> <p>and the biggest municipality in each of the other districts: Kasargod, Mananthavadi, Malappuram, Palakkad, Thodupuzha, Alappuzha, Kottayam, Thiruvalla.</p> <p>Important points to note:</p> <ul> <li>The total names being considered for this analysis is <strong>2,197,000</strong> which is roughly <strong>8%</strong> of the voters list population.</li> <li>The age in voters list is not entirely correct. My age in the list is still 23 even though I'm 26 now.</li> <li><strong>2025</strong> is set as the base year to calculate birth year from the age.</li> <li>Some names have minor spelling differences. This has been rectified. <a href="https://github.com/subins2000/kerala-baby-name-analysis/blob/main/data/make-simplified-db.rb#L16">See this file</a>.</li> <li>To simplify the analysis, only the top 50 names from each year (separated by gender) were included in the final SQLite database used for this study.</li> </ul> <h2 id="analysis">Analysis</h2> <p>The graph below shows the year on the x-axis and, on the y-axis, the number of people with a given name who were born in that year.</p> <h3 id="top-10-names-over-the-years">Top 10 names over the years</h3> <p><img src="https://subinsb.com/uploads/2026/02/top10-girl-names-over-time.png" alt="Top 10 girl names over time"></p> <p><img src="https://subinsb.com/uploads/2026/02/top10-boy-names-over-time.png" alt="Top 10 boy names over time"></p> <h3 id="aishwarya">Aishwarya</h3> <p>The name <em>Aishwarya</em> appears to have gained popularity due to the fame of actress <a href="https://en.wikipedia.org/wiki/Aishwarya_Rai_Bachchan">Aishwarya Rai</a>.</p> <p><img src="https://subinsb.com/uploads/2026/02/aishwarya-name-popularity-in-kerala.png" alt=""></p> <h3 id="rahul-and-priyanka">Rahul and Priyanka</h3> <p>Rahul appears as a baby name in Kerala for the first time in 1971, a year after <a href="https://en.wikipedia.org/wiki/Rahul_Gandhi">Rahul Gandhi</a> was born. Priyanka first appears in 1974, two years after <a href="https://en.wikipedia.org/wiki/Priyanka_Gandhi">Priyanka Gandhi</a>'s birth.</p> <p>Thanks to <a href="https://abhay.app/">Abhay</a>'s dad for mentioning this.</p> <p><img src="https://subinsb.com/uploads/2026/02/rahul-priyanka-name-in-kerala.png" alt=""></p> <h3 id="fathima">Fathima</h3> <p>There was a hit song about a girl named <a href="https://www.youtube.com/watch?v=roP9RKDmyko">&quot;Fathima&quot;</a> released in 2005. This is the overlap of the song release with popularity of the name.</p> <p>Note that people don't necessarily name a baby immediately after birth. In many cases, the official name is finalized at the time of school admission, which is usually around age four. Therefore, this graph may reflect a correlation between the song and name popularity in the years after 2000.</p> <p><img src="https://subinsb.com/uploads/2026/02/fathima-name-popularity-in-kerala.png" alt="Popularity of name Fathima in Kerala"></p> <h3 id="bindhu-vs-sindhu">Bindhu vs Sindhu</h3> <p>The names Bindhu and Sindhu began gaining popularity in the mid-1960s and became closely associated with each other. Both saw a sharp decline in usage after 1985.</p> <p>It's quite likely that the first daughter was named Bindhu and the next one Sindhu ๐Ÿ˜„.</p> <p><img src="https://subinsb.com/uploads/2026/02/bindhu-vs-sindhu-kerala-name.png" alt="Bindhu vs Sindhu name popularity in Kerala"></p> <h3 id="baby">Baby</h3> <p>A unique naming trend in Kerala was the use of the name &quot;Baby&quot; for both boys and girls. This peaked in the 60s and then gradually faded out. <a href="https://en.wikipedia.org/wiki/M._A._Baby">M.A. Baby</a> is one of the most well-known people with the name &quot;Baby&quot; here.</p> <p>This was surprising to me โ€” more girls were named &quot;Baby&quot; than boys, which was the opposite of what I expected.</p> <p><img src="https://subinsb.com/uploads/2026/02/kerala-name-baby.png" alt="Babies named &quot;Baby&quot; in Kerala"></p> <h3 id="sheela">Sheela</h3> <p>Actress <a href="https://en.wikipedia.org/wiki/Sheela">Sheela</a> popularized the name &quot;Sheela&quot; and helped start the trend.</p> <p><img src="https://subinsb.com/uploads/2026/02/kerala-name-sheela.png" alt="Babies named &quot;Sheela&quot; in Kerala"></p> <h3 id="check-your-name">Check your name</h3> <p>Replace the names in the textbox below to generate comparison graphs. You can also control the year. If this is small in mobile view, <a href="https://lab.subinsb.com/kerala-baby-name-analysis/name-graph/">open this page</a> separately.</p> <p>Note that the dataset only has top 50 names from each year. So submitting your name might not show anything.</p> <iframe src="https://lab.subinsb.com/kerala-baby-name-analysis/name-graph/" width="100%" height="580px" id="name-graph-iframe"></iframe> <h2 id="interactive-chart">Interactive chart</h2> <p>This interactive chart shows top 10 popular names each year from 1930 (95 years old) to 2007 (18 years old). The chart in the early years is not pretty because there's less people in that age group in the dataset.</p> <p>Thanks to <a href="https://www.visualcinnamon.com/">Nadieh Bremer</a> for making <a href="https://nbremer.github.io/babynames/">this interactive chart</a>. I explored several data visualizations of popular names and found hers to be the best.. Since it <a href="https://github.com/nbremer/babynames">is open source</a>, I was able to modernize it a bit and <a href="https://github.com/subins2000/kerala-baby-name-analysis/tree/main/interactive-chart">put our data</a> in.</p> <p>This won't look good if you're seeing this from mobile. Open <a href="https://lab.subinsb.com/kerala-baby-name-analysis/interactive-chart/">this page</a> in landscape mode or better, a computer.</p> <iframe src="https://lab.subinsb.com/kerala-baby-name-analysis/interactive-chart/" width="100%" height="680px" id="interactive-chart-iframe"></iframe> <h3 id="syllable-cycle">Syllable cycle</h3> <p>One pattern observed in the interactive chart is a generational shift in popular names from three syllables to two syllables, and then back to three syllables over three generations.</p> <blockquote> <p>เดคเด™เตเด•เดฎเตเดฎ, เด…เดฎเตเดฎเดฟเดฃเดฟ, เดฐเดพเดœเดฎเตเดฎ, เด“เดฎเดจ, เด…เดจเตเดจเดฎเตเดฎ, เดฒเด•เตเดทเตเดฎเดฟ, เดœเดพเดจเด•เดฟ, เดถเดพเดฐเดฆ</p> <p>เดฌเดฟเดจเตเดฆเต, เดธเดฟเดจเตเดฆเต, เดฌเต€เดจ, เดทเต€เดœ, เดทเต€เดฌ, เด—เต€เดค, เดฆเต€เดช, เดจเดฟเดท</p> <p>เด…เดถเตเดตเดคเดฟ, เด—เต‹เดชเดฟเด•, เดเดถเตเดตเดฐเตเดฏ, เดซเดพเดคเตเดคเดฟเดฎ, เด†เดคเดฟเดฐ, เดฆเต‡เดตเดฟเด•, เดจเดจเตเดฆเดจ, เด…เดžเตเดœเดจ</p> </blockquote> <h2 id="racing-chart">Racing chart</h2> <p>Some names are very popular that it dominated the racing chart for many years. To make it race-chart-worthy, a name is set to have an age of 8 years. This makes the race chart feel more of how your classroom looked like.</p> <h3 id="girls">Girls</h3> <div class="video-container"> <video controls> <source src="https://github.com/subins2000/kerala-baby-name-analysis/raw/refs/heads/main/racing-graph/videos/audio-girls.mp4" type="video/mp4"> Your browser does not support the video tag. </video> </div> <style> .video-container { display: flex; justify-content: center; margin: 1.5rem 0; } .video-container video { max-width: 100%; height: 500px; } </style> <h3 id="boys">Boys</h3> <div class="video-container"> <video controls> <source src="https://github.com/subins2000/kerala-baby-name-analysis/raw/refs/heads/main/racing-graph/videos/audio-boys.mp4" type="video/mp4"> Your browser does not support the video tag. </video> </div> <style> .video-container { display: flex; justify-content: center; margin: 1.5rem 0; } .video-container video { max-width: 100%; height: 500px; } </style> <p>I later realized that Muhammad was actually the most common &quot;first name&quot; in my classroom, but students usually had another name to distinguish them. For example, someone's official name might be Muhammad Raheez, but we would simply know him as Raheez.</p> <p>Muhammad is also the most common &quot;first name&quot; in the world, and that trend is reflected here as well.</p> <p>Both Abdul and Muhammad function as prefixes. The actual given name is the one that follows, and that is the name by which the person is commonly known. Therefore, listing the prefix in my analysis above as the first name does not accurately represent the true name choice; it only reflects the choice of prefix.</p> <h2 id="further-analysis">Further analysis</h2> <p>More analysis can be done with this data. I've been working on this project for over a year now, and I'm honestly exhausted ๐Ÿ˜ญ. If you notice any interesting patterns or have ideas for further analysis, please let me know in the comments!</p> <p>You can download the SQLite DB <a href="https://github.com/subins2000/kerala-baby-name-analysis/tree/main/data">here</a>. All source is on git: <a href="https://github.com/subins2000/kerala-baby-name-analysis">https://github.com/subins2000/kerala-baby-name-analysis</a></p> <p>You can put this SQLite database into ChatGPT or Gemini and ask questions too.</p> <h2 id="technical-notes">Technical notes</h2> <ul> <li>Nadieh Bremer made <a href="https://nbremer.github.io/babynames/">that interactive chart</a> in good ol' JavaScript of 2013. No transpilers, no npm, just a simple HTML page with &lt;script&gt; tags. Because of this, I was able to easily run and modify it locally.</li> <li>Like in the <a href="https://subinsb.com/kpna">previous place name analysis</a>, the SQLite DB is loaded in the webpage</li> <li>The JavaScript library <a href="https://github.com/hatemhosny/racing-bars">racing-bars</a> was used on a webpage, which was then screen recorded.</li> </ul> <p>Query used for <a href="#baby">Baby</a> graph in <a href="https://lab.subinsb.com/kerala-baby-name-analysis/name-graph/">graph generator</a>:</p> <div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sql" data-lang="sql"><span style="display:flex;"><span><span style="color:#66d9ef">SELECT</span> </span></span><span style="display:flex;"><span> id, </span></span><span style="display:flex;"><span> <span style="color:#66d9ef">CASE</span> </span></span><span style="display:flex;"><span> <span style="color:#66d9ef">WHEN</span> gender <span style="color:#f92672">=</span> <span style="color:#e6db74">&#39;M&#39;</span> <span style="color:#66d9ef">THEN</span> <span style="color:#e6db74">&#39;Baby Boy&#39;</span> </span></span><span style="display:flex;"><span> <span style="color:#66d9ef">WHEN</span> gender <span style="color:#f92672">=</span> <span style="color:#e6db74">&#39;F&#39;</span> <span style="color:#66d9ef">THEN</span> <span style="color:#e6db74">&#39;Baby Girl&#39;</span> </span></span><span style="display:flex;"><span> <span style="color:#66d9ef">END</span> <span style="color:#66d9ef">AS</span> name, gender, <span style="color:#66d9ef">year</span>, <span style="color:#66d9ef">count</span> </span></span><span style="display:flex;"><span><span style="color:#66d9ef">FROM</span> humans <span style="color:#66d9ef">WHERE</span> name <span style="color:#f92672">=</span> <span style="color:#e6db74">&#39;Baby&#39;</span> <span style="color:#66d9ef">ORDER</span> <span style="color:#66d9ef">BY</span> <span style="color:#66d9ef">year</span>; </span></span></code></pre></div><p>Do you know the reason behind your name? Let me know in the comments!</p> <h2 id="misc">Misc</h2> <p>Discussions elsewhere:</p> <ul> <li><a href="https://www.reddit.com/r/Kerala/comments/1qz0sa2/i_did_an_analysis_of_top_10_girl_baby_names_in/">Reddit</a></li> <li><a href="https://x.com/SubinSiby/status/2020393056529445184">Twitter</a></li> <li><a href="https://www.linkedin.com/posts/subinsiby_i-analyzed-the-top-10-girl-baby-names-in-activity-7426159283488112641-z3Qm">LinkedIn</a></li> </ul> <p>External coverage:</p> <ul> <li>In the New Indian Express: <a href="https://subinsb.com/uploads/2026/02/new-indian-express-kerala-baby-names-report.jpg">Link 1</a> <a href="https://www.newindianexpress.com/states/kerala/2026/Feb/11/baby-to-fathima-tracing-kerala-through-names">Link 2</a></li> <li><a href="https://youtu.be/CytXhhMWwyg">Talk with ClubFM Radio</a></li> </ul> KDE India Conf 2025 https://subinsb.com/kde-india-conf-2025/ Sun, 11 May 2025 00:00:00 +0530 https://subinsb.com/kde-india-conf-2025/ <p>I attended KDE India Conf (conf.kde.in, CKI) 2025 in Gandhinagar, Gujarat. My last and first CKI was in 2020 in Delhi. Had written a <a href="https://subinsb.com/cki2020">blog then</a>.</p> <p>There was a CKI last year in Pune but I was unable to attend it. So it's been 5 years. The constant from then and now is <a href="https://blog.bshah.in/2025/05/02/conf-kde-in-2025-gandhinagar/">Bhushan</a> :)</p> <h2 id="my-talk">My talk</h2> <p>Title of the talk was &quot;Learnings from creating an input method for KDE&quot;. My primary desktop environment since 2018 is KDE Plasma. <a href="https://varnamproject.com">Varnam input method</a> was created to use in KDE. The talk was about the learnings of creating the input method.</p> <p>The talk has been uploaded here: <a href="https://mirror.freedif.org/KDE/files/confkdein/2025/learnings-from-creating-an-input-method-for-kde.mp4">https://mirror.freedif.org/KDE/files/confkdein/2025/learnings-from-creating-an-input-method-for-kde.mp4</a></p> <h3 id="emoji-picker">Emoji picker</h3> <p>The current way to input emoji in KDE Plasma is by copy-pasting the emoji from a window. GNOME has a better emoji input where you could open the emoji suggestions box anywhere you type and directly insert it. Behind the conference, I looked at whether this can be improved.</p> <p>I tried to make an emoji input method just like Varnam. The source code is here: <a href="https://github.com/subins2000/semoji">https://github.com/subins2000/semoji</a></p> <p>It was partially successful, it works, but one month in I still use the KDE copy-paste one.</p> <p>I later saw that one of KDE goals this year is this, &quot;We care about your input&quot;. There is already an issue open: <a href="https://invent.kde.org/teams/goals/we-care-about-your-input/-/issues/15">https://invent.kde.org/teams/goals/we-care-about-your-input/-/issues/15</a></p> <p>This is a very core thing to Qt, so it is beyond my expertise. I'm just gonna watch in the sidelines, and meanwhile I'll survive with copy paste ๐Ÿ™‚.</p> <h2 id="conference">Conference</h2> <p>Like all other free software conferences, I met people who shared the same interests as me, so there was lot to talk about!</p> <p>Rishi has done an elaborate write up about the conference, so I'm not gonna repeat things. <a href="https://blog.rishikumar.dev/posts/cki2025/">Link to Rishi's blog</a>.</p> <p>Rishi had also brought a Steam Deck which was fun to use! A popular mainstream device that comes with GNU/Linux? That has been a dream once. That too gaming!</p> <p>One thing I have to mention here is Joseph's talk on <a href="https://endof10.org/">End of 10</a>. Windows 10 is about to end its support in 2025 October 14. The newer Windows 11 requires modern hardware. This would mean millions of working devices will end up being unupgradable, and potentially e-waste.</p> <p>My personal computer from 2010 to 2018 was a 2GB RAM machine. I had to use Linux Mint + XFCE + i3wm to get the maximum out of the system. Windows 8 and 10 was uninstallable in that machine.</p> <p>There was a BoF on the same, and one major thing about India at least is that &quot;if it works, then don't touch it&quot;. I've seen retail stores using Windows 7 to even Windows XP (A display in Cochin international airport). When they have a working flow, it's difficult for them to change.</p> <p>Adobe Pagemaker that was deprecated in 2003 is still being used here. It works because Windows is very good in backwards compatibility. If Windows ever breaks it, maybe they'd upgrade.</p> <p>My state Kerala already uses GNU/Linux widely across school, government departments etc. School students are usually given a laptop which is low-end hardware that already runs GNU/Linux. No way can these laptops and machine run Windows, even Windows 10.</p> <h2 id="next-conference">Next conference</h2> <p>This is the second time CKI has been ogranized in Gandhinagar. I've lowkey suggested that maybe Kerala can host it next year ๐Ÿคž. Last time it happened in Kerala was in 2015, that's 10 years ago!</p> <p>A good place to do it would be a university. I've been helping organizing <a href="https://kochifoss.org/">Kochi FOSS meetups</a> for the past 2 years. There is definitely audience for the conf, it's just that where would we do it.</p> <p>Let's see.</p> Use ActiveRecord + SQLite without Rails https://subinsb.com/ruby-activerecord-sqlite/ Sun, 09 Feb 2025 00:00:00 +0530 https://subinsb.com/ruby-activerecord-sqlite/ <p>Recently been using ActiveRecord + SQLite a LOT, so making this post for the basic template.</p> <h2 id="gemfile">Gemfile</h2> <pre tabindex="0"><code>source &#34;https://rubygems.org&#34; gem &#34;activerecord&#34;, &#34;~&gt; 8.0&#34; gem &#34;pry&#34; gem &#34;sqlite3&#34;, &#34;~&gt; 2.4&#34; </code></pre><h2 id="playgroundrb">playground.rb</h2> <div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-ruby" data-lang="ruby"><span style="display:flex;"><span>require <span style="color:#e6db74">&#39;active_record&#39;</span> </span></span><span style="display:flex;"><span>require <span style="color:#e6db74">&#39;pry&#39;</span> </span></span><span style="display:flex;"><span>require <span style="color:#e6db74">&#39;sqlite3&#39;</span> </span></span><span style="display:flex;"><span> </span></span><span style="display:flex;"><span><span style="color:#66d9ef">ActiveRecord</span><span style="color:#f92672">::</span><span style="color:#66d9ef">Base</span><span style="color:#f92672">.</span>establish_connection( </span></span><span style="display:flex;"><span> <span style="color:#e6db74">adapter</span>: <span style="color:#e6db74">&#39;sqlite3&#39;</span>, </span></span><span style="display:flex;"><span> <span style="color:#e6db74">database</span>: <span style="color:#e6db74">&#39;db.sqlite3&#39;</span> </span></span><span style="display:flex;"><span>) </span></span><span style="display:flex;"><span> </span></span><span style="display:flex;"><span><span style="color:#66d9ef">class</span> <span style="color:#a6e22e">Place</span> <span style="color:#f92672">&lt;</span> <span style="color:#66d9ef">ActiveRecord</span><span style="color:#f92672">::</span><span style="color:#66d9ef">Base</span> </span></span><span style="display:flex;"><span><span style="color:#66d9ef">end</span> </span></span><span style="display:flex;"><span> </span></span><span style="display:flex;"><span>@first_run <span style="color:#f92672">=</span> <span style="color:#f92672">!</span><span style="color:#66d9ef">Place</span><span style="color:#f92672">.</span>table_exists? </span></span><span style="display:flex;"><span> </span></span><span style="display:flex;"><span><span style="color:#75715e"># Create the table (migration-like setup)</span> </span></span><span style="display:flex;"><span><span style="color:#66d9ef">if</span> @first_run </span></span><span style="display:flex;"><span> <span style="color:#66d9ef">ActiveRecord</span><span style="color:#f92672">::</span><span style="color:#66d9ef">Schema</span><span style="color:#f92672">.</span>define <span style="color:#66d9ef">do</span> </span></span><span style="display:flex;"><span> create_table <span style="color:#e6db74">:places</span> <span style="color:#66d9ef">do</span> <span style="color:#f92672">|</span>t<span style="color:#f92672">|</span> </span></span><span style="display:flex;"><span> t<span style="color:#f92672">.</span>string <span style="color:#e6db74">:name</span> </span></span><span style="display:flex;"><span> t<span style="color:#f92672">.</span>string <span style="color:#e6db74">:lat</span> </span></span><span style="display:flex;"><span> t<span style="color:#f92672">.</span>string <span style="color:#e6db74">:lon</span> </span></span><span style="display:flex;"><span> t<span style="color:#f92672">.</span>timestamps </span></span><span style="display:flex;"><span> <span style="color:#66d9ef">end</span> </span></span><span style="display:flex;"><span> add_index <span style="color:#e6db74">:places</span>, <span style="color:#e6db74">:name</span>, <span style="color:#e6db74">unique</span>: <span style="color:#66d9ef">true</span> </span></span><span style="display:flex;"><span> <span style="color:#66d9ef">end</span> </span></span><span style="display:flex;"><span><span style="color:#66d9ef">end</span> </span></span><span style="display:flex;"><span> </span></span><span style="display:flex;"><span>binding<span style="color:#f92672">.</span>pry </span></span></code></pre></div> Talks https://subinsb.com/talks/ Fri, 13 Dec 2024 16:00:55 +0000 https://subinsb.com/talks/ <p>Whenever I feel like it, I give talks at conferences and meetups. I like public speaking especially when it's to showcase something that excites me.</p> <h3 id="2025">2025</h3> <ul> <li> <p><a href="https://www.youtube.com/watch?v=Fb8Q4P2v1o0"> GTA Kochi City map + analysis of Kerala place names thanks to OpenStreetMap</a></p> <p><a href="https://kochifoss.org">Kochi FOSS meetup</a>, Kochi, India</p> </li> </ul> <h3 id="2024">2024</h3> <ul> <li> <p><a href="https://www.youtube.com/watch?v=1Em1eCfPzCs">ActiveRecord + SQLite on WASM!</a></p> <p><a href="https://rubyconf.in/">RubyConf India</a>, Jaipur, India</p> </li> <li> <p>Simple analysis on place names of Kerala (Video coming soon)</p> <p><a href="https://wiki.openstreetmap.org/wiki/State_of_the_Map_Kerala_2024">State of The Map Kerala</a>, Wayanad, India</p> </li> <li> <p><a href="https://www.youtube.com/watch?v=lWoXsdDrPkk">Learnings from creating an input method for GNU/Linux from a product perspective</a></p> <p><a href="https://debconf24.debconf.org/">DebConf24</a>, Busan, South Korea</p> <p><a href="https://laotzu.ftp.acc.umu.se/pub/debian-meetings/2024/DebConf24/debconf24-386-learnings-from-creating-an-input-method-for-gnulinux-from-a-product-perspective.av1.webm"><em>Mirror</em></a></p> </li> <li> <p><a href="https://hasgeek.com/fosscell/fossmeet24/sub/making-a-semantic-dictionary-from-2001-pagemaker-f-HjVpJCtN8VjSYm9WT2oxBt">Making a semantic dictionary from 2001 Pagemaker files using FOSS tools</a></p> <p><a href="https://wiki.fosscell.org/index.php?title=FOSSMeet/24">FOSSMeet'24</a>, NIT Calicut, India</p> </li> </ul> <h3 id="2023">2023</h3> <ul> <li> <p><a href="https://www.youtube.com/watch?v=iBM1OLYP8os">เดชเดฏเตเดฏเดจเตเด‚ เดซเตเดฐเต€เด•เตเด•เดจเตเด‚ เดชเดฟเดจเตเดจเต† เดžเดพเดจเตเด‚. &quot;Fยฅp hn[nbnXv !&quot;</a></p> <p><a href="https://kochifoss.org">Kochi FOSS Meetup</a>, Kochi, India</p> </li> <li> <p><a href="https://www.youtube.com/watch?v=S-EadO1n38k">Using Ruby as a config file syntax</a> (Lightning talk)</p> <p><a href="https://rubyconf.in/">RubyConf India</a>, Pune, India</p> </li> <li> <p><a href="https://www.youtube.com/watch?v=DZrq6FkxW48">How I made เด•เดฟเดŸเตเดŸเตเด‚.com</a></p> <p><a href="https://kochifoss.org">Kochi FOSS Meetup</a>, Kochi, India</p> <p><a href="https://www.youtube.com/watch?v=EctlcR8zygg"><em>Mirror</em></a></p> </li> <li> <p><a href="https://www.youtube.com/watch?v=o8IWwuLaqTs">Using WebTorrent trackers for purposes other than torrents</a></p> <p>IndiaFOSS, Bengaluru, India</p> </li> <li> <p><a href="https://www.youtube.com/watch?v=XPm-i8smfNU">Open source beginner experience of contributing to WebTorrent and building apps with it</a></p> <p><a href="https://wiki.fosscell.org/index.php?title=FOSSMEET#2023_(13th_Edition)">FOSSMeet'23</a>, NIT Calicut, India</p> </li> </ul> <h3 id="2021">2021</h3> <ul> <li> <p><a href="https://www.youtube.com/watch?v=vewyVG6TfgA">GoVarnam, a new &quot;Intelligent&quot; Input Method for Indian Languages in Desktop &amp; Mobile</a></p> <p><a href="https://debconf21.debconf.org/talks/21-govarnam-a-new-intelligent-input-method-for-indian-languages-in-desktop-mobile/">DebConf21</a>, Online</p> </li> <li> <p><a href="https://www.youtube.com/watch?v=oBD7iA6zmgk">เดŸเดฟ.เดตเดฟ เดชเดฐเดธเตเดฏเด˜เดพเดคเด•เตป, Television AdBlocker</a></p> <p><a href="https://in2021.mini.debconf.org/talks/13-/">MiniDebConf India 2021</a>, Online</p> </li> </ul> <h3 id="2020">2020</h3> <ul> <li> <p><a href="https://www.youtube.com/watch?v=Fy0r-pHE6Us">State of writing Malayalam on GNU/Linux : เด—เตเดจเต/เดฒเดฟเดจเด•เตเดธเดฟเดฒเต† เดฎเดฒเดฏเดพเดณเดฎเต†เดดเตเดคเตเดคเตเตโ€Œ</a></p> <p><a href="https://debconf20.debconf.org/talks/77-state-of-writing-malayalam-on-gnulinux/">DebConf20</a>, Online</p> </li> </ul> <!-- ### 2019 * [โ€ŒSelfie a Day project](https://www.youtube.com/watch?v=zIWdH1cV88s) [PyCon India](), Chennai, India --> <style> article li { margin-bottom: 10px; } </style> Simple analysis of place names in Kerala https://subinsb.com/simple-analysis-of-kerala-place-names/ Thu, 31 Oct 2024 00:00:00 +0530 https://subinsb.com/simple-analysis-of-kerala-place-names/ <h2 id="update">Update</h2> <p>After this post was published, some people asked for some other suffixes to be analyzed. I've now made an interactive webpage to analyse place names in any way with SQL:</p> <div class="padlinks"> <a class="demo" href="https://lab.subinsb.com/kerala-place-name-analysis/" target="_blank">Open Playground</a> </div> <h2 id="intro">Intro</h2> <p>I noticed something unique when I walked around in Kakkanad, some of the local place names ended with the word &quot;เดฎเตเด—เตพ&quot;.</p> <p><img src="https://subinsb.com/uploads/2024/10/nilampathinjamugal.png" alt="Nilampathinjamugal"></p> <p>I haven't heard of any other place having this suffix in Kerala before, so it was quite interesting to me. The curiosity instantly brewed in my mind, is this really specific to Kakkanad? Why so?</p> <p>I never got the time to explore this idea more until last week at a <a href="https://meta.wikimedia.org/wiki/Event:Wiki_Loves_Onam_2024/Wikimedia_Workshop_Thrissur">Wikimedia event in my alma mater</a>.</p> <h2 id="goal">Goal</h2> <p>To list all the places in Kerala with a particular suffix and show them as dots on an interactive map. This'll help to know the frequency better.</p> <h2 id="gathering-data">Gathering data</h2> <p>Where to get the list of all place names in Kerala &amp; their coordinates?</p> <p>It is only when you try to do data analysis, you realize the lack of data and errors in the data that is available.</p> <h3 id="openstreetmap">OpenStreetMap</h3> <ul> <li>Get the list of all place names</li> </ul> <blockquote> <p><a href="https://overpass-api.de/api/interpreter?data=%5Bout:json%5D;area%5Bname=%22Kerala%22%5D;node(area)%5Bplace%5D;out;">https://overpass-api.de/api/interpreter?data=[out:json];area[name=%22Kerala%22];node(area)[place];out;</a></p> </blockquote> <ul> <li>Get the list of all bus stops</li> </ul> <blockquote> <p><a href="https://overpass-api.de/api/interpreter?data=%5Bout:json%5D;area%5Bname=%22Kerala%22%5D-%3E.searchArea;node%5B%22highway%22=%22bus_stop%22%5D(area.searchArea);out;">https://overpass-api.de/api/interpreter?data=[out:json];area[name=%22Kerala%22]-%3E.searchArea;node[%22highway%22=%22bus_stop%22](area.searchArea);out;</a></p> </blockquote> <p>Bus stop names are usually the place names itself, I noticed in OSM that some place name nodes are not on the map but the bus stops are. Hence why I collected them both, there will be duplicates because of this but that's fine, this is a simple human analysis.</p> <h3 id="wikidata">Wikidata</h3> <p><a href="https://query.wikidata.org/">Wikidata query service</a> is used to run these SPARQL queries.</p> <ul> <li>Get the list of human settlements in Kerala:</li> </ul> <div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sql" data-lang="sql"><span style="display:flex;"><span><span style="color:#66d9ef">SELECT</span> <span style="color:#66d9ef">DISTINCT</span> <span style="color:#f92672">?</span>item <span style="color:#f92672">?</span>len <span style="color:#f92672">?</span>lml <span style="color:#f92672">?</span>coord </span></span><span style="display:flex;"><span><span style="color:#66d9ef">WHERE</span> </span></span><span style="display:flex;"><span><span style="color:#960050;background-color:#1e0010">{</span> </span></span><span style="display:flex;"><span> <span style="color:#f92672">?</span>item wdt:P31 wd:Q486972 . </span></span><span style="display:flex;"><span> <span style="color:#f92672">?</span>item wdt:P131<span style="color:#f92672">/</span>wdt:P131<span style="color:#f92672">*</span> wd:Q1186. </span></span><span style="display:flex;"><span> <span style="color:#f92672">?</span>item wdt:P625 <span style="color:#f92672">?</span>coord. </span></span><span style="display:flex;"><span> OPTIONAL <span style="color:#960050;background-color:#1e0010">{</span> <span style="color:#f92672">?</span>item rdfs:label <span style="color:#f92672">?</span>len. FILTER(LANG(<span style="color:#f92672">?</span>len)<span style="color:#f92672">=</span><span style="color:#e6db74">&#34;en&#34;</span>) <span style="color:#960050;background-color:#1e0010">}</span> </span></span><span style="display:flex;"><span> OPTIONAL <span style="color:#960050;background-color:#1e0010">{</span> <span style="color:#f92672">?</span>item rdfs:label <span style="color:#f92672">?</span>lml. FILTER(LANG(<span style="color:#f92672">?</span>lml)<span style="color:#f92672">=</span><span style="color:#e6db74">&#34;ml&#34;</span>) <span style="color:#960050;background-color:#1e0010">}</span> </span></span><span style="display:flex;"><span><span style="color:#960050;background-color:#1e0010">}</span> </span></span><span style="display:flex;"><span><span style="color:#66d9ef">LIMIT</span> <span style="color:#ae81ff">100</span> </span></span></code></pre></div><p>The good folks at <a href="https://opendatakerala.org/">OpenDataKerala</a> has made ward data openly accessible on Wikidata and OpenStreetMap. Some of these wards have coordinates assigned.</p> <ul> <li>Get list of local body wards that has a coordinate.</li> </ul> <div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sql" data-lang="sql"><span style="display:flex;"><span><span style="color:#66d9ef">SELECT</span> <span style="color:#66d9ef">DISTINCT</span> <span style="color:#f92672">?</span>item <span style="color:#f92672">?</span>len <span style="color:#f92672">?</span>lml <span style="color:#f92672">?</span>coord </span></span><span style="display:flex;"><span><span style="color:#66d9ef">WHERE</span> </span></span><span style="display:flex;"><span><span style="color:#960050;background-color:#1e0010">{</span> </span></span><span style="display:flex;"><span> <span style="color:#f92672">?</span>item wdt:P31 wd:Q1195098 . </span></span><span style="display:flex;"><span> <span style="color:#f92672">?</span>item wdt:P131<span style="color:#f92672">*</span> wd:Q1186. </span></span><span style="display:flex;"><span> <span style="color:#f92672">?</span>item wdt:P625 <span style="color:#f92672">?</span>coord. </span></span><span style="display:flex;"><span> OPTIONAL <span style="color:#960050;background-color:#1e0010">{</span> <span style="color:#f92672">?</span>item rdfs:label <span style="color:#f92672">?</span>len. FILTER(LANG(<span style="color:#f92672">?</span>len)<span style="color:#f92672">=</span><span style="color:#e6db74">&#34;en&#34;</span>) <span style="color:#960050;background-color:#1e0010">}</span> </span></span><span style="display:flex;"><span> OPTIONAL <span style="color:#960050;background-color:#1e0010">{</span> <span style="color:#f92672">?</span>item rdfs:label <span style="color:#f92672">?</span>lml. FILTER(LANG(<span style="color:#f92672">?</span>lml)<span style="color:#f92672">=</span><span style="color:#e6db74">&#34;ml&#34;</span>) <span style="color:#960050;background-color:#1e0010">}</span> </span></span><span style="display:flex;"><span><span style="color:#960050;background-color:#1e0010">}</span> </span></span></code></pre></div><h2 id="combining-data">Combining data</h2> <p>We have <a href="https://github.com/subins2000/kerala-place-name-analysis/tree/main/raw">four sources of data in JSON</a>. They need to be combined so that it's easy to filter out data.</p> <p>I figured putting them all into a SQLite DB would be the best way. For this I wrote a Ruby script. <a href="https://github.com/rails/rails/tree/main/activerecord">Rails' ActiveRecord</a> makes it pretty easy to manage the DB.</p> <h3 id="activerecord-without-ruby-on-rails">ActiveRecord without Ruby on Rails</h3> <p>One of the main features of Ruby on Rails is the ActiveRecord ORM. This can be used without Ruby on Rails as well.</p> <div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-ruby" data-lang="ruby"><span style="display:flex;"><span>require <span style="color:#e6db74">&#39;active_record&#39;</span> </span></span><span style="display:flex;"><span>require <span style="color:#e6db74">&#39;sqlite3&#39;</span> </span></span><span style="display:flex;"><span> </span></span><span style="display:flex;"><span><span style="color:#66d9ef">ActiveRecord</span><span style="color:#f92672">::</span><span style="color:#66d9ef">Base</span><span style="color:#f92672">.</span>establish_connection( </span></span><span style="display:flex;"><span> <span style="color:#e6db74">adapter</span>: <span style="color:#e6db74">&#39;sqlite3&#39;</span>, </span></span><span style="display:flex;"><span> <span style="color:#e6db74">database</span>: <span style="color:#e6db74">&#39;db.sqlite3&#39;</span> </span></span><span style="display:flex;"><span>) </span></span><span style="display:flex;"><span> </span></span><span style="display:flex;"><span><span style="color:#75715e"># This is a model that corresponds to a table</span> </span></span><span style="display:flex;"><span><span style="color:#66d9ef">class</span> <span style="color:#a6e22e">Place</span> <span style="color:#f92672">&lt;</span> <span style="color:#66d9ef">ActiveRecord</span><span style="color:#f92672">::</span><span style="color:#66d9ef">Base</span> </span></span><span style="display:flex;"><span><span style="color:#66d9ef">end</span> </span></span><span style="display:flex;"><span> </span></span><span style="display:flex;"><span><span style="color:#75715e"># Table name in SQLite will be plural: &#34;places&#34;</span> </span></span><span style="display:flex;"><span>@first_run <span style="color:#f92672">=</span> <span style="color:#f92672">!</span><span style="color:#66d9ef">Place</span><span style="color:#f92672">.</span>table_exists? </span></span><span style="display:flex;"><span> </span></span><span style="display:flex;"><span><span style="color:#75715e"># 3. Create the table (migration-like setup)</span> </span></span><span style="display:flex;"><span><span style="color:#66d9ef">if</span> @first_run </span></span><span style="display:flex;"><span> <span style="color:#66d9ef">ActiveRecord</span><span style="color:#f92672">::</span><span style="color:#66d9ef">Schema</span><span style="color:#f92672">.</span>define <span style="color:#66d9ef">do</span> </span></span><span style="display:flex;"><span> create_table <span style="color:#e6db74">:places</span> <span style="color:#66d9ef">do</span> <span style="color:#f92672">|</span>t<span style="color:#f92672">|</span> </span></span><span style="display:flex;"><span> t<span style="color:#f92672">.</span>string <span style="color:#e6db74">:name</span> </span></span><span style="display:flex;"><span> t<span style="color:#f92672">.</span>string <span style="color:#e6db74">:lat</span> </span></span><span style="display:flex;"><span> t<span style="color:#f92672">.</span>string <span style="color:#e6db74">:lon</span> </span></span><span style="display:flex;"><span> t<span style="color:#f92672">.</span>timestamps </span></span><span style="display:flex;"><span> <span style="color:#66d9ef">end</span> </span></span><span style="display:flex;"><span> add_index <span style="color:#e6db74">:places</span>, <span style="color:#e6db74">:name</span>, <span style="color:#e6db74">unique</span>: <span style="color:#66d9ef">true</span> </span></span><span style="display:flex;"><span> <span style="color:#66d9ef">end</span> </span></span><span style="display:flex;"><span><span style="color:#66d9ef">end</span> </span></span></code></pre></div><p>The above script will setup the DB. Sometimes you'll want to reset and start over, simply just the delete the <code>db.sqlite3</code> file (Good part of SQLite being simple).</p> <h3 id="insert-data">Insert data</h3> <p>The next step is to insert the data, for this I created <a href="https://github.com/subins2000/kerala-place-name-analysis/blob/main/analysis.rb#L79">separate functions</a>.</p> <div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-ruby" data-lang="ruby"><span style="display:flex;"><span><span style="color:#66d9ef">if</span> @first_run </span></span><span style="display:flex;"><span> osm_bus_stops </span></span><span style="display:flex;"><span> osm_place_nodes </span></span><span style="display:flex;"><span> wikidata_places </span></span><span style="display:flex;"><span> wikidata_wards </span></span><span style="display:flex;"><span> </span></span><span style="display:flex;"><span> <span style="color:#66d9ef">Place</span><span style="color:#f92672">.</span>insert_all(@records) </span></span><span style="display:flex;"><span><span style="color:#66d9ef">end</span> </span></span></code></pre></div><p>Now that we have the DB setup, we can do the analysis.</p> <p>Ruby interactive console can be used to debug and query easily with ActiveRecord, for this I trigger the runtime developer console at the end of the file.</p> <div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-ruby" data-lang="ruby"><span style="display:flex;"><span>require <span style="color:#e6db74">&#39;pry&#39;</span> </span></span><span style="display:flex;"><span><span style="color:#f92672">...</span> </span></span><span style="display:flex;"><span><span style="color:#f92672">...</span> </span></span><span style="display:flex;"><span>binding<span style="color:#f92672">.</span>pry </span></span></code></pre></div><p>Using the console to fetch all the places that has the word <code>mugal</code> in it:</p> <div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-ruby" data-lang="ruby"><span style="display:flex;"><span><span style="color:#66d9ef">Place</span><span style="color:#f92672">.</span>where(<span style="color:#e6db74">&#34;name LIKE &#39;%mugal%&#39;&#34;</span>)<span style="color:#f92672">.</span>pluck(<span style="color:#e6db74">:name</span>, <span style="color:#e6db74">:lat</span>, <span style="color:#e6db74">:lon</span>) </span></span></code></pre></div><p><img src="https://subinsb.com/uploads/2024/10/ruby-binding-pry-debugger.png" alt="binding.pry runtime developer console"></p> <h2 id="analysis">Analysis</h2> <p>The most effective way to show the result is with a map of marked points. I figured using <a href="https://leafletjs.com/">Leaflet</a> will be the easiest because I can programmatically control it and I have seen it being used everywhere on the web.</p> <h3 id="showing-just-kerala-region">Showing just Kerala region</h3> <p>Leaflet showed the full map of the Earth, but I wanted to show just Kerala. This was difficult to achieve. I needed to get the exact boundaries of the Kerala region. My first attempt was to use the <a href="https://commons.wikimedia.org/w/index.php?title=Data:India/Kerala.map&amp;action=edit">geometry data from Wikipedia</a>.</p> <p><img src="https://subinsb.com/uploads/2024/10/kerala-marked-region-in-leaflet.png" alt="Kerala region colored in red"></p> <p>But I wanted to distinguish the districts better. I explored many ways and finally reached the best solution. Write a query in Overpass, download the geojson and load it in leaflet.</p> <p>The geojson can be obtained by running this query on <a href="https://overpass-turbo.eu/">https://overpass-turbo.eu/</a></p> <div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-ruby" data-lang="ruby"><span style="display:flex;"><span><span style="color:#f92672">[</span><span style="color:#e6db74">out</span>:xml<span style="color:#f92672">][</span><span style="color:#e6db74">timeout</span>:<span style="color:#ae81ff">500</span><span style="color:#f92672">]</span>; </span></span><span style="display:flex;"><span>{{<span style="color:#e6db74">geocodeArea</span>:<span style="color:#66d9ef">Kerala</span>}}<span style="color:#f92672">-&gt;.</span>searchArea; </span></span><span style="display:flex;"><span>( </span></span><span style="display:flex;"><span> nwr<span style="color:#f92672">[</span><span style="color:#e6db74">&#34;boundary&#34;</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;administrative&#34;</span><span style="color:#f92672">][</span><span style="color:#e6db74">&#34;admin_level&#34;</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;5&#34;</span><span style="color:#f92672">]</span>(area<span style="color:#f92672">.</span>searchArea); </span></span><span style="display:flex;"><span>); </span></span><span style="display:flex;"><span><span style="color:#e6db74">//</span> print results </span></span><span style="display:flex;"><span>out meta; </span></span><span style="display:flex;"><span><span style="color:#f92672">&gt;</span>; </span></span><span style="display:flex;"><span>out meta qt; </span></span></code></pre></div><p>If you notice the query, it fetches administrative regions with level 5, this is the districts of Kerala.</p> <h3 id="coloring-districts-uniquely">Coloring districts uniquely</h3> <p>Since the geojson is made up of district region boundaries, based on the name of the region, the fill color can be changed. This is how that looks like:</p> <div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-javascript" data-lang="javascript"><span style="display:flex;"><span><span style="color:#a6e22e">L</span>.<span style="color:#a6e22e">geoJSON</span>(<span style="color:#a6e22e">json</span>, { </span></span><span style="display:flex;"><span> <span style="color:#a6e22e">style</span><span style="color:#f92672">:</span> <span style="color:#66d9ef">function</span>(<span style="color:#a6e22e">feature</span>) { </span></span><span style="display:flex;"><span> <span style="color:#66d9ef">return</span> { </span></span><span style="display:flex;"><span> <span style="color:#a6e22e">fillColor</span><span style="color:#f92672">:</span> <span style="color:#a6e22e">colors</span>[<span style="color:#a6e22e">feature</span>.<span style="color:#a6e22e">properties</span>.<span style="color:#a6e22e">name</span>], <span style="color:#75715e">// colors[&#34;Thrissur&#34;] </span></span></span><span style="display:flex;"><span><span style="color:#75715e"></span> <span style="color:#a6e22e">fillOpacity</span><span style="color:#f92672">:</span> <span style="color:#ae81ff">0.5</span>, </span></span><span style="display:flex;"><span> <span style="color:#a6e22e">color</span><span style="color:#f92672">:</span> <span style="color:#e6db74">&#34;#000&#34;</span>, </span></span><span style="display:flex;"><span> <span style="color:#a6e22e">weight</span><span style="color:#f92672">:</span> <span style="color:#ae81ff">0.2</span>, </span></span><span style="display:flex;"><span> } </span></span><span style="display:flex;"><span> } </span></span><span style="display:flex;"><span>}) </span></span></code></pre></div><p><img src="https://subinsb.com/uploads/2024/10/kerala-districts-colored-separately-in-leaflet.png" alt="Kerala districts colored separately"></p> <h2 id="result">Result</h2> <p>I've analyzed suffixes of &quot;kari&quot;, &quot;mugal&quot;, &quot;ssery&quot;, and &quot;kulam&quot; suffixes, plotted it on to the map, then use Firefox's screenshot tool to grab the boundary box. This is how the webpage of Leaflet looks like:</p> <p><img src="https://subinsb.com/uploads/2024/10/leaflet-page-in-browser.png" alt="Leaflet page in Firefox"></p> <p>Firefox' screenshot tool is pretty nice to grab just the rectangle box by the border:</p> <p><img src="https://subinsb.com/uploads/2024/10/data-maps/kari.png" alt="Leaflet page in Firefox"></p> <h2 id="conclusion">Conclusion</h2> <h3 id="mugal">mugal</h3> <p>The place names ending with &quot;mugal&quot; suffix is indeed a specialty of Kakkanad. The logical reasoning I have so far is that it's because of the nature of the place. Since they're hilly areas, using the name mugal/เดฎเตเด•เตพ (top) makes sense.</p> <p><img src="https://subinsb.com/uploads/2024/10/data-maps/mugal-kakkanad.png" alt="Mugal suffixed places in Kakkanad"></p> <h3 id="kari">kari</h3> <p>Kuttanad has a reason why it has a lot of place names ending with kari/เด•เดฐเดฟ. <a href="https://en.wikipedia.org/wiki/Kuttanad">From Wikipedia</a>:</p> <blockquote> <p>Kuttanad was once believed to be a wild forest with dense tree growth which was destroyed subsequently by a wild fire. Chuttanad (place of the burnt forest), was eventually called Kuttanad. Until the recent past burned black wooden logs were mined from paddy fields called as &quot;Karinilam&quot; (Black paddy fields). This fact substantiates the theory of Chuttanad evolving to Kuttanad. Ramankary, Puthukkary, Amichakary, Oorukkary, Mithrakary, Mampuzhakary, Kainakary, Chathurthiakary, Thakazhy, Edathua, Chambakkulam, Mankombu and Chennamkary are some familiar place names in Kuttanad</p> </blockquote> <p><img src="https://subinsb.com/uploads/2024/10/data-maps/kari.png" alt="kari suffixed places in Kerala"></p> <p>Interestingly, Kannur mountain ranges also have a lot of such places! I don't have a good answer to this but I think it must be because the people who settled in these mountain regions are people from south Kerala. When people migrate, they tend to name the new places from the places they came from or are familar with.</p> <h3 id="kulam">kulam</h3> <p>Kulam means pond and Kerala has a lot of it. So it obviously makes snese that it's present everywhere in Kerala.</p> <p><img src="https://subinsb.com/uploads/2024/10/data-maps/kulam.png" alt="kulam suffixed places in Kerala"></p> <h3 id="ssery">ssery</h3> <p>Interestingly it's not present in Kasargod or Thiruvananthapuram but is present everywhere else.</p> <p><img src="https://subinsb.com/uploads/2024/10/data-maps/ssery.png" alt="ssery suffixed places in Kerala"></p> <p>You can see more imagery <a href="https://gitlab.com/subins2000/subinsb.com/-/tree/master/static/uploads/2024/10/data-maps?ref_type=heads">here</a>.</p> <h2 id="credits">Credits</h2> <p>Thanks to OpenStreetMap, Wikidata contributors. Data analysis is all fancy and all, but no analysis is possible without data. So first and foremast thanks to all the people who contibute!</p> <p>Thanks to <a href="https://en.wikipedia.org/wiki/User:Gnoeee">Jinoy</a>, <a href="https://wiki.openstreetmap.org/wiki/User:Manojk">Manoj K</a> &amp; <a href="https://meta.wikimedia.org/wiki/User:Ranjithsiji">Ranjith Siji</a> for answering my queries at the event. This made things faster to build.</p> samam, Malayalam Kannada Tamil Telugu dictionary https://subinsb.com/samam-malayalam-kannada-tamil-telugu-dictionary/ Thu, 04 Apr 2024 00:00:00 +0530 https://subinsb.com/samam-malayalam-kannada-tamil-telugu-dictionary/ <p>This is the story of solving a problem, making a dictionary book online.</p> <h2 id="the-dictionary">The dictionary</h2> <p><a href="https://en.wikipedia.org/wiki/Njattyela_Sreedharan">Njattyela Sreedharan (เดžเดพเดฑเตเดฑเตเดฏเต‡เดฒ เดถเตเดฐเต€เดงเดฐเตป)</a> is an 85 year old person from Kannur, Kerala. Out of his interest for Dravidian languages, he spent <a href="https://timesofindia.indiatimes.com/blogs/tracking-indian-communities/words-their-multiple-meanings/">25 years in compiling a dictionary</a> of four Dravidian languages - Malayalam, Kannada, Tamil, Telugu.</p> <p>The dictionary was originaly handwritten in a book of four columns. This was later published as a book by Senior Citizens Forum. <a href="https://www.newindianexpress.com/states/kerala/2011/Jan/02/open-source-animation-movie-comes-to-india-215861.html">This news article</a> tells a better story than me here :)</p> <p>The story of Njatyela Sreedharan's effort became a <a href="https://www.youtube.com/watch?v=IWmRnOcm_Ko">documentary</a> and it won the National Film Award for Best Educational/Motivational/Instructional Film (2020).</p> <p>The documentary is really good and seeing it gave me a huge motivation to make this dictionary online.</p> <h2 id="start">Start</h2> <p>The easiest way to make this dictionary book online is to convert the soft copy to a format understandable by <a href="https://github.com/knadh/dictpress">dictpress</a>.</p> <p>A dictionary is structured data, in this case here is how the ideal structure looks like for each entry:</p> <ul> <li>Malayalam word</li> <li>Malayalam definition</li> <li>Tamil word</li> <li>Tamil definition</li> <li>Kannada word</li> <li>Kannada definition</li> <li>Telugu word</li> <li>Telugu definition</li> </ul> <p>Pretty simple structure.</p> <p>The soft copy we have is PDF and the Adobe Pagemaker 7 files.</p> <p>Here is how the book/PDF/Pagemaker file looks like visually:</p> <p><img src="https://subinsb.com/uploads/2024/04/samam-dictionary-pdf.png" alt=""></p> <p>There are 4 columns. This looks all pretty in the front but behind the scenes the way it is created is superbly difficult to parse.</p> <p>There are 4 hidden problems here to summarize:</p> <ul> <li>The Malayalam text is written in <strong>ASCII</strong> (Adobe Pagemaker 7 doesn't support Unicode)</li> <li>The way the table is created is not the best way to create a table, the black border is fake, it's an image</li> <li>There are hidden text in each cells to make the row alignment correct. These text has white text color, so it's not visible when printed, but when we try to copy text, we get these unwanted characters.</li> <li>In some pages, the ordering of columns is incorrect although it's shown correctly in PDF</li> </ul> <h2 id="getting-semantic-data">Getting semantic data</h2> <p>HTML/XML is a good data structure for semantic data. HTML/XML is semantic in nature by default. Take this code for example</p> <pre tabindex="0"><code>&lt;tr&gt; &lt;td&gt;&lt;b&gt;Apple&lt;/b&gt;&lt;/td&gt; &lt;td&gt;-&lt;/td&gt; &lt;td&gt;a fruit&lt;/td&gt; &lt;/tr&gt; </code></pre><p>The word and its meaning can be separated out from the above HTML very easily because the distinct content has its own tags. Since our PDF already shows text formatting like this, getting the HTML of it would help things out.</p> <h3 id="attempt-1---extract-from-pdf">Attempt 1 - Extract from PDF</h3> <p>I used many tools to convert PDF to text/HTML but the output had no proper structure.</p> <p>I learnt it the hard way that PDF is black magic, what you see is not what you get, copying the text from it is not giving the correct datapoints. <a href="https://learnlearn.in/">Akshay</a> gave an eye opener on this:</p> <p><img src="https://subinsb.com/uploads/2024/04/samam-dictionary-pdf-black-magic.png" alt="Akshay talking about PDF black magic"></p> <p>The first team call on how to make this into an online dictionary we learnt about all these problems, and things were looking bleak. The initial talks were all focused on the PDF and it was Joice who suggested if there's a possibility of getting HTML because it'd make things a lot easier.</p> <p>Ok, so how do we get the HTML?</p> <h3 id="attempt-2---extract-from-pagemaker">Attempt 2 - Extract from Pagemaker</h3> <p>Along with the PDF, we had the original <code>.psd</code> files.</p> <p>Adobe officially stopped Pagemaker in 2004. It has a proprietary data format that is difficult to parse. Document Foundation (Libreoffice) has made a library <a href="https://wiki.documentfoundation.org/DLP/Libraries/libpagemaker">libpagemaker</a> to parse Pagemaker documents. (Side note: <a href="https://gitlab.com/kannanvm/freaknz-qt">freaknz</a> has made changes in libpagemaker to accomodate some rare Malayalam ASCII bugs)</p> <p>But I wanted to see what this Pagemaker actually looked like. So I got a Windows machine that had <code>Pagemaker.exe</code>.</p> <p>I opened these files in Pagemaker and could see an <strong>Export to HTML</strong> option. But as soon as I clicked the export button, Pagemaker crashed. I figured out that I have to not change any options in export and to be very careful in moving the mouse and clicking the &quot;Export&quot; button. Some weird bug.</p> <blockquote> <p>Gotta appreciate the backward compatibility of Windows,</p> <p>this 20+ year old software works smooth on a Windows 10 machine.</p> <p>It is a good thing and also a bad thing.</p> </blockquote> <p>I got the <a href="https://gitlab.com/smc/samam/-/blob/master/data-cleanup/1-original/1.htm?ref_type=heads">HTML output</a> and it was not what I expected:</p> <p><img src="https://subinsb.com/uploads/2024/04/samam-dictionary-html-output.png" alt="HTML output from Adobe Pagemaker"></p> <p>We have new problems now:</p> <ul> <li>The table data structure is weird, it is column wise instead of row wise</li> <li>There are empty cells in all kinda places</li> <li>Some entries continue into the next page</li> <li>Some entries doesn't have any Kannada Tamil Telugu values because it is a duplicate of some other entry</li> <li>Many more edge cases that I forgot (it's been 6 months since I last touched the code)</li> </ul> <p>If I explained the solution of these, this blog post would go soooooooooo long. Here is the code which fixed these problems and made it into a CSV format:</p> <ul> <li><a href="https://gitlab.com/smc/samam/-/blob/master/data-cleanup/3-csv/fix-tables.js?ref_type=heads">fix-tables.js</a></li> <li><a href="https://gitlab.com/smc/samam/-/blob/master/data-cleanup/3-csv/make-csv.js?ref_type=heads">make-csv.js</a></li> </ul> <h2 id="interesting-tidbits">Interesting tidbits</h2> <p>&quot;Jack of all trades, master of none&quot; is a quote that I often see from developers. For solving problems, these surface level knowledge of many things is actually very useful. You will know what to apply, where to apply.</p> <p>I'm just gonna mention these trades.</p> <h3 id="usage-of-jquery">Usage of jQuery</h3> <p>The best way to parse HTML is JavaScript (duh) and a swiss-knife that makes this easier is jQuery. I've used jQuery for various kind of things from <a href="https://github.com/subins2000/open">building apps</a> to <a href="https://twitter.com/SubinSiby/status/1735768246744424678">browser automation</a>.</p> <p>Remember the problem of white color text in the PDF/HTML? This can be solved by removing all such white colored text like this:</p> <pre tabindex="0"><code>$(&#34;font[color=&#39;#ffffff&#39;]&#34;).remove(); </code></pre><p>Pretty simple eh!</p> <h3 id="usage-of-php">Usage of PHP</h3> <p>There are 10 HTML files, I want to first experiment with some tables, and then expand it to others. How do I dynamically load the HTML pages? The easiest way to do this is in PHP.</p> <p>PHP is another swiss-knife for hacks. PHP's beginning itself is from quick shortcut hacks for making websites.</p> <pre tabindex="0"><code>&lt;?php $number_of_tables = 100; // Configure how many tables to show $src = file_get_contents(&#34;source-of-truth.html&#34;); $table_count = 0; $tables = preg_split(&#39;/\&lt;\/table\&gt;+/&#39;, $src); for ($i = 0; $i &lt; $number_of_tables; $i++) { echo $tables[$i]; } echo &#34;&lt;/table&gt;&#34; ?&gt; &lt;script src=&#34;fix-tables.js&#34;&gt;&lt;/script&gt; &lt;script src=&#34;make-csv.js&#34;&gt;&lt;/script&gt; </code></pre><p>Unlike 2012, you don't need apache server for rendering PHP pages, you can do this</p> <pre tabindex="0"><code>php -S localhost:3000 </code></pre><p>PHP + jQuery helped to get a CSV file but it was still in ASCII text</p> <p><img src="https://subinsb.com/uploads/2024/04/samam-dictionary-ascii-csv.png" alt=""></p> <h3 id="usage-of-c">Usage of C++</h3> <p><a href="https://github.com/libindic/payyans">payyans</a> is a python library <a href="http://lists.smc.org.in/pipermail/discuss-smc.org.in/2008-June/029459.html">made in 2008</a> by <a href="https://thottingal.in/">Santhosh Thottingal</a> for converting ASCII text to Unicode.</p> <p><a href="https://alphafork.com/">AlphaFork</a> has made a desktop app called <a href="https://gitlab.com/kannanvm/freaknz-qt">freaknz</a> using the payyans logic. They made it for <a href="https://blog.smc.org.in/smc-monthly-report-october-2019/">Janayugom newspaper's migration to Free/Libre software</a>.</p> <p>Freaknz desktop app is a very simple application that does the job really well. I simply copy pasted the CSV into it and got the Unicode output back.</p> <p>payyans is in Python, freaknz is in C++, the logic of both is the same. There is also <a href="https://gitlab.com/smc/chathans">chathans</a> reimplementing the same logic in C. To prevent this in future and to bring a standardization, we (SMC) have started a <a href="https://github.com/smc/payyans-go">Go port of payyans</a>. Just like <a href="https://varnamproject.com">Varnam</a>, the output will be a C shared library which can be binded to in any other language.</p> <h3 id="usage-of-python">Usage of Python</h3> <p>The next process was to convert the CSV into a format understandable by <a href="https://github.com/knadh/dictpress">dictpress</a> and along with it try to transliterate the Kannada, Tamil, Telugu text written in Malayalam script to its corresponding scripts.</p> <p><a href="https://libindic.org/Transliteration">libindic's transliteration module</a> was used for this. It gave transliteration to native script, Latin script and IPA.</p> <h3 id="usage-of-go">Usage of Go</h3> <p><a href="https://github.com/knadh/dictpress">dictpress</a> is written in Go. It was created considering two languages like <a href="https://olam.in/">Olam</a> which has English -&gt; Malayalam and Malayalam -&gt; Malayalam.</p> <p>Accomodating samam, a 4 language dictionary into it is a task. <a href="https://github.com/knadh/dictpress/issues/35">Some new things</a> had to be implemented for it. I consider this very hacky, and it is not following the relational DB way of handling things. It's just one JSONB column ๐Ÿ˜ฌ. But hey it works.</p> <h3 id="usage-of-ruby-on-rails">Usage of Ruby on Rails</h3> <p>dictpress only gave a search -&gt; result interface. The glossary view of dictpress lacks the ability to show a tabular structure like what the book/PDF had. That is the main hero here, the <strong>tabular view for comparitive study</strong>.</p> <p>Modifying dictpress for this is a heavy task, glossary logic needs a change, new search logic needs to be implemented in glossary.</p> <p>The easiest, fastest way to do this is to make it in Ruby on Rails. I was able to make the <a href="https://samam.net/glossary/">glossary view /glossary</a> in 4 hours.</p> <p>Side note: I haven't mentioned this in my blog, but for the past 2.5 years I've been working on Ruby on Rails and I love it. ActiveRecord and the rails console helped to do analysis, manipulations on the data easily:</p> <pre tabindex="0"><code>Entry.find_each do |entry| entry.update!(meta: JSON.parse(entry.notes)) rescue print(&#34;error #{entry.id}&#34;) end </code></pre><p><a href="https://guides.rubyonrails.org/active_record_basics.html">ActiveRecord</a>'s elegance in handling DB data is another fantastic tool to do quick hacks. <strong>Both dictpress and the glossary app uses the same DB just to make it clear</strong>.</p> <p>This is how the <code>Entry</code> model looks like:</p> <pre tabindex="0"><code>class Entry &lt; ApplicationRecord LANGS = %i[malayalam kannada tamil telugu] has_many :relations, foreign_key: :from_id has_many :definitions, through: :relations, source: :to_entry enum lang: Hash[LANGS.map { |symbol| [symbol, symbol.to_s] }] LANGS.each do |target_lang| define_method :&#34;#{target_lang}_defintions&#34; do return self if lang.to_sym == target_lang definitions.where(lang: target_lang).select(%i[content]).first end end end </code></pre><p>With the Ruby magic, this brings the convenience to do this:</p> <pre tabindex="0"><code>first_entry = Entry.first first_entry.malayalam_definitions first_entry.tamil_definitions </code></pre><h2 id="deployment">Deployment</h2> <p><a href="https://learnlearn.in/">Akshay</a> helped in setting up the server. In the era of Docker, Kubernetes blah blah blah deployment has gotten quite a complicated topic. We had a <a href="https://twitter.com/SubinSiby/status/1723980741795791035">phone call</a> on this and decided to keep it <a href="https://twitter.com/SubinSiby/status/1723980741795791035">dumb simple</a>:</p> <blockquote> <p>Debian &amp; ssh</p> </blockquote> <p>Whatever deployment process you choose, what matters is the documentation and simplicity. Here is the <a href="https://gitlab.com/smc/samam/-/blob/master/dictpress/DEPLOY.md?ref_type=heads">doc we made</a>.</p> <p>Volunteer driven projects really need the simplicity.</p> <p>And finally we have <a href="https://samam.net">samam.net</a>.</p> <p>PS: I don't work in samam anymore.</p> Running JavaScript code & Getting Result from Go using V8 Engine https://subinsb.com/run-js-code-from-go-with-chrome-v8-engine/ Sun, 17 Jul 2022 00:00:00 +0000 https://subinsb.com/run-js-code-from-go-with-chrome-v8-engine/ <p>I have a VueJS app, I want to make the <code>&lt;title&gt;</code> and <code>&lt;meta&gt;</code> tags to be populated in page source itself for better SEO.</p> <p>I could use Server Side Rendering but it was difficult, express.js keeps crashing and there's JavaScript inconsistencies (ES Module imports didn't work in node). More explanation at the very bottom.</p> <p>To solve this problem, I did something wild.</p> <p>I made a Go server, served the JS app. On each request, the HTML file is processed by Go and title, meta tags are dynamically populated, rest of the page is just another VueJS app.</p> <p>The title and meta tags depend upon the page URL (subdomain to be exact). The logic of how title and meta tags should be is already in the VueJS app, I'd have to rewrite the logic in Go.</p> <p>To avoid that I now call the JS function from Go, get the result and use it to make <code>&lt;title&gt;</code> and <code>&lt;meta&gt;</code>. Calling JavaScript from Go is done via V8 Engine. There is a <a href="https://github.com/rogchap/v8go">Go library called v8go</a> that has C bindings for V8 Engine.</p> <h2 id="serving-a-vue-app-from-go">Serving a Vue App From Go</h2> <p>I'm using <a href="https://echo.labstack.com/">echo library</a> to make a server easier.</p> <div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-go" data-lang="go"><span style="display:flex;"><span><span style="color:#66d9ef">func</span> <span style="color:#a6e22e">main</span>() { </span></span><span style="display:flex;"><span> <span style="color:#a6e22e">e</span> <span style="color:#f92672">:=</span> <span style="color:#a6e22e">echo</span>.<span style="color:#a6e22e">New</span>() </span></span><span style="display:flex;"><span> </span></span><span style="display:flex;"><span> <span style="color:#a6e22e">e</span>.<span style="color:#a6e22e">GET</span>(<span style="color:#e6db74">&#34;/&#34;</span>, <span style="color:#a6e22e">HandleIndex</span>) </span></span><span style="display:flex;"><span> <span style="color:#a6e22e">e</span>.<span style="color:#a6e22e">Static</span>(<span style="color:#e6db74">&#34;/&#34;</span>, <span style="color:#e6db74">&#34;dist&#34;</span>) </span></span><span style="display:flex;"><span> </span></span><span style="display:flex;"><span> <span style="color:#a6e22e">e</span>.<span style="color:#a6e22e">Logger</span>.<span style="color:#a6e22e">Fatal</span>(<span style="color:#a6e22e">e</span>.<span style="color:#a6e22e">Start</span>(<span style="color:#e6db74">&#34;:1323&#34;</span>)) </span></span><span style="display:flex;"><span>} </span></span></code></pre></div><p>The <code>dist</code> folder has the output from building JS (<code>yarn build</code>). A script of <code>/assets/index.js</code> in webpage will be in filesystem at <code>/dist/assets/index.js</code>.</p> <h2 id="dynamically-making-title-and-meta-tags">Dynamically Making title and meta Tags</h2> <p>Modify <code>index.html</code> used by VueJS app. Insert a placeholder for the things we need to modify via Go.</p> <div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-html" data-lang="html"><span style="display:flex;"><span>&lt;<span style="color:#f92672">html</span>&gt; </span></span><span style="display:flex;"><span> &lt;<span style="color:#f92672">head</span>&gt; </span></span><span style="display:flex;"><span> &lt;<span style="color:#f92672">title</span>&gt;${title}&lt;/<span style="color:#f92672">title</span>&gt; </span></span><span style="display:flex;"><span> &lt;<span style="color:#f92672">meta</span> <span style="color:#a6e22e">itemprop</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;name&#34;</span> <span style="color:#a6e22e">content</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;${title}&#34;</span> /&gt; </span></span><span style="display:flex;"><span> &lt;<span style="color:#f92672">meta</span> <span style="color:#a6e22e">itemprop</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;description&#34;</span> <span style="color:#a6e22e">content</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;${description}&#34;</span> /&gt; </span></span><span style="display:flex;"><span> <span style="color:#75715e">&lt;!-- other stuff --&gt;</span> </span></span><span style="display:flex;"><span> &lt;/<span style="color:#f92672">head</span>&gt; </span></span><span style="display:flex;"><span> &lt;<span style="color:#f92672">body</span>&gt; </span></span><span style="display:flex;"><span> &lt;<span style="color:#f92672">div</span> <span style="color:#a6e22e">id</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;app&#34;</span>&gt;&lt;/<span style="color:#f92672">div</span>&gt; </span></span><span style="display:flex;"><span> &lt;<span style="color:#f92672">script</span> <span style="color:#a6e22e">type</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;module&#34;</span> <span style="color:#a6e22e">src</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;/src/main.js&#34;</span>&gt;&lt;/<span style="color:#f92672">script</span>&gt; </span></span><span style="display:flex;"><span> &lt;/<span style="color:#f92672">body</span>&gt; </span></span><span style="display:flex;"><span>&lt;/<span style="color:#f92672">html</span>&gt; </span></span></code></pre></div><p>Our Go server will replace <code>${title}</code> and <code>${description}</code>. Echo library has a template engine which can be used for this but its syntax conflicted with Vue's syntax and <code>yarn build</code> failed because of it.</p> <p>The title and meta tags are depended on the request hostname (subdomain to be exact) :</p> <div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-go" data-lang="go"><span style="display:flex;"><span><span style="color:#66d9ef">type</span> <span style="color:#a6e22e">PageInfo</span> <span style="color:#66d9ef">struct</span> { </span></span><span style="display:flex;"><span> <span style="color:#a6e22e">title</span> <span style="color:#66d9ef">string</span> </span></span><span style="display:flex;"><span> <span style="color:#a6e22e">description</span> <span style="color:#66d9ef">string</span> </span></span><span style="display:flex;"><span>} </span></span><span style="display:flex;"><span> </span></span><span style="display:flex;"><span><span style="color:#66d9ef">var</span> <span style="color:#a6e22e">html</span> <span style="color:#66d9ef">string</span> </span></span><span style="display:flex;"><span> </span></span><span style="display:flex;"><span><span style="color:#66d9ef">func</span> <span style="color:#a6e22e">HandleIndex</span>(<span style="color:#a6e22e">c</span> <span style="color:#a6e22e">echo</span>.<span style="color:#a6e22e">Context</span>) <span style="color:#66d9ef">error</span> { </span></span><span style="display:flex;"><span> <span style="color:#a6e22e">hostname</span>, <span style="color:#a6e22e">_</span>, <span style="color:#a6e22e">_</span> <span style="color:#f92672">:=</span> <span style="color:#a6e22e">net</span>.<span style="color:#a6e22e">SplitHostPort</span>(<span style="color:#a6e22e">c</span>.<span style="color:#a6e22e">Request</span>().<span style="color:#a6e22e">Host</span>) </span></span><span style="display:flex;"><span> <span style="color:#a6e22e">pageInfo</span> <span style="color:#f92672">:=</span> <span style="color:#a6e22e">getPageInfo</span>(<span style="color:#a6e22e">hostname</span>) </span></span><span style="display:flex;"><span> </span></span><span style="display:flex;"><span> <span style="color:#a6e22e">formattedHTML</span> <span style="color:#f92672">:=</span> <span style="color:#a6e22e">strings</span>.<span style="color:#a6e22e">Replace</span>(<span style="color:#a6e22e">html</span>, <span style="color:#e6db74">&#34;${title}&#34;</span>, <span style="color:#a6e22e">pageInfo</span>.<span style="color:#a6e22e">title</span>, <span style="color:#ae81ff">50</span>) </span></span><span style="display:flex;"><span> <span style="color:#a6e22e">formattedHTML</span> = <span style="color:#a6e22e">strings</span>.<span style="color:#a6e22e">Replace</span>(<span style="color:#a6e22e">formattedHTML</span>, <span style="color:#e6db74">&#34;${description}&#34;</span>, <span style="color:#a6e22e">pageInfo</span>.<span style="color:#a6e22e">description</span>, <span style="color:#ae81ff">50</span>) </span></span><span style="display:flex;"><span> </span></span><span style="display:flex;"><span> <span style="color:#66d9ef">return</span> <span style="color:#a6e22e">c</span>.<span style="color:#a6e22e">HTML</span>(<span style="color:#a6e22e">http</span>.<span style="color:#a6e22e">StatusOK</span>, <span style="color:#a6e22e">formattedHTML</span>) </span></span><span style="display:flex;"><span>} </span></span></code></pre></div><p><code>HandleIndex</code> will be called on every request to <code>/</code>. We don't ned to make a filesystem read of the HTML file on every request (that'd be slow) :</p> <div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-go" data-lang="go"><span style="display:flex;"><span><span style="color:#66d9ef">func</span> <span style="color:#a6e22e">loadHTML</span>() { </span></span><span style="display:flex;"><span> <span style="color:#a6e22e">fileBytes</span>, <span style="color:#a6e22e">err</span> <span style="color:#f92672">:=</span> <span style="color:#a6e22e">ioutil</span>.<span style="color:#a6e22e">ReadFile</span>(<span style="color:#e6db74">&#34;dist/index.html&#34;</span>) </span></span><span style="display:flex;"><span> <span style="color:#66d9ef">if</span> <span style="color:#a6e22e">err</span> <span style="color:#f92672">!=</span> <span style="color:#66d9ef">nil</span> { </span></span><span style="display:flex;"><span> <span style="color:#a6e22e">log</span>.<span style="color:#a6e22e">Fatalln</span>(<span style="color:#a6e22e">err</span>.<span style="color:#a6e22e">Error</span>()) </span></span><span style="display:flex;"><span> } </span></span><span style="display:flex;"><span> <span style="color:#a6e22e">html</span> = string(<span style="color:#a6e22e">fileBytes</span>) </span></span><span style="display:flex;"><span>} </span></span><span style="display:flex;"><span> </span></span><span style="display:flex;"><span><span style="color:#66d9ef">func</span> <span style="color:#a6e22e">main</span>() { </span></span><span style="display:flex;"><span> <span style="color:#a6e22e">loadHTML</span>() </span></span><span style="display:flex;"><span> <span style="color:#75715e">// rest of it </span></span></span><span style="display:flex;"><span><span style="color:#75715e"></span>} </span></span></code></pre></div><h2 id="calling-javascript-from-go">Calling JavaScript from Go</h2> <p><code>getPageInfo()</code> can be anything. Here I'm using V8 Engine to call a JavaScript function that will give the page info :</p> <div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-go" data-lang="go"><span style="display:flex;"><span><span style="color:#f92672">import</span> ( </span></span><span style="display:flex;"><span> <span style="color:#a6e22e">v8</span> <span style="color:#e6db74">&#34;rogchap.com/v8go&#34;</span> </span></span><span style="display:flex;"><span>) </span></span><span style="display:flex;"><span> </span></span><span style="display:flex;"><span><span style="color:#66d9ef">var</span> <span style="color:#a6e22e">jsContext</span> <span style="color:#f92672">*</span><span style="color:#a6e22e">v8</span>.<span style="color:#a6e22e">Context</span> </span></span><span style="display:flex;"><span> </span></span><span style="display:flex;"><span><span style="color:#66d9ef">func</span> <span style="color:#a6e22e">getPageInfo</span>(<span style="color:#a6e22e">host</span> <span style="color:#66d9ef">string</span>) <span style="color:#a6e22e">PageInfo</span> { </span></span><span style="display:flex;"><span> <span style="color:#a6e22e">jsContext</span>.<span style="color:#a6e22e">RunScript</span>(<span style="color:#e6db74">&#34;var siteInfo = getSiteInfo(&#39;&#34;</span><span style="color:#f92672">+</span><span style="color:#a6e22e">host</span><span style="color:#f92672">+</span><span style="color:#e6db74">&#34;&#39;)&#34;</span>, <span style="color:#e6db74">&#34;call.js&#34;</span>) </span></span><span style="display:flex;"><span> <span style="color:#a6e22e">title</span>, <span style="color:#a6e22e">_</span> <span style="color:#f92672">:=</span> <span style="color:#a6e22e">jsContext</span>.<span style="color:#a6e22e">RunScript</span>(<span style="color:#e6db74">&#34;siteInfo.title&#34;</span>, <span style="color:#e6db74">&#34;retrieval.js&#34;</span>) </span></span><span style="display:flex;"><span> <span style="color:#a6e22e">description</span>, <span style="color:#a6e22e">_</span> <span style="color:#f92672">:=</span> <span style="color:#a6e22e">jsContext</span>.<span style="color:#a6e22e">RunScript</span>(<span style="color:#e6db74">&#34;siteInfo.description&#34;</span>, <span style="color:#e6db74">&#34;retrieval.js&#34;</span>) </span></span><span style="display:flex;"><span> </span></span><span style="display:flex;"><span> <span style="color:#66d9ef">return</span> <span style="color:#a6e22e">PageInfo</span>{<span style="color:#a6e22e">title</span>.<span style="color:#a6e22e">String</span>(), <span style="color:#a6e22e">description</span>.<span style="color:#a6e22e">String</span>()} </span></span><span style="display:flex;"><span>} </span></span></code></pre></div><p><code>jsContext</code> is a context inside a V8 JavaScript VM. We need to make this VM and context once only :</p> <div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-go" data-lang="go"><span style="display:flex;"><span><span style="color:#66d9ef">func</span> <span style="color:#a6e22e">makeJSContext</span>() { </span></span><span style="display:flex;"><span> <span style="color:#a6e22e">scriptBytes</span>, <span style="color:#a6e22e">err</span> <span style="color:#f92672">:=</span> <span style="color:#a6e22e">ioutil</span>.<span style="color:#a6e22e">ReadFile</span>(<span style="color:#e6db74">&#34;dist/utils.js&#34;</span>) </span></span><span style="display:flex;"><span> <span style="color:#66d9ef">if</span> <span style="color:#a6e22e">err</span> <span style="color:#f92672">!=</span> <span style="color:#66d9ef">nil</span> { </span></span><span style="display:flex;"><span> <span style="color:#a6e22e">log</span>.<span style="color:#a6e22e">Fatalln</span>(<span style="color:#a6e22e">err</span>.<span style="color:#a6e22e">Error</span>()) </span></span><span style="display:flex;"><span> } </span></span><span style="display:flex;"><span> </span></span><span style="display:flex;"><span> <span style="color:#a6e22e">iso</span> <span style="color:#f92672">:=</span> <span style="color:#a6e22e">v8</span>.<span style="color:#a6e22e">NewIsolate</span>() </span></span><span style="display:flex;"><span> <span style="color:#a6e22e">jsContext</span> = <span style="color:#a6e22e">v8</span>.<span style="color:#a6e22e">NewContext</span>(<span style="color:#a6e22e">iso</span>) </span></span><span style="display:flex;"><span> </span></span><span style="display:flex;"><span> <span style="color:#a6e22e">script</span> <span style="color:#f92672">:=</span> string(<span style="color:#a6e22e">scriptBytes</span>) </span></span><span style="display:flex;"><span> </span></span><span style="display:flex;"><span> <span style="color:#75715e">// dummy module object </span></span></span><span style="display:flex;"><span><span style="color:#75715e"></span> <span style="color:#a6e22e">jsContext</span>.<span style="color:#a6e22e">RunScript</span>(<span style="color:#e6db74">&#34;var module = {}&#34;</span>, <span style="color:#e6db74">&#34;module.js&#34;</span>) </span></span><span style="display:flex;"><span> </span></span><span style="display:flex;"><span> <span style="color:#a6e22e">_</span>, <span style="color:#a6e22e">err</span> = <span style="color:#a6e22e">jsContext</span>.<span style="color:#a6e22e">RunScript</span>(<span style="color:#a6e22e">script</span>, <span style="color:#e6db74">&#34;index.js&#34;</span>) </span></span><span style="display:flex;"><span> <span style="color:#66d9ef">if</span> <span style="color:#a6e22e">err</span> <span style="color:#f92672">!=</span> <span style="color:#66d9ef">nil</span> { </span></span><span style="display:flex;"><span> <span style="color:#a6e22e">fmt</span>.<span style="color:#a6e22e">Println</span>(<span style="color:#a6e22e">err</span>) </span></span><span style="display:flex;"><span> } </span></span><span style="display:flex;"><span>} </span></span><span style="display:flex;"><span> </span></span><span style="display:flex;"><span><span style="color:#66d9ef">func</span> <span style="color:#a6e22e">main</span>() { </span></span><span style="display:flex;"><span> <span style="color:#a6e22e">makeJSContext</span>() </span></span><span style="display:flex;"><span> <span style="color:#75715e">// rest of it </span></span></span><span style="display:flex;"><span><span style="color:#75715e"></span>} </span></span></code></pre></div><p><code>dist/utils.js</code> has the JavaScript function that we need to call. If that function depends on external libraries, you'd need to bundle the JS and then call the script. V8go <a href="https://github.com/rogchap/v8go/issues/99">doesn't know the ES syntax to import files</a>.</p> <p>We can use <code>esbuild</code> for bundling. Add a build script to <code>package.json</code> :</p> <div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-json" data-lang="json"><span style="display:flex;"><span>{ </span></span><span style="display:flex;"><span> <span style="color:#f92672">&#34;scripts&#34;</span>: { </span></span><span style="display:flex;"><span> <span style="color:#f92672">&#34;build:utils&#34;</span>: <span style="color:#e6db74">&#34;esbuild src/utils.js --bundle --outfile=dist/utils.js --format=cjs&#34;</span>, </span></span><span style="display:flex;"><span> } </span></span><span style="display:flex;"><span>} </span></span></code></pre></div><p>Here's a rough sketch of how <code>utils.js</code> looks like :</p> <div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-js" data-lang="js"><span style="display:flex;"><span><span style="color:#66d9ef">import</span> <span style="color:#f92672">*</span> <span style="color:#a6e22e">as</span> <span style="color:#a6e22e">punycode</span> <span style="color:#a6e22e">from</span> <span style="color:#e6db74">&#34;punycode&#34;</span>; </span></span><span style="display:flex;"><span><span style="color:#66d9ef">import</span> <span style="color:#a6e22e">pages</span> <span style="color:#a6e22e">from</span> <span style="color:#e6db74">&#34;./pages/index.json&#34;</span>; </span></span><span style="display:flex;"><span> </span></span><span style="display:flex;"><span><span style="color:#66d9ef">export</span> <span style="color:#66d9ef">function</span> <span style="color:#a6e22e">getSiteInfo</span>(<span style="color:#a6e22e">host</span>) { </span></span><span style="display:flex;"><span> <span style="color:#75715e">// ... stuff </span></span></span><span style="display:flex;"><span><span style="color:#75715e"></span>} </span></span></code></pre></div><p>esbuilding this would bundle all the dependencies (<code>punycode</code>, that <code>index.json</code> file) into a single file <code>dist/utils.js</code>. Note that we're not minifying the output file, so <code>getSiteInfo()</code> will still be named the same in output file.</p> <p>To make things easier for deployment, here's a simple build script :</p> <div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>yarn build </span></span><span style="display:flex;"><span>yarn build:utils </span></span><span style="display:flex;"><span>go build . </span></span></code></pre></div><p>I also use a <code>restart.sh</code> script for convenience :</p> <div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>kill <span style="color:#66d9ef">$(</span>ps aux | grep <span style="color:#e6db74">&#39;[k]ittum&#39;</span> | awk <span style="color:#e6db74">&#39;{print $2}&#39;</span><span style="color:#66d9ef">)</span> </span></span><span style="display:flex;"><span>./kittum &gt;&gt; web.log &amp; </span></span></code></pre></div><h2 id="final-result">Final Result</h2> <p>That's it. See these subdomains to see the final result :</p> <ul> <li><a href="https://%E0%B4%A8%E0%B5%8B%E0%B4%95%E0%B5%8D%E0%B4%95%E0%B4%BF-%E0%B4%87%E0%B4%B0%E0%B5%81%E0%B4%A8%E0%B5%8D%E0%B4%A8%E0%B5%8B-%E0%B4%87%E0%B4%AA%E0%B5%8D%E0%B4%AA%E0%B5%8B.%E0%B4%95%E0%B4%BF%E0%B4%9F%E0%B5%8D%E0%B4%9F%E0%B5%81%E0%B4%82.com/">เดจเต‹เด•เตเด•เดฟ-เด‡เดฐเตเดจเตเดจเต‹-เด‡เดชเตเดชเต‹.เด•เดฟเดŸเตเดŸเตเด‚.com</a></li> <li><a href="https://%E0%B4%AC%E0%B4%BF%E0%B4%B0%E0%B4%BF%E0%B4%AF%E0%B4%BE%E0%B4%A3%E0%B4%BF-%E0%B4%8E%E0%B4%AA%E0%B5%8D%E0%B4%AA%E0%B5%8A.%E0%B4%95%E0%B4%BF%E0%B4%9F%E0%B5%8D%E0%B4%9F%E0%B5%81%E0%B4%82.com/">เดฌเดฟเดฐเดฟเดฏเดพเดฃเดฟ-เดŽเดชเตเดชเตŠ.เด•เดฟเดŸเตเดŸเตเด‚.com</a></li> <li><a href="https://%E0%B4%95%E0%B4%BF%E0%B4%9F%E0%B5%8D%E0%B4%9F%E0%B5%81%E0%B4%82.%E0%B4%95%E0%B4%BF%E0%B4%9F%E0%B5%8D%E0%B4%9F%E0%B5%81%E0%B4%82.com">เด•เดฟเดŸเตเดŸเตเด‚.เด•เดฟเดŸเตเดŸเตเด‚.com</a></li> </ul> <p>You can see the full source code at <a href="https://github.com/subins2000/kittum.com">https://github.com/subins2000/kittum.com</a></p> <h2 id="more-context-to-the-problem">More Context To The Problem</h2> <p>I'm making this site <a href="https://%E0%B4%95%E0%B4%BF%E0%B4%9F%E0%B5%8D%E0%B4%9F%E0%B5%81%E0%B4%82.com">เด•เดฟเดŸเตเดŸเตเด‚.com</a>, it's built in VueJS. The <code>&lt;title&gt;</code> &amp; <code>&lt;meta&gt;</code> tags of the page is dynamic in nature. One can put any subdomain to the site and it'll have a page with text that depend upon that subdomain.</p> <p>As you may know changing <code>&lt;title&gt;</code> and <code>&lt;meta&gt;</code> dynamically after page load is not good for SEO.</p> <p>To solve this problem, they have a thing called &quot;Server Side Rendering&quot; (<strong>SSR</strong>), Vue pages will be generated in server and the HTML is sent to the browser. It works just as before.</p> <p>SSR runs via node.js and most solutions use <code>express.js</code>, the HTTP server framework in node. I tried this and it was difficult to set it up from scratch. There is this project called &quot;NuxtJS&quot; which is an easier solution to make an SSR app. But my project <a href="https://%E0%B4%95%E0%B4%BF%E0%B4%9F%E0%B5%8D%E0%B4%9F%E0%B5%81%E0%B4%82.com">เด•เดฟเดŸเตเดŸเตเด‚.com</a> is very simple and doesn't need the complexities of Nuxt, so I avoided it.</p> <p>Anyway I made an SSR site. Here are the problems I faced :</p> <ul> <li>I'm using ES6 syntax in my files (<code>import * as pages from './pages.json'</code>). I needed it to make the <code>&lt;title&gt;</code> value but node.js doesn't support ES6 module imports like this and so I had to <a href="https://github.com/subins2000/kittum.com/tree/82aff17d2398f06f6cdec546fe1badbd5dbc5816/src/utils">maintain 2 utils file, one in CommonJS and other in ES6</a>.</li> <li>express.js crashes randomly. After bringing it back up, it <a href="https://github.com/subins2000/kittum.com/issues/3">crashes again in 2 days or so</a>.</li> </ul> <p>I had enough with this and decided to make a simple Go server that serves the JS site and dynamically makes the <code>&lt;title&gt;</code> and <code>&lt;meta&gt;</code> tags.</p> <p>Why Go ? <a href="https://github.com/varnamproject/varnamd-govarnam">Varnam API server</a> is written in Go and it hasn't crashed even once (uptime 100%). It serves more than <strong>1,000,000 requests every month</strong> on a small ARM server.</p> Coding In Malayalam https://subinsb.com/coding-in-malayalam/ Tue, 14 Jul 2020 00:00:00 +0000 https://subinsb.com/coding-in-malayalam/ <p>Some days ago, I came across <a href="https://en.wikipedia.org/wiki/Malayalam_script#Numeral_System">Malayalam numerals</a> and found it very interesting. Unlike Hindi or Kannada numerals, the numerical grammar of Malayalam was unique. It's a direct fork of the Tamil numeric system. So, Tamil &amp; Malayalam has this unique numeral system. It is no longer commonly used though. Like the rest of the world, we use Hindu-Arabic numeral system now.</p> <p>I had to include my phone number in a webpage recently for an event hosting and was concerned whether spammers would take hold of it with their fancy phone-number mining scripts. An idea to prevent this and still give the phone number was to write it in Malayalam numerals. The event was related to Malayalam, so some people would recognize it. Besides, if there were people who really really wanted to reach via phone, they'd go through the trouble to read the numerals eh ? ๐Ÿ˜‰ :D (psst, see my <a href="https://subinsb.com/contact">contact page</a>)</p> <p>Here's a phone number sample :</p> <blockquote> <p>+91 7458367458</p> <p>+เตฏเตง เตญเตชเตซเตฎเตฉเตฌเตญเตชเตซเตฎ</p> </blockquote> <p>So this is a good usecase right, and it's very unlikely that there's a spam crawler script which can read malayalam numerals.</p> <p>It's difficult to look up each number and do a manual replace. I automated it by making a webtool to convert Hindu-Arabic numerals to Malayalam numerals.</p> <div class="padlinks"> <a class="demo" href="https://demos.subinsb.com/malayakkam/">Demo</a> <a class="download" href="https://github.com/subins2000/malayakkam">Source Code</a> </div> <p>But I wanted to make this more cool, so I decided to write the code in Malayalam using <a href="https://makers-of-kerala.now.sh/thengascript/">Thengascript</a>. Thengascript is a dialect of JavaScript. Each JavaScript keyword has a Malayalam alternative in it. Once you have the dictionary, it's fairly easy to write code.</p> <h2 id="editor">Editor</h2> <p>My primary code editor is Sublime Text, but Malayalam rendering in it wasn't good. So I had to find alternatives.</p> <p>KDE's Kate editor with Manjari (and other Unicode Malayalam) fonts worked really well.</p> <p>VSCode failed to give correct rendering of some ligatures even after setting the font. This is definitely because of splitting up of characters due to syntax highlighting :</p> <p><img src="https://lab.subinsb.com/projects/blog/uploads/2020/07/programming-in-malayalam-vscode.png" alt="Programming in Malayalam - VSCode"></p> <p>So I picked Kate.</p> <h2 id="typing">Typing</h2> <p>I used a mix of <a href="https://www.varnamproject.com/">Varnam</a> &amp; <a href="https://swanalekha.smc.org.in/">Swanalekha</a> to code in Malayalam on Linux. With the <a href="https://github.com/varnamproject/libvarnam-ibus">ibus integration</a>, I can toggle between them and English very easily.</p> <h2 id="language-style">Language Style</h2> <p>Since Malayalam is Subject-Object-Verb as opposed to English's Subject-Verb-Object, it feels awkward to write some statements.</p> <p>Example :</p> <div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-js" data-lang="js"><span style="display:flex;"><span><span style="color:#66d9ef">var</span> <span style="color:#a6e22e">arr</span> <span style="color:#f92672">=</span> [<span style="color:#ae81ff">1</span>, <span style="color:#ae81ff">2</span>, <span style="color:#ae81ff">3</span>] </span></span><span style="display:flex;"><span><span style="color:#66d9ef">for</span> (<span style="color:#66d9ef">var</span> <span style="color:#a6e22e">a</span> <span style="color:#66d9ef">in</span> <span style="color:#a6e22e">arr</span>) { </span></span><span style="display:flex;"><span> <span style="color:#66d9ef">if</span> (<span style="color:#a6e22e">a</span> <span style="color:#f92672">==</span> <span style="color:#ae81ff">1</span>) { </span></span><span style="display:flex;"><span> <span style="color:#66d9ef">continue</span> </span></span><span style="display:flex;"><span> } </span></span><span style="display:flex;"><span>} </span></span></code></pre></div><p>In Thengascript, the equivalent is :</p> <div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-js" data-lang="js"><span style="display:flex;"><span><span style="color:#a6e22e">เด†เดตเดŸ</span><span style="color:#960050;background-color:#1e0010">เต</span><span style="color:#a6e22e">เดŸ</span><span style="color:#960050;background-color:#1e0010">เต†</span> <span style="color:#a6e22e">arr</span> <span style="color:#f92672">=</span> [<span style="color:#ae81ff">1</span>, <span style="color:#ae81ff">2</span>, <span style="color:#ae81ff">3</span>] </span></span><span style="display:flex;"><span><span style="color:#a6e22e">เด‡เดจ</span><span style="color:#960050;background-color:#1e0010">เต</span> (<span style="color:#a6e22e">เด†เดตเดŸ</span><span style="color:#960050;background-color:#1e0010">เต</span><span style="color:#a6e22e">เดŸ</span><span style="color:#960050;background-color:#1e0010">เต†</span> <span style="color:#a6e22e">a</span> <span style="color:#a6e22e">เด‡เดฒ</span><span style="color:#960050;background-color:#1e0010">เตโ€</span> <span style="color:#a6e22e">arr</span>) { </span></span><span style="display:flex;"><span> <span style="color:#a6e22e">เด†เดฃ</span><span style="color:#960050;background-color:#1e0010">เต†</span><span style="color:#a6e22e">เด™</span><span style="color:#960050;background-color:#1e0010">เต</span><span style="color:#a6e22e">เด•</span><span style="color:#960050;background-color:#1e0010">เดฟ</span><span style="color:#a6e22e">เตฝ</span> (<span style="color:#a6e22e">a</span> <span style="color:#f92672">==</span> <span style="color:#ae81ff">1</span>) { </span></span><span style="display:flex;"><span> <span style="color:#a6e22e">เดค</span><span style="color:#960050;background-color:#1e0010">เต</span><span style="color:#a6e22e">เดŸเดฐ</span><span style="color:#960050;background-color:#1e0010">เต</span><span style="color:#a6e22e">เด•</span> </span></span><span style="display:flex;"><span> } </span></span><span style="display:flex;"><span>} </span></span></code></pre></div><p>If following Malayalam grammar, the better way to write it would be :</p> <div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-js" data-lang="js"><span style="display:flex;"><span><span style="color:#a6e22e">arr</span> <span style="color:#f92672">=</span> [<span style="color:#ae81ff">1</span>, <span style="color:#ae81ff">2</span>, <span style="color:#ae81ff">3</span>] <span style="color:#a6e22e">เด†เดตเดŸ</span><span style="color:#960050;background-color:#1e0010">เต</span><span style="color:#a6e22e">เดŸ</span><span style="color:#960050;background-color:#1e0010">เต†</span> </span></span><span style="display:flex;"><span>(<span style="color:#a6e22e">arr</span> <span style="color:#a6e22e">เดฒ</span><span style="color:#960050;background-color:#1e0010">เต†</span> <span style="color:#a6e22e">a</span>) <span style="color:#a6e22e">เด“เดฐ</span><span style="color:#960050;background-color:#1e0010">เต‹</span><span style="color:#a6e22e">เดจ</span><span style="color:#960050;background-color:#1e0010">เต</span><span style="color:#a6e22e">เดจ</span><span style="color:#960050;background-color:#1e0010">เตเด‚</span> { </span></span><span style="display:flex;"><span> (<span style="color:#a6e22e">a</span> <span style="color:#f92672">==</span> <span style="color:#ae81ff">1</span>) <span style="color:#a6e22e">เด†เดฃ</span><span style="color:#960050;background-color:#1e0010">เต†</span><span style="color:#a6e22e">เด™</span><span style="color:#960050;background-color:#1e0010">เต</span><span style="color:#a6e22e">เด•</span><span style="color:#960050;background-color:#1e0010">เดฟ</span><span style="color:#a6e22e">เตฝ</span> { </span></span><span style="display:flex;"><span> <span style="color:#a6e22e">เดค</span><span style="color:#960050;background-color:#1e0010">เต</span><span style="color:#a6e22e">เดŸเดฐ</span><span style="color:#960050;background-color:#1e0010">เต</span><span style="color:#a6e22e">เด•</span> </span></span><span style="display:flex;"><span> } </span></span><span style="display:flex;"><span>} </span></span></code></pre></div><p><img src="https://lab.subinsb.com/projects/blog/uploads/2020/07/programming-in-malayalam-kde-kate.png" alt="Programming in Malayalam - KDE Kate Editor"></p> <p>At last, I've made a <a href="https://github.com/subins2000/malayakkam/blob/master/malayakkam.js">simple script</a> to encode and decode Malayalam numerals &lt;-&gt; Hindu-Arabic numerals. I called it <a href="https://github.com/subins2000/malayakkam">Malayakkam (เดฎเดฒเดฏเด•เตเด•เด‚)</a> and it's just under 30 lines of Thengascript.</p> <p>Also check out <a href="https://github.com/Sreyas-Sreelal/malluscript">malluscript</a>, a scripting language in Malayalam and Manglish made with Rust.</p> <p>Tamil has its own programming language called <a href="https://en.wikipedia.org/wiki/Ezhil_(programming_language)">Ezhil</a> from 2007 onwards. They specially made it for kids to understand programming better which is noble. It follows Tamil language logical constructs in the code syntax which makes it easier to understand for a Tamil native.</p> Projects https://subinsb.com/projects/ Sun, 28 Jun 2020 23:00:00 +0530 https://subinsb.com/projects/ Make Picture In Picture Browser Window Visible On All Workspaces in i3 https://subinsb.com/i3-make-picture-in-picture-window-seen-on-all-workspaces/ Fri, 29 May 2020 00:00:00 +0000 https://subinsb.com/i3-make-picture-in-picture-window-seen-on-all-workspaces/ <p>If you're using i3 window manager and you want the Picture in Picture (PiP) window of Firefox and Chromium to be seen in all workspaces, just add this to your i3 config file :</p> <div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-text" data-lang="text"><span style="display:flex;"><span>for_window [title=&#34;Picture-in-Picture&#34;] sticky enable </span></span></code></pre></div><p>This will work for both Firefox and Chromium/Chrome PiP.</p> <p>If it doesn't work, open a video in Picture in Picture mode and run the command <code>wmctrl -l</code> in terminal which will produce a similar output :</p> <pre tabindex="0"><code>0x0b800006 1 swift Screenshots - Dolphin 0x07e00005 2 swift Telegram (278659) 0x03c00003 3 swift Make Picture In Picture Browser Window Seen On All Workspaces in i3 - Subins Blog - Mozilla Firefox 0x08c00007 3 swift Konsole 0x08600001 4 swift Akkara Kazhchakal Ep 42 (Part A) - YouTube - Chromium 0x08c00003 3 swift Akkara Kazhchakal Ep 42 (Part B) - YouTube - Mozilla Firefox 0x03c008e7 -1 swift Picture-in-Picture 0x03c008e7 -1 swift Picture in picture </code></pre><p>You can see the title of the PiP window there. For me, it was <code>Picture-in-Picture</code> for Firefox (v76) and <code>Picture in picture</code> for Chromium (v81). Use this obtained title in the i3 config above.</p> <p>Sticky windows are windows that is visible on all workspaces. <a href="https://i3wm.org/docs/userguide.html#_sticky_floating_windows">Read more about sticky windows in i3</a>.</p> <p>You can see my <a href="https://github.com/subins2000/dotfiles/blob/master/i3/.config/i3/config">i3 config</a> and <a href="//github.com/subins2000/dotfiles">other dotfiles here</a>.</p> Indic-En, a Browser Extension to Convert Indian Language Websites to English Script https://subinsb.com/indicen-convert-indian-language-websites-to-english-script/ Wed, 01 Apr 2020 00:00:00 +0000 https://subinsb.com/indicen-convert-indian-language-websites-to-english-script/ <p>This is certainly not an April Fool and doesn't involve <a href="https://subinsb.com/rickroll">a rickroll</a>. :P ๐Ÿ˜</p> <p>Introducing Indic-En, a browser extension to convert websites in Indian languages (Malayalam, Hindi, Kannada) to Manglish, Hinglish &amp; Kanglish. This is the first WebExtension that I've made.</p> <p>This extension will be useful for people who can understand the language, but can't read it (read the script). I've also made a similar <a href="https://subinsb.com/manglish">Android app &quot;Manglish&quot;</a> which does this, but only for the Malayalam language. Special shoutout to <a href="https://www.reddit.com/r/Kerala/"><strong>r/Kerala</strong></a> folks who support and help spread the word around of Manglish app. Thanks to all the folks who <a href="https://subinsb.com/malayalam-to-manglish-converter/#donors">have donated</a> and spread the word about Manglish app. I'm happy that it's helping people โค๏ธ. As a Free software indie developer, marketing is a difficult thing to do. Please spread the word around :)</p> <p>The extension is available for both desktop and mobile. Download the extension from your browser store :</p> <div class="padlinks"> <a class="btn demo" href="https://addons.mozilla.org/en-US/firefox/addon/indicen/">Firefox</a> <a class="btn download" href="https://addons.mozilla.org/en-US/android/addon/indicen/">Firefox Android</a> <a class="btn demo" href="https://chrome.google.com/webstore/detail/indic-en/fbbhbgpgjfjdncnealckbfdmieafpgon">Chrome</a> </div> <p>Extensions are not available for Chrome mobile browser, but extensions can be installed in other Chrome based browsers such as <a href="https://support.brave.com/hc/en-us/articles/360017909112-How-can-I-add-extensions-to-Brave-">Brave Browser</a>.</p> <h2 id="the--nglish-scripts">The -nglish Scripts</h2> <p>Languages are for communication and they're created and evolved by speaking. Some languages have its own unique script to write or might use other scripts to write them. A language can be writen in multiple scripts. For example, Malayalam is (used to be) written in 3 scripts :</p> <ul> <li>Its own <a href="https://en.wikipedia.org/wiki/Malayalam_script">Malayalam script</a></li> <li>Arabic Script : <a href="https://en.wikipedia.org/wiki/Arabi_Malayalam">Arabi Malayalam</a></li> <li>Syriac Script : <a href="https://en.wikipedia.org/wiki/Suriyani_Malayalam">Suriyani Malayalam</a></li> </ul> <p>And in this internet age, we're using English script (<a href="https://en.wikipedia.org/wiki/Latin_script">Roman/Latin script</a>) mostly through chats, messages because it is easier to type. Here's <a href="https://aana.site/web/statuses/103725837392057887">a thread on it</a> [<a href="https://twitter.com/SubinSiby/status/1232687825448890369">Twitter</a>].</p> <p>Similarly, Hindi written in English is called <strong>Hinglish</strong> and Kannada, <strong>Kanglish</strong>. Here are some examples :</p> <blockquote> <p>เด•เดพเด•เตเด• =&gt; kaakka</p> <p>เค•เฅŒเค† =&gt; kauaa</p> <p>เฒ•เฒพเฒ—เณ† =&gt; kaage</p> </blockquote> <p>So that's what this browser extension <strong>Indic-En</strong> basically do, convert Indic scripts to English/Roman/Latin script.</p> <h2 id="usage">Usage</h2> <p>Simply install the extension from your browser's extension/addon store. You will then see the Indic-En logo on your toolbar. On the page that you want to transliterate, click the button on toolbar, a popup will appear, choose language and Transliterate !</p> <p>In Firefox Mobile, you can access the extension popup straight from browser menu (toolbar) on a page. It'll be below the &quot;Help&quot; button in the menu.</p> <h3 id="features">Features</h3> <ul> <li>Supports Malayalam, Hindi, Kannada : Manglish, Hinglish, Kanglish</li> <li>Auto transliterate page on load</li> <li>Offline [Requires no internet to transliterate]</li> <li>Privacy : Your data stays with you and only you</li> <li>Options page has a transliterator tool for converting text</li> </ul> <h2 id="screenshots">Screenshots</h2> <div class="gallery caption-position-bottom caption-effect-slide hover-effect-zoom hover-transition" itemscope itemtype="http://schema.org/ImageGallery"> <link rel="stylesheet" href="https://subinsb.com/css/hugo-easy-gallery.css" /> <div class="box" > <figure itemprop="associatedMedia" itemscope itemtype="http://schema.org/ImageObject"> <div class="img" style="background-image: url('//raw.githubusercontent.com/subins2000/indicen/master/screenshots/firefox-malayalam-manglish.png');"> <img itemprop="thumbnail" src="//raw.githubusercontent.com/subins2000/indicen/master/screenshots/firefox-malayalam-manglish.png" /> </div> <a href="//raw.githubusercontent.com/subins2000/indicen/master/screenshots/firefox-malayalam-manglish.png" itemprop="contentUrl"></a> </figure> </div> <div class="box" > <figure itemprop="associatedMedia" itemscope itemtype="http://schema.org/ImageObject"> <div class="img" style="background-image: url('//raw.githubusercontent.com/subins2000/indicen/master/screenshots/firefox-hindi-hinglish.png');"> <img itemprop="thumbnail" src="//raw.githubusercontent.com/subins2000/indicen/master/screenshots/firefox-hindi-hinglish.png" /> </div> <a href="//raw.githubusercontent.com/subins2000/indicen/master/screenshots/firefox-hindi-hinglish.png" itemprop="contentUrl"></a> </figure> </div> <div class="box" > <figure itemprop="associatedMedia" itemscope itemtype="http://schema.org/ImageObject"> <div class="img" style="background-image: url('//raw.githubusercontent.com/subins2000/indicen/master/screenshots/firefox-indicen-offline-transliterator.png');"> <img itemprop="thumbnail" src="//raw.githubusercontent.com/subins2000/indicen/master/screenshots/firefox-indicen-offline-transliterator.png" /> </div> <a href="//raw.githubusercontent.com/subins2000/indicen/master/screenshots/firefox-indicen-offline-transliterator.png" itemprop="contentUrl"></a> </figure> </div> <div class="box" > <figure itemprop="associatedMedia" itemscope itemtype="http://schema.org/ImageObject"> <div class="img" style="background-image: url('//raw.githubusercontent.com/subins2000/indicen/master/screenshots/firefox-kannada-kanglish.png');"> <img itemprop="thumbnail" src="//raw.githubusercontent.com/subins2000/indicen/master/screenshots/firefox-kannada-kanglish.png" /> </div> <a href="//raw.githubusercontent.com/subins2000/indicen/master/screenshots/firefox-kannada-kanglish.png" itemprop="contentUrl"></a> </figure> </div> <div class="box" > <figure itemprop="associatedMedia" itemscope itemtype="http://schema.org/ImageObject"> <div class="img" style="background-image: url('//raw.githubusercontent.com/subins2000/indicen/master/screenshots/chrome-indicen-malayalam-manglish.png');"> <img itemprop="thumbnail" src="//raw.githubusercontent.com/subins2000/indicen/master/screenshots/chrome-indicen-malayalam-manglish.png" /> </div> <a href="//raw.githubusercontent.com/subins2000/indicen/master/screenshots/chrome-indicen-malayalam-manglish.png" itemprop="contentUrl"></a> </figure> </div> <div class="box" > <figure itemprop="associatedMedia" itemscope itemtype="http://schema.org/ImageObject"> <div class="img" style="background-image: url('//raw.githubusercontent.com/subins2000/indicen/master/screenshots/firefox-android-indicen-before.png');"> <img itemprop="thumbnail" src="//raw.githubusercontent.com/subins2000/indicen/master/screenshots/firefox-android-indicen-before.png" alt="A Malayalam webpage"/> </div> <a href="//raw.githubusercontent.com/subins2000/indicen/master/screenshots/firefox-android-indicen-before.png" itemprop="contentUrl"></a> <figcaption> <p>A Malayalam webpage</p> </figcaption> </figure> </div> <div class="box" > <figure itemprop="associatedMedia" itemscope itemtype="http://schema.org/ImageObject"> <div class="img" style="background-image: url('//raw.githubusercontent.com/subins2000/indicen/master/screenshots/firefox-android-indicen-after.png');"> <img itemprop="thumbnail" src="//raw.githubusercontent.com/subins2000/indicen/master/screenshots/firefox-android-indicen-after.png" alt="Malayalam webpage after running Indic-En"/> </div> <a href="//raw.githubusercontent.com/subins2000/indicen/master/screenshots/firefox-android-indicen-after.png" itemprop="contentUrl"></a> <figcaption> <p>Malayalam webpage after running Indic-En</p> </figcaption> </figure> </div> <div class="box" > <figure itemprop="associatedMedia" itemscope itemtype="http://schema.org/ImageObject"> <div class="img" style="background-image: url('//raw.githubusercontent.com/subins2000/indicen/master/screenshots/firefox-android-indicen-page.png');"> <img itemprop="thumbnail" src="//raw.githubusercontent.com/subins2000/indicen/master/screenshots/firefox-android-indicen-page.png" alt="Indic-En extension page on Firefox Android"/> </div> <a href="//raw.githubusercontent.com/subins2000/indicen/master/screenshots/firefox-android-indicen-page.png" itemprop="contentUrl"></a> <figcaption> <p>Indic-En extension page on Firefox Android</p> </figcaption> </figure> </div> </div> <h2 id="technical">Technical</h2> <h3 id="libindic">libindic</h3> <p><a href="https://indicproject.org/">Indic Project</a> [<a href="https://smc.org.in/">SMC Project</a>] has made a library <code>libindic</code> which has a <a href="https://libindic.org/Transliteration">Transliteration</a> module. It's written in Python and has support for various languages. You can cross transliterate Malayalm into Kannada and others.</p> <p>I extracted the Indic-English part of it and ported it into JavaScript and called it <a href="//gitlab.com/subins2000/indicjs">indicjs</a>. The name <code>Indic-En</code> is made from a function in the original Python module : <a href="https://github.com/libindic/Transliteration/blob/master/libindic/transliteration/core.py#L280"><code>transliterate_indic_en</code></a>. It was kinda difficult and I had to make some unique changes in JavaScript to make it work. I have published it as a <a href="https://www.npmjs.com/package/libindic-transliteration">library in npmjs</a>. It's also my first published npm package ! Yaaaay ๐ŸŽ‰</p> <p>The transliterator library can be used like this :</p> <pre tabindex="0"><code>const Transliterator = require(&#39;libindic-transliteration&#39;); const t = new Transliterator(); console.log(t.transliterate_ml_en(&#39;เด…&#39;)); console.log(t.transliterate_hi_en(&#39;เค…&#39;)); console.log(t.transliterate_kn_en(&#39;เฒ…&#39;)); </code></pre><p>And the output of all of em will be <code>a</code>.</p> <h3 id="free-software">Free Software</h3> <p><code>libindic</code> is licensed under LGPL while this extension and <code>indicjs</code> is <code>GPL-3</code>. Indic-En is a Free/Libre/เดธเตเดตเดคเดจเตเดคเตเดฐ software.</p> <p>You can see the source code <a href="https://gitlab.com/subins2000/indicen">here on GitLab</a>. There's also a <a href="https://github.com/subins2000/indicen">GitHub mirror</a>.</p> <h3 id="extension">Extension</h3> <p>It's my first time making a WebExtension. I thought I'd have to use different APIs to build extensions for different browsers. Nope, there's a standard API : <a href="https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions">WebExtensions</a>. The manifest file of extensions has differences for some browsers, but this can be easily taken care of with this :</p> <p>I used <a href="https://github.com/abhijithvijayan">Abhijith Vijayan</a>'s awesome <a href="https://github.com/abhijithvijayan/web-extension-starter">web-extension-starter</a> to make the extension. It's very easy to use and helps to build extensions simultaneously for Chrome, Firefox, Safari etc. Shoutout to this fellow Malayalee and his useful project :)</p> <h3 id="logo">Logo</h3> <p>The logo is designed by my good friend, <a href="//twitter.com/AkshayTG3">Akshay TG</a>. This guy is special: he draws very well on paper and digital. I've known <a href="//twitter.com/AkshayTG3">Akshay</a> from wayyy back in grade 6. We together grew in a free software environment. While I got into coding, he drew with GIMP and now he's amazing all of us with his artwork. He draws with a mouse and the artwork he has made (<a href="https://twitter.com/AkshayTG3/status/1205171559452663808/photo/1">Here's one of em</a>) is just WOW !!</p> <p><a href="https://gitlab.com/subins2000/indicen/blob/master/src/assets/icons/favicon.svg"><img src="https://raw.githubusercontent.com/subins2000/indicen/master/src/assets/icons/favicon-128.png" alt="Indic-En logo"></a></p> <p>If you like my work, <a href="https://subinsb.com/donate">buy me a tea</a>. Psssst, I like tea more ;)</p> Rickroll, Love Calculator & Social Engineering https://subinsb.com/rickroll-love-calculator-social-engineering/ Sun, 22 Mar 2020 00:00:00 +0000 https://subinsb.com/rickroll-love-calculator-social-engineering/ <p>A global pandemic is going on and we're all staying in our homes. College's been closed for a week now. Yes, it gets boring staying in home all day. But, we must !</p> <p>Out of boredom and a wish to cheer up people in my circle, I made a website which ends up rickrolling the visitor. It took me an hour to make it.</p> <p>If you're reading this, you probably got rickrolled by me ;) ๐Ÿ˜‰</p> <p>In this post, I'm gonna talk about <a href="https://en.wikipedia.org/wiki/Social_engineering_(security)">Social Engineering</a> and the experience I've had with it.</p> <h2 id="whats-a-rickroll-">What's A Rickroll ?</h2> <p>There's a <a href="https://en.wikipedia.org/wiki/Rickrolling">whole Wikipedia article</a> on it :D</p> <p>Have you heard the awesome song &amp; dance moves of Rick Astley in the song &quot;<a href="https://invidio.us/watch?v=dQw4w9WgXcQ">Never Gonna Give You Up</a>&quot; (<a href="https://www.youtube.com/watch?v=dQw4w9WgXcQ">YouTube</a>) ? IF NOT, YOU MUST !</p> <p>In the early internet days, people used to prank each other with this. You would see a link like &quot;The cutest cat ever&quot; and when you click it, it goes to the Rick Astley's dance moves in Never Gonna Give You Up. You just got rickrolled !</p> <p><img src="//lab.subinsb.com/projects/blog/uploads/2020/03/rickroll.gif" alt="Rickroll gif"></p> <h2 id="see-who-has-visited-your-instagram-profile--omg-">See who has visited your Instagram profile ! OMG !!</h2> <p>I haven't ever rickrolled anyone before (maybe in reddit, but that doesn't count), but I've been rickrolled.</p> <p>If I'm gonna rickroll them, how can I convince them to click the link I send them ? I didn't want it to be like a normal [here's the cutest cat ever] cause 50% people likes dogs :P ๐Ÿ˜›. It should be something creative, and harmless fun !</p> <p>What's the one thing millenials/teenagers/youth has in common ? Enjoying memes ? Yes. Also, majority of them are on Instagram. Some people just use Instagram for the memes. It's the safe haven for kids these days. It was Facebook before, but our parents' generation has overcrowded there ๐Ÿคท.</p> <p>Majority of &quot;Instagrammers&quot; do want to know who's seeing their profile. Teenagers, eh ? They want all the attention ๐Ÿ˜†.</p> <p>So that's what I chose. I made the website, this message :</p> <blockquote> <p>I just found a new secret endpoint in Instagram that allows you to know who has visited your profile.</p> <p>Find out who has visited your Instagram profile : <a href="https://cdpn.io/subins2000/fullpage/QWbVWry">https://cdpn.io/subins2000/fullpage/QWbVWry</a></p> </blockquote> <p>and sent it to people (plus WhatsApp status / Instagram story). And boy oh boy, didn't I trick many people ! ๐Ÿ‘ฟ</p> <p><img src="//lab.subinsb.com/projects/blog/uploads/2020/03/jim-best-prank-ever.gif" alt="Jim-Best Prank Ever gif"></p> <h3 id="why-i-did-it-">Why I did it ?</h3> <ul> <li>Fun, Fun, Fun :D !!</li> <li>Kids these days don't know what a rickroll is. I'm enlightening them about the good ol' Internet days. Don't <code>Ok Boomer</code> me :P</li> <li>To demonstrate social engineering</li> <li>For motivation to write this blog (It's the success of the prank that made me write this)</li> <li>Ay, come on ! You'll obviously smile when you get rickrolled. I did make you laugh eh ;) ๐Ÿ˜‰</li> </ul> <h3 id="how-it-works">How it works</h3> <p>I made the website in CodePen. You can see the <a href="https://codepen.io/subins2000/pen/QWbVWry">pen here</a>.</p> <p>It's simple. An alright looking form which asks user to enter their Instagram username. When user clicks the button, a purposeful delay is made (<code>setTimeout</code>) before showing the Rick Astley gif and the YouTube video.</p> <p><strong>The video should have autoplayed</strong>. Autoplaying videos work in desktop browsers, but is <a href="https://stackoverflow.com/a/40537827/1372424">disabled in mobile browsers</a>. It would have been wayyyy better if the music autoplayed ๐Ÿ˜ญ. But, sadly, mobile browsers won't allow it :(</p> <p>Hence, I added the gif and then the video. The gif is 2MB long and it'd take time to load in a slow connection. Pffttt.</p> <p>This rickroll ain't perfect (-_-), but it works.</p> <h2 id="love-calculator">Love Calculator</h2> <p>IIRC (If I Remember Correctly), it was in 2016 that I came across a message like this in the school group on WhatsApp :</p> <blockquote> <p>Find how match you and your crush is. Check the love calculator : <a href="https://linkto.that.love.calculator.com">https://linkto.that.love.calculator.com</a></p> </blockquote> <p>Pretty bored at the time, I checked out this link.</p> <p>Pretty stupid at the time, I typed in the original name of me and my crush.</p> <p>Pretty nishku (innocent) at the time, I submitted the form without any thinking.</p> <p>The screen showed &quot;Calculating... Calculating...&quot; and after some seconds, it showed :</p> <blockquote> <p>YOU'VE BEEN PRANKED !! Your name and your crush's name has been sent to <a href="mailto:v*****[email protected]">v*****[email protected]</a></p> </blockquote> <p>๐Ÿ˜จ๐Ÿ˜ฑ ARGHHHHHHH !!!! OH NO !!!</p> <p>At the time, it was a secret known only to me and me only. How stupid was I to believe it !! I immediately sent a message to the guy who set it up and begged him to not share it. I remember his exact reply :</p> <blockquote> <p>Ithra valiya computer daavaayittum neeyithil veenallo</p> <p>You even fell for it, you big computer geek</p> </blockquote> <p>That's the point. Anyone can be fooled or tricked or pranked.</p> <p>End of story: He didn't share my secret, though he kept ridiculing me when we saw again face-to-face. Ah, embarassing !</p> <p>Anyone can do this prank with this Love Calculator website. You only gotta sign-up with your email and prank anyone you want to. I don't remember the site, otherwise would have linked here. PS: There's lot of ads in it, so it's a good revenue booster for the site owner ๐Ÿ˜‚.</p> <h2 id="social-engineering">Social Engineering</h2> <p><a href="https://en.wikipedia.org/wiki/Social_engineering_(security)">Social Engineering</a> in the context of information security is defined as :</p> <blockquote> <p>any act that influences a person to take an action that may or may not be in their best interests.</p> </blockquote> <p>Love Calculator is definitely an example of Social Engineering. Rickroll can be considered as an example of it too.</p> <p>I had one more experience of being a victim to Social Engineering, a severe one, it was <a href="https://en.wikipedia.org/wiki/Self-XSS">self XSS</a> ๐Ÿ˜จ</p> <h3 id="see-who-has-visited-your-facebook-profile--omg-">See who has visited your Facebook profile ! OMG !!</h3> <p>IIRC, it was in 2014 that I saw a Facebook friend adding me to a group in Facebook. The group was titled <strong>&quot;100% Working. See who has visited your Facebook profile&quot;</strong>. It also had a pretty convincing header image (thinking now, it probbably didn't :P).</p> <p>A post in the group specifically had the instructions on how to find it :</p> <ol> <li>Press <code>F12</code></li> <li>Go to the <code>Console</code> tab</li> <li>Paste this long code (script) there</li> <li>Press Enter key</li> </ol> <p>Whoa! Cool! You have to paste a weird looking code ? Pretty legit.</p> <p>I did exactly as it said.</p> <p>A window popped up, showing some of my Facebook friends in the list, I believed it.</p> <p>In fact, all my Facebook friends were added to this group by me ! In the background, this script (the long code) picked up my friends list and added each of them to this <strong>&quot;100% Working. See who has visited your Facebook profile&quot;</strong> group. And the list was just random people. This scam would then continue with other people and so on and on.</p> <p>This is called <a href="#self-xss"><strong>Self-XSS</strong></a>.</p> <h3 id="self-xss">Self XSS</h3> <p>As per <a href="https://en.wikipedia.org/wiki/Self-XSS">Wikipedia</a> :</p> <blockquote> <p>In a self-XSS attack, the victim of the attack unknowingly runs malicious code in their own web browser, thus exposing personal information to the attacker.</p> </blockquote> <p>In the previous &quot;Find Facebook profile visitors&quot; mishap, the malicious code added all of my friends to that group.</p> <p>This malicious code can be changed to do much dangerous things :</p> <ul> <li>Send rude messages to everyone in your friend list</li> <li>Unfriend all your friends</li> <li>Post obscene messages in your wall</li> </ul> <p>Basically, the script can do anything like what you can normally do, at many times faster than a human.</p> <p>Since this scam became rampant, Facebook started putting this in browser console :</p> <p><img src="//lab.subinsb.com/projects/blog/uploads/2020/03/selfxss-facebook-warning-in-browser-console.png" alt="Self-XSS Facebook warning in Firefox Browser console"></p> <p>Self-XSS can be used for much worse things with your banking site, financial services etc.</p> <p>Don't do any things that ask you to open browser console and paste some code (unless you absolutely know what you're doing and know the code). The browser console can be used for good things too (TODO: Write about it in a new post).</p> <h2 id="conclusion">Conclusion</h2> <p>So I've shared my experience with Social Engineering and being a victim of it. I have one more experience to share, but later :)</p> <p>This can happen to anyone. You should be careful putting your trust on people on the internet. There are many nice people, yes, but there are others too.</p> <p>Be careful on the internet.</p> <p>Stay Safe.</p> <p>Garnier.</p> <p>PS: Since yesterday, I dug into a hole of Rick Astley interviews and videos. And I can't stop listening to &quot;Never Gonna Give You Up&quot;. Send help.</p> Making Piano Stairs With Raspberry Pi and Ultrasonic sensors https://subinsb.com/piano-stairs-raspberry-pi-ultrasonic/ Mon, 17 Feb 2020 00:00:00 +0000 https://subinsb.com/piano-stairs-raspberry-pi-ultrasonic/ <p>We made a stair into a Piano ! It was our college tech fest and we needed something cool to showcase, something audience can interact with and have fun ! Piano Stairs sounded like a cool idea, but implementing it was a challenge.</p> <p>I'm a 3rd year B.Tech CS engineering student now and this is my first time hacking with hardware. So I didn't know much. I was joined by my juniors, <a href="https://hashimjvz.github.io/">Muhammed Hashim</a> and <a href="https://twitter.com/Outoftune2000">Athul Raj</a>, both in their 2nd year of CS engineering. They have played with hardware before and has more experience than me. Having them with me was a great help for a noobie me.</p> <p><strong>Note</strong>: It's better if you use Infrared sensors or Light Sensitive Resistors instead of Ultrasonic. We learnt it the hard way ๐Ÿ˜ฌ</p> <h2 id="demo">Demo</h2> <p>You can see the videos here :</p> <ul> <li><a href="https://aana.site/@subins2000/103663707322974207">Mastodon</a></li> <li><a href="https://twitter.com/SubinSiby/status/1228711855293526018">Twitter Mirror</a></li> </ul> <center> <video src="https://cf.mastohost.com/v1/AUTH_91eb37814936490c95da7b85993cc2ff/aanasite/media_attachments/files/000/418/122/original/1a98f5d70723feb4.mp4" controls="true" style="height: 400px"></video> <video src="https://cf.mastohost.com/v1/AUTH_91eb37814936490c95da7b85993cc2ff/aanasite/media_attachments/files/000/418/056/original/58dd288065e13327.mp4" controls="true" style="height: 400px"></video> </center> <h2 id="requirements">Requirements</h2> <ul> <li>Raspberry Pi</li> <li>HC-SR04 Ultrasonic Distance Sensor</li> <li><a href="https://www.raspberrypi.org/downloads/raspbian/">Raspbian Buster OS</a> installed in Pi</li> <li><a href="https://freesound.org/people/Tesabob2001/packs/12995/">Piano key sounds</a></li> <li>mpg123 program : <pre tabindex="0"><code>sudo apt install mpg123 </code></pre></li> </ul> <p>The ultrasonic sensor measures distance by sending sound waves. It bounces back to the sensor after hitting someting. This time dealy is used to calculate the distance.</p> <p>You can directly see the <a href="https://github.com/FOSSersVAST/piano-stairs">source code here</a>.</p> <h2 id="the-idea">The Idea</h2> <h3 id="piano-keys">Piano Keys</h3> <p>The idea was to assign each step of a staircase with a piano key. There are primarily <strong>7</strong> piano tones :</p> <ol> <li>C - Sa</li> <li>D - Re</li> <li>E - Ga</li> <li>F - Ma</li> <li>G - Pa</li> <li>A - Da</li> <li>B - Ni</li> <li>C - Sa (repeat)</li> </ol> <p>All other keys in a piano is a different variant of these <strong>primary musical tones</strong>, and those are named with numbers :</p> <pre><code>C0, D0, E0, F0, ..., C1, D1, ..., F8, G8, A8, B8 </code></pre> <p>We picked C4 to B4 (7 keys =&gt; 10 steps). You can download the <a href="https://freesound.org/people/Tesabob2001/packs/12995/">sound files from here</a>.</p> <p><a href="https://github.com/FOSSersVAST/piano-stairs/blob/master/run.py">In the code</a>, we make a simple dictionary in Python to easily track them :</p> <pre tabindex="0"><code>pins = { # Index: [echo pin, trigger pin, &#34;piano key sound filename&#34;] 0: [17, 18, &#34;c4&#34;], 1: [27, 23, &#34;d4&#34;], 2: [22, 24, &#34;e4&#34;], 3: [5, 25, &#34;f4&#34;], 4: [6, 12, &#34;g4&#34;], 5: [13, 16, &#34;a4&#34;], 6: [19, 20, &#34;b4&#34;], 7: [26, 21, &#34;c4&#34;], } </code></pre><p>You don't have to give the file extension in the 3rd value of each list.</p> <h3 id="plan">Plan</h3> <ul> <li>Place ultrasonic sensor on one side of each step</li> <li>Periodically measure distance. It should be a constant value throughout</li> <li>If there's an obstruction (leg on step), the distance measurement would change and when it does so, make the corresponding piano key sound</li> <li>The sound should not repeat as the leg is kept on the step. For this a <code>playStatus</code> list is kept (See the code)</li> </ul> <h2 id="setup">Setup</h2> <h3 id="ultrasonic-sensor">Ultrasonic sensor</h3> <p>The HC-SR04 sensor has 4 pins :</p> <ol> <li>Vcc - Where you give the voltage</li> <li>GND - Ground</li> <li>Trig - Trigger pin (Output : We trigger the sensor to send a sound wave)</li> <li>Echo - Echo pin (Input : We receive the sound wave back.)</li> </ol> <p><code>Vcc</code> and <code>GND</code> can be each made common to all the sensors.</p> <p>Trigger and echo should be separate for each sensor. (Trigger can be made common into one pin too, see <a href="#footnotes">footnotes</a>).</p> <p>Fix each sensor at one side of the step. Connect wires to the 4 pins and extend them all together to a single place where we'll join them with our Pi.</p> <p>As said before, you can use one wire for the <code>Vcc</code> of all the sensors. Similarly for <code>GND</code> too.</p> <h3 id="pi">Pi</h3> <p>Get a Raspberry Pi.</p> <h4 id="code">Code</h4> <p>The source code is <a href="https://github.com/FOSSersVAST/piano-stairs">available here</a>. Download this to your Pi. You need to run <code>python3 run.py</code> to start the piano. But it'll only work once you connect the pins.</p> <p>Make a folder named <code>sounds</code> and place each musical note file there like <code>c4.mp3</code>, <code>d4.mp3</code> etc. This filename should match the ones we gave in <code>pins</code> dictionary.</p> <p>We use Python's <code>Process</code> to parallelly track distance with the sensors. This is only possible if the trigger wires are separate. You can make it common too. See <a href="#footnotes">footnotes</a></p> <h4 id="connections">Connections</h4> <p>There are 40 pins on a Pi. We'll use GPIO pins to connect to our sensors.</p> <p>Using this <a href="https://www.jameco.com/Jameco/workshop/circuitnotes/raspberry_pi_circuit_note_fig2a.jpg">pin diagram of a Pi</a>, connect the common <code>Vcc</code> to pin <code>2</code> (<code>5V</code>). Connect the common <code>GND</code> wire to pin <code>6</code>. There are many ground pins available. You can use <a href="https://en.wikipedia.org/wiki/Jump_wire">jump wires</a> to easily connect.</p> <p>Now, we need to connect the separate trigger and echo pins. Note these pin number down. We need to mention them in our code later. <strong>Important</strong>: We use the GPIO's pin number in the code, not the physical number from the <code>40</code> pins.</p> <p>Example: Connect the trigger of the first sensor to <code>GPIO6</code> (<code>31</code>) and echo to <code>GPIO13</code> (<code>33</code>). Now, the dictionary in the code will be :</p> <pre tabindex="0"><code>pins = { # Index: [echo pin, trigger pin, &#34;piano key sound filename&#34;] 0: [6, 13, &#34;c4&#34;], } </code></pre><p>Note that in the above code that <strong>we used <code>6</code> and <code>13</code> from <code>GPIO6</code> &amp; <code>GPIO13</code> instead of <code>31</code> and <code>33</code></strong>. You should similarly add new item to this <code>pins</code> dictionary with the GPIO pin numbers for every sensor attached.</p> <p>Once you've made every connections, you can now run the script <code>run.py</code>. There's a <code>maxDistance</code> value hardcoded in the script. This is the distance below which we count it as an obstruction.</p> <h2 id="footnotes">Footnotes</h2> <h3 id="common-trigger">Common Trigger</h3> <p>By using a common trigger, you can reduce the number of GPIO pins used. With the extra pins, you can connect it to a relay and turn on LEDs which will make it more cool.</p> <p>When you use a common trigger, you'll have to change the code to remove usage of <code>Process</code> and instead, sense one by one :</p> <pre tabindex="0"><code>while True: for k, v in pins.items(): sonarSensor(k) </code></pre><h3 id="make-it-more-cool-with-leds">Make It More Cool With LEDs</h3> <p>If you use a common trigger, then you can use the extra pins to run a <a href="https://en.wikipedia.org/wiki/Relay">relay</a> and light up each stairs on stepping.</p> <h2 id="conclusion">Conclusion</h2> <p>Ultrasonic sensor is not the best way to make this. Because distance measurement is not accurate in case of an obstruction and there might be variations. The delay to calculate the distance will affect the smoothness of the piano. It only worked out smooth for us at lucky times.</p> <p>I enquired with few of my hardware friends and they all recommended using light sensitive resistors. See <a href="https://www.instructables.com/id/Piano-Stairs-with-Arduino-and-Raspberry-Pi/">this piano stairs made by Bonnie</a> which has a very good result, though it requires both Arduino and Pi.</p> KDE India Conf 2020 https://subinsb.com/kde-india-conf-2020/ Sun, 16 Feb 2020 00:00:00 +0000 https://subinsb.com/kde-india-conf-2020/ <p>I attended my first KDE India conf ! <a href="//conf.kde.in">conf.kde.in</a> 2020 happened in Maharaja Agrasen Institute of Technology, Delhi during January 17-19, 2020.</p> <p>I started contributing to KDE since 2019 in localization as part of <a href="//smc.org.in">Swathanthra Malayalam Computing</a>. The KDE localization process is still on SVN and it's difficult for a newbie to localize. I simplified it for the Malayalam localization by setting up an easy to use web interface with <a href="//kde.smc.org.in">Weblate</a>.</p> <p>I attended <a href="//twitter.com/hashtag/cki2020">#CKI2020</a> as a speaker.</p> <p><img src="//lab.subinsb.com/projects/blog/uploads/2020/02/cki2020-subin-siby-poster.jpg" alt=""></p> <h2 id="event">Event</h2> <p>I attended CKI2020 along with <a href="https://aana.site/@kannan">Kannan VM</a>. His talk was on how their company AlphaFork managed to <a href="https://poddery.com/posts/4691002">migrate Janayugom newspaper entirely to free software</a>. Janayugom is probably the only mainstream newspaper in the world to run entirely on free software.</p> <p>KDE contributors from different parts of India attended the event. Some students who are doing <a href="https://community.kde.org/SoK/Ideas/2020">Season of KDE (SoK)</a> were also at the event. It was very nice to meet them in person. <a href="https://euroquis.nl">Adriaan de Groot</a> &amp; <a href="https://phabricator.kde.org/p/ahiemstra/">Arjen Hiemstra</a> travelled all the way from Europe to attend CKI2020.</p> <p>Last year, me and <a href="https://balasankarc.in/">Balasankar C</a> took the initiative to localize <a href="https://calamares.io/">Calamares</a> (The universal installer framework) to Malayalam. We were able to make it <a href="https://euroquis.nl/calamares/2019/09/24/malayalam.html">100%</a>.</p> <p><a href="https://euroquis.nl">Adrian De Groot a.k.a @kdedude</a> is the maintainer of Calamares. He's also a KDE dev and is a member of the KDE e.V board. I got to meet <a href="https://twitter.com/SubinSiby/status/1224293509668069377">him in person</a> ! @kdedude did a talk on localization and KDE Frameworks which was very fascinating. Did you know that there's an <a href="https://api.kde.org/frameworks/kholidays/html/classKHolidays_1_1LunarPhase.html">API in KHolidays for moon time cycle</a> ?!</p> <p>Arjen's <a href="https://conf.kde.org/en/cki2020/public/events/183">presentation on QtQuick</a> was amusing. He took presentation to the next level, by making the presentation with Qt itself. It had live code-compiling demos right in the presentation itself !</p> <p>My roommate was <a href="https://twitter.com/anupambasak27">Anupam Basak</a>, one of the devs of <a href="https://mauikit.org/">MAUI project</a>. He also had a talk on MAUI. He had a Plasma mobile to experiment on. The MAUI apps were very cool. Convergent apps that work the same as on desktop and mobile with good performace is just ๐Ÿ”ฅ !</p> <p>Saw Krita running on Android and artists drawing on it. It will soon be available for the public to work on !</p> <p>I got to meet with the Indian northeastern KDE people. Coming from the extreme south of India, knowing that KDE folks are spread throughout India, to the north, west and east was very interesting. We all speak different languages, have different culture, but we have 2 things in common : India &amp; KDE โค๏ธ. <strong>Unity in diversity</strong>.</p> <h2 id="gallery">Gallery</h2> <div class="gallery caption-position-bottom caption-effect-slide hover-effect-zoom hover-transition" itemscope itemtype="http://schema.org/ImageGallery"> <link rel="stylesheet" href="https://subinsb.com/css/hugo-easy-gallery.css" /> <div class="box" > <figure itemprop="associatedMedia" itemscope itemtype="http://schema.org/ImageObject"> <div class="img" style="background-image: url('//lab.subinsb.com/projects/blog/uploads/2020/02/cki2020-group-pic.jpg');"> <img itemprop="thumbnail" src="//lab.subinsb.com/projects/blog/uploads/2020/02/cki2020-group-pic.jpg" alt="CKI2020 Group pic"/> </div> <a href="//lab.subinsb.com/projects/blog/uploads/2020/02/cki2020-group-pic.jpg" itemprop="contentUrl"></a> <figcaption> <p>CKI2020 Group pic</p> </figcaption> </figure> </div> <div class="box" > <figure itemprop="associatedMedia" itemscope itemtype="http://schema.org/ImageObject"> <div class="img" style="background-image: url('//lab.subinsb.com/projects/blog/uploads/2020/02/cki2020-group-pic-from-top-scaled.jpg');"> <img itemprop="thumbnail" src="//lab.subinsb.com/projects/blog/uploads/2020/02/cki2020-group-pic-from-top-scaled.jpg" alt="CKI2020 Group pic from top"/> </div> <a href="//lab.subinsb.com/projects/blog/uploads/2020/02/cki2020-group-pic-from-top.jpg" itemprop="contentUrl"></a> <figcaption> <p>CKI2020 Group pic from top</p> </figcaption> </figure> </div> <div class="box" > <figure itemprop="associatedMedia" itemscope itemtype="http://schema.org/ImageObject"> <div class="img" style="background-image: url('//lab.subinsb.com/projects/blog/uploads/2020/02/cki2020-subin-siby-talk.jpg');"> <img itemprop="thumbnail" src="//lab.subinsb.com/projects/blog/uploads/2020/02/cki2020-subin-siby-talk.jpg" alt="My talk at CKI2020"/> </div> <a href="//lab.subinsb.com/projects/blog/uploads/2020/02/cki2020-subin-siby-talk.jpg" itemprop="contentUrl"></a> <figcaption> <p>My talk at CKI2020</p> </figcaption> </figure> </div> <div class="box" > <figure itemprop="associatedMedia" itemscope itemtype="http://schema.org/ImageObject"> <div class="img" style="background-image: url('//lab.subinsb.com/projects/blog/uploads/2020/02/cki2020-group-pic-2-scaled.jpg');"> <img itemprop="thumbnail" src="//lab.subinsb.com/projects/blog/uploads/2020/02/cki2020-group-pic-2-scaled.jpg" alt="CKI2020 ladder group pic"/> </div> <a href="//lab.subinsb.com/projects/blog/uploads/2020/02/cki2020-group-2.jpg" itemprop="contentUrl"></a> <figcaption> <p>CKI2020 ladder group pic</p> </figcaption> </figure> </div> <div class="box" > <figure itemprop="associatedMedia" itemscope itemtype="http://schema.org/ImageObject"> <div class="img" style="background-image: url('//lab.subinsb.com/projects/blog/uploads/2020/02/cki2020-sandwich-pe-charcha.jpg');"> <img itemprop="thumbnail" src="//lab.subinsb.com/projects/blog/uploads/2020/02/cki2020-sandwich-pe-charcha.jpg" alt="Sandwich pe charchaa"/> </div> <a href="//lab.subinsb.com/projects/blog/uploads/2020/02/cki2020-sandwich-pe-charcha.jpg" itemprop="contentUrl"></a> <figcaption> <p>Sandwich pe charchaa</p> </figcaption> </figure> </div> </div> <h2 id="my-talk">My Talk</h2> <p>My talk was titled &quot;KDE Kerala&quot;. You can see the slides <a href="https://subinsb.com/s/cki2020">here</a>.</p> <p>The talk was separated into 3 sections :</p> <ul> <li>History of FOSS In Kerala</li> <li>How FOSS is used in Kerala's education sector</li> <li>Localization</li> </ul> <h3 id="foss-in-education">FOSS In Education</h3> <p>My extensive experiments with GNU/Linux started from school. I first used Ubuntu when I was 10 (2010) in 6th grade. I didn't have a computer back then. Previously, I only knew of the Windows OS. So, the free software push in schools have personally helped me. It helped many other kids too.</p> <p>Now, Kerala schools have local students clubs called &quot;KITE Clubs&quot; where students learn and make stuff with FOSS tools. They play with Blender, Raspberry Pi, Arduino etc. Here are a couple examples of animation videos made by school kids :</p> <ul> <li><a href="https://youtu.be/NEwy06ek7Eo">Handloom weaving</a></li> <li><a href="https://www.youtube.com/watch?v=oj3pwYrdMuE">The Bird</a></li> <li><a href="https://www.youtube.com/watch?v=wv9kQmYn5zo">You reap what you sow</a></li> </ul> <p>I've known <a href="https://twitter.com/AkshayTG3">@AkshayTG3</a> since I was a kid. We together grew in a free software environment. While I got into coding, he drew with GIMP and now he's amazing all of us with his artwork. He is the chief designer of our college club <a href="http://fossers.vidyaacademy.ac.in/">@fossersvast</a>. And he draws with <strong>a mouse</strong> !! <a href="https://twitter.com/AkshayTG3/status/1205171559452663808">Here's an amazing artwork by him</a>.</p> <h2 id="the-aftermath">The Aftermath</h2> <p>After CKI2020, <a href="https://wrix.me/conf-kde-in-2020/">Wrishiraj Kaushik</a> from KDE Assam took the initiative to localize Calamares to Assamese, which <a href="https://wrix.me/conf-kde-in-2020/#the-aftermath">hit 100%</a> ! I'm now helping Wrishiraj and <a href="https://superxos.com/">SuperX</a> team in setting up an easy to use infrastructure for localizing KDE apps to Assamese, similar to what <a href="//kde.smc.org.in">we did for Malayalam</a>.</p> <p>When I got into KDE Malayalam localization, I had a hunch that this will help other teams too. So, I documented everything as I progressed and tried different tools. We ended up using Weblate and it's going smooth. And now Assamese team are using <a href="https://github.com/subins2000/kde-weblate">that documentation</a> to setup their Weblate instance !</p> <h2 id="conclusion">Conclusion</h2> <p>It was my first ever conf this far outside Kerala, that too as a speaker. I had a wonderful experience at CKI2020 and Delhi. Thanks to the Delhi organizers for successfully conducting CKI2020 conf. I hope to participate in Akademy and more KDE confs in the future. And along with it, more contributions :)</p> <p>You might wanna read other blogs on CKI2020 :</p> <ul> <li><a href="https://medium.com/@anupam.basak27/cki-2020-6f47ee33de2d">Anupam Basak</a></li> <li><a href="https://euroquis.nl/kde/2020/01/26/cki.html">@kdedude</a></li> <li><a href="https://wrix.me/conf-kde-in-2020">Wrishiraj Kaushik</a></li> </ul> 20 Years Of Revolving Around The Sun https://subinsb.com/20-years-revolving-around-sun/ Mon, 20 Jan 2020 06:29:06 +0000 https://subinsb.com/20-years-revolving-around-sun/ <p>Writing this at Delhi airport waiting for the flight back home. I came to the capital city of India for <a href="https://conf.kde.in/">KDE India Conference</a>.</p> <p>This blog is a part of the <code>revolving around the sun</code> series :</p> <ul> <li><a href="https://subinsb.com/19/">19 years of revolving around the sun</a></li> <li><a href="https://subinsb.com/18/">18 years of revolving around the sun</a></li> <li><a href="https://subinsb.com/17/">17 years of revolving around the sun</a></li> </ul> <p>This birthday is very fancy :</p> <div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-php" data-lang="php"><span style="display:flex;"><span><span style="color:#ae81ff">01</span><span style="color:#f92672">-</span><span style="color:#ae81ff">20</span><span style="color:#f92672">-</span><span style="color:#ae81ff">2020</span> <span style="color:#ae81ff">20</span><span style="color:#f92672">:</span><span style="color:#ae81ff">20</span><span style="color:#f92672">:</span><span style="color:#ae81ff">20</span> </span></span><span style="display:flex;"><span><span style="color:#a6e22e">MM</span><span style="color:#f92672">-</span><span style="color:#a6e22e">DD</span><span style="color:#f92672">-</span><span style="color:#a6e22e">YYYY</span> <span style="color:#a6e22e">HH</span><span style="color:#f92672">:</span><span style="color:#a6e22e">mm</span><span style="color:#f92672">:</span><span style="color:#a6e22e">SS</span> </span></span></code></pre></div><p>I'm turning <strong>20</strong> on <strong>20</strong> in the year of <strong>2020</strong>. Very fancy ! And at <code>20:20</code> (8PM) tonight, it's the peak moment of fanciness ๐Ÿ˜‚. The next such fanciness will be in the year <code>3030</code> at <code>1030</code> years old ? Nopeeeee, this is my fanciest birthday timestamp ever ! :P ๐Ÿ˜</p> <p>I have officially revolved around the sun 20 times ! Woah ! At the beginning of the last decade, I was in 5th grade and at the end, I'm in college 3rd year. That's a lot of time eh!</p> <p>A tagline that I've been using for the blog were &quot;A 21st century teen&quot;. Gonna have to replace &quot;teen&quot; with &quot;millenial&quot; or something else hehe ๐Ÿ˜๐Ÿ˜Œ.</p> <h2 id="coding">Coding</h2> <ul> <li>Went to many events, networked with people</li> <li>Contributed to <a href="https://indicnlp.org/">IndicNLP project</a></li> <li>I participated in my first ever International Hackathon, ETHIndia and won it !!</li> <li>Participated in national hackathon InOut. Didn't win any thing, but learnt about P2P tech, WebTorrent and those cool stuff. Torrent is now my favorite thing</li> <li>Released <a href="https://www.reddit.com/r/Kerala/comments/bvygio/ive_made_this_android_app_to_convert_malayalam_to/">Manglish app</a>. <a href="https://subinsb.com/manglish">Blog on it</a></li> <li>Released <a href="https://www.reddit.com/r/india/comments/cicpcz/i_made_a_hinglish_to_hindi_editor_other_languages/">Varnam Editor</a>. <a href="https://subinsb.com/varnam">Blog on it</a></li> </ul> <h3 id="kde">KDE</h3> <p>I'm now a KDE contributor ! I'm a maintainer of KDE Malayalam localization now ! This gives me a developer access to KDE's localization SVN repo. This means I can directly push to it which is kinda dangerous too ๐Ÿ˜ฌ.</p> <p>In the <a href="https://subinsb.com/19/">post of '19</a>, I shared my wish of getting selected for GSoC with KDE. I made my <a href="https://gitlab.com/snippets/1838918">own project idea proposal</a> on improving the localization experience, but the community was divided on whether implementing it. So, that went down.</p> <p>But !</p> <p>I implemented that proposal anyway for our Malayalam localization. And it worked ! <a href="https://wiki.smc.org.in/KDE">KDE Malayalam localization</a> is being done <a href="https://kde.smc.org.in/">now on Weblate</a>. The whole step to implement is <a href="//github.com/subins2000/kde-weblate">documented here</a> which might be useful for other localization teams.</p> <p>This led me to work with the <a href="https://smc.org.in/">SMC Team</a> and become a SMC contributor.</p> <p>Here's <a href="https://twitter.com/SubinSiby/status/1162390557332627456?s=20">the Twitter thread</a> on completing a part of localization and having Malayalam included with KDE after many long years.</p> <blockquote> <p>เด’เดฐเต เดตเต†เดŸเดฟเด•เตเด•เต เดฐเดฃเตเดŸเต เดชเด•เตเดทเดฟ =&gt; A contributor to both SMC &amp; KDE.</p> </blockquote> <h2 id="pycon">PyCon</h2> <p>I attended my very first PyCon last October in Chennai. It was a very big event. Lot of people from across India attended it. Got to meet some online folks in real life. Got some swags participating in contests in some booths.</p> <p>I did a <a href="https://www.youtube.com/watch?v=zIWdH1cV88s">lightning talk</a> on my project <a href="https://github.com/subins2000/SelfieADay">Selfie A Day</a>. It was both exciting and anxious to do a talk in front a wide audience. I have a habit of talking too fast and that helped me to finish this talk within the alloted time of 5 minutes.</p> <p>Since I have to go to Chennai and it's a conf, I wanted to make it a bit more grand. My family has never got in an aeroplane before. My first was also last year when I came back from Bangalore attending ETHIndia. So I asked my family to come with. They can see Chennai while I attend the conf.</p> <p>We went to Chennai by train. We haven't ever went on such a long journey together (Appa was never the travelling vibe person). It was a new experience for us. We enjoyed Chennai and we all got to fly back ! Amma was scared in her first flight. I love it though, the turbulences are a poor human's way to experience <em>almost</em> 0g.</p> <p>So much has happened to write, but it better stay as memories &amp; photographs in our minds.</p> <p>I had some savings doing freelance and used that to buy the plane tickets. I'm proud that I got to do this for my family (eldest son extra proundness :P). Amma was so happy of all this :)</p> <p>UPDATE: With 2020, lockdowns, masks &amp; air-travel not being the same anymore, we're super glad that we did this before it all went down.</p> <h2 id="college">College</h2> <h3 id="academics">Academics</h3> <p>Just like <a href="https://subinsb.com/19/">'19</a>, I was more outside of college than in. I was afraid that I won't pass all subjects in semester 3rd last time. But that didn't happen. I passed all subjects, but with bad grades tho. Mehhh, it's alright.</p> <p>The 5th semester exam just finished at the beginning of this month, and yes, I'm afraid there's a chance that I'll fail on atleast 1 subject :/ ๐Ÿ˜•.</p> <h3 id="fossers">FOSSers</h3> <p>FOSSers is there, but I feel like it wasn't as active as the year previous to <a href="https://subinsb.com/19/">'19</a>.</p> <p>For the first time, we had a <a href="http://fossers.vidyaacademy.ac.in/blog/vyvidh-2019/">FOSS Stall in our college tech fest</a>. We also did a <a href="http://cryptux.vidyaacademy.ac.in/">online puzzle-solving competition called CrypTux</a>, an offline treasure hunt event and more... All of the software we made/used is <a href="https://github.com/FOSSersVAST">open sourced</a> of course ;)</p> <p><img src="//lab.subinsb.com/projects/blog/uploads/2020/01/fossers-group-pic-2019.jpg" alt="Group photo on tech-fest. 2019 February"></p> <p>We did a <a href="https://news.vidyaacademy.ac.in/2019/08/28/fossers-club-of-vidya-conducts-one-day-workshop-on-debian-packaging/">Debian Packaging workshop</a>. We got to invite <a href="https://qa.debian.org/[email protected]">Pirate Praveen</a> and <a href="https://qa.debian.org/[email protected]">Sruthi Chandran</a>.</p> <p>Attending the workshop, one FOSSer (oh yeah, that's a name we can call each member :D), <a href="https://abspython.gitlab.io/">Abhijith Sheheer</a> digged deep into packaging. He has got more than 5 packages into Debian at the time of writing this.</p> <p>We introduced Inkscape to <a href="https://twitter.com/radhikaa2001">Radhika Sharma</a> and now she's really good at it ! She's making all her posters, artwork with Inkscape.</p> <p><a href="https://twitter.com/JijinKh">Jijin KH</a>, <a href="https://twitter.com/Outoftune2000">Athul Raj</a>, <a href="https://twitter.com/Hashimjvz">Muhammed Hashim</a> worked on <a href="//github.com/FOSSersVAST/vaasu">making a bot</a> to easily get our college attendance. It works ! We call the bot <code>VAASU</code> (<code>V</code>AST <code>A</code>ttendance <code>A</code>nalyzer &amp; <code>S</code>tats <code>U</code>tilizer) :P</p> <p>We hope to do more, grander events and more contributions.</p> <h2 id="life">Life</h2> <p>The past year's been good, though I feel I could have done more. Time is moving pretty fast. Next year, at this time, I'll be in my last semester of college. Woah ! It was like yesterday I joined college.</p> <p>I've always been a nostalgic person, having butterflies in stomach thinking of the past and memories. Y'know that feeling ? And I'm getting nostalgic now. Just 1 more year and my college life comes to an end. Another part of my life is going to end.</p> <blockquote> <p>เดˆ เด•เต‹เดณเต‡เดœเต เด•เดพเดฒเด‚ เด’เด•เตเด•เต† เด’เดจเตเดจเดฒเตเดฒเต‡ เด‰เดณเตเดณเต‚ เดซเตเดฐเดฃเตเดŸเต‡</p> </blockquote> <p><a href="https://www.youtube.com/watch?v=nSSZvroFmtc">Gonna listen to this song and delve in nostalgia</a>.</p> My Article In Infokairali Magazine on Localization https://subinsb.com/my-article-infokairali-malayalam-localization/ Thu, 14 Nov 2019 20:00:00 +0530 https://subinsb.com/my-article-infokairali-malayalam-localization/ <h2 id="about">About</h2> <p>Lately, I've been volunteering for <a href="https://smc.org.in/">Swathanthra Malayalam Project (SMC)</a>. I took up the initiative in revamping <a href="https://wiki.smc.org.in/KDE_Malayalam">KDE localization</a> which was dorminant for many years. More about how, why I started <a href="https://twitter.com/SubinSiby/status/1162390557332627456">this is in this Twitter thread</a>. We were successful in pushing new Malayalam localization to the wide range of KDE products.</p> <p>November 1 is the birthday of Kerala state of India. Kerala was formed on the basis of the language spoken, Malayalam. Being November, Infokairali magazine decided to roll this edition with the theme &quot;Digital Malayalam&quot;. Infokairali is the only tech magazine in Malayalam.</p> <p>Seeing my work with KDE localization, <a href="https://nandakumar.co.in/">Nandakumar Edamana</a> of Infokairali invited me to write an article on localization. I've never published in a magazine before, that too with this wide reach. Well, I made one and here's my final draft.</p> <p>This draft is very much likely boring to read. It's pieces scrambled finally at the end. Nandakumar fixed it all up and made it cool to read. Thanks ! You can see the <a href="https://aana.site/@subins2000/103125433222273578">pictures of the article in the magazine here</a>.</p> <p>Well, here's the draft :</p> <h2 id="article">Article</h2> <p>เด‡เด‚เด—เตเดฒเต€เดทเดฟเดฒเต‹ เดฎเดฑเตเดฑเต เดญเดพเดทเด•เดณเดฟเดฒเต‹ เดจเดฟเตผเดฎเตเดฎเดฟเดšเตเดšเดฟเดŸเตเดŸเตเดณเตเดณ เดธเต‹เดซเตเดŸเตโ€เดตเต†เดฏเดฑเตเด•เตพ เดชเตเดฐเดพเดฆเต‡เดถเดฟเด• เดญเดพเดทเด•เดณเดฟเดฒเต‡เด•เตเด•เต เดฎเดพเดฑเตเดฑเตเดจเตเดจ เดชเตเดฐเด•เตเดฐเดฟเดฏเต†เดฏเดพเดฃเต เดชเตเดฐเดพเดฆเต‡เดถเดฟเด•เดตเดคเตเด•เดฐเดฃเด‚ เดŽเดจเตเดจเต เดชเดฑเดฏเตเดจเตเดจเดคเต. เดตเต†เดฑเตเด‚ เดคเตผเดœเตเดœเดฎเตเดฎเดฏเดฒเตเดฒ เดชเตเดฐเดพเดฆเต‡เดถเดฟเด•เดตเดคเตเด•เดฐเดฃเดคเตเดคเดฟเตฝ เดจเดŸเด•เตเด•เตเดจเตเดจเดคเต. เด† เดธเตŠเดซเตเดฑเตเดฑเตเดตเดฏเต†เดฑเดฟเดจเตเดฑเต† เด‰เดชเดชเต‹เด—เตเดคเตเดคเดพเดตเดฟเดจเต เดŽเดณเตเดชเตเดชเด‚ เดฎเดจเดธเตเดธเดฟเดฒเดพเดตเตเดจเตเดจเดคเตเด‚ เด‰เดชเดฏเต‹เด—เดฟเด•เตเด•เดพเดตเตเดจเตเดจ เดฐเต€เดคเดฟเดฏเดฟเดฒเดพเดฃเต เดชเตเดฐเดพเดฆเต‡เดถเดฟเด•เดตเดคเตเด•เดฐเดฃเด‚ เดจเดŸเดคเตเดคเตเดจเตเดจเดคเต.</p> <p>เดชเตเดฐเดพเดฆเต‡เดถเดฟเด•เดตเดคเตเด•เดฐเดฃเด‚ เด…เดจเตเดตเดฆเดฟเดšเตเดšเดฟเดŸเตเดŸเตเดณเตเดณ เดธเต‹เดซเตเดŸเตโ€เดตเต†เดฏเดฑเตเด•เตพ เดชเตเดฐเดคเตเดฏเต‡เด•เดคเดฐเดคเตเดคเดฟเดฒเตเดณเตเดณ POT เดซเดฏเดฒเตเด•เตพ เดฒเดญเตเดฏเดฎเดพเด•เตเด•เตเด‚. เด…เดคเดฟเตฝ เด‰เดชเดชเต‹เด•เตเดคเดพเดตเดฟเดจเต เด•เดพเดฃเดคเตเดคเด•เตเด•เดฎเตเดณเตเดณ เดŽเดฒเตเดฒเดพ เดตเดพเด•เตเด•เตเด•เดณเตเด‚ เดตเดฐเดฟเด•เดณเตเด‚ เด‰เตพเดชเตเดชเต†เดŸเตเดคเตเดคเดฟเดฏเดฟเดŸเตเดŸเตเดฃเตเดŸเดพเดตเตเด‚. เดˆ POT เดฐเต‚เดชเดฐเต‡เด– เดซเดฏเดฒเดฟเตฝ เดจเดฟเดจเตเดจเต เด“เดฐเต‹ เดญเดพเดทเดฏเตเด•เตเด•เต เด“เดฐเต‹ PO เดซเดฏเตฝ เด‰เดฃเตเดŸเดพเด•เตเด•เตเด‚. เด‡เดคเดฟเดฒเดพเดฃเต เดชเตเดฐเดพเดฆเต‡เดถเดฟเด•เดญเดพเดทเดฏเดฟเดฒเตเดณเตเดณ เดคเดคเตเดคเตเดฒเตเดฏ เดตเดพเด•เตเด•เตเด•เดณเตเด‚ เดตเดฐเดฟเด•เดณเตเด‚ เด‰เตพเดชเตเดชเต†เดŸเตเดคเตเดคเตเดจเตเดจเดคเต. เดˆ เดซเดฏเดฒเดฟเตฝ เดจเดฟเดจเตเดจเตเด‚ เดธเด‚เด—เตเดฐเดนเดฟเดšเตเดš MO เดซเดฏเดฒเตเด•เตพ เดจเดฟเตผเดฎเตเดฎเดฟเดšเตเดšเต เดธเต‹เดซเตเดŸเตโ€เดตเต†เดฏเดฑเตเด•เดณเดฟเตฝ เด‰เตพเดชเตเดชเต†เดŸเตเดคเตเดคเดฟเดฏเดพเดฃเต เด…เดต เดชเตเดฑเดคเตเดคเดฟเดฑเด•เตเด•เตเดจเตเดจเดคเต. เด‡เด™เตเด™เดจเต†เดฏเดพเดตเตเดฎเตเดชเต‹เตพ เด† เดธเต‹เดซเตเดŸเตโ€เดตเต†เดฏเตผ เดชเดฒ เดญเดพเดทเด•เดณเดฟเตฝ เด‰เดชเดฏเต‹เด—เดฟเด•เตเด•เดพเตป เดจเดฎเตเด•เตเด•เดพเด•เตเดจเตเดจเต.</p> <p>Android, Windows เด…เด™เตเด™เดจเต† เดชเดฒเดคเตเด‚ เดฎเดฒเดฏเดพเดณเดคเตเดคเดฟเตฝ เดฒเดญเตเดฏเดฎเดพเดฃเต. เด‡เดคเดฟเดจเดพเดฏเดฟ เดˆ เด•เดฎเตเดชเดจเดฟเด•เดณเตเดŸเต† เด‰เดณเตเดณเดฟเตฝ เดคเดจเตเดจเต† เดญเดพเดทเดพ เดŸเต€เดฎเตเด•เตพ เด‰เดฃเตเดŸเต. เดธเตเดตเดคเดจเตเดคเตเดฐ เดธเต‹เดซเตเดŸเตโ€เดตเต†เดฏเดฑเตเด•เดณเตเดŸเต† เด•เดพเดฐเตเดฏเดคเตเดคเดฟเดฒเดพเดฃเต†เด™เตเด•เดฟเตฝ volunteers เด†เดฃเต เดฎเดฒเดฏเดพเดณเดคเตเดคเดฟเดฒเต‡เด•เตเด•เดพเด•เตเด•เดพเตป เดถเตเดฐเดฎเดฟเด•เตเด•เตเดจเดคเต. เดธเตเดตเดคเดจเตเดคเตเดฐ เดฎเดฒเดฏเดพเดณเด‚ เด•เดฎเตเดชเตเดฏเต‚เดŸเตเดŸเดฟเด™เตเด™เดฟเดจเตเดฑเต† เด†เดฆเตเดฏ เด•เดพเดฒเด‚ เดฎเตเดคเดฒเต‡ เด‡เดคเดฟเดจเดพเดฏเดฟ เดชเดฐเดฟเดถเตเดฐเดฎเด™เตเด™เตพ เดคเตเดŸเด™เตเด™เดฟเดฏเดฟเดฐเตเดจเตเดจเต. GNOME, Debian, KDE เด…เด™เตเด™เดจเต† เดชเดฒ เดธเตเดตเดคเดจเตเดคเตเดฐ เดธเต‹เดซเตเดŸเตโ€เดตเต†เดฏเดฑเตเด•เดณเตเด‚ SMCเดฏเตเดŸเต† เดจเต‡เดคเตƒเดคเตเดตเดคเตเดคเดฟเตฝ เดชเตเดฐเดพเดฆเต‡เดถเดฟเด•เดตเดคเตเด•เดฐเดฟเดšเดฟเดŸเตเดŸเตเดฃเตเดŸเต. เด‡เดตเดฏเตเดŸเต† settingsเตฝ เดชเต‹เดฏเดฟ เดจเดฟเด™เตเด™เตพเด•เตเด•เต เดญเดพเดท เดฎเดพเดฑเตเดฑเดพเดตเตเดจเตเดจเดคเดพเดฃเต.</p> <p>เด‡เด™เตเด™เดจเต† เดฎเดฒเดฏเดพเดณเดคเตเดคเดฟเดฒเดพเด•เตเด•เตเดฎเตเดชเต‹เตพ เด’เดฐเต เดชเตเดฐเดถเตเดจเด‚ เด…เดจเตเดญเดตเดฟเด•เตเด•เตเดจเดคเต เดŽเดจเตเดคเต เดตเดพเด•เตเด•เตเด•เตพ เด‰เดชเดฏเต‹เด—เดฟเด•เตเด•เดฃเด‚ เดŽเดจเตเดจเดพเดฃเต. เดธเดพเด™เตเด•เต‡เดคเดฟเด• เดตเดพเด•เตเด•เตเด•เตพเด•เตเด•เตเดณเตเดณ เดชเด•เดฐเด‚ เดตเดพเด•เตเด•เต เดฎเดฒเดฏเดพเดณเดคเตเดคเดฟเตฝ เด‡เดฒเตเดฒ. เดฎเดฒเดฏเดพเดณเดคเตเดคเดฟเตฝ เดชเตเดคเดฟเดฏ เดตเดพเด•เตเด•เตเด•เตพ เด‰เดฃเตเดŸเดพเด•เตเด•เดพเตป เด’เดฐเต เด”เดฆเตเดฏเต‹เด•เดฟเด• เดธเด‚เดฐเดญเด‚ เด‡เดฒเตเดฒเดพเดคเตเดคเดคเตเด•เตŠเดฃเตเดŸเต เดคเดจเตเดจเต† เด‡เดคเต เดฌเตเดฆเตเดงเดฟเดฎเตเดŸเตเดŸเดพเด•เตเดจเตเดจเต. เด…เดชเตเดชเตŠ เด…เดคเต เดžเด™เตเด™เตพเด•เตเด•เต เดจเดฟเตผเดฎเตเดฎเดฟเด•เตเด•เต‡เดฃเตเดŸเดฟ เดตเดฐเตเดจเตเดจเต. เดฎเดฒเดฏเดพเดณเด‚ UI เด‰เดชเดฏเต‹เด—เดฟเดšเตเดšเต เด‰เดชเดฏเต‹เด—เดฟเดšเตเดšเดพเดฃเต เดˆ เดตเดพเด•เตเด•เตเด•เตพ เดชเตŠเดคเตเดตเดพเดฏเดฟ เดตเดฐเตเดจเตเดจเดคเต. เด‰เดฆเดพเดนเดฐเดฃเดคเตเดคเดฟเดจเต &quot;Folder&quot; เดŽเดจเตเดจ เดตเดพเด•เตเด•เดฟเดจเต &quot;เด…เดฑ&quot; เดŽเดจเตเดจเดพเดฃเต เด‰เดชเดฏเต‹เด—เดฟเด•เตเด•เตเด•. เด†เดฆเตเดฏเดฎเดพเดฏเดฟ เดฎเดฒเดฏเดพเดณเด‚ UI เด‰เดชเดฏเต‹เด—เดฟเด•เตเด•เตเดจเตเดจ เด’เดฐเต เดตเตเดฏเด•เตเดคเดฟเด•เตเด•เต เด‡เดคเต เดฎเดจเดธเตเดธเดฟเดฒเดพเดตเดฃเดฎเต†เดจเตเดจเดฟเดฒเตเดฒ. เด•เต‚เดŸเตเดคเตฝ เด†เดณเตเด•เตพ เด‰เดชเดฏเต‹เด—เดฟเดšเตเดšเต เด‰เดชเดฏเต‹เด—เดฟเดšเตเดšเต เด…เดคเต เดชเตเดฐเดšเดพเดฐเดคเตเดคเดฟเดฒเดพเด•เตเดจเตเดจเต, เดฎเดฒเดฏเดพเดณเด‚ เดญเดพเดท เด•เดพเดฒเดคเตเดคเดฟเดจเตŠเดชเตเดชเด‚ เดตเดณเดฐเตเด•เดฏเตเด‚ เดšเต†เดฏเตเดฏเตเดจเตเดจเต. เด’เดฐเต เด•เดฎเตเดชเดจเดฟ เดŽเดจเตเดคเต เดตเดพเด•เตเด•เต เดตเต‡เดฃเด‚ เดŽเดจเตเดจเต เดคเต€เดฐเตเดฎเดพเดจเดฟเด•เตเด•เดพเดคเต†, เด‰เดชเดชเต‹เด•เตเดคเดพเด•เตเด•เตพ เดคเดจเตเดจเต† เด…เดคเต เดถเตƒเดทเตเดŸเดฟเด•เตเด•เตเดฎเตเดชเต‹เดดเดพเดฃเต เด•เต‚เดŸเตเดคเตฝ เด‡เดฃเด™เตเด™เตเด•. เดธเตเดตเดคเดจเตเดคเตเดฐ เดธเต‹เดซเตเดŸเตโ€เดตเต†เดฏเดฑเดฟเตฝ เด† เดธเตเดตเดพเดคเดจเตเดคเตเดฐเด‚ เดจเดฎเตเด•เตเด•เต เดฒเดญเดฟเด•เตเด•เตเดจเตเดจเต.</p> <h3 id="l10n--i18n">l10n &amp; i18n</h3> <p>i18n - เดธเต‹เดซเตเดŸเตโ€เดตเต†เดฏเตผ เดชเตเดฐเดพเดฆเต‡เดถเดฟเด•เดตเดคเตเด•เดฐเดฟเด•เตเด•เดพเตป เดคเดฐเดคเตเดคเดฟเดฒเตเดณเตเดณ เดฐเต€เดคเดฟเดฏเดฟเตฝ เดฎเดพเดฑเตเดฑเตเดจเตเดจเดคเดฟเดจเต†เดฏเต‹ เดจเดฟเตผเดฎเตเดฎเดฟเด•เตเด•เตเดจเตเดจเดคเดฟเดจเต†เดฏเดพเดฃเต &quot;Internationalization&quot; เดŽเดจเตเดจเต เดชเดฑเดฏเตเดจเตเดจเดคเต. เด…เดคเต เดšเตเดฐเตเด•เตเด•เดฎเดพเดฏเดฟ &quot;i18n&quot; เดŽเดจเตเดจเตเดชเดฏเต‹เด—เดฟเด•เตเด•เตเดจเตเดจเต. l10n - &quot;Localization&quot; เดŽเดจเตเดจ เดตเดพเด•เตเด•เดฟเดจเตเดฑเต† เดšเตเดฐเตเด•เตเด• เดชเต‡เดฐเดพเดฃเดฟเดคเต. เดชเตเดฐเดพเดฆเต‡เดถเดฟเด•เดตเดคเตเด•เดฐเดฟเด•เตเด•เตเด• เดŽเดจเตเดจเตผเดคเตเดฅเด‚.</p> <h3 id="ai--localization">AI &amp; Localization</h3> <p>เดˆ PO เดซเดฏเดฒเตเด•เตพ เด’เดฐเต dataset เด†เดฏเดฟ เด‰เดชเดฏเต‹เด—เดฟเดšเตเดšเต malayalam NLP AI เดตเดšเตเดšเต เดตเดฟเด•เดธเดฟเดชเตเดชเดฟเด•เตเด•เดพเดจเดพเดตเตเด‚. เด…เดคเดพเดฃเต indicnlp.org เดŽเดจเตเดจ เดธเตเดตเดคเดจเตเดคเตเดฐ เดธเต‹เดซเตเดŸเตโ€เดตเต†เดฏเตผ เดชเตเดฐเต‹เดœเต†เด•เตเดฑเตเดฑเต เดšเต†เดฏเตเดฏเตเดจเตเดจเดคเต. เด…เดชเตเดชเต‹เตพ เดชเตเดฐเดพเดฆเต‡เดถเดฟเด•เดตเตฝเด•เตเด•เดฐเดฃเด‚เด•เตŠเดฃเตเดŸเต เดฐเดฃเตเดŸเตเดฃเตเดŸเต เด—เตเดฃเด‚ !</p> <h3 id="apps-localized-good-in-ml">Apps localized good in ml</h3> <ul> <li>Firefox - both mobile and desktop</li> <li>Calamares Linux Installer - <a href="https://t.me/calamaresl10n">https://t.me/calamaresl10n</a></li> <li>GNOME Chess game and lot of others - <a href="https://l10n.gnome.org/languages/ml/gnome-3-34/ui/">https://l10n.gnome.org/languages/ml/gnome-3-34/ui/</a> Anish Sheela did the most</li> <li>KFind</li> <li>Kate - KDE code editor</li> <li>Kwrite - KDE text editor</li> <li>Dolphin file manager</li> <li>Konsole terminal</li> </ul> <h3 id="kde">KDE</h3> <p>เดฒเต‹เด•เดคเตเดคเดฟเดฒเต† เดคเดจเตเดจเต† เด’เดฐเต เดตเดฒเดฟเดฏ เดธเตเดตเดคเดจเตเดคเตเดฐ เดธเต‹เดซเตเดŸเตโ€เดตเต†เดฏเตผ เด•เต‚เดŸเตเดŸเดพเดฏเตเดฎเดฏเดพเดฃเต เด•เต†.เดกเดฟ.เด‡. เด•เต†.เดกเดฟ.เด‡เดฏเตเดŸเต† เด•เต€เดดเดฟเตฝ เด•เตŠเดฑเต†เดฏเดงเดฟเด•เด‚ เดธเต‹เดซเตเดŸเตโ€เดตเต†เดฏเดฑเตเด•เดณเตเดฃเตเดŸเต. เดฒเดฟเดจเด•เตเดธเดฟเตฝ เด’เดฐเต เดกเต†เดธเตเด•เตเดŸเต‹เดชเต UIเดฏเตเด‚ เด•เต†.เดกเดฟ.เด‡ เด•เตเด•เตเดฃเตเดŸเต (เดชเตเดณเดพเดธเตเดฎ). เด‡เดตเดฏเตŠเด•เตเด•เต† เดฎเดฒเดฏเดพเดณเดคเตเดคเดฟเดฒเต‡เด•เตเด•เต เดชเตเดฐเดพเดฆเต‡เดถเดฟเด•เดตเดคเตเด•เดฐเดฟเด•เตเด•เดพเดจเตเดณเตเดณ เด‰เดฆเตเดฏเดฎเด‚ เด‡เดชเตเดชเต‹เตพ เดจเดŸเดจเตเดจเตเด•เตŠเดฃเตเดŸเดฟเดฐเดฟเด•เตเด•เตเดจเตเดจเต.</p> <p>เดฎเดฒเดฏเดพเดณเดฟเด•เดณเตเดŸเต† เดธเตเดตเดจเตเดคเด‚ OS เด†เดฏ เดคเต†เด™เตเด™เต เด’เดŽเดธเดฟเดจเตเดฑเต† เด…เดŸเตเดคเตเดค เดชเดคเดฟเดชเตเดชเต เด•เต†.เดกเดฟ.เด‡ เดธเตŠเดซเตเดฑเตเดฑเตเดตเดฏเต†เดฑเตเด•เตพ เด‰เตพเดชเตเดชเต†เดŸเตเดคเตเดคเดฟเด•เตเด•เตŠเดฃเตเดŸเดพเดฏเดฟเดฐเดฟเด•เตเด•เตเด‚. เด…เดคเดฟเดจเต เดตเต‡เดฃเตเดŸเดฟเดฏเดพเดฃเต เด•เต†.เดกเดฟ.เด‡ เดชเตเดฐเดพเดฆเต‡เดถเดฟเด•เดตเตฝเด•เตเด•เดฐเดฟเด•เตเด•เดพเดจเตเดณเตเดณ เดฏเดžเตเดœเด‚ เดตเต€เดฃเตเดŸเตเด‚ เด‰เดฃเตผเดจเตเดจเดคเต. เด‡เดคเดฟเตฝ เดชเด™เตเด•เดพเดณเดฟเดฏเดพเด•เดพเตป เดจเดฟเด™เตเด™เตพเด•เตเด•เตเด‚ เดธเดพเดงเดฟเด•เตเด•เตเด‚ : <a href="https://kde.smc.org.in">https://kde.smc.org.in</a></p> <p>เดฎเดฒเดฏเดพเดณเต€เด•เดฐเดฟเดšเตเดš PO เดซเดฏเดฒเตเด•เตพ เด•เต†เดกเดฟเด‡ เดธเด‚เดญเดฐเดฃเดฟเดฏเดฟเดฒเตโ€ เดšเต‡เดฐเตโ€เด•เตเด•เดพเดจเตโ€ เด…เดจเตเดตเดพเดฆเด‚ เด‰เดณเตเดณเดตเดฐเดพเดฃเต &quot;Localization Maintainers&quot;. เด‡เดคเดฟเตฝ เด’เดฐเดพเดณเดพเดฃเต เดžเดพเตป (เดธเตเดฌเดฟเตป เดธเดฟเดฌเดฟ). เดชเตŠเดคเตเดตเต‡ เดˆ PO เดซเดฏเดฒเตเด•เตพ เด“เดฐเต‹ เด†เดณเตเด•เตพ download เดšเต†เดฏเตเดคเดฟเดŸเตเดŸเดพเดฃเต เดชเดฃเดฟเดฏเต†เดŸเตเด•เตเด•เตเด•. เดชเด•เตเดทเต† เด…เดคเดฟเดฒเตเด‚ เดŽเดณเตเดชเตเดชเดฎเดพเดฏเดฟ เด’เดฐเต websiteเตฝ เดคเดจเตเดจเต† เดชเตเดฐเดพเดฆเต‡เดถเดฟเด•เดตเดคเตเด•เดฐเดฟเด•เตเด•เดพเตป เดธเดนเดพเดฏเดฟเด•เตเด•เตเดจเตเดจ เด’เดฐเต†เดฃเตเดฃเด‚ เดžเดพเตป เด‰เดฃเตเดŸเดพเด•เตเด•เดฟ. เด…เดคเดพเดฃเต kde.smc.org.in. เด‡เดคเตเดชเต‹เดฒเต† Firefoxเดจเตเดณเตเดณเดคเดพเดฃเต <a href="https://pontoon.mozilla.org/">https://pontoon.mozilla.org/</a></p> <h4 id="top-contributors-to-kde-malayalam">Top Contributors to KDE Malayalam</h4> <ul> <li>เดจเต€เดจเต เดšเดพเด•เตเด•เต‹</li> <li>เด…เดฎเตƒเดคเดจเดพเดฅเตโ€Œ เดฎเดจเต‹เดนเดฐเตป</li> <li>เด…เดคเตเตฝ เดฐเดพเดœเต</li> <li>เดถเตเดฐเต€เดฐเดพเด‚ เดตเต†เด™เตเด•เดฟเดŸเต‡เดทเต</li> <li>เดฒเด•เตเดทเตเดฎเดฟ เดธเตเดจเดฟเดฒเตโ€,</li> <li>เด…เดจเต‚เดชเต เดŽเด‚ เดŽเดธเต</li> </ul> <p>More : <a href="https://blog.smc.org.in/smc-monthly-report-april-2019/">https://blog.smc.org.in/smc-monthly-report-april-2019/</a></p> Varnam, An Editor To Easily Type Malayalam & Other Indian Languages https://subinsb.com/varnam-easily-type-malayalam-indian-languages/ Thu, 25 Jul 2019 03:00:00 +0530 https://subinsb.com/varnam-easily-type-malayalam-indian-languages/ <p>Today, I'm introducing <strong>Varnam Editor</strong>, an easy software for you to write Malayalam and other Indian languages. It is easily installable for GNU/Linux distros like Ubuntu, Linux Mint, Debian, Archlinux etc.</p> <p>Technically, it's an editor for transliterating Indian languages. Varnam Editor uses an existing library called <a href="https://varnamproject.com"><strong>Varnam</strong></a> and makes it easy to install &amp; use.</p> <h2 id="transliteration">Transliteration</h2> <p>From <a href="https://en.wikipedia.org/wiki/Transliteration">Wikipedia</a> :</p> <blockquote> <p>Transliteration is a type of conversion of a text from one script to another that involves swapping letters (thus trans- + liter-) in predictable ways (such as ฮฑ โ†’ a, ะด โ†’ d, ฯ‡ โ†’ ch, ีถ โ†’ n or รฆ โ†’ ae).</p> </blockquote> <p>Basically transliteration is <strong>Manglish to Malayalam</strong> conversion. Example :</p> <blockquote> <p>ennaa -&gt; เดŽเดจเตเดจเดพ</p> </blockquote> <p>We write the text in english letters and it will be converted to the language we need. This can be done for any languages. Even malayalam to hindi or tamil to bangla. Check out <a href="http://github.com/libindic">libindic project</a> which do just that.</p> <h2 id="varnam">Varnam</h2> <p>Varnam is a C library to easily type Indian languages using transliteration. <a href="https://www.varnamproject.com/">The project</a> was started by a malayalee <a href="http://nkn.io/">Navaneeth K.N</a> in 2010. It's written in C and works on GNU/Linux and Windows.</p> <p>Varnam is a great tool ! I found it very useful and typing with it so easy ! There's an ibus integration which makes it easy to type natively in apps (ibus is a keyboard input system for GNU/Linux.) :</p> <p><img src="//lab.subinsb.com/projects/blog/uploads/2019/07/varnam-ibus.jpg" alt="Varnam ibus autocomplete dialog in Telegram, a Qt app"></p> <h3 id="varnam-components">Varnam Components</h3> <ul> <li><a href="https://github.com/varnamproject/libvarnam">libvarnam</a> - The varnam C library</li> <li><a href="https://github.com/varnamproject/libvarnam-ibus">varnam-ibus</a> - The ibus integration for varnam</li> </ul> <p>Compiling and installing <code>libvarnam</code> will give a nifty command line tool :</p> <div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>varnamc -s ml -t aa ennaa undu </span></span></code></pre></div><p>which will give an output :</p> <blockquote> <p>เด† เดŽเดจเตเดจเดพ เด‰เดฃเตเดŸเต</p> </blockquote> <p>Installing varnam for the first time won't give good predictions. You need to import a word corpus. <a href="https://github.com/varnamproject/libvarnam#word-corpus">Read the README</a>. This is also another problem that is solved by my flatpak package.</p> <p>One amazing feature of Varnam is that it has predictions + character map :</p> <blockquote> <p>ennaa -&gt; เดŽเดจเตเดจเดพ eNNaa -&gt; เดŽเดฃเตเดฃเดพ</p> </blockquote> <p>So capitalizing letters will give better results. Google Input Tools doesn't support this.</p> <h2 id="varnam-editor">Varnam Editor</h2> <h3 id="why-i-built-varnam-editor">Why I Built Varnam Editor</h3> <p>Altough varnam is a great tool, setting it up was difficult :</p> <ul> <li>Need to compile and manually install</li> <li>No debian or other distro package</li> <li>Setting it with ibus didn't work in some apps such as Telegram (Qt app)</li> <li>In KDE+i3, switching ibus layouts didn't work sometimes</li> <li>Varnam has to be set up to learn words which is time consuming</li> <li>For the average user, setting up Varnam is hard</li> <li>Google Input Tools which does transliteration isn't available for GNU/Linux</li> </ul> <p>Varnam is such a <strong>great tool</strong> that most people don't know of it, possibly because it's hard to set up. So to make things very very easy, I made a <strong><a href="https://flatpak.org/">Flatpak</a> package</strong> ! ๐ŸŽ‰</p> <p>I tried packaging it with <a href="https://flatpak.org/">Flatpak</a>, but the <code>ibus engine</code> didn't work out because flatpak has some issues with ibus, dbus. I've filed a <a href="https://github.com/flatpak/flatpak/issues/3019">bug report</a>; if that gets solved, I'll package the engine too.</p> <p>So I made an editor web app that integrates with the <code>varnamc</code> CLI tool installed in the system :</p> <p><img src="//lab.subinsb.com/projects/blog/uploads/2019/07/varnam-editor.png" alt="Varnam Editor app"></p> <p>I purposefully <strong>avoided electron</strong>, cause that would make it heavy. Instead I used <a href="https://github.com/ChrisKnott/Eel">Python eel</a>.</p> <h3 id="install">Install</h3> <h4 id="gnulinux">GNU/Linux</h4> <ol> <li><a href="https://flatpak.org/setup/">Install flatpak</a></li> <li><a href="https://github.com/subins2000/varnam/releases">Download the latest varnam.zip from here</a> <ul> <li><a href="https://github.com/subins2000/varnam/releases/download/0.1/varnam.zip">Version 0.1</a></li> </ul> </li> <li>Extract the zip file</li> <li>Double clicking the extracted <code>varnam.flatpak</code> file may open it in your Softwares app and allow you to install from there</li> <li>If step 4 didn't work, open a terminal an do these :</li> </ol> <div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>cd ~/Downloads </span></span><span style="display:flex;"><span>flatpak install varnam.flatpak </span></span></code></pre></div><h4 id="windows">Windows</h4> <p>I don't know if it'll work in Windows, but <a href="https://blogs.gnome.org/alexl/2018/09/17/flatpak-on-windows/">it may work</a> with the new Windows subsystem for Linux. The steps are same as GNU/Linux's. Please do let me know what it took to make it work there. I'll include it here.</p> <p>If you have any problems setting it up, please feel free to comment below.</p> <h3 id="features">Features</h3> <ul> <li>Lightweight</li> <li>Supports Malayalam, Hindi, Tamil, Telugu, Bangla</li> <li>Malayalam works really good. <a href="#screenshots">Better than Google Input Tools</a></li> <li>Free &amp; Open Source Software</li> <li>Pressing the corresponding number will pick the suggested word</li> </ul> <h3 id="contribute">Contribute</h3> <p>Varnam uses C, Go, Ruby &amp; Varnam Editor uses Python, JavaScript, HTML/CSS. So there are multiple stacks you can contribute to.</p> <ul> <li><a href="https://github.com/varnamproject/">varnamproject GitHub</a> <ul> <li><a href="https://www.varnamproject.com/docs/contributing">Contributing to Varnam</a></li> </ul> </li> <li><a href="https://gitlab.com/subins2000/varnam">Varnam Editor GitLab</a></li> </ul> <p>Thanks to <a href="http://nkn.io/">Navaneeth K N</a> for this amazing Varnam library without which we won't be able to type Malayalam so easily in GNU/Linux !</p> <h3 id="screenshots">Screenshots</h3> <p><img src="//lab.subinsb.com/projects/blog/uploads/2019/07/varnam-multi-lang.png" alt="Varnam multiple language support"></p> <p><img src="//lab.subinsb.com/projects/blog/uploads/2019/07/varnam-better-than-googles.png" alt="Varnam Malayalam better than Google Input Tools"></p> Manglish, a Malayalam to Manglish Converter Android App https://subinsb.com/Malayalam-to-manglish-converter/ Sun, 02 Jun 2019 16:00:00 +0530 https://subinsb.com/Malayalam-to-manglish-converter/ <p>I'm happy to announce a new Android app called &quot;Manglish&quot;, it's an app to convert Malayalam text to Manglish. It's a GNU GPL v3 licensed completely free software app <a href="#donate">with no ads thanks to the donors</a>. Kept it as light as possible.</p> <p>You can download &amp; install it in many ways :</p> <div class="padlinks"> <a class="btn demo" href="https://play.google.com/store/apps/details?id=subins2000.manglish">Play Store</a> <a class="btn download" href="https://f-droid.org/packages/subins2000.manglish/">F-Droid</a> <a class="btn demo" href="https://github.com/subins2000/manglish/releases">APK (1.5MB)</a> </div> <h2 id="updates">Updates</h2> <ul> <li> <p><strong>2021 May</strong>: Version 7 released with new On Screen Button feature.</p> </li> <li> <p><strong>2020 August</strong>: App has reached 5000 active installs.</p> </li> <li> <p><strong>2019 November</strong> : App has reached <a href="https://twitter.com/SubinSiby/status/1190104060961136640"><strong>1000</strong>+ active installs</a> and more than <strong>3000</strong> downloads !</p> </li> </ul> <h2 id="manglish">Manglish</h2> <p>When Malayalam text is written with English letters, it's called Manglish. Not to be confused with <a href="https://en.wikipedia.org/wiki/Manglish">Malaysian pidgin language</a>.</p> <blockquote> <p>Manglish = Malayalam + English</p> </blockquote> <p>For example, consider this Malayalam text :</p> <blockquote> <p>เดŽเดฒเตเดฒเดพเดตเดฐเตโ€เด•เตเด•เตเด‚ เดธเตเด–เดฎเดฒเตเดฒเต‡</p> </blockquote> <p>The above Malayalam text will be written in Manglish as :</p> <blockquote> <p>ellavarkkum sughamalle</p> </blockquote> <p>Manglish text is used mostly in chatting, social media etc. It basically came into existence and became popular after internet. It's an easy way to write Malayalam.</p> <p><a href="https://en.wikipedia.org/wiki/Malayalam">Malayalam</a> is a bit complicated language. It has 52 letters including 16 vowels and 36 consonants. So fitting all of them in a small sized Phone keyboard is hard and to type it more harder.</p> <p>This persuades people to use manglish instead. There are apps &amp; keyboards available to convert manglish to Malayalam. This helps everyone to easily type Malayalam.</p> <h2 id="why-manglish-app-">Why Manglish App ?</h2> <p>I know people who are malayalees, can understand Malayalam, but can't read. There are many such people. Malayalees are everywhere in the world. Most of us are expats. So the kids brought up are most likely to not get a good education in their native language Malayalam.</p> <p>I have some cousins too like this. They speak excellent Malayalam, but can't even read a letter. There are such students in my college too. Well, this app would help them all โค๏ธ.</p> <p>I've made this app for such people to easily understand malayalam text without depending on someone else. All you have to do is paste the text, click a button and voila !</p> <ul> <li>Help people understand Malayalam text they see/receive</li> <li>Potentially help people learn the language</li> </ul> <p>Now you can understand what your WhatsApp ammavan forwards. :P ๐Ÿ˜</p> <h2 id="features">Features</h2> <ul> <li>Fast, quick conversion</li> <li>Ability to select text in other apps, browsers and share to this app to convert</li> <li>No ads, bloatware</li> <li>As lightweight as possible</li> <li><strong>NEW May 2021</strong>: On Screen button to transliterate text on any app</li> </ul> <h3 id="on-screen-button">On Screen Button</h3> <p>Version 7 introduces a new feature: A &quot;เดฎ&quot; button that floats on screen. When clicked, it will convert Malayalam text on screen to Manglish.</p> <p>To enable this feature, a special permission is needed. You will need to explicitly give this permission in <code>Android Settings -&gt; Accessibility</code>. How this feature works is explained in technical section below.</p> <div class="gallery caption-position-bottom caption-effect-slide hover-effect-zoom hover-transition" itemscope itemtype="http://schema.org/ImageGallery"> <link rel="stylesheet" href="https://subinsb.com/css/hugo-easy-gallery.css" /> <div class="box" style="max-width:300px"> <figure itemprop="associatedMedia" itemscope itemtype="http://schema.org/ImageObject"> <div class="img" style="background-image: url('https://raw.githubusercontent.com/subins2000/manglish/master/fastlane/metadata/android/en-GB/images/phoneScreenshots/2-IgCaption.png');"> <img itemprop="thumbnail" src="https://raw.githubusercontent.com/subins2000/manglish/master/fastlane/metadata/android/en-GB/images/phoneScreenshots/2-IgCaption.png" alt="Manglish On Screen button converting text on screen"/> </div> <a href="https://raw.githubusercontent.com/subins2000/manglish/master/fastlane/metadata/android/en-GB/images/phoneScreenshots/2-IgCaption.png" itemprop="contentUrl"></a> <figcaption> <p>Before converting</p> </figcaption> </figure> </div> <div class="box" style="max-width:300px"> <figure itemprop="associatedMedia" itemscope itemtype="http://schema.org/ImageObject"> <div class="img" style="background-image: url('https://raw.githubusercontent.com/subins2000/manglish/master/fastlane/metadata/android/en-GB/images/phoneScreenshots/3-IgCaptionConverted.png');"> <img itemprop="thumbnail" src="https://raw.githubusercontent.com/subins2000/manglish/master/fastlane/metadata/android/en-GB/images/phoneScreenshots/3-IgCaptionConverted.png" alt="Manglish On Screen button converting text on screen"/> </div> <a href="https://raw.githubusercontent.com/subins2000/manglish/master/fastlane/metadata/android/en-GB/images/phoneScreenshots/3-IgCaptionConverted.png" itemprop="contentUrl"></a> <figcaption> <p>Manglish On Screen button after converting text on screen</p> </figcaption> </figure> </div> </div> <h2 id="contribute">Contribute</h2> <h3 id="donate">Donate</h3> <p>The app is and will always be free of ads. It was made for the sole intend of helping people. If you can, you may help financially in the development of this app.</p> <div class="padlinks"> <a class="demo" href="https://subinsb.com/donate">Donate</a> </div> <h4 id="donors">Donors</h4> <p>Thank you so much to these donors who helps keep the app ad-free and help me maintain the app.</p> <ul> <li><a href="https://www.athulcyriac.me/">Athul Cyriac</a></li> <li>Mathew Mani</li> <li><a href="https://twitter.com/devpranoy">Pranoy Dev</a></li> </ul> <h3 id="code">Code</h3> <p>Read the <a href="#technical">technical</a> section and contribute to the code !</p> <h3 id="feature-request">Feature Request</h3> <p>You can submit a feature request in the comments below or on our <a href="https://github.com/subins2000/manglish/issues">GitHub issues</a>.</p> <h2 id="screenshots">Screenshots</h2> <div class="box" style="max-width:300px"> <figure itemprop="associatedMedia" itemscope itemtype="http://schema.org/ImageObject"> <div class="img"> <img itemprop="thumbnail" src="https://raw.githubusercontent.com/subins2000/manglish/master/fastlane/metadata/android/en-GB/images/phoneScreenshots/1-Intro.png" alt="Manglish app screenshot"/> </div> <a href="https://raw.githubusercontent.com/subins2000/manglish/master/fastlane/metadata/android/en-GB/images/phoneScreenshots/1-Intro.png" itemprop="contentUrl"></a> </figure> </div> <p><a href="https://github.com/subins2000/manglish/tree/master/fastlane/metadata/android/en-GB/images/phoneScreenshots">More screenshots here</a>.</p> <h2 id="technical">Technical</h2> <h3 id="ml2en">ml2en</h3> <p>The app uses <a href="https://github.com/knadh/ml2en">ml2en</a> library made by <a href="https://nadh.in">Kailash Nadh</a>. It's the brain behind the conversion. This library is also used by a reddit and twitter bot to help in translation. But those require a server to run and is not reliable forever. This app solves that problem.</p> <p>A <a href="https://nadh.in/code/ml2en/">web app</a> is also available for <strong>ml2en</strong>. ml2en is licensed under GNU GPL v2.0.</p> <p>ml2en's not perfect, but is enough.</p> <h3 id="app">App</h3> <div class="padlinks"> <a class="demo" href="https://github.com/subins2000/manglish">Source Code</a> </div> <p>The JavaScript version of <code>ml2en.js</code> is used by the app. Mozilla's Java implementation of JavaScript, <a href="https://www.mozilla.org/rhino/">Rhino</a> is used to run this JS file. Yes, it's not efficient. Instead, a native Java implementation of the ml2en algorithm would be the best. I tried to do it, but failed because of my inexperience with Java.</p> <p><a href="https://github.com/subins2000/manglish/issues/2">See this issue</a>.</p> <p><strong>UPDATE July 2019</strong>: This issue has been fixed. I made a Java port of the ml2en algorithm.</p> <h4 id="on-screen-button-1">On Screen Button</h4> <p>The On Screen button feature works using Android's Accessibility API. You may have seen people with vision impairment using screen readers for using phone. Such screen reader apps use this API to get data from apps and read it out aloud. Similarly, Manglish app gets text from screen and make an On Screen box on it with the converted text.</p> <p>This was challenging because some apps like Facebook &amp; Instagram uses special TextView elements for displaying text. I couldn't solve <a href="https://stackoverflow.com/questions/46932091/reading-text-from-facebook-recyclerview-with-accessibilityservice">the issue with Facebook app</a>. But for every other app it works.</p> <p>I hope this app has been helpful. Please do let me know your feedback :)</p> <p>And rate it on <a href="https://play.google.com/store/apps/details?id=subins2000.manglish">Play Store</a> !</p> Curse Words https://subinsb.com/curse-words/ Sun, 26 May 2019 23:45:28 +0530 https://subinsb.com/curse-words/ <p>I have an interesting story of how I learnt &amp; used a curse word.</p> <h2 id="myru">Myru</h2> <p>In Malayalam, a main curse word is &quot;myru&quot; which translates to &quot;pubic hair&quot;. In Tamil, it simply means &quot;hair&quot;. You can just go to a barber shop and say &quot;annaa, cut my myru&quot;, but in Malayalam this sentence is hilarious ๐Ÿคฃ.</p> <p>When you refer the word to someone, it becomes &quot;myre&quot;. It's like calling someone bro, but in the worst way possible :</p> <pre><code>eda myre = hey pubic hair </code></pre> <p>This word is weird.</p> <p><a href="https://www.urbandictionary.com/define.php?term=Myru">Urban dictionary calls it the Malayalam equivalent of f*ck</a>.</p> <h2 id="story">Story</h2> <p>I'm writing this because of <a href="https://www.instagram.com/p/Bx7HfOzlO5V/">this meme</a> I saw earlier today :</p> <p><img src="//lab.subinsb.com/projects/blog/uploads/2019/05/myre-meme.jpg" alt="myre meme"></p> <p>&quot;been there done that&quot;</p> <p>When I was 12 (2012), there was this new word in school. I thought it was just a one more level upwards of those normie words like &quot;patti&quot; <code>เดชเดŸเตเดŸเดฟ</code> (dog), &quot;thendi&quot; <code>เดคเต†เดฃเตเดŸเดฟ</code> (beggar) stuff. I never bothered to know what its meaning was. I was just happy that I'm not missing out on stuff (high school eh).</p> <p>Some months after that, we were all in a family get-together. It was during nighttime. The room had us kids (8 of us cousins) just simply sitting (y'know the time before the smarthphones). My uncle was sitting and peeling onions. Amma was in the next room doing something. I remember all this vividly. I'll never forget this wonderful experience.</p> <p>I have a sister (cousin to be exact) named &quot;Ammu&quot;. I'm called Appu in home. She's just 6 months younger than me. We fight all the time like any other siblings do. This time, somehow we ended up calling each other words.</p> <p>It started from &quot;patti&quot;, went to thendi and then to some others. BTW, my &quot;bad words&quot; dictionary goes like this :</p> <blockquote> <p>patti thendi pulle naaye chette naari</p> </blockquote> <p>After all these words we knew ended, it was my turn to call her something. And BEHOLD, THE LATEST WORD THAT NO ONE KNEW...</p> <p>The room quickly got silent. Everyone looked at me in a weird way. I heard Amma who were in the other room saying</p> <blockquote> <p>Apputtaaaa, enthaadaa nee ee parayunne. Evidunnu kitti ninakkithokke</p> </blockquote> <p>in the most exclamatory way possible ! Kinda like this (+/- 30%) :</p> <center> <video src="//lab.subinsb.com/projects/blog/uploads/2019/05/pizhachu-poyi-meme.mp4" controls="controls"></video> </center> <p>I got frightened, my heart was racing. Damn, I remember every little detail.</p> <p>My uncle still sat there peeling the onions. My older brothers were laughing trying to easen the mood. They were too &quot;enthaaanu appuuu&quot;.</p> <p>Meanwhile Ammu went around asking what the meaning of the word was which I didn't know too. I pleaded before amma &quot;I DON'T KNOW THE MEANING MAAA&quot;. She was like &quot;ente mon pizhachu poyeeee&quot;.</p> <p>After the incident, I asked my friend Vishnu Manoj the meaning of the word. Well... he enlightened me. And have I never ever ever used the word... until college.</p> <blockquote> <p>aadyam arinja theriyum ath padippichu thannavanem aarum marakkillaaa ๐Ÿ˜Œ</p> </blockquote> <p>Few years later we all went to watch a football game of Kerala Blasters. Blasterd were playing really poor and I heard the word there again. But this time it was my uncle ๐Ÿ˜‚ who stood silent before peeling the onions. It was a surprise to us all, we have never heard him swearing before. As we grow up, we see new things and discover new faces. The elders too were kids once eh ๐Ÿ˜.</p> <h2 id="now">Now</h2> <p>Fast forward to now, Ammu cerainly hasn't forgotten the incident nor did anyone else of us cousins. I asked my mom if she remembers it, nope she doesn't.</p> <p>Ammu, I taught you the word. I regretted it during the time and later. But, not now.</p> <blockquote> <p>Nee enthaayalum arinjene, ithithiri nerathe aayenne ullu ๐Ÿฅด</p> </blockquote> <blockquote> <p>ingane paranju samaadhaanikkaale :P</p> </blockquote> <p>You would have eventually learnt anyway kiddo ๐Ÿฅด.</p> <p>Looking back, it's just a funny moment and we can have a laugh on this forever ๐Ÿ˜‚</p> InstaLV - Live Stream To Instagram From Computer https://subinsb.com/instagram-livestream-from-computer/ Sun, 07 Apr 2019 12:56:00 +0530 https://subinsb.com/instagram-livestream-from-computer/ <p>Instagram allows you to livestream from the phone only. And that too from the camera which means you can't add extra effects, overlays or cool stuff like that.</p> <p>If you could livestream from the computer, you can customize the livestream video as you like. Similar to livestreams on YouTube or Twitch.</p> <p>I was bored and was thinking of cool projects to do. I just got into <a href="https://instagram.com/subins2000">Instagram</a> and was checking it out. Livestream was pretty cool ! So I searched for livestream from desktop and <a href="https://github.com/subins2000/InstagramLive-PHP">found this</a>. It worked, but didn't have some features I needed and it isn't easy for a normal user to use (cause everything was in the terminal).s</p> <p>So I forked it and made <a href="https://github.com/subins2000/InstaLV"><strong>InstaLV โค</strong></a> (InstaLiVe. โค is optional :P)</p> <h2 id="how-it-works">How It Works</h2> <p>YouTube, Twitch and other streamers use a broadcaster software for livestreaming. The most popular of them is OBS Studio (Open Broadcaster Software Studio).</p> <p>The Streaming service (YouTube) provide a link, username &amp; password for connecting to it. These credentials are set in OBS Studio and streaming is started. Instagram also works like this, but they don't give you these credentials. But it can be obtained. InstaLV gives you these credentials and allows you to control the livestream from the computer.</p> <h2 id="features">Features</h2> <ul> <li>A webapp to easily control livestream</li> <li>See livestream viewers</li> <li>See likes &amp; comments during livestream</li> <li>Pin/Unpin comments</li> <li>Call custom callbacks when a user like or comment</li> </ul> <h2 id="screenshots">Screenshots</h2> <p><img src="//lab.subinsb.com/projects/blog/uploads/2018/12/instalv-streaming.png" alt="Livestreaming an"></p> <p><img src="//lab.subinsb.com/projects/blog/uploads/2018/12/instalv-window.png" alt="InstaLV manager window"></p> <p><img src="//lab.subinsb.com/projects/blog/uploads/2018/12/instalv-desktop-notifications.png" alt="Desktop notifications of comments during livestream"></p> <h2 id="installation">Installation</h2> <p>The commands</p> <ul> <li> <p><a href="http://lmgtfy.com/?q=install+php">Install PHP</a></p> </li> <li> <p><a href="http://lmgtfy.com/?q=install+php+composer">Install Composer</a></p> </li> <li> <p><a href="https://github.com/subins2000/InstaLV/archive/master.zip">Download the latest version of InstaLV</a></p> </li> <li> <p>Extract the folder to a place</p> </li> <li> <p>Open a terminal in that folder and run this command :</p> <pre tabindex="0"><code>path/to/composer.phar install </code></pre></li> <li> <p>Edit the file <code>config.php</code> and add your Instagram username and password</p> </li> <li> <p>In the terminal again, run the <code>live.php</code> script :</p> <pre tabindex="0"><code>php live.php </code></pre></li> <li> <p>On another terminal in the same folder, run the server :</p> <pre tabindex="0"><code>php -S localhost:8000 server.php </code></pre></li> </ul> <p>You can also simply execute the run_server.sh or run_server.bat (Windows) which will run the above command.</p> <ul> <li>Open the link <a href="http://localhost:8000">http://localhost:8000</a> in a browser.</li> <li>In the InstaLV webpage, click on the button Stream Key/URL. Copy the Stream-URL and Stream-Key and paste them into your streaming software. For setting up OBS, <a href="#OBS-Setup">read this</a></li> </ul> <h2 id="obs-setup">OBS Setup</h2> <ul> <li>Go to the &quot;Stream&quot; section of your OBS Settings</li> <li>Set &quot;Stream Type&quot; to &quot;Custom Streaming Server&quot;</li> <li>Set the &quot;URL&quot; field to the stream url you got from InstaLV</li> <li>Set the &quot;Stream key&quot; field to the stream key you got from InstaLV</li> <li>Make Sure &quot;Use Authentication&quot; is <strong>unchecked</strong> and press &quot;OK&quot;</li> <li>Start Streaming in OBS</li> <li>To stop streaming, click on the &quot;Stop Stream&quot; button in InstaLV and then press &quot;Stop Streaming&quot; in OBS</li> <li>Note: To emulate the exact content being sent to Instagram, set your OBS canvas size to 720x1280. This can be done by going to Settings-&gt;Video and editing Base Canvas Resolution to &quot;720x1280&quot;.</li> </ul> <p>At the time of writing this post, the original project of JRoy's has improved a lot ! Do <a href="https://github.com/JRoy/InstagramLive-PHP">check that out</a> too !</p> 19 Years Of Revolving Around The Sun https://subinsb.com/19-years-revolving-around-sun/ Sun, 20 Jan 2019 06:29:06 +0000 https://subinsb.com/19-years-revolving-around-sun/ <p>Writing this at <a href="https://dhishna.org/make-a-ton/">CUSAT MakeATon Hackathon</a>.</p> <p>Part of the revolving around series :</p> <ul> <li><a href="https://subinsb.com/18">18 years of revolving around the sun</a></li> <li><a href="https://subinsb.com/17">17 years of revolving around the sun</a></li> </ul> <div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-python" data-lang="python"><span style="display:flex;"><span>age <span style="color:#f92672">=</span> <span style="color:#ae81ff">18</span> </span></span><span style="display:flex;"><span>age <span style="color:#f92672">=</span> age <span style="color:#f92672">+</span> <span style="color:#ae81ff">1</span> </span></span></code></pre></div><p>I have officially revolved around the sun 19 times. 19 years of existence. This is the beginning of my last teenage year. I feel old.</p> <p>A tagline that I've been using these days is &quot;A 21st century teen&quot;. Well that's gonna go off in a year.</p> <h2 id="coding">Coding</h2> <p>I participated in a lot of hackathons this year. Well, I'm writing this from one ! And my GitLab &amp; GitHub profile is lit this year !</p> <ul> <li>Made some cool projects and learnt new stuff.</li> <li>Networked with a lot of people and made some cool new friends !</li> </ul> <p><strong>I MET RICHARD STALLMAN</strong> this year at Kochi Muziris Biennale ! One of the living greatest person on this planet. Got a really weird pic with him, cause he don't like taking photos :P</p> <p>One quote he said during the talk was hilarious :</p> <blockquote> <p>Calling me the father of open source is like calling Ambedkar the father of BJP</p> </blockquote> <p>I'm also trying to participate in Google Summer of Code this year. I have to work full time for it and I hope I can. I would really love to work in a large project and make a significant contribution to a FOSS project. I'm currently looking at KDE cause I use it everyday and they have really cool projects (Have I mentioned how much I love KDEConnect :P).</p> <h2 id="college">College</h2> <p>The past 3rd semester, I was more outside of college than in. <a href="https://subinsb.com/2018">More about my hackathon experiences</a>. That's probably gonna affect my grades this semester. I seriously doubt I'll pass all the subjects last semester.</p> <p>FOSSers is getting very active. We now have a <a href="http://fossers.vidyaacademy.ac.in/">good website up and running</a>. The community is growing and I'm very happy and excited to lead it. We're one of the most active FOSS clubs in our state now and I'm proud. I never thought that I had a leader in me. I always doubted that. But I'm now realising that I'm capable of being a leader :)</p> <p>Discovered more friends ! I met a gal and a guy who are Pewdiepie fans. This is a first. Bros ๐Ÿ‘Š. This gal was the first new person I met in first day of college. There was this orientation class and we were divided into groups and she was in my group. I made some lame jokes (<code>Subin v17.08</code> <code>lame-jokes-bug</code>) and yet she laughed to it :D. I found her laugh pretty cute. Never thought she was a Pewdiepie fan. In my place, it's pretty rare to find such people.</p> <p>Well... after that, we didn't even speak or mind at all for over a year (MY FAULT. Another <code>Subin v17.08</code> bug). And now we've renewed that one-day friendship again. I absolutely regret not doing it earlier. Here's one quote to remember :</p> <blockquote> <p>At the end of the day, you'll regret the chances you didn't take</p> </blockquote> <p>I've also made friends with some new cool people. What's interesting is that the friendship happened online through messages. We're in the same college yet we haven't talked directly</p> <p>I've said this many times and I'm saying it again :</p> <blockquote> <p><strong>I have a variety of interests and lots of stuff to talk about. I'm that middle intersection in a Venn Diagram ๐Ÿค“</strong></p> </blockquote> <p>I mentioned about the possibilty of getting a scholarship in the <a href="https://subinsb.com/18">last post</a>. I GOT IT ! So less burden on the money part :)</p> <h2 id="personal">Personal</h2> <p>My grandma died just a week ago. Every year for birthday, she would call me first in the morning and wish me. This year, there won't be a call :(</p> <p><img src="//lab.subinsb.com/projects/blog/uploads/2019/03/mummy.jpeg" alt="The best picture I have with grandma. Took this placing the camera on a table and controlling it with an Android app"></p> <blockquote> <p>The best picture I have with grandma. Took in June, 2018. <code>Took this placing the camera on a table and controlling it with an Android app</code></p> </blockquote> <p>I stayed along with her for the first time ever in last June during semester break. I'm glad I did that. Atleast I could spend some happy moments with her :)</p> <p>I've never lost someone so dearest to me. Death is hard to comprehend.</p> <p>I hope to do more stuff in the future.</p> <blockquote> <p>เดตเต†เดฑเตเดคเต† เด‡เดฐเตเดจเตเดจเดฟเดŸเตเดŸเต เด•เดพเดฐเตเดฏเดฎเดฟเดฒเตเดฒ</p> </blockquote> <p>and meet new people...</p> <blockquote> <p>I am because we are โค๏ธ</p> </blockquote> 2018 Year Review ๐Ÿ‘๐Ÿ‘๐Ÿ‘ https://subinsb.com/2018-year-review/ Mon, 31 Dec 2018 00:00:00 +0000 https://subinsb.com/2018-year-review/ <p><em><strong>Year Review ๐Ÿ‘๐Ÿ‘๐Ÿ‘</strong></em></p> <p>And there goes another year. Been very inactive in this blog. Should have blogged of some of the major events, but couldn't. I'm all now posting stories on <a href="https://instagram.com/subins2000">Instagram</a> and on my <a href="https://t.me/SubinSiby">channel in Telegram</a>. Here's a summing up of my year 2018.</p> <h2 id="coding">Coding</h2> <p>I kinda tried doing a <strong>#100DaysOfCode</strong> challenge, but stopped at <strong>73</strong>. This is my longest streak ever on GitHub !</p> <p>When I look back at my contribution wall, I can see what I've been doing my whole year. It's kind of like a journal and you don't have to write anything. It just explains itself !</p> <p><img src="//lab.subinsb.com/projects/blog/uploads/2018/12/github-contribution-wall-2018-explained.jpg" alt=""></p> <h3 id="projects">Projects</h3> <h4 id="bex">BeX</h4> <p>A book exchanging webapp specifically meant for colleges. I made this to learn Django &amp; ReactJS.</p> <p><a href="https://github.com/subins2000/bex">Source</a></p> <p>Created this in semester break to implement in the following semester, but it wasn't complete. Have to work on this and possibly implement it in my college soon !</p> <h4 id="opensalve">OpenSalve</h4> <p>A disaster management software for volunteers and rescue teams. Created as part of hackathons.</p> <p><a href="https://github.com/subins2000/OpenSalve">Source</a></p> <h4 id="torrentbro">TorrentBro</h4> <p>Ceated <a href="https://github.com/subins2000/TorrentBro">TorrentBro</a> in 2017. Added some more features to it I think. I don't remember much :D</p> <h2 id="hackathons">Hackathons</h2> <p>This year, I participated in my very first hackathon and went on to more hackathons !</p> <p>Photos, experience and stuff I did there are all uploaded as stories in <a href="https://instagram.com/subins2000"><strong>my Instagram profile</strong></a> !</p> <h3 id="hackfortomorrow">HackForTomorrow</h3> <p><a href="http://hackfortomorrow.excelmec.org/">HackForTomorrow</a> is my first ever hackathon. Me and my college senior, <a href="https://geongeorge.com/">Geon George</a> participated in it. I didn't know what hackathons were.</p> <p>And we won 2nd ! Our project was <a href="https://github.com/subins2000/OpenSalve-prototype">OpenSalve</a>, a disaster management software.</p> <h3 id="fisat-techplanet">FISAT TechPlanet</h3> <p>The next hackathon was at <a href="http://iesummit.fisat.ac.in/">FISAT TechPlanet</a>. Our team consisted of 5, all from college. We won <strong>1st</strong> !</p> <h3 id="hardware-hackathon">Hardware Hackathon</h3> <p>I never got into hardware hackathon but I was curious. So I got into a hardware hackathon to see how things were. We didn't win anything but the experience was damn awesome !</p> <h3 id="nasa-spaceapps">NASA SpaceApps</h3> <p>Level up ๐Ÿ†™. I travelled solo 300KMs to Technopark, Thiruvananthapuram to participate in <a href="https://2018.spaceappschallenge.org/">NASA's SpaceApps challenge</a>. This hackathon was 48 hours and is the best hackathon I've been to.</p> <h3 id="ibeto">IBeto</h3> <p>Winning 2nd position in <a href="#hackfortomorrow">HackForTomorrow</a> got us into a direct entry to <a href="http://ibeto.excelmec.org/">IBeto</a>. I teamed up with 4 people who I met in HackForTomorrow event. We were able to make an Android app of OpenSalve and make the OpenSalve backend more better.</p> <h3 id="drishti">Drishti</h3> <p>College of Engineering, Thiruvananthapuram conducts their annual tech fest called Drishti. I participated in MCA deaprtment's DCOD3.0 competition. The aim is to find the best techie. It had interesting various rounds.</p> <p>There was a round to decrypt encrypted values which I found very interesting. I was able to solve it. It was in PHP. All I had to do was reverse engineer the encrypt function.</p> <p>At the end, passing through 8 challenges, I won DCOD3.0 !</p> <h3 id="localhackday">LocalHackDay</h3> <p>The last hackathon I've been to is <a href="https://localhackday.mlh.io/lhd-2018/events/563-asiet-hack-club">Local Hack Day</a>. It was a general hackathon and what we made is a <a href="http://github.com/subins2000/lisa">site of information about Linux distributions</a>.</p> <h2 id="hackathons-are-great">Hackathons Are Great</h2> <p>I had this worry in my mind of going to hackathon thinking that I won't be able to do well in it and other people are all smarter than me and stuff. I wanted to know what hackathons are like. So I went for <a href="#hackfortomorrow">HackForTomorrow</a> and enjoyed it !</p> <p>There are all kinds of people at hackathons. Whether you're an absolute beginner or not, just go. Hackathons are the best place to learn. You're in a room full of vibrant people collaborating and learning together.</p> <p>And it's not just for coders. A software has all kinds of people involved in it; coders, designers, testers, documentation people and so on. You can pick your path and be in a team.</p> <p>Hackathons are all about learning, collaborating and sharing together. The experience I got from attending such events is tremendous. And I got to meet a lot of fun, interesting people. And I'm now doing projects with them !</p> <h2 id="college">College</h2> <h3 id="fossers">FOSSers</h3> <p>I talked about <a href="//subinsb.com/18-years-revolving-around-sun/#activities">revamping the FOSS club of our college in an old post</a>.</p> <p>Here's the update : It's going REALLY WELL ! We now have a good community of people. Got a website set up, social media accounts and did a lot of events ! I should make an entire blog post on FOSSers itself, cause there's lot to say ! (Into the wishlist it goes !).</p> <p><a href="https://fossers.vidyaacademy.ac.in/">FOSSers Website</a></p> <p><a href="https://instagram.com/FOSSersVAST">FOSSers Instagram</a></p> <p><a href="https://t.me/FOSSersVAST">FOSSers Telegram</a></p> <h3 id="life">Life</h3> <p>Pretty rad ! I disliked college at first, but visiting other colleges and seeing the state, I became more happy with my college ๐Ÿ˜‚. Students in my class are not that most-active, but are alright. Just need to push, set them ablaze to do stuff.</p> <p>The CSE juniors who just came 5 months back are pretty awesome. Vibrant bunch of people.</p> <p>I'm now more of an extrovert now. I got to know that <strong>there are a lot of interesting, fun people</strong> in my class and college itself. All you gotta do is find them which is why I'm trying to be friends with almost everybody ! I'm now a people person ๐Ÿ˜๐Ÿค—</p> <p>Every person's interesting and I have something in common to talk to. I'm that middle intersection in a Venn Diagram ๐Ÿค“</p> <p><strong>Introvert -&gt; extrovert ๐Ÿ’ฏ</strong></p> <p>If I had time and interest, I would have written a lot more. Have an exam on <code>2019 January 4th</code>. Oh and BTW, I'm not focusing on academics much anymore.</p> <p>I'm writing this all in a hurry and I've missed a lot. Perhaps another post soon ๐Ÿคž</p> <p>Peace out โœŒ๏ธ</p> OpenStreetMap Mapathon on Software Freedom Day 2018 https://subinsb.com/openstreetmap-mapathon-on-software-freedom-day/ Tue, 18 Sep 2018 23:06:19 +0530 https://subinsb.com/openstreetmap-mapathon-on-software-freedom-day/ <p>I mentioned about me working with the FOSS club of my college in a <a href="https://subinsb.com/18-years-revolving-around-sun/">recent post</a>. Well, we're getting more active ! On <a href="http://www.softwarefreedomday.org/">Software Freedom Day 2018</a>, we did an OpenStreetMap mapathon.</p> <p><a href="//osm.org">OpenStreetMap (OSM)</a> is a collaborative project to create a free editable map of the world. Unlike Google Maps, OSM is completely open source. Its data can be accessed and used by anyone. Because of this, many softwares and organizations use OSM. Examples would be <code>Pokemon Go</code>, <code>Facebook</code> and many others.</p> <h2 id="mapathon">Mapathon</h2> <p>An OSM mapathon is a collaborative work of mapping places on OSM. From satellite imagery and local surveys, we mark the buildings, roads, lakes etc. in OSM. By doing so, we can extract specific layers of data from the map. For example, if I need to <strong>see all houses in a particular area</strong> or if I need to see all the roads in an area, then I can simply use OSM to get that data. This is not possible in Google Maps.</p> <p>But who will add these data ? <strong>The world is vaaaast</strong>. This is where communities come in. Free Software communities, students, social groups etc. contribute to OSM. They go to a certain place, go around surveying places, note the details down, head to a lab and upload the info by looking at the satellite imagery.</p> <p>Nodes are created and joined to make a building, road etc. Information such as elevation, floors, name can also be added to each buildings. In case of roads, the type, lanes, width etc. are also given. Overall, each item is related with a lot of data.</p> <h2 id="relevance">Relevance</h2> <p>My home state Kerala went through the worst flood in over a century. When the dams were opened, government failed to accurately evacuate places. As a result, a lot of places got flooded and people suffered.</p> <p>During the flood, developers in Kerala came together to make <a href="http://keralarescue.in">keralarescue.in</a> and <a href="microid.in/keralaflood">microid.in/keralaflood</a>. Both helped a lot during the flood. <strong>Both used OSM</strong>.</p> <ul> <li>keralaresuce.in - Requests for help were collected, organized and shown in maps for help to reach</li> <li><a href="microid.in/keralaflood">microid.in/keralaflood</a> - A map to see the flooded roads. Useful while travelling</li> </ul> <p>Technology has evolved so much and we can use it in situations like these. <strong>Never before in human history had the capability of doing this</strong>. We have grown so much and we should use the technology to help people and make the world a better place.</p> <p><a href="https://en.wikipedia.org/wiki/Geographic_information_system">GIS</a> can be used for knowing that <strong>if a river overflows</strong>, which all places would be flooded. It can also be used to exactly know which places require to be evacuated. It helps a lot in disaster management as well as prevention.</p> <p><a href="https://en.wikipedia.org/wiki/QGIS">QGIS</a> is a free and open-source desktop GIS application that supports viewing, editing, and analysis of geospatial data. <strong>OSM</strong>'s data can be used in QGIS to do this.</p> <p>But for that to happen, OSM should be populated with data and it is necessary to do it. I understood its importance during the flood.</p> <h2 id="event">Event</h2> <p>We planned this event just 4 days before SFD. Made a Google Forms link and passed to college groups. We got <strong>36 volunteers</strong> through it.</p> <p>Our FOSS club is called <strong>FOSSers</strong> and our group is on Telegram, Matrix and a mailing list. So these new members were added to each. We have grown from 2 (last year) to 80+ now ! Yay !</p> <p>Together with OSM Kerala, <a href="http://thrissur.fsug.in">FSUG Thrissur</a>, <a href="http://kole.org.in">Kole Birders</a>, River Research Centre Thrissur, we conducted a mapathon on <a href="//softwarefreedomday.org">Software Freedom Day</a>.</p> <p>We also had experts from outside who joined the program :</p> <ul> <li><a href="https://www.facebook.com/manoj.k.mohan">Manoj K</a>, our alumni, Free Software Activist, Wikipedia/OpenStreetMap volunteer, coordinator of Kole Birders Collective led the mapathon.</li> <li>Ajith Kumar (GIS Expert from CSRD)</li> <li>Rajaneesh P (River Research Centre, Thrissur)</li> <li>Sujin NS (Jawarhalal Nehru Tropical Botanical Garden, Thiruvananthapuram)</li> <li>Sreenath K (Soil Test expert, Irinjalakkuda)</li> </ul> <p>People who have also helped include :</p> <ul> <li>Naveen Francis (Open Street Map and Wikimedia India) gave Technical Help for the event</li> <li><a href="https://grandalstonia.wordpress.com/">Jaison Nedumbala</a> (Asst. Secretary , Koorachundu Village Panchayat and Member of <a href="//smc.org.in">Swathandra Malayalam Computing</a>) gave advice in Mapping Efforts.</li> </ul> <p>Led by Manoj, we were given instructions on how to map and what to do. I had no idea on how to do it. We used <a href="http://tasks.openstreetmap.in/">tasks.openstreetmap.in</a> to manage tasks. In it, our district was divided into many blocks and each volunteer would pick a block and start mapping.</p> <h2 id="result">Result</h2> <p>In under 5 hours of working, we were able to do :</p> <ul> <li><strong>4,388</strong> edits</li> <li><strong>2,799</strong> buildings</li> <li><strong>118 km</strong> roads</li> <li>Map Lakes, Streams, etc.</li> </ul> <p>Complete info of contributions can be found <a href="http://www.missingmaps.org/leaderboards/#/fossersvast">here on MissingMaps</a>.</p> <p><img src="//lab.subinsb.com/projects/blog/uploads/2018/06/osm_mapathon_vast.jpg" alt="The Team"></p> <h2 id="links">Links</h2> <ul> <li><a href="http://www.missingmaps.org/leaderboards/#/fossersvast">MissingMaps</a></li> <li><a href="https://www.facebook.com/pg/FOSSersVAST/photos/?tab=album&amp;album_id=2365937880300059">Album: Mapathon on Software Freedom Day 2018</a></li> </ul> Search https://subinsb.com/search/ Thu, 22 Mar 2018 15:26:47 +0530 https://subinsb.com/search/ Install Realtek d723 WiFi driver for GNU/Linux https://subinsb.com/install-realtek-d723-wifi-driver-linux/ Thu, 22 Mar 2018 13:20:37 +0530 https://subinsb.com/install-realtek-d723-wifi-driver-linux/ <p>I've been doing a lot of Linux Mint installations lately and one very annoying thing that I found in 2 laptops was the non availability of WiFi driver. Apparently, it's a new hardware and is not in the Linux kernel.</p> <p>The hardware is <code>Realtek device d723</code>. This new WiFi hardware is being shipped in new PCs and laptops now. Without having the internet, one can't do almost anything. So it's important to have this fixed up.</p> <p><strong>UPDATE : Added a new method to make it work on Ubuntu 18.04 LTS</strong></p> <p>If <a href="#method-1">method 1</a> doesn't work for you, try <a href="#method-2">method 2</a> or <a href="#method-3">method 3</a>.</p> <h2 id="getting-internet">Getting Internet</h2> <p>We need a temporary internet connection to fix WiFi. Ways to connect :</p> <ul> <li>Connect USB cable and use <strong>USB Tethering</strong> in your phone to connect your computer to the internet (through phone's cellular data/WiFi)</li> <li>Use wired ethernet cable for connecting to internet</li> </ul> <h2 id="finding-device">Finding Device</h2> <p>Open a terminal and do the command <code>lspci</code>. You will see all the PCI devices of your system. If you have the <code>d723</code> device, you can see it at the bottom :</p> <p><img src="//lab.subinsb.com/projects/blog/uploads/2018/03/realtek-d723-lspci.jpg" alt="lspci output"></p> <p>Or to quickly know if you have the <code>d723</code> WiFi hardware, do :</p> <pre tabindex="0"><code>lspci | grep d723 </code></pre><h2 id="prerequisite">Prerequisite</h2> <p>You should install the corresponding header of your kernel :</p> <pre tabindex="0"><code>sudo apt-get install linux-headers-`uname -r` </code></pre><p>Next, install the packages necessary for building :</p> <pre tabindex="0"><code>sudo apt-get install git build-essential dkms </code></pre><h2 id="method-1">Method 1</h2> <p>This is the <strong>RECOMMENDED METHOD</strong> because in future, when kernel is updated, the installed driver will be automatically compiled to make it work in newer kernel.</p> <p>We're gonna use the driver available in <a href="https://github.com/lwfinger/rtlwifi_new/tree/extended">this GitHub repository's extended branch</a>.</p> <p>To simplify everything, run the following commands one by one :</p> <pre tabindex="0"><code>git clone -b extended --single-branch https://github.com/lwfinger/rtlwifi_new.git sudo dkms add rtlwifi_new sudo dkms install rtlwifi-new/0.6 </code></pre><p><strong>Restart</strong> your computer. And you'll get your WiFi !</p> <h2 id="method-2">Method 2</h2> <p>We're gonna use the driver available in <a href="https://github.com/lwfinger/rtlwifi_new/tree/extended">this GitHub repository's extended branch</a>.</p> <p>To simplify everything, run the following commands one by one :</p> <pre tabindex="0"><code>wget -d -c -O &#39;rtlwifi_new.zip&#39; &#39;https://github.com/lwfinger/rtlwifi_new/archive/extended.zip&#39;; unzip rtlwifi_new.zip; cd rtlwifi_new-extended; make; sudo make install; sudo modprobe -r rtl8723de; sudo modprobe rtl8723de; </code></pre><p>What the commands does is download the GitHub repository (extended branch) with <code>wget</code>. If your system doesn't have <code>wget</code>, install it :</p> <pre tabindex="0"><code>sudo apt install wget </code></pre><p>After that, the downloaded <strong>zip</strong> file is extracted with <code>unzip</code>. Then inside the extracted folder, the drivers are compiled and installed with <code>make</code> &amp; <code>make install</code></p> <p>After that the drivers are enabled using the <code>modprobe</code> command with <code>sudo</code>.</p> <p>PS : Thanks to <a href="http://disq.us/p/1ttiq1z">Bruno Loy</a> for confirming that this works !</p> <h2 id="method-3">Method 3</h2> <p><a href="https://github.com/smlinux">smlinux</a> has made a driver for <code>d723</code>. Compiling it and installing it will help you connect to WiFi.</p> <p>First step is to identify the version of your Linux kernel :</p> <pre tabindex="0"><code>uname -r </code></pre><p>The driver is different according to the Linux kernel version. Only the driver to download will vary. Rest of the installation steps are the same.</p> <h4 id="download">Download</h4> <p>Now according to the kernel version download the driver :</p> <h6 id="411-and-up">4.11 and up</h6> <p>If the Linux kernel version is 4.11 or greater (&gt;=4.11), then download <a href="https://github.com/smlinux/rtl8723de/archive/4.11-up.zip">this file</a> :</p> <div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>wget -d -c -O <span style="color:#e6db74">&#39;rtl8723de.zip&#39;</span> https://github.com/smlinux/rtl8723de/archive/4.11-up.zip </span></span></code></pre></div><h6 id="410-and-down">4.10 and down</h6> <p>If the Linux kernel version is 4.10 or below (&lt;=4.10), then download <a href="https://github.com/smlinux/rtl8723de/archive/4.10-down.zip">this file</a> :</p> <div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>wget -d -c -O <span style="color:#e6db74">&#39;rtl8723de.zip&#39;</span> https://github.com/smlinux/rtl8723de/archive/4.10-down.zip </span></span></code></pre></div><h4 id="build--install">Build &amp; Install</h4> <p>Now let's build the driver and install it.</p> <p>After the download of the driver zip file, extract it :</p> <div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>unzip rtl8723de.zip </span></span></code></pre></div><p>Go into the extracted folder, build it and install it :</p> <div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>cd rtl8723de </span></span><span style="display:flex;"><span>make </span></span><span style="display:flex;"><span>sudo make install </span></span></code></pre></div><h3 id="reboot">Reboot</h3> <p>After the installation, restart your computer. After the restart, you'll be able to connect to WiFi :</p> <p><img src="//lab.subinsb.com/projects/blog/uploads/2018/03/realtek-d723-driver-after-install.jpg" alt="WiFi connections"></p> <h2 id="faq">FAQ</h2> <h3 id="required-key-not-available">&quot;Required key not available&quot;</h3> <p>The easiest solution is to disable Secure Boot in UEFI settings. <a href="https://askubuntu.com/a/762255/87199">Solution here</a>.</p> <h3 id="poor-wifi-range">Poor WiFi Range</h3> <p>Open a terminal and do :</p> <pre tabindex="0"><code>sudo modprobe rtl8723be ant_sel=1 </code></pre><p>If that doesn't fix it, do this instead :</p> <pre tabindex="0"><code>sudo modprobe rtl8723be ant_sel=2 </code></pre><p>This is a temporary solution. To make it permanent, we need to run it every time the system starts. For that, edit the file <code>/etc/rc.local</code> :</p> <pre tabindex="0"><code>sudo gedit /etc/rc.local </code></pre><p>Replace <code>gedit</code> above with whatever text editor you have.</p> <p>Then, in that file add :</p> <pre tabindex="0"><code>sleep 10 sudo modprobe -r rtl8723be sudo modprobe rtl8723be ant_sel=1 </code></pre><p>Replace <code>ant_sel=1</code> above with the one that worked for you. Either '1' or '2'.</p> 18 Years Of Revolving Around The Sun https://subinsb.com/18-years-revolving-around-sun/ Sat, 20 Jan 2018 06:29:06 +0000 https://subinsb.com/18-years-revolving-around-sun/ <p>I'm legally an adult now. I have successfully revolved around the sun 18 times. Yay !</p> <p>This post is dedicated to the future me who will be having nostalgic feelings reading this. Hey there, future me !</p> <h2 id="coding">Coding</h2> <p>Lobby was a mistake. I think I've wasted my 2 years in developing it. I was too ambitious. But I gained a lot of experience. This was the first time that I got into cross-compiling, virtual environments, Android development, etc.</p> <pre><code>Every project is an experience may it be a disaster or not. Be grateful of that experience </code></pre> <p>^ I guess I have to just say this loud to comfort me. My GitHub commit history is filled with Lobby contributions. There was a day with <strong>56 commits</strong>.</p> <p>I was very much focused on developing Lobby that I forgot to see the bigger picture, people aren't gonna use it if there aren't enough apps. Don't we already have Android Play Store and similar things.</p> <p>The idea of Lobby is good though, open source apps where you can directly edit the code to modify it and so on. But I don't think it's possible without a good team of devs and a solid framework.</p> <p>OpenShift ended their free plan and 2 of my sites is discontinued :</p> <ul> <li><a href="https://open.subinsb.com/">Open</a></li> <li><a href="https://lobby.subinsb.com">Lobby</a></li> </ul> <p>Both the above projects were really helpful to me as a self-learning dev. <a href="https://demos.subinsb.com/">My lab site</a> was migrated to Heroku and it runs fine on the free plan. And this blog is now a static site with the help of <a href="https://gohugo.io">Hugo</a>.</p> <p>I started developing desktop apps with Python and Qt :</p> <ul> <li><a href="https://github.com/subins2000/TorrentBro">TorrentBro</a></li> <li><a href="https://gitlab.com/subins2000/setrix">Setrix</a></li> </ul> <p>Python is beautiful โค</p> <p>My project <a href="https://demos.subinsb.com/Francium/CryptoDonate/">CryptoDonate</a> got some attention and someone created a whole <a href="https://cryptodonate.online">new site for it</a>. He/she also linked back to me. That made me happy.</p> <h2 id="college">College</h2> <p>I have joined Vidya Academy of Science And Technology in July 2017 pursuing a BTech degree in Computer Science Engineering. It's a private college and it's expensive ! There's a chance for a scholarship and I hope I get it.</p> <p>I like it here. Got some really great friends ! I have company with everyone in my class and is getting to know more kind of people from different parts of Kerala.</p> <pre><code>Every person is unique and it's interesting to know them </code></pre> <p>I've benn in internet too long that I know a variety of things. So there's always something in common to talk to a person. Be it politics, science or entertainment.</p> <p>So I have very different set of friend circles. It's a <strong>Venn diagram</strong> where I intersect in every other sets.</p> <p>Some noticeable changes :</p> <ul> <li>Much more active on WhatsApp (more friends)</li> <li>Less coding than before (as a consequence of #1)</li> <li>Addicted to social media (phones are dangerous, another consequence of #1 ?)</li> <li>Much more socially comfortable. I was awkward before. Now I don't mind it at all. I just ring up conversations and my sense of humour is okay-ish.</li> </ul> <h3 id="activities">Activities</h3> <p>I took initiative in revamping the FOSSers (Free and Open Source Software Users) club of our college. Even though we're freshmen, we were able to move it around and attract people to GNU/Linux :)</p> <p>I think I have helped more than 25 people in installing a distro. I recommend Linux Mint for newbies.</p> <h2 id="teenage">Teenage</h2> <p>I've always expressed myself as a &quot;teenage developer&quot;. That's gonna go soon. I'm getting old.</p> <p>This blog has been very inactive. I don't have that energy and enthusiasm I had during my early teenage years. What happened to me ?</p> <p>Maybe it's gonna get better ?</p> <p>Maybe.</p> <pre><code>Originally wrote this post on March 14. I missed updating my blog about my birthday :( </code></pre> CryptoDonate, The Donation Button For CryptoCurrencies https://subinsb.com/cryptodonate/ Fri, 16 Jun 2017 08:12:53 +0000 https://subinsb.com/cryptodonate/ <p>CryptoDonate is a JavaScript (vanilla JS) library to embed a donation button for cryptocurrency. It doesnโ€™t require any external library and is very lightweight. I created it to replace my existing BTC donation button in my blog.</p> <div class="padlinks"> <a class="demo" href="https://demos.subinsb.com/Francium/CryptoDonate/" target="_blank" rel="noopener">Demo</a><a class="download" href="https://demos.subinsb.com/download/francium-cryptodonate" target="_blank" rel="noopener">Download</a> </div> <h2 id="features">Features</h2> <ul> <li>Supports BTC, LTC, ETH, XMR</li> <li>Lightweight</li> <li>Have an embed script</li> <li>Easy usage</li> <li>Supports theming</li> </ul> <h2 id="widget">Widget</h2> <p>You can simply add the CryptoDonate widget to your blog or site by using this <a href="https://demos.subinsb.com/Francium/CryptoDonate/">Widget Maker Tool</a>. The widget maker tool generates a script that will load the files asynchoronously meaning your pageโ€™s load time wonโ€™t be affected.</p> <p>The <code>Fr.loadCD()</code>ย function is used to load CryptoDonate to an element. Itโ€™s first parameter is the element (can be an element ID or element DOM object). The second parameter is the options.</p> <pre class="prettyprint"><code>Fr.loadCD(document.getElementById('cd-loc'),ย { coin: 'bitcoin' });</code></pre> <p>To the second parameter, you can pass the same <a href="#options">options</a> as you pass to CryptoDonate object.<figure class="wp-caption aligncenter"></p> <p><a href="//lab.subinsb.com/projects/blog/uploads/2017/06/cryptodonate-dialog.png"><img class="size-medium" src="https://lab.subinsb.com/projects/blog/uploads/2017/06/cryptodonate-dialog.png" alt="CryptoDonate dialog" width="1327" height="741" /></a><figcaption class="wp-caption-text">CryptoDonate dialog</figcaption></figure></p> <h2 id="usage">Usage</h2> <p>CryptoDonate comes under <a href="http://subinsb.com/the-francium-project">The Francium Project</a>ย and therefore the object is referenced by <code>Fr.CryptoDonate</code>. Here is how itโ€™s constructed :</p> <pre class="prettyprint"><code>var cd = new Fr.CryptoDonate({ ย  coin: 'bitcoin', address: '3Q2zmZA3LsW5JdxkJEPDRbsXu2YzzMQmBQ' });</code></pre> <p>Then you can add the button to an element by using the <code>appendTo</code> function :</p> <pre class="prettyprint"><code>cd.appendTo(document.getElementById('target'));</code></pre> <h2 id="options">Options</h2> <p>Options is passed to CryptoDonate as the first parameter while constructing the CryptoDonate object. Here are the default options (JSON object) :</p> <pre class="prettyprint"><code>{ coin: 'bitcoin', address: '3Q2zmZA3LsW5JdxkJEPDRbsXu2YzzMQmBQ', qr: true, getQrImage: function(data) { return 'https://api.qrserver.com/v1/create-qr-code/?size=200x200&data=' + data; }, strings: { button: 'Donate', buttonTitle: 'Donate {coinName}', coins: { bitcoin: 'Bitcoin', ethereum: 'Ether', litecoin: 'Litecoin', monero: 'Monero', }, dialogHeader: 'Donate {coinName}', dialogHelper: 'Please use this {coin} address to donate. Thanks !', openInWallet: 'Click here to send this address to your wallet.' }, baseURL: '//lab.subinsb.com/projects/francium/cryptodonate', buttonLarge: false, buttonClass: '', dialogClass: '', }</code></pre> <p>Notice the sub-object <code>strings</code>. It helps you to change the text displayed. You can use another language or change the &quot;donation&quot; to a &quot;Pay Now&quot; button.</p> <h3 id="coin">coin</h3> <p>Type: string; Values: โ€˜bitcoinโ€™, โ€˜litecoinโ€™, โ€˜ethereumโ€™, โ€˜moneroโ€™</p> <h3 id="address">address</h3> <p>Type: string;</p> <p>The address to which payment is made. This value will be in different format for different coins. CryptoDonate does not check whether itโ€™s valid or not. Make sure itโ€™s correct.</p> <h3 id="qr">qr</h3> <p>Type: boolean; Values: true, false</p> <p>Should the QR image be displayed or not.</p> <h3 id="getqrimage">getQRImage</h3> <p>Type: function(string data);</p> <p>The callback function used to get the URL to QR image representation of the given string.</p> <h3 id="strings">strings</h3> <p>Type: object;</p> <p>The strings that are displayed to the user is stored in this object. This is useful for translating strings.</p> <p>Certain words closed in curly braces can be substituted :</p> <ul> <li>{coin} โ€“ The coinโ€™s name in lowercase. Example: bitcoin, ethereum</li> <li>{coinName} โ€“ The coinโ€™s name. Example: Bitcoin, Ether</li> </ul> <h3 id="baseurl">baseURL</h3> <p>Type: string;</p> <p>The base URL from which resources are loaded. The folder structure of base folder should be like <a href="https://github.com/subins2000/CryptoDonate/tree/master/src" target="_blank" rel="noopener">this</a>.</p> <h3 id="buttonlarge">buttonLarge</h3> <p>Type: boolean; Values: true, false</p> <p>Should the button be large sized.</p> <h3 id="buttonclass">buttonClass</h3> <p>Type: string;</p> <p>Additional classes that must be added to the button. The classes must be separated by a whitespace.</p> <p>If โ€˜darkโ€™ class is added, then the buttonโ€™s theme will be changed to dark.</p> <h3 id="dialogclass">dialogClass</h3> <p>Type: string;</p> <p>Similar to <a href="#buttonclass">buttonClass</a>, it adds additional classes to dialog. Can be used for theming the dialog as well.</p> <h2 id="functions">Functions</h2> <h3 id="appendto">appendTo</h3> <p>Parameters:</p> <ul> <li>element โ€“ Type: DOM Object; Element to which the button should be appended</li> </ul> <p>Example :</p> <pre class="prettyprint"><code>cd.appendTo(document.getElementById('target'));</code></pre> <p>Using the CryptoDonate library directly may feel difficult for you if you donโ€™t know JavaScript. In that case, I highly recommend you use the <a href="#widget">widget</a>.</p> How To Cache GPG Passphrase In Ubuntu https://subinsb.com/cache-gpg-passwords-ubuntu/ Wed, 07 Jun 2017 18:25:13 +0000 https://subinsb.com/cache-gpg-passwords-ubuntu/ <p>I got into Debian packaging and one of the most brutal part was to type in the GPG secret keyโ€™s password every time I sign a package. I wasted a lot of time typing my long password.</p> <p>I searched a lot to cache my password for some time after I type it once. All of them said to edit <strong>gpg-agent.conf</strong>, but none of them worked for my fresh installation ofย <strong>Xubuntu 16.04</strong>. Iโ€™m writing this to save you a lot of trouble.</p> <p>First of all, install seashore :</p> <pre class="prettyprint"><code>sudo apt install seashore</code></pre> <p>Seashore is a great application to manage your keys. Iโ€™m asking you to install seashore as it comes with a graphical pinentry tool.</p> <h2 id="configuring-gpg-agent">Configuring gpg-agent</h2> <p>Edit the file <code>/home/username/gpg-agent.conf</code>ย and add these two lines :</p> <pre class="prettyprint"><code>default-cache-ttl 1800 max-cache-ttl 1800</code></pre> <p>If your gpg-agent version is less than 2 (you can check it by running <code>gpg-agent --version</code>), add these lines instead :</p> <pre class="prettyprint"><code>default-cache-ttl 1800 maximum-cache-ttl 1800</code></pre> <p>The value gives the maximum amount of time the password should be cached.ย <strong>1800 seconds</strong> mean 30 minutes. Here are some conversions :</p> <blockquote> <p>600 seconds = 10 minutes</p> </blockquote> <blockquote> <p>1800 seconds = 30 minutes</p> </blockquote> <blockquote> <p>3600 seconds = 60 minutes = 1 hour</p> </blockquote> <h2 id="configure-gpg">Configure gpg</h2> <p>This is the secret sauce Iโ€™m going to give you that might solve your problem. This is what worked for me.</p> <p>Edit the file <code>/home/username/.gnupg/gpg.conf</code>. If it doesnโ€™t exist (most likely) create it. Add this line to it :</p> <pre class="prettyprint"><code>use-agent</code></pre> <p>This makes gpg to use an agent to enter passwords.</p> <p>Restart gpg-agent and youโ€™re all set :</p> <pre class="prettyprint"><code>killall -q gpg-agent && gpg-agent --daemon </code></pre> <p>Now when you need to enter the password, a graphical dialog will be brought up :<figure class="wp-caption aligncenter"></p> <p><a href="https://lab.subinsb.com/projects/blog/uploads/2017/06/gpg-pinentry.png"><img class="size-medium" src="https://lab.subinsb.com/projects/blog/uploads/2017/06/gpg-pinentry.png" alt="pinentry dialog" width="392" height="243" /></a><figcaption class="wp-caption-text">Pinentry dialog for entering password to unlock GPG private key</figcaption></figure></p> <p>and after you enter it, itโ€™ll be cached according to gpg-agent configuration file.</p> 17 Years Of Revolving Around The Sun https://subinsb.com/17-years-revolving-around-sun/ Fri, 20 Jan 2017 06:29:06 +0000 https://subinsb.com/17-years-revolving-around-sun/ <p>Sweet 17 ! The age in between an adult and juvenile. Iโ€™m going to take a relook at my 16th year.</p> <h2 id="coding">Coding</h2> <ul> <li>Lobby 1.0 was released. That was a trough one.</li> <li>Francium logSys 0.7 was released</li> <li>Updates to Francium voice</li> <li>Release of Francium Diffsocket &amp; Francium Star</li> <li>Many more contributions to FOSS</li> </ul> <p>I could have done more if there was less school. I also got into Android programming and released my first app Lobby.</p> <h2 id="videos">Videos</h2> <p>I took my old hobby of making videos. Editing using Kdenlive makes me happy. I look forward to making tutorial videos, and other kinds in the future.</p> <p>Iโ€™ll continue maintaining my projects and making new ones !</p> Google Code In 2016 https://subinsb.com/google-code-in-2016/ Mon, 16 Jan 2017 14:23:04 +0000 https://subinsb.com/google-code-in-2016/ <p>Google Code In is a contest run by Google for teenagers (13-17) to promote contributing to open source projects. It is like Google Summer Of Code, but for teenagers who are not in colleges.</p> <p>This is my 4th time in Code In and it was fantastic just like before. Hereโ€™s a summary :</p> <blockquote> <p>2013 โ€“ Wikimedia</p> </blockquote> <blockquote> <p>2014 โ€“ <a href="http://subinsb.com/into-drupal">Drupal</a></p> </blockquote> <blockquote> <p>2015 โ€“ย <a href="http://subinsb.com/ubuntu-dekko">Ubuntu</a></p> </blockquote> <blockquote> <p>2016 โ€“ Wikimedia</p> </blockquote> <p>This year (2016), I chose Wikimedia again ! Itโ€™s nice to contribute to various FOSS projects. Even a small help to FOSS projects is a big deal.</p> <h2 id="joy-of-first-commit">Joy of First Commit</h2> <p>My first commit was replacing Linker::link() usages with LinkRenderer in the mediawiki core. It was simple, but a little complicated since it was my first.ย The task was to do it inย <strong>5 special pages</strong>, but I did <strong>10</strong>. I had to make 6 patches to make it perfect.</p> <p>The joy of the first commit to a project that powers upย <strong>Wikipedia</strong> and thousands of other wiki sites is so much. I still remember that feeling I had in me. The commits after didnโ€™t evoke that much feeling.</p> <h2 id="tasks">Tasks</h2> <p>I didย <strong>16</strong> tasks. Never wanted to do tasksย speedily, because I donโ€™t wanna mess anything up by going too fast. The idea is to be smooth, steady and being calm.</p> <blockquote> <p>Itโ€™s not about how many you did, but the quality of how you did</p> </blockquote> <p>The <a href="https://meta.wikimedia.org/wiki/User:Subins2000/Open_Source_Design_Tools">last task</a> I did was pretty hard, but itโ€™s gonna help a lot of newcomers. I had a fever during the task which made me not use the computer. Funny thing, a good nightโ€™s sleep cured me. Didnโ€™t even needed to take any medicine.</p> <h2 id="videos">Videos</h2> <p>Apart from programming, another hobby I had since 11 was making videos. Thereโ€™s some really embarrassing videos I made in the early days. If you want to feel cringe, <a href="https://www.youtube.com/user/subins2000/videos" target="_blank">see those</a>.</p> <p>For Wikimedia, I made <a href="https://commons.wikimedia.org/w/index.php?title=Special:ListFiles/Subins2000&amp;ilshowall=1">some tutorials</a> on using Phabricator. I used my phone to record the audio andย **Kazamย **for screencast. For editing, I used **Kdenliveย **andย <strong>Audacity</strong>. All these softwares are very awesome and make the FOSS community proud.</p> <p>I hope these tutorials I made will help the people who come in the future.</p> <h2 id="community">Community</h2> <p>I would like to say a thousand thanks to all the mentors who were in this year. What makes kids like me continue a work is appreciation and what the community did is give them a lot.</p> <p>The appreciations they gave really helped me. I could only work with a few of <a href="https://www.mediawiki.org/wiki/Google_Code-in_2016#List_of_Wikimedia_mentors">mentors</a>, but Iโ€™m sure everyone is supportive.</p> <h2 id="what-i-learnt">What I Learnt</h2> <p>The biggest thing I learnt is how development of a big software work. Many people contribute to MediaWiki a day and managing all those works trough Phabricator and gerrit is amazing.</p> <p>I have a lot of open source projects, but none of them is very much active like MediaWiki. Working in their environment helps me to be prepared when a project of mine explodes.</p> <p>I also learnt how important documentation is. If it werenโ€™t for those beautifully documented functions, I wouldnโ€™t be able to make even a single change.</p> <p>Another thing I learnt is the coding standards and how code can be made beautiful to see.</p> <p>My future FOSS projects will absolutely be influenced by my experience with MediaWiki.</p> Draw Animated Christmas Tree In Bash https://subinsb.com/bash-animated-christmas-tree/ Sun, 25 Dec 2016 07:34:24 +0000 https://subinsb.com/bash-animated-christmas-tree/ <p>It's Christmas again and you'll be receiving all kinds of greetings. How about greeting them back with a fancy way ? Show off your nerdiness with this super coolย <strong>Christmas Tree in Bash</strong>.</p> <p>All you need is a bash shell. Most systems have bash shell by default, so you don't have to install anything for this !</p> <p>All thanks goes to the Argentian programmerย <a href="http://www.sergiolepore.net/">Sergio Lepore</a>ย for this cool script.</p> <p>Here's how it looks :<figure class="wp-caption aligncenter"></p> <p><a href="//i.imgur.com/oCU56St.gif"><img src="https://i.redd.it/080aqe51c0601.gif" alt="Christmas Tree in Bash" /></a><figcaption class="wp-caption-text">Christmas Tree in Bash</figcaption></figure></p> <p>First of all open a terminal and copy <a href="https://github.com/sergiolepore/ChristBASHTree/blob/master/tree-EN.sh">this script</a> to your computer :</p> <pre class="prettyprint"><code>wget -d -c -O "christmas.sh" "https://raw.githubusercontent.com/sergiolepore/ChristBASHTree/master/tree-EN.sh"</code></pre> <p>Make the file executable :</p> <pre class="prettyprint"><code>chmod u+x ./christmas.sh</code></pre> <p>RUN !</p> <pre class="prettyprint"><code>./christmas.sh </code></pre> <p>Ain't that fancy ? All thanks goes to the Argentian programmerย <a href="http://www.sergiolepore.net/">Sergio Lepore</a>ย for this cool trick.</p> <h2 id="fork">Fork</h2> <p>You can make your own little changes in the script to add your name and other stuff. I added my name using this line :</p> <pre class="prettyprint"><code>tput cup $((lin + 3)) $((c - 4)); echo subins2000</code></pre> <p>I added the above line just after &quot;And lots of CODE in $new_year&quot; line.</p> <p>You can do anything with this script. Maybe translate it your own language or add more fancy stuff. Let me know what you have done ๐Ÿ™‚</p> <h2 id="make-a-gif">Make A Gif</h2> <p>Let's make a gif of this great terminal gift. You can use this gif to send to your friends or post on social networks.</p> <p>We'll use a screen recorder and a gif converter. For this, install these :</p> <pre class="prettyprint"><code>sudo apt install gtk-recordmydesktop ffmpeg winff </code></pre> <p>Use gtk-recordmydesktop to record the terminal. This will output a OGV file. Then do the following 2 commands to make the gif :</p> <pre class="prettyprint"><code>ffmpeg -y -i input.ogv -vf fps=10,scale=800:-1:flags=lanczos,palettegen palette.png ffmpeg -i input.ogv -i palette.png -filter_complex "fps=10,scale=800:-1:flags=lanczos[x];[x][1:v]paletteuse" output.gif</code></pre> <p>If you want to trim the video, you can add the following options to the second command :</p> <pre><code>-ss 3 -t 30 </code></pre> <p>which stands for &quot;start from 3rd second and end at 30th second.</p> <h2 id="make-a-video-with-background-sound">Make A Video With Background Sound</h2> <p>How about mixing a christmas song to the gif and make a video ! We can use <code>ffmpeg</code> for this. I'm gonna mix <a href="https://www.youtube.com/watch?v=RTtc2pM1boE">Feliz Navidad</a> which is saved as <code>sound.mp3</code>. Here's what the command looks :</p> <div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>ffmpeg -ss <span style="color:#ae81ff">34</span> -i <span style="color:#e6db74">&#34;sound.mp3&#34;</span> -i output.gif -vf <span style="color:#e6db74">&#34;scale=trunc(iw/2)*2:trunc(ih/2)*2&#34;</span> -strict -2 -c:v libx264 -c:a aac -b:a 192k -pix_fmt yuv420p -t <span style="color:#ae81ff">17</span> xmas.mp4 </span></span></code></pre></div><p>In the above command, I specifically mention the point of audio to mix : start from <code>34</code>th second and duration <code>17</code> seconds. This is the point where the lyrics is <em>I wanna wish you a merry christmas, I wanna wish you a merry christmas from the bottom of my heart</em></p> <p><a href="https://v.redd.it/krdropdtc9621">And here's the result</a></p> An Interview With GNUKhata Developer Krishnakant Mane https://subinsb.com/interview-with-krishnakant-mane/ Tue, 06 Dec 2016 05:47:09 +0000 https://subinsb.com/interview-with-krishnakant-mane/ <p>This is my first interview with a person. I don't do interviews normally. But when I read about Krishnakant Mane I wanted to know more about him. So I contacted him by email and got the response within an hour. The guy is really hooked up with computers !</p> <p>Krishnakant Mane is blind, but that didn't stop him from coding. He created and maintains theย <strong><a href="http://gnukhata.in/">GNUKhata</a></strong> project, a free and open source accounting software. <a href="http://gnukhata.in/">GNUKhata</a> is an alternative to the proprietary softwares like Tally which is widely used all over the world.<figure class="wp-caption aligncenter"></p> <p><img src="//lab.subinsb.com/projects/blog/uploads/2016/12/krishnakant-mane.png" alt="Krishnakant Mane"></p> <p>Even in my small town, people use Tally and they pay huge sums for it. I'm glad that there is an open source alternative to it. Here is the full interview with him :</p> <h3 id="which-languages-do-you-know--which-is-your-favorite-programming-language-">Which languages do you know ? Which is your favorite programming language ?</h3> <p>I know Java, PHP, C and Python, apart from SQL and Javascript.</p> <p>Python is my personal favorite because it has the best balance of ease of use and great power. You almost end up writing English like code. Indentation and other things make it a clean syntax language.</p> <h3 id="how-do-you-code-without-seeing-what-you-have-made--what-softwares-do-you-use-for-coding-">How do you code without seeing what you have made ? What softwares do you use for coding ?</h3> <p>I use a screen reader for all my computing.</p> <p>It is a free and open source software called <a href="https://wiki.gnome.org/Projects/Orca"><strong>Orca</strong></a> which now comes with almost all distros of GNU/Linux. It is a complete screen reader which reads out every thing including web pages, documents, spreadsheet or code.</p> <h3 id="youre-working-for-foss-how-do-you-pay-the-bills-">You're working for FOSS. How do you pay the bills ?</h3> <p>Apart from being a great movement for people's digital freedom and rights, free software is a great source of earning. Lot of people come to free software due to it's low cost to start with and then tend to like the features most of the time. Then they need customization with few features specifically for their needs. Many corporates pay for free software support and also for specific modifications which they need for running their business. They see the transparency and the low Total Ownership Cost (TOC) as a benefit.</p> <p>More than this there are a lot of crowd funding opportunities.</p> <h3 id="does-people-donate-money-for-your-works--if-so-what-is-the-major-contribution-you-received-">Does people donate money for your works ? If so, what is the major contribution you received ?</h3> <p>People hardly donate specially in India. Yet the central government has given lakhs of Rs as grant to my projects, <a href="http://gnukhata.in/">GNUKhata</a> in particular.</p> <p>Kerala state government has given more than 50,00,000 Rs (73,000$).</p> <p>A commercial software company called Tech blue ENTP has also contributed.</p> <h3 id="how-does-foss-help-you-in-your-life-">How does FOSS help you in your life ?</h3> <p>I use only and exclusively free software and I never use or recommend or advocate proprietary software in any form. ย I have got a lot of benefit personally because I use software as I please and I never have virus issues. I totally get digital freedom of my own.</p> <p>I can help build communities around technology including for training etc. ย This way I also gain professionally both in terms of money and as a personal satisfaction, <span style="text-decoration: underline;">because I am doing some thing good for society</span>.</p> <h3 id="gnukhata-is-a-rival-software-to-tally-and-similar-proprietary-softwares-many-over-the-world-pay-huge-amount-of-money-for-tally-do-you-think-gnukhata-is-developed-enough-to-be-substituted-for-such-proprietary-softwares-">GNUKhata is a rival software to Tally and similar proprietary softwares. Many over the world pay huge amount of money for Tally. Do you think GNUKhata is developed enough to be substituted for such proprietary softwares ?</h3> <p>As a matter of fact, in many aspect the said free software is having more and better features than the likes of Tally. ย We had made it a point that we will not copy every thing blindly. We took new standards based approaches in many cases and what ever was good in other programs we took it.</p> <p><a href="http://gnukhata.in/">GNUKhata</a> is being used by many organizations now. In fact this project started on the very demand of many companies and a lot of accountants who found that <span style="text-decoration: underline;">a certain software is exploiting them</span>.</p> <h3 id="how-do-you-get-inspired-to-do-something--who-are-your-role-models-">How do you get inspired to do something ? Who are your role models ?</h3> <p>Every good work done by any individual is valuable so every one is a roll model in a way, yet Dr. RMS, the founder of free software movement is my role model.</p> <p>In addition, Dr. Nagarjun from Homibhabha Center for Science Education of TIFR, Dr Prakash Amte, socialist leaders like Lal Bahadur Shastri are all my role models. I am a proud liberal socialist myself so the list becomes obvious.</p> <h3 id="how-are-you-planning-to-go-forward-in-the-future--any-plans-for-a-new-project-">How are you planning to go forward in the future ? Any plans for a new project ?</h3> <p>My vision is to make rural india digitally empowered and raise the level of education and employment. I have an organization called <a href="http://dff.org.in">Digital Freedom Foundation</a> and we wish to bring cost of education down and also bring disabled people to the level of main stream society. All this is possible through ICT and if that has to be available for every one then free software is the only solution.</p> <h3 id="what-message-do-you-have-to-say-to-the-youth-today-">What message do you have to say to the youth today ?</h3> <p>We all are capable and do what you feel best for you.</p> <p>Unless your acts are physically harmful to an individual or a group and unless your acts are harming the nation's integrity and status, there is nothing right and wrong. So do what you feel, but think about those who might be as capable as you are but can't come up only because there are no opportunities and no high quality education because they are not provided with enough social and financial infrastructure. So always be socially conscious and do not play unfair.</p> <hr> <p>Krishnakant is an inspiration, to overcome the odds, do what you love and make a difference. You may also want to check out his <a href="https://www.youtube.com/watch?v=DhMybi3eq3U">TEDx speech</a> and follow him on <a href="https://twitter.com/kkmane">Twitter</a>.</p> My Interview With Paysa https://subinsb.com/my-interview-with-paysa/ Thu, 01 Dec 2016 02:50:53 +0000 https://subinsb.com/my-interview-with-paysa/ <p><strong>Paysa</strong> is the worldโ€™s first platform to empower individuals to maximize their salary across the span of their career.</p> <p>I have taken a look at <strong>Paysa</strong> and itโ€™s wonderful to know that you can get self-evaluated about your career and salary. I didnโ€™t know there was one. It also gives you guidance to follow the career path of your choice. An excellent service indeed !</p> <p>Iโ€™m very happy that such a company like <strong>Paysa</strong> has interviewed me. Thank you <strong>Paysa</strong>. Please do <a href="https://www.paysa.com/blog/2016/11/28/expert-interview-series-subin-siby/">read it</a> !</p> <div class="padlinks"> <a class="demo" href="https://www.paysa.com/blog/expert-interview-series-subin-siby/">Read Interview</a> </div> Newsletter https://subinsb.com/newsletter/ Sun, 27 Nov 2016 15:32:39 +0000 https://subinsb.com/newsletter/ <div class="tnp tnp-subscription"> </div> Make Headers Jump Links In WordPress Posts https://subinsb.com/make-wordpress-post-headers-jump-links/ Tue, 22 Nov 2016 12:24:57 +0000 https://subinsb.com/make-wordpress-post-headers-jump-links/ <p>You might have noticed that the <h2>, <h3> headers in my blog posts are links that can be used to jump to that section. These links are calledย <strong>Jump Links</strong>.</p> <p>These <strong>Jump Links</strong> can be sent anywhere on web for reading that particular section. This is very useful for tutorials as when someone comments a problem, we can use the link to redirect that user to the section where the solution is situated.</p> <div class="padlinks"> <a class="demo" href="#what-it-does">Demo</a> </div> <p>Iโ€™ll show you how to automatically make all headers Jump Links in WordPress.</p> <ul> <li>Go toย <strong>WordPress Admin</strong> -&gt;ย <strong>Appearance</strong> -&gt;ย <strong>Editor</strong>. This will bring you to Theme Editor.</li> <li>Choose &quot;Theme Functions (functions.php)&quot; file from the list on the right.</li> </ul> <p>At the end of that file, add this :</p> <pre class="prettyprint"><code>/** * Add id attribute to &lt;h1&gt;, &lt;h2&gt;, &lt;h3&gt; tags * http://subinsb.com/make-wordpress-post-headers-jump-links */ function anchor_content_headings($content) { $content = preg_replace_callback("/\&lt;h([1|2|3])\&gt;(.*?)\&lt;\/h([1|2|3])\&gt;/", function ($matches) { $hTag = $matches[1]; $title = $matches[2]; $slug = sanitize_title_with_dashes($title); return '&lt;a href="#'. $slug .'"&gt;&lt;h'. $hTag .' id="' . $slug . '"&gt;' . $title . '&lt;/h'. $hTag .'&gt;&lt;/a&gt;'; }, $content); return $content; } add_filter('the_content', 'anchor_content_headings');</code></pre> <h2 id="what-it-does">What It Does</h2> <p>This is the HTML of the headers that are normally outputted in your postย :</p> <pre class="prettyprint"><code>&lt;h1&gt;Hello World&lt;/h1&gt; &lt;h2&gt;Who ???&lt;/h2&gt; &lt;h3&gt;It's Me&lt;/h3&gt;</code></pre> <p>The code you just added will make them into this :</p> <pre class="prettyprint"><code>&lt;a href="#hello-world"&gt;&lt;h1 id="hello-world"&gt;Hello World&lt;/h1&gt;&lt;/a&gt; &lt;a href="#who"&gt;&lt;h2 id="who"&gt;Who ???&lt;/h2&gt; &lt;a href="#its-me"&gt;&lt;h3 id="its-me"&gt;It's Me&lt;/h3&gt; </code></pre> <p>What it means is that if you go to this URL :</p> <pre class="prettyprint"><code>http://myblog.com/my-post#hello-world </code></pre> <p>You will be shown the section that starts from Hello World heading.</p> <h2 id="hacks">Hacks</h2> <p>You can modify the script to also includeย <strong><h4></strong> andย <strong><h5></strong>ย as well. You can do this by replacing the &quot;preg_replace_callback&quot; line with this :</p> <pre class="prettyprint"><code>$content = preg_replace_callback("/\&lt;h([1|2|3|4|5])\&gt;(.*?)\&lt;\/h([1|2|3|4|5])\&gt;/", function ($matches) {</code></pre> <p>You may want to add a prefix or suffix to the IDs of headers. You can do this by modifyingย <strong>$slug</strong> variable :</p> <pre class="prettyprint"><code>$slug = "section-" . sanitize_title_with_dashes($title); </code></pre> <p>This will make the URLs :</p> <pre class="prettyprint"><code>http://myblog.com/my-post#section-hello-world</code></pre> Create A Profile Picture Framer Web App https://subinsb.com/create-profile-picture-framer-web-app/ Sun, 20 Nov 2016 09:10:40 +0000 https://subinsb.com/create-profile-picture-framer-web-app/ <p>You might have seen your Facebook friendsโ€™ fancy profile pictures with the frame of the sports team they support. These days for any major events, the best way to support them is by adding a frame to your profile picture with their logo.</p> <p>Football (soccer) is my favorite sport. My state Kerala have a franchise club in the Indian Super League calledย <strong>Kerala Blasters</strong>. We are the largest club by average crowd attendance and the fans are so passionate. What if a passionate, crazy fan is also a programmer. Then you will <a href="https://demos.subinsb.com/isl-profile-pic">get this</a>.</p> <p>Facebook didnโ€™t have a profile picture frame for Kerala Blasters and so I had to make one myself. It was an interesting project and I was able to make it in a night.ย <strong>UPDATE</strong>: Facebook now has a frame for Kerala Blasters and all other Indian Super League clubs, but the frames are ugly ๐Ÿ˜›</p> <div class="padlinks"> <a class="download" href="//demos.subinsb.com/down.php?class=45" target="_blank">Download</a><a class="demo" href="//demos.subinsb.com/isl-profile-pic" target="_blank">Demo</a> </div> <p>When I released theย <strong>Kerala Blasters Profile Picture Framer</strong>, it was very successful and thousands of fans in Kerala had used it. The visitor count reached 3,000 in a single day on a site that had an average of 200 in a day.</p> <p>To be exact, <strong>3759</strong> people have downloaded their framed profile pictures. Here is a sample :</p> <p><a href="//lab.subinsb.com/projects/blog/uploads/2016/11/kerala-blasters-profile-picture-frame.png"><img class="size-medium aligncenter" src="//lab.subinsb.com/projects/blog/uploads/2016/11/kerala-blasters-profile-picture-frame.png" alt="" width="404" height="404" /></a></p> <h2 id="features">Features</h2> <li style="text-align: left;"> Crop image </li> <li style="text-align: left;"> Preview before download </li> <li style="text-align: left;"> Customisable frame </li> <li style="text-align: left;"> Ability to choose different frames </li> <li style="text-align: left;"> Direct upload to Facebook </li> <p style="text-align: left;"> Besides all this, the greatest feature is that the code is simple and easy. </p> <h2 style="text-align: left;"> <span id="set-up">Set Up</span> </h2> <p style="text-align: left;"> Let&#8217;s begin by creating the files and libraries needed. The directory tree looks like this : </p> <li style="text-align: left;"> css </li> <li style="text-align: left;"> frames </li> <li style="text-align: left;"> js </li> <li style="text-align: left;"> uploads<br /> convert.php<br /> download.php<br /> index.php<br /> upload.php </li> <p style="text-align: left;"> All except the ".php" files above are folders. </p> <p style="text-align: left;"> We&#8217;ll use <a href="http://foliotek.github.io/Croppie/">Croppie</a>ย for letting user crop her/his profile picture. Download <a href="https://raw.githubusercontent.com/Foliotek/Croppie/master/croppie.css">this file</a> to "css/croppie.css" and <a href="https://raw.githubusercontent.com/Foliotek/Croppie/master/croppie.min.js">this file</a> to "js/croppie.min.js". </p> <p style="text-align: left;"> Set the permissions of "uploads" folder to Read/Write. On Linux this would be : </p> <pre class="prettyprint"><code>sudo chown ${USER}:www-data uploads && sudo chmod 0755 uploads </code></pre> <h2 style="text-align: left;"> <span id="makeframe">Makeย Frame</span> </h2> <p style="text-align: left;"> Make a frame using your favorite image editor. It should be a square and should have a minimum size ofย <strong>400x400px</strong>. An example : </p><figure class="wp-caption aligncenter"> <p><a href="https://demos.subinsb.com/isl-profile-pic/image/dp-fg.png"><img class="size-medium" src="https://demos.subinsb.com/isl-profile-pic/image/dp-fg.png" alt="Frame" width="400" height="400" /></a><figcaption class="wp-caption-text">Frame</figcaption></figure></p> <p>Make sure you make the frame keeping in mind that a face has to fit in it. Also make the background of the image <strong>transparent</strong> and save it as a <strong>PNG</strong> file.</p> <p>You can make multiple frames, because our app supports choosing from a list of frames. You should save the frames in &quot;frames&quot; folder as &quot;frame-0.png&quot;, &quot;frame-1.png&quot; etc. Note that we start numbering from &quot;0&quot; and not &quot;1&quot;.</p> <h2 id="indexphp">index.php</h2> <p>Copy <a href="https://github.com/subins2000/profile-picture-framer/blob/master/index.php" target="_blank">this file</a>ย to &quot;index.php&quot;.</p> <p>The page has a small box for customizing the profile picture, a button to upload profile picture and a button to upload to Facebook.</p> <h2 id="downloadphp">download.php</h2> <p>Copy <a href="https://github.com/subins2000/profile-picture-framer/blob/master/download.php" target="_blank">this file</a> to &quot;download.php&quot;.</p> <p>When user clicks the download button, he/she is redirected to this page. This page will show the generated profile picture and when user clicks on that image, the file will be downloaded. This is done byย <strong>download</strong> attribute :</p> <pre class="prettyprint"><code>&lt;a href='uploads/123.png' download='kerala-blasters-profile'&gt;&lt;img src='uploads/123.png' /&gt;&lt;/a&gt;</code></pre> <p>Theย <strong>download</strong> attribute gives the file name to the downloaded file.</p> <h2 id="convertphp">convert.php</h2> <p>Copy <a href="https://github.com/subins2000/profile-picture-framer/blob/master/convert.php" target="_blank">this file</a> to &quot;convert.php&quot;.</p> <p>This file has a function called &quot;makeDP()&quot; :</p> <pre class="prettyprint"><code>binary makeDP(string $profilePicturePath, int $design = 0) </code></pre> <p>&quot;binary&quot; denotes the imageโ€™s RAW data. Example usage :</p> <pre class="prettyprint"><code>makeDP("/home/me/profile-picture.png", 1);</code></pre> <p>If theย <strong>$design</strong>ย argument is not passed, &quot;frame-0.png&quot; will be used.</p> <h2 id="uploadphp">upload.php</h2> <p>Copy <a href="https://github.com/subins2000/profile-picture-framer/blob/master/upload.php" target="_blank">this file</a> to &quot;upload.php&quot;.</p> <p>When user clicks the download button, the profile picture is uploaded to this file viaย <strong>AJAX</strong>. Then this file will make the framed profile picture and save it to &quot;uploads&quot; folder.</p> <p>Theย AJAX response would be something like this :</p> <pre class="prettyprint"><code>uploads/sk2e9c1cu2.png </code></pre> <p>The file name would be of length 10.</p> <h2 id="cssstylecss">css/style.css</h2> <p>Copy <a href="https://github.com/subins2000/profile-picture-framer/blob/master/style.css" target="_blank">this file</a> to &quot;css/style.css&quot;.</p> <p>The stylesheet probably donโ€™t work for old IE. But it is supposed to work in all modern browsers and is mobile compatible.</p> <h2 id="jsappjs">js/app.js</h2> <p>Copy <a href="https://github.com/subins2000/profile-picture-framer/blob/master/js/app.js" target="_blank">this file</a> to &quot;js/app.js&quot;.</p> <p>When user uploads her/his profile picture,ย <strong>onFileChange()</strong> is called and a preview of the image is shown. If the image is smaller thanย <strong>400x400px</strong>, then an alert box is shown.</p> <p>The user could then adjust the profile picture according to the frame. This feature is done with the help of <a href="http://foliotek.github.io/Croppie/">Croppie.js</a>.</p> <p>When user is done adjusting, the &quot;Download Profile Picture&quot; button is clicked and the blob data of cropped picture is obtained :</p> <pre class="prettyprint"><code>croppie.result({ size: "viewport" }).then(function(dataURI){ var formData = new FormData(); formData.append("design", $("#fg").data("design")); formData.append("image", dataURItoBlob(dataURI)); ...</code></pre> <p>Croppie returns a data URI and we convert it to blob usingย <strong>dataURItoBlob()</strong> function. The form data that is sent to &quot;upload.php&quot; looks like this :</p> <pre class="prettyprint"><code>design=0; image=&lt;binary&gt;;</code></pre> <p>The design parameter is an integer of design chosen. This value is got from the list of designs :</p> <pre class="prettyprint"><code>&lt;div id="designs"&gt; &lt;img class="design active" src="frames/frame-0.png" data-design="0" /&gt; &lt;img class="design" src="frames/frame-1.png" data-design="1" /&gt; &lt;img class="design" src="frames/frame-2.png" data-design="2" /&gt; &lt;/div&gt;</code></pre> <p>Theย <strong>data-design</strong> attribute is the ID of that design.</p> <h2 id="upload-to-facebook">Upload To Facebook</h2> <p>There is an option to upload the framed profile picture to Facebook. But this requires you to <a href="http://developers.facebook.com/apps">create a Facebook app</a>ย and submit a review request for the following permissions :</p> <ul> <li>publish_actions</li> </ul> <p>Before you submit the App Review request, you must set up the website and make a video of how your app works. It took me a week to get the permissions approved.</p> <p>If you would like to implement this feature, copy <a href="https://github.com/subins2000/profile-picture-framer/blob/master/js/fb.js">this file</a> to &quot;js/fb.js&quot;. Donโ€™t forget to replace the URL to image file with yours.</p> <p>Note that we canโ€™t directly set the userโ€™s profile picture. The FB API doesnโ€™t allow you to do that. What we can do is upload the image to userโ€™s wall and redirect the user to that image in FB, so that user can click the Make Profile Picture button.</p> <p>Thatโ€™s it ! Enjoy your own profile picture framer web app. Use it for special events.</p> New Theme Brenton https://subinsb.com/new-theme-brenton/ Fri, 18 Nov 2016 12:51:18 +0000 https://subinsb.com/new-theme-brenton/ <p>Itโ€™s been some time since I have been active on this blog. For the past months, I had been paying little attention to my blog. Itโ€™s because I was busy with other projects and school of course.</p> <p>From now on, Iโ€™ll try to make the blog more active. As a first step, I have updated the theme. This is the third update to the theme.</p> <p>The previous themes were named &quot;Subinโ€™s Blog V1&quot; &amp; &quot;Subinโ€™s Blog V2&quot;. Thatโ€™s a pretty boring name. So I went to a random name picker website and chose one โ€“ &quot;Brenton&quot;.</p> <p>Someone who liked my last theme wanted it to be open sourced and so I did it. The old repo is moved to the new one.</p> <div class="padlinks"> <a class="demo" href="https://github.com/subins2000/brenton" target="_blank">GitHub</a> </div> <h2 id="changes">Changes</h2> <p>Youโ€™ll notice the UI change first. The comet falling background is removed for good. The site was laggy in performance because of that bg. Here is how I did that bg :</p> <pre class="prettyprint"><code>body:before{ content: ""; position: fixed; top: -50%; left: -50%; bottom: -50%; right: -50%; z-index: -1; -webkit-transform: rotate(-30deg); -moz-transform: rotate(-30deg); -ms-transform: rotate(-30deg); -o-transform: rotate(-30deg); transform: rotate(-30deg); background-image: url("bg.png"); background-color: #000; background-repeat: repeat; }</code></pre> <p>The &quot;bg.png&quot; file was rotated diagonally to make the comet falling effect. This was a huge mistake as browser had trouble rendering this effect every time the user scrolled. As a result scrolling caused a lag and it was messy as glue. Yuck !</p> <p>That background is replaced by a linear gradient now :</p> <pre class="prettyprint"><code>body{ background: linear-gradient( 0deg, #4CA454, #000 ); }</code></pre> <p>And overall this is how the site look :</p> <p><a href="https://raw.githubusercontent.com/subins2000/brenton/master/screenshot.png"><img src="https://raw.githubusercontent.com/subins2000/brenton/master/screenshot.png" alt="Brenton WordPress Theme" height="673" /></a></p> <p>Please comment your feedback &amp; suggestions. It will be very helpful. As I said, Iโ€™m gonna drive this blog on the right track once again. ๐Ÿ™‚</p> Get Architecture Plainly Without Version In Android https://subinsb.com/just-plainly-get-android-architecture/ Sat, 03 Sep 2016 19:09:08 +0000 https://subinsb.com/just-plainly-get-android-architecture/ <p>If you want to just get plainly the architecture of system like &quot;arm&quot; or &quot;x86&quot; in your apps, then this post is just for you.</p> <p>So with this function that Iโ€™m gonna present, you will get 3 values, &quot;arm&quot;, &quot;mips&quot; or &quot;x86&quot; whether or not the system is 32 bit or 64 bit.</p> <p>Here is the function :</p> <pre class="prettyprint"><code>public static String getArch() { String arch = System.getProperty("os.arch").substring(0, 3).toLowerCase(); if (arch.equals("aar") || arch.equals("arm")) { return "arm"; }else if(arch.equals("mip")){ return "mips"; }else{ return arch; } }</code></pre> <p>Just call it statically if itโ€™s under a class :</p> <pre class="prettyprint"><code>MyClass.getArch() </code></pre> <p>and you can correctly check if itโ€™s an ARM or MIPS or x86 :</p> <pre class="prettyprint"><code>if(getArch().equals("arm")) // Hurray, it's an ARM system</code></pre> School Election Software "sElec" https://subinsb.com/school-election/ Wed, 10 Aug 2016 13:12:46 +0000 https://subinsb.com/school-election/ <p>Iโ€™m currently studying inย <strong>12th grade</strong> atย <strong>Government Model Girls Higher Secondary School</strong>. Donโ€™t mind the word &quot;Girls&quot; in the name, because in higher secondary both boys and girls study.</p> <p>Like schools all over the world, we have an election for each classes to select our class leader. Even inย 21st century, our schools were conducting the election withย <strong>ballot papers</strong>.</p> <p>So I thought why not make a software for it ? This led to the creation of &quot;<strong>sElec</strong>&quot; โ€“ a Lobby app for conducting school elections. (I just came up with the name at this moment writing this line)</p> <h2 id="features">Features</h2> <ul> <li> <p>Free, Open Source (Apache v2 licensed)</p> </li> <li> <p>Web based (so it works on Linux/Windows)</p> </li> <li> <p><a href="#article-security"><strong>99.99% Secure</strong></a></p> </li> <li> <p>Class &amp; Division support</p> </li> <li> <p>One software for all school elections</p> </li> <li> <p>Easy to download and install</p> </li> <li> <p>Can be used for various type of elections</p> </li> <li> <p>Passwords for students (voters)</p> </li> <li> <p>Networking capability</p> <p>Run electionย on multiple computers in a computer lab</p> </li> <li> <p>Highly Customizable</p> <ul> <li>Can be used for various type of elections</li> <li>Lockย class-division choice to prevent fraud</li> </ul> </li> </ul> <h2 id="download">Download</h2> <p>There are two versions you can download :</p> <div class="padlinks"> <a class="demo" href="https://drive.google.com/open?id=0B2VjYaTkCpiQUFNrZTNPdlh5SWc">sElec Linux</a><a class="download" href="https://drive.google.com/open?id=0B2VjYaTkCpiQU3pIc2pHZkhEWXc">sElec Windows</a> </div> <p>Since Iโ€™m a FOSS guy, I recommend using the <strong>sElec Linux</strong>ย onย <strong>Ubuntu 16.04 Xenial Xerus</strong>.</p> <h2 id="install">Install</h2> <p>Installation is pretty simple if you do it rightly.</p> <ul> <li>Download the &quot;.zip&quot; file according to your system (I recommend using Linux)</li> <li>Extract the folder inside the zip file to a location of your choice (I prefer Home folder or Downloads folder)</li> </ul> <h2 id="open">Open</h2> <p>Run the file &quot;Lobby&quot; inside the folder you just extracted.</p> <p>If youโ€™re using Linux you may double click on &quot;Lobby.sh&quot; file and choose &quot;Execute&quot; in the dialog that will pop out.</p> <p><strong>NOTE (Windows)</strong> โ€“ When you run &quot;Lobby.exe&quot;, there is a chance for an error :</p> <blockquote> <p>VCRUNTIME110.dll is missing</p> </blockquote> <p>To fix it, see <a href="https://lobby.subinsb.com/docs/quick/windows#running-lobby" target="_blank">this page and read it</a>.</p> <p>After you run it, the URL &quot;<a href="http://127.0.0.1:2020">http://127.0.0.1:2020</a>&quot; will be opened in your default web browser :<figure class="wp-caption aligncenter"></p> <p><a href="//lab.subinsb.com/projects/blog/uploads/2016/08/selec-index.png"><img class="" src="//lab.subinsb.com/projects/blog/uploads/2016/08/selec-index.png" width="1368" height="768" /></a><figcaption class="wp-caption-text">The voter registration</figcaption></figure></p> <p>If you got a window similar to above, installation is completed. If not try :</p> <ul> <li>Update your browser to a latest version. (I recommend Chromium or Google Chrome)</li> <li>(Linux) Run Lobby.sh in terminal and see the output. Google the error shown in output to find a solution</li> </ul> <h2 id="administration">Administration</h2> <p>Okay, letโ€™s add some candidates. For thisย letโ€™s go to the admin page. Admin pageโ€™s URL is :</p> <blockquote> <p><a href="http://127.0.0.1:2020/admin">http://127.0.0.1:2020/admin</a></p> </blockquote> <p>A login page will be shown :<figure class="wp-caption aligncenter"></p> <p><a href="//lab.subinsb.com/projects/blog/uploads/2016/08/selec-admin-login.png"><img class="" src="//lab.subinsb.com/projects/blog/uploads/2016/08/selec-admin-login.png" alt="Lobby admin login" width="1327" height="741" /></a><figcaption class="wp-caption-text">Admin login</figcaption></figure></p> <p>Both the default username and password is &quot;admin&quot; :</p> <blockquote> <p>Username : admin</p> </blockquote> <blockquote> <p>Password : admin</p> </blockquote> <p>After youย login as admin, hover on the &quot;<strong>I</strong>&quot; symbol seen on the top of the page and choose &quot;App Admin&quot; :<figure class="wp-caption aligncenter"></p> <p><a href="//lab.subinsb.com/projects/blog/uploads/2016/08/selec-admin-app.png"><img class="" src="//lab.subinsb.com/projects/blog/uploads/2016/08/selec-admin-app.png" alt="Lobby Indi app admin" width="343" height="147" /></a><figcaption class="wp-caption-text">Hover on &quot;I&quot; symbol and choose &quot;App Admin&quot;</figcaption></figure></p> <p>Now you have entered the administration part ofย <strong>sElec</strong>. Whenever you want to enter the <strong>Election Panel</strong>, just click the &quot;App Admin&quot; button after you hover the &quot;I&quot; symbol.</p> <h2 id="election-panel">Election Panel</h2> <p>The Election Panel lets you configure the election :<figure class="wp-caption aligncenter"></p> <p><a href="//lab.subinsb.com/projects/blog/uploads/2016/08/selec-admin-index.png"><img class="" src="//lab.subinsb.com/projects/blog/uploads/2016/08/selec-admin-index.png" alt="Election Panel" width="1327" height="741" /></a><figcaption class="wp-caption-text">Election Panel</figcaption></figure></p> <p>Here is a brief description about the options you see in that page :</p> <ul> <li>General Settings โ€“ Basic settings for election</li> <li>Manage Candidates โ€“ Add, edit and remove candidates</li> <li>Manage Voters โ€“ Generate passwords for user if you have chosen to set password for voters</li> <li>Results โ€“ View the results of election</li> <li>Voted List โ€“ See who all have voted or not in a class.</li> <li>CLEAR ALL DATA! โ€“ Clear all data stored including candidate information, votes and voter passwords</li> </ul> <h2 id="clear-all-data">Clear All Data!</h2> <p>Before you start a election, <strong>ALWAYS</strong> clear data before proceeding to add candidates. So, click on the &quot;CLEAR ALL DATA!&quot; button colored in red and choose Ok on the dialog that comes. This will clear all data associated with election.</p> <h2 id="general-settings">General Settings</h2> <p>The page looks like this :<figure class="wp-caption aligncenter"></p> <p><a href="//lab.subinsb.com/projects/blog/uploads/2016/08/selec-admin-general-settings.png"><img class="" src="//lab.subinsb.com/projects/blog/uploads/2016/08/selec-admin-general-settings.png" width="1327" height="741" /></a><figcaption class="wp-caption-text">Election Panel -&gt; General Settings</figcaption></figure></p> <h3 id="election-type">Election Type</h3> <p>There are 3 types of election you can do withย <strong>sElec</strong>. They are :</p> <ul> <li> <p>Normal Election (Default)</p> <p>Used for school leader elections.</p> <p>There will be a set of candidates for the whole school and students in each class must vote for them to become school leader</p> </li> <li> <p>Class Wise</p> <p>Used for class leader election.</p> <p>There will be separate set of candidates for each class and students in those class must vote for their candidates to make them class leader.</p> </li> <li> <p>Boys &amp; Girls</p> <p>Used for school leader selection from boys and girls separately.</p> <p>Similar to Normal Election. But there will be separate &quot;Boys&quot; &amp; &quot;Girls&quot; candidates list. The voter must choose their candidate from these two lists.</p> </li> </ul> <h3 id="number-of-votes">Number of Votes</h3> <p>This option tells how many votes can one voter do. If this value is changed into &quot;2&quot;, the voter can choose 2 candidates from the list. The default value is &quot;1&quot;.</p> <h3 id="maximum-strength">Maximum Strength</h3> <p>This value indicates the maximum roll number one can enter.ย Example: If 5A has <code>60</code> students and 5B has <code>63</code> students, then the value should be <code>63</code></p> <h3 id="password-for-voters">Password For Voters</h3> <p>Whether the voter need to enter password along with roll number to vote. If you enable this option, you would have to go to Election Panel -&gt; Manage Voters and generate passwords for voters.</p> <h3 id="classes">Classes</h3> <p>Add the classes that will be using <strong>sElec</strong>ย to vote. You can add a new class field by clicking the &quot;+&quot; button and remove an existing field by clicking the &quot;-&quot; button alongside the input.</p> <h3 id="divisions">Divisions</h3> <p>Add the divisionsย that will be using <strong>sElec</strong>ย to vote. You can add a new division field by clicking the &quot;+&quot; button and remove an existing field by clicking the &quot;-&quot; button alongside the input.<figure class="wp-caption aligncenter"></p> <p><a href="//lab.subinsb.com/projects/blog/uploads/2016/08/selec-admin-general-settings-classes.png"><img class="" src="//lab.subinsb.com/projects/blog/uploads/2016/08/selec-admin-general-settings-classes.png" width="1327" height="741" /></a><figcaption class="wp-caption-text">Add/remove classes and divisions</figcaption></figure></p> <h3 id="default-class">Default Class</h3> <p>This option tells which class should be selected by default when the voter sees the page.</p> <h3 id="default-division">Default Division</h3> <p>This option tells which divisionย should be selected by default when the voter sees the page.</p> <h3 id="disable-choice-of-class-and-division">Disable choice of class and division</h3> <p>The voter can change the class and division if he/she wants to. You can prevent them from doing so by enabling this option. When this is enabled the class and division remains constant according to the default class and division chose in the above setting.</p> <p>After you have chose the settings, click &quot;Save Settings&quot; button.</p> <h2 id="return-to-election-panel">Return To Election Panel</h2> <p>You can return to the Election Panel by choosing the activatedย <strong>sElec</strong> tab in the sidebar :<figure class="wp-caption aligncenter"></p> <p><a href="//lab.subinsb.com/projects/blog/uploads/2016/08/selec-admin-sidebar.png"><img class="" src="//lab.subinsb.com/projects/blog/uploads/2016/08/selec-admin-sidebar.png" width="210" height="257" /></a><figcaption class="wp-caption-text">The sElec option lets you go to Election Panel</figcaption></figure></p> <h2 id="manage-candidates">Manage Candidates</h2> <p>In this page, you can add, edit or remove candidates. You can add a new candidate field by clicking the &quot;+&quot; button and remove one with &quot;-&quot; button.</p> <p>The gender option is not actually necessary unless the election type is &quot;Boy and Girls&quot;.</p> <h2 id="manage-voters">Manage Voters</h2> <p>Passwords for the voters can be generated in this page. This should only be done if you have enabled &quot;Passwords&quot; in General Settings.</p> <p>Enter the roll number up to which passwords should be generated and submit the form. The passwords will be shown :<figure class="wp-caption aligncenter"></p> <p><a href="//lab.subinsb.com/projects/blog/uploads/2016/08/selec-admin-passwords.png"><img class="" src="//lab.subinsb.com/projects/blog/uploads/2016/08/selec-admin-passwords.png" width="1327" height="741" /></a><figcaption class="wp-caption-text">Password generator</figcaption></figure></p> <p>It is better to re generate passwords after a class has completedย voting.</p> <h2 id="results">Results</h2> <p>The results will have two sections &quot;Standings&quot; and &quot;Graph&quot;. Both are color coded by Gold, Silver, Bronze and all others black. Gold is for 1st, Silver is for 2nd and Bronze for 3rd.<figure class="wp-caption aligncenter"></p> <p><a href="//lab.subinsb.com/projects/blog/uploads/2016/08/selec-admin-results.png"><img class="" src="//lab.subinsb.com/projects/blog/uploads/2016/08/selec-admin-results.png" width="1012" height="609" /></a><figcaption class="wp-caption-text">Results of election</figcaption></figure></p> <p>If the election type is &quot;Class Wise&quot;, then you have to submit a form asking for class and division to get the result in that class.</p> <h2 id="voted-list">Voted List</h2> <p>In this page, you canย see :</p> <ul> <li>How many votes in a class has been done</li> <li>How many didnโ€™t vote in a class</li> <li>Time when a vote was made<figure class="wp-caption aligncenter"></li> </ul> <p><a href="//lab.subinsb.com/projects/blog/uploads/2016/08/selec-admin-voted-list.png"><img class="" src="//lab.subinsb.com/projects/blog/uploads/2016/08/selec-admin-voted-list.png" width="1147" height="629" /></a><figcaption class="wp-caption-text">Voted List</figcaption></figure></p> <p>There is no provision to see who has voted who.ย **sElecย **does not store that data in any ways whatsoever.</p> <h2 id="implementation">Implementation</h2> <p>We have seen the software. But, how to implement it ? Let me follow you through the procedure :</p> <ul> <li>Clear data</li> <li>Change General Settings</li> <li>Add Candidates</li> <li>Make a polling booth with a computer havingย <strong>sElec</strong> installed</li> <li>Form a voter line to the polling booth</li> <li>Generate Passwords in <strong>sElec</strong>ย (if youโ€™re going to enable passwords)</li> <li>Enter the first voter, tell him/her the password, let him/her go to the polling booth and do his vote</li> <li>When theย <a href="https://raw.githubusercontent.com/subins2000/lobby-school-election/master/src/audio/beep.mp3" target="_blank"><strong>BEEP sound</strong></a> is made, make him/her leave and let the next voter inside</li> <li>Continue the processโ€ฆ</li> </ul> <p>It is recommended toย <strong>re generate</strong> the passwordsย at intervals like when a class completes voting.</p> <h2 id="networking">Networking</h2> <p>Another interesting feature aboutย <strong>sElec</strong> is that you can use it on aย <strong>WiFi</strong> orย <strong>Wired</strong> network. For this, :</p> <ul> <li> <p>Connect the computer and a smartphone to the sameย <strong>WiFi</strong> network.</p> </li> <li> <p>Get the computerโ€™sย <strong>LAN IP address</strong> (192.168.1.2)</p> </li> <li> <p>Copy this IP address</p> </li> <li> <p>In theย folder where the software is installed,</p> <p>โ€“ Open &quot;Lobby.sh&quot; if system is Linux and change &quot;127.0.0.1:2020&quot; to theย <strong>IP address</strong> you just copied before</p> <p>โ€“ Open &quot;lobby.ini&quot; if system is Windows andย change &quot;127.0.0.1:2020&quot; to theย <strong>IP address</strong> you just copied before</p> </li> <li> <p>Stop the Lobby Server by running &quot;Stop Lobby Server&quot; file in that folder</p> </li> <li> <p><a href="#article-open">Start Lobby again by running &quot;Lobby&quot; inside the folder</a>.</p> </li> </ul> <h2 id="security">Security</h2> <p>As I stated above, <strong>no one will know who you voted for</strong>. Itโ€™s secure, guaranteed.</p> <p>The data is stored in anย <strong>SQLite</strong> database. The data refers to candidates info, number of votes and passwords.</p> <ul> <li>During the election, itโ€™s impossible for one person to find this database and copy it. Even if he/she copied it, there is no use for it.</li> <li>Admin area is password protected and this password is hashed with a very secure algorithm</li> <li>Free of SQL injection and XSS attack vulnerability</li> </ul> <p>If you faced any problem (however small it may be) or have any questions, feel absolute free to comment below. Iโ€™ll be more than happy to help.</p> PHP Output Buffering For Noobies https://subinsb.com/php-output-buffering/ Fri, 10 Jun 2016 16:37:00 +0000 https://subinsb.com/php-output-buffering/ <p>You might have heard about output buffering while you code inย <strong>PHP</strong>. I will tell you what it is and how to use it simply.</p> <h2 id="output-buffering-meaning">&quot;Output Buffering&quot; Meaning</h2> <p>&quot;Buffering&quot; in <strong>computing</strong>ย means</p> <blockquote> <p>store (data) in a buffer while it is being processed or transferred.</p> </blockquote> <p>This is exactly what PHP does too. But, the default mechanism is not this. It is turned <strong>off</strong> by default i.e :</p> <blockquote> <p>data is not stored in a buffer while it is being processed or transferred.</p> </blockquote> <h2 id="output-buffering-off-default">Output Buffering Off (Default)</h2> <p>When a user requests aย <strong>PHP</strong> page from your server, PHP processes the page and on the fly, theย HTML is sent to the browser (user).</p> <p>This means, that HTML is received by the browser in chunks during the connection and the connection wonโ€™t close until the processing is finished.</p> <p>This is theย <strong>default</strong> setting inย <strong>PHP</strong> i.e output buffer turned off.</p> <h2 id="output-buffering-on">Output Buffering On</h2> <p>As the word meaning says, theย <strong>processed HTML</strong> is stored in a variable until the processing is finished and when it is finished, the contents of the variable is sent.</p> <p>So, instead of chunks of data, the full dataย is sent at an instant. These are the advantages if output buffering is turnedย <strong>on</strong> :</p> <ul> <li> <p>Able to do redirects even at the end of page : <pre class="prettyprint"><code>Hello World &lt;?php header(&quot;Location: <a href="https://subinsb.com">https://subinsb.com</a>&quot;); ?&gt;</code></pre></p> <p>Normally, the above code will print &quot;headers already sent error&quot;. But, with output buffering turned on, this error wonโ€™t be produced.</li></p> <ul> <li>&quot;Warning: Cannot modify header information โ€“ headers already sent by (output)&quot; error and all such errors wonโ€™t be produced</ul></li> </ul> <h2 id="toggle-output-buffering">Toggle Output Buffering</h2> <p>You can choose to turn on/off output buffering <strong>permanently</strong> by editing &quot;php.ini&quot; file. Find &quot;output_buffering&quot; key and set the value :</p> <pre class="prettyprint"><code>&lt;a class="link" href="http://php.net/manual/en/outcontrol.configuration.php#ini.output-buffering">output_buffering&lt;/a>=On</code></pre> <p>You can also set it by &quot;.htaccess&quot; file :</p> <pre class="prettyprint"><code>php_flag output_buffering On</code></pre> </li> </ul> Run Multiple WebSocket Services On Same Port https://subinsb.com/run-multiple-websocket-services-on-same-port/ Mon, 30 May 2016 17:28:51 +0000 https://subinsb.com/run-multiple-websocket-services-on-same-port/ <p>Are you as crazy as me when developingย <strong>WebSocket</strong> applications ? Itโ€™s so awesome to work withย <strong>WebSockets</strong> that will blow up your mind and irritate you at the same time.</p> <p><strong>WebSockets</strong> can be used for any real time applications such as :</p> <ul> <li>Games</li> <li>Chat</li> <li>News</li> <li>File Transfer</li> </ul> <p>And because itโ€™s impact is so vast, we can develop as many applications as we want. But, a problem arises for freebies like me and you.</p> <h2 id="problem">Problem</h2> <p>Running multipleย <strong>WebSocket</strong> servers for multiple apps requires you to run a listening node on different ports. But, on some hosting servers, this isnโ€™t possible.</p> <p>In case ofย <strong>OpenShift</strong>, this is impossible as thereโ€™s only one port in the app where you listen for incoming data ieย <strong>8080</strong>. <a href="https://developers.openshift.com/managing-your-applications/port-binding-routing.html" target="_blank">See Port Binding On Openshift</a>.</p> <p>In this scenario, your only solution is to listen on a single port and send out data according to the service the client requested.</p> <h2 id="francium-diffsocket">Francium DiffSocket</h2> <p>And for this purpose, I developed a smallย <strong>Composer</strong> package calledย <strong>Francium DiffSocket</strong>, an abbreviationย for :</p> <pre class="prettyprint"><code>Francium Different Sockets</code></pre> <p>What it does is, allow you to add your own custom services and serve it through a single port. This means you can host yourย <strong>Online game server</strong>,ย <strong>Chat server</strong> etc. on a single port.</p> <h2 id="usage">Usage</h2> <p>Instructions on how to use it is in theย <a href="https://github.com/subins2000/Francium-DiffSocket/blob/master/README.md">README file of the project</a>.</p> <h2 id="demo">Demo</h2> <p>All of the WebSocket demos that I have created usesย <strong>Francium DiffSocket</strong>. List :</p> <ul> <li><a href="http://demos.subinsb.com/pi/">Finding Value Of Pi</a></li> <li><a href="http://demos.subinsb.com/php/advanced-chat-websocket/">Advanced Live Group Chat With PHP, jQuery &amp; WebSocket</a></li> <li><a href="http://demos.subinsb.com/php/websocketChat">Live Group Chat With PHP, jQuery &amp; WebSocket</a></li> <li><a href="https://lobby.subinsb.com/apps/chess">Online Chess Game</a></li> </ul> <h2 id="example">Example</h2> <p>Let us make three different services :</p> <ul> <li>A service that responds &quot;hello&quot; to incoming messages</li> <li>A service that responds the incoming message itself (mimic)</li> <li>A service that responds &quot;hey, how are you ?&quot; when &quot;hi&quot; is sent (bot)</li> </ul> <p>We make three separate class files for the three services. These are stored in a folder called &quot;services&quot;.</p> <h3 id="hello-service">Hello Service</h3> <p>Location โ€“ services/Hello.php</p> <pre class="prettyprint"><code>namespace Fr\DiffSocket\Service; use Ratchet\MessageComponentInterface; use Ratchet\ConnectionInterface; class Hello implements MessageComponentInterface { public function onOpen(ConnectionInterface $conn){ echo "New Connection - " . $conn-&gt;resourceId; } public function onClose(ConnectionInterface $conn){} public function onError(ConnectionInterface $conn,\Exception $error){} public function onMessage(ConnectionInterface $conn, $message){ $conn-&gt;send("Hello"); } } </code></pre> <p>The API used to build the service is <a href="https://github.com/cboden/ratchet">Ratchet</a> as mentioned in the README file.</p> <h3 id="mimic-service">Mimic Service</h3> <p>Location โ€“ services/Mimic.php</p> <pre class="prettyprint"><code>namespace Fr\DiffSocket\Service; use Ratchet\MessageComponentInterface; use Ratchet\ConnectionInterface; class Mimic implements MessageComponentInterface { public function onOpen(ConnectionInterface $conn){ echo "New Connection - " . $conn-&gt;resourceId; } public function onClose(ConnectionInterface $conn){} public function onError(ConnectionInterface $conn,\Exception $error){} public function onMessage(ConnectionInterface $conn, $message){ $conn-&gt;send($message); } }</code></pre> <h3 id="bot-service">Bot Service</h3> <p>Location โ€“ services/Bot.php</p> <pre class="prettyprint"><code>namespace Fr\DiffSocket\Service; use Ratchet\MessageComponentInterface; use Ratchet\ConnectionInterface; class Bot implements MessageComponentInterface { public function onOpen(ConnectionInterface $conn){ echo "New Connection - " . $conn-&gt;resourceId; } public function onClose(ConnectionInterface $conn){} public function onError(ConnectionInterface $conn, \Exception $error){} public function onMessage(ConnectionInterface $conn, $message){ if($message === "hi") $conn-&gt;send("hey, how are you ?"); } }</code></pre> <p>Okay, all of the services are made.</p> <h2 id="run-the-server">Run The Server</h2> <p>Now, we must make the code to integrate the services intoย <strong>Francium DiffSocket</strong> and then run the server.</p> <pre class="prettyprint"><code>require_once "vendor/autoload.php"; $DS = new \Fr\DiffSocket(array( "server" =&gt; array( "host" =&gt; "127.0.0.1", "port" =&gt; "8000" ), "service" =&gt; array( "hello" =&gt; __DIR__ . "/services/Hello.php", "mimic" =&gt; __DIR__ . "/services/Mimic.php", "bot" =&gt; __DIR__ . "/services/Bot.php" ) ));</code></pre> <p>You can add more services by calling theย <strong>addService()</strong> method too :</p> <pre class="prettyprint"><code>$DS-&gt;addService("service-name", "path/to/class.php"); </code></pre> <p>Now, we can run the server :</p> <pre class="prettyprint"><code>$DS-&gt;run(); </code></pre> <p>Thatโ€™s it ! When the server is started, this message will be printed out :</p> <pre class="prettyprint"><code>Server started on 127.0.0.1:8000 </code></pre> <p>You can connect to the different services inย <strong>JavaScript</strong> like so :</p> <pre class="prettyprint"><code>var hello = new WebSocket("ws://localhost:8000/?service=hello"); hello.send("nothing"); // Server will respond "Hello" var mimic = new WebSocket("ws://localhost:8000/?service=mimic"); mimic.send("Hola!"); // Server will respond "Hola!" var bot = new WebSocket("ws://localhost:8000/?service=bot"); bot.send("hi"); // Server will respond "hey, how are you ?" </code></pre> <p>Use and hack the project all you want. It is licensed under the &quot;Apache License&quot;.</p> Greed โ€“ A Short Film https://subinsb.com/greed-a-short-film/ Fri, 20 May 2016 15:18:10 +0000 https://subinsb.com/greed-a-short-film/ <p>Besides coding, my other passion is film making. I have already made some films since the age of 8. But those were raw footage and I didnโ€™t edit them.</p> <p>When I was 11, I created an another film and edited it with Windows Movie Maker. I didnโ€™t publish it and it still exist in my computer.</p> <p>Now, after 5 years I decided to create another film. This time with the help of my friends. I got the idea when I was studying at 5 AM in the morning of Mathematics exam.</p> <p>Iโ€™m glad to tell you that I have completed the short film and published it. Check it out :</p> <h2 id="about-film">About Film</h2> <p>This is a film created by four friends. Here, in Kerala this summer was the most hottest reaching up to 42 degree celsius in some places.</p> <p>Global Warming is real and we are experiencing it. We complain about it, but doesnโ€™t do anything. The selfishness of humans are overcoming our kind hearts.</p> <p>Together, we must throw over our greediness and work together to make our world habitable for the future generations. By not doing so, what is the need of us students studying and people working if there is no future ?</p> <h2 id="how-it-started">How It Started</h2> <p>I got the story idea through a daydream while I was studying for Maths. Maths rocks ! At the start of the vacation, the first thing I did was create the script.</p> <p>You know that Yes/No feeling in your gut when you try to do something ? I have experienced the same feeling when I tried to get out and do this.</p> <p>At first, when I tried to meet up with my friends Vikas &amp; Rejohn, it failed as Rejohn is too busy with his stuff. But with constant tries, I made a little meeting between us and decided what to do. But, further proceedings failed.</p> <p>Then the summer classes began and at there my other friends asked me about the film. I replied it <strong>didnโ€™t work out</strong>. Just after two days, the school was closed due to <strong>severe heat</strong>. This was a big coincidence, because the film weโ€™re about to do was also about heat.</p> <p>That night, Vikas called me asking whether I was going to do the film. Now, I knew that he had interest in doing it. This renewed my confidence in making the film. I asked my brother whether he could act and he said yes in a sudden. But, shooting with him was so tiring. He is a stubborn, arrogant person. I think this probably because heโ€™s my brother.</p> <p>The 6 minute film was shot in 4 days. The time difference between the shots blend really well.</p> <h2 id="final-thoughts">Final Thoughts</h2> <p>Iโ€™m glad that we could finish what we started. <strong>This vacation was spent really well</strong>.</p> <blockquote> <p>Now, I have a memory that I can look back after 20 years and say &quot;I spent my teenage well&quot;</p> <p>If you are planning on doing something, do it. Gain confidence, you can do it !</p> </blockquote> <p>Just do itโ€ฆ</p> Lobby https://subinsb.com/lobby/ Sun, 08 May 2016 19:13:00 +0000 https://subinsb.com/lobby/ <p>Lobby is a localhost Web OS. It can be attributed as a combination ofย <strong>Android</strong> andย <strong>WordPress</strong>.</p> <p>Lobby is a framework for building web apps and publishing it.</p> How To Install & Run Composer Binaries Globally https://subinsb.com/install-run-composer-binaries-globally/ Thu, 28 Apr 2016 15:19:18 +0000 https://subinsb.com/install-run-composer-binaries-globally/ <p>Takeย <strong>PHPUnit</strong> as an example. You can install it using Composer doing this :</p> <pre class="prettyprint"><code>composer require phpunit/phpunit</code></pre> <p>This will install aย <strong>phpunit</strong> shortcut inย <strong>vendor/bin</strong> directory. This obviously means you can run it. But, you would have to point to the exact location of theย <strong>phpunit</strong> file to run :ย </p> <pre class="prettyprint"><code>/home/username/mysite/vendor/bin/phpunit phpunit.xml</code></pre> <p>But, thatโ€™s long and uncomfortable. And you would have to installย <strong>PHPUnit</strong> separately for each projects.</p> <p>Iโ€™m gonna tell you how to install binaries globally as well as running it simply.</p> <h2 id="install-packages-globally">Install Packages Globally</h2> <p>Same command, but add a &quot;global&quot; before &quot;require&quot; :ย </p> <pre class="prettyprint"><code>composer global require phpunit/phpunit</code></pre> <p>If youโ€™re using Linux, this will installย <strong>PHPUnit</strong> to :</p> <pre class="prettyprint"><code>/home/username/.config/composer/vendor&lt;br /></code></pre> <p>This will also create theย <strong>phpunit</strong> binary shortcut inย <strong>vendor/bin</strong> directory.</p> <h2 id="use-it-simply">Use It Simply</h2> <p>Now, letโ€™s add the location so that we can use it like this in terminal :</p> <pre class="prettyprint"><code>phpunit phpunit.xml&lt;br /></code></pre> <p>For this, you simply enter this into your terminal session :</p> <pre class="prettyprint"><code>export PATH=$PATH:~/.config/composer/vendor/bin</code></pre> <p>But this (^) is only temporary and will fade away when the terminal is closed.</p> <p>To make it permanent, open any of the following files using your text editor :</p> <pre class="prettyprint"><code>/home/username/.bashrc&lt;br />/home/username/.bash_profile</code></pre> <p>Then, add the command we used before at the end of the file :</p> <pre class="prettyprint"><code># http://subinsb.com/install-run-composer-binaries-globally&lt;br />export PATH=$PATH:~/.config/composer/vendor/bin&lt;br /></code></pre> <p>I added the link to this post, because in the future if you open this file, you shouldnโ€™t confuse yourself. You should close all running terminals and re open before you test it out.</p> <p>Now, you can use any binary shortcuts in &quot;/home/username/.config/composer/vendor/bin&quot; by simply typing it on your terminal.ย Also, make sure the <strong>Linux</strong>ย native programs doesnโ€™t conflict with the file names of <strong>Composer</strong>ย binaries.</p> Earth Day Special โ€“ 21 KMs of Exploration https://subinsb.com/earth-day-21-kms-exploration/ Fri, 22 Apr 2016 15:56:45 +0000 https://subinsb.com/earth-day-21-kms-exploration/ <p>Today isย <strong>Earth Day</strong>, a special day dedicated to our mother Earth. I didnโ€™t knew about this day until I saw theย <strong>Google Doodle</strong> today morning atย <strong>12:15</strong> (around-ish).</p> <p>When I looked it up, I saw the ways to participate in this event :</p> <blockquote> <p><a href="http://www.telegraph.co.uk/technology/2016/04/21/earth-day-2016-five-facts-to-inspire-you-and-how-to-get-involved/" target="_blank">Walk to work, cycle or take public transport</a></p> </blockquote> <p>Cycle ? Thatโ€™s my favorite thing besides coding. Itโ€™s a way I could relax and exercise without losing the fun.</p> <p>I had this plan long before to goย <strong>Westwards</strong> and reach the beach. In my place, goingย <strong>West</strong> is nearer to reach the seashore than going in any other directions.</p> <p>I looked up onย <strong>Google Maps</strong> (of course) and found the way to reach the place faster with less distance. First, I wanted to go alone. But, going this much distance provoked my parents and saidย <strong>No!</strong> So, I went with my dad on a motorbike.</p> <p><strong>Google</strong> Navigation certainly helped and we reached the place.</p> <p>^ This happened about one year ago. I canโ€™t remember the date.</p> <p>Today, I went alone on myย <strong>bicycle</strong>. My Mom asked me not to do it, but I went on. Myย <strong>GOD</strong>, it was one hell of a trip !</p> <p><a href="http://goo.gl/zBz0Fi" target="_blank">This is the path I took.</a></p> <p>I left the house at <strong>4 PM</strong>ย with these :</p> <ul> <li>A bottle of Water</li> <li>Purse</li> <li>Phone</li> <li>And of course the cycle !</li> </ul> <p>The starting of the trip did not go as I planned. Going about 20 Meters, I realized the tyres didnโ€™t have enough air. So, I went back and filled it. How idiotic I was !</p> <p>It was then alright. I calmly rode the cycle without any problem until I traveled aboutย <strong>8 KMs</strong> (5 Miles). The cycle was moving slowly even though I gave the strength it needed. Then I realized the air inside the front tyre was less.</p> <p>I then started to walk instead of riding it. I entered into a house in which a kid was in the porch with his cycle. I asked him if there was a cycle pump. He said &quot;No&quot;. I only had a little more to go to reach the destination.</p> <p>Iย <strong>dinโ€™t give up</strong> and went on walking. To my surprise, a man in the fifties smiled at me. I donโ€™t know the guy and havenโ€™t even met him before, yet he smiled. I saw that there were no cycle inside, but still I asked if there was a cycle pump.</p> <p>He said, &quot;Let me look&quot; and I entered into the porch of the house. He was searching for the pump in the house. To my surprise, he looked for a while and brought me a pump. I didnโ€™t expected a stranger to be this nice.</p> <p>The air entered the back tyre finely. But, the air kept coming out in the front one.ย <strong>Alas !</strong> another problem. I was like &quot;Iโ€™m screwed&quot;. A conversation was started :</p> <blockquote> <p>The Kind Guy : Did it work fine ?</p> </blockquote> <blockquote> <p>Me : No, the air is not getting inside the front tyre.</p> </blockquote> <blockquote> <p>The Kind Guy : It's probably because that the wal tube is damaged</p> </blockquote> <blockquote> <p>Me : Hmmm...</p> </blockquote> <blockquote> <p>The Kind Guy : Where are you from ?</p> </blockquote> <blockquote> <p>Me : Kunnamkulam</p> </blockquote> <blockquote> <p>The Kind Guy : Kunnamkulam !!! From all the way there ? Why did you come here for ?</p> </blockquote> <blockquote> <p>Me : I came here to go to the beach (Smiles)</p> </blockquote> <blockquote> <p>The Kind Guy : Oh ! (Smiles back) How will you bring the cycle back to Kunnamkulam ?</p> </blockquote> <blockquote> <p>Me : Is there a bicycle shop near ?</p> </blockquote> <blockquote> <p>The Kind Guy : Yeah, it's in the junction</p> </blockquote> <p>You should know, people like me who goes on these &quot;**longย **<strong>trips</strong>&quot; on a cycle isย <strong>considered</strong> <strong>CRAZY</strong>.</p> <p>I saidย <strong>Thanks</strong> and went back to the junction to find theย <strong>cycle</strong> shop. I fixed the tyre forย <strong>5 Rupees</strong> (0.075 USD). I went ahead.</p> <p>After a while (about 2ย <strong>KMs</strong>), I found the air inside the back tyre was also becoming less. Shitโ€ฆShitโ€ฆShit. I should have went back, fix it and come back. But, I went on as there is also another junction coming upโ€ฆ That was a really stupid mistake.</p> <p>The cycle shop on the next junctionย wasย <strong>closed</strong>. Iโ€™m screwed again. Meanwhile, the air inside the tyre was going out.</p> <p>I went on and reached the destination. The feeling I had in my mind cannot be expressed in words !!!<figure class="wp-caption aligncenter"></p> <p><a href="//i.imgur.com/80cNiIR.jpg"><img class="" src="//i.imgur.com/80cNiIR.jpg" alt="A dream come true !" width="480" height="640" /></a><figcaption class="wp-caption-text">A dream come true !</figcaption></figure></p> <p>The confidence and happiness I had at that point was the highest I ever had. Iโ€™m normally a shy person (but not too shy), but there I confidently asked a boy to take a photo of me with the cycle :<figure class="wp-caption aligncenter"></p> <p><a href="//i.imgur.com/MN3Fwe3.jpg"><img class="" src="//i.imgur.com/MN3Fwe3.jpg" alt="What A Trip !" width="480" height="640" /></a><figcaption class="wp-caption-text">What A Trip !</figcaption></figure></p> <p>I couldnโ€™t stay there for a long time as I reached atย <strong>5:30 PM</strong> and it becomes dark byย <strong>7 PM</strong>. It took meย <strong>1 and a half hour</strong> to reach here. How the hell am I gonna reach back with this tiredness and fatigues legs ? Also, I need to hurry to get my back tyre fixed.</p> <p>So, I quickly left after staying forย <strong>15 Minutes</strong>. After a while, most of the air inside the tyre had gone and the cycle was jumping when the wal tube part hit the ground.</p> <p>If I continued this &quot;jumping journey&quot;, the tube inside would become flat. Iโ€™m long away from home and my dad isnโ€™t at home yet from work. Iโ€™m trapped. But, I continued walking and sometimes I rode the cycle with the flat tire even though it can damage the tyre from fixing.</p> <p>A guy from North Indian said in Hindi :</p> <blockquote> <p>เคฏเฅ‡ เคชเคจเฅเคœเคฐ เคนเฅˆ !</p> </blockquote> <p>meaning &quot;The tyre is punctured&quot;. The vast diversity of people Kerala have !</p> <p>After some more while atย <strong>6:15 PM</strong>, I reached the <strong>same shop</strong> where I had fixed my front tyre. The first time I came, the old man there gave me a balance ofย <strong>5 Rupees</strong>. Now, to fix the back tyre, I gave back the same coins I once got from him ! Ah, the irony !</p> <p>It was a miracle that the shop didnโ€™t close even afterย <strong>6 PM</strong>. Incidents like this make you believe inย <strong>GOD</strong>.</p> <p>Now, with the two tyres fixed, I was able to reach my house atย <strong>6:45 PM</strong>. The return trip took onlyย <strong>1 Hour</strong>.</p> <p>Iโ€™m glad that I took this trip. But, Iโ€™m <strong>never gonna go this much distance again</strong>. I was very much lucky this time.</p> <p>Now, I have a story to remember in my life. Guys and gals, make memorable moments in your like. You shouldnโ€™t have any regrets when you die.</p> <p>๐Ÿ™‚</p> Doing Random Things in PHP https://subinsb.com/php-do-random-things/ Tue, 12 Apr 2016 19:30:30 +0000 https://subinsb.com/php-do-random-things/ <p>Suppose you want to display something randomly in a news feed, or pick random elements from an array, or anything random in general. Programming Languages are used to define the way how something must be done. Hence in a technical way, it canโ€™t do things randomly on itโ€™s own. Otherwise it would be anย <strong>AI</strong> (Artificial Intelligence). Doing random things is not doneย at compiling, but in execution. In case ofย <strong>PHP</strong>, this doesnโ€™t matter as itโ€™s anย <strong>interpreter</strong>.</p> <h2 id="note">Note</h2> <p>In situations like generating random salts for password and other security related things, youย <strong>shouldnโ€™t</strong> use this. There are really better functions to do those likeย <strong>random_int()</strong>,ย <strong>openssl_random_pseudo_bytes()</strong></p> <h2 id="the-problem">The Problem</h2> <p>The Random Function is useful in these scenarios :</p> <ul> <li><a href="//open.subinsb.com" target="_blank">Showing Extra Box (Ads, Friend Suggestions) between some &quot;posts&quot; randomly in a news feed of a social network.</a></li> <li>Show &quot;Subscribe&quot; box randomly to readers in blogs</li> </ul> <p>There isnโ€™t a definite function inย <strong>PHP</strong> to do something at random. How about we make one ?</p> <h2 id="the-solution-aka-random">The Solution aka random()</h2> <p>Meet the functionย <strong>random()</strong> which will return positive (In boolean terms, itโ€™s called <strong>TRUE</strong>), and negative if itโ€™s not the right time to do something.</p> <pre class="prettyprint"><code>/** * $occurence - integer * $range - integer */ function random($occurence = 3, $range = 100){ return mt_rand(1, $range) % $occurence === 0; }</code></pre> <p>By tweaking theย <strong>$occurence</strong> parameter, you can increase/decrease the possibility ie returningย <strong>TRUE</strong>. <strong>$range</strong> can be used to increase/decrease the scope of randomness. Example: By increasing bothย <strong>$occurence</strong> andย <strong>$range</strong>, the possibility of getting aย **TRUEย **outputย <strong>decreases</strong>. It is inversely proportional. Note that :</p> <blockquote> <p><strong>$range</strong> &gt; <strong>$occurence</strong></p> </blockquote> <p>Which means, tweakingย <strong>$occurence</strong> has greater effect on the randomness thanย <strong>$range</strong>. Yeah, itโ€™s confusing. You can decrease this confusion by reading theย <strong><a href="#article-how-it-works">How It Works ?</a></strong></p> <h2 id="how-it-works">How It Works</h2> <p>As you may know, there is already a function inย <strong>PHP</strong> to get a random number ieย <strong>rand()</strong>. We simply uses it to returnย <strong>TRUE</strong>/<strong>FALSE</strong> instead of numbers. So, how is it done ? By checking whether theย <strong>random number</strong>ย is <strong>divisible</strong> by the integer inย <strong>$occurence</strong>. The random number is made from :</p> <blockquote> <p>1ย โ€“ $range</p> </blockquote> <p>^ I omitted zero as 0 can be divided by any number. As theย <strong>random number</strong> is random (obviously!), it wonโ€™t be always divisible byย <strong>$occurence</strong>. So, when it is divisible, you get aย <strong>TRUE</strong> return value and when itโ€™s not divisible you get aย <strong>FALSE</strong> return value. This is why I earlier stated that :</p> <blockquote> <p>Tweakingย <strong>$occurence</strong> has greater effect on the randomness thanย <strong>$range</strong>.</p> </blockquote> <p>Increasingย <strong>$range</strong> would just increase the list from where the random number is picked. This means that the altering of the randomness will be small. But, if you changeย <strong>$occurence</strong>, the whole scenario changes and the randomness dramatically changes. Hereโ€™s a <a href="https://gist.github.com/subins2000/40d8023cfaf2d0836c5e33a616a2e747" target="_blank">test case</a> running <strong>random()</strong> in a loop for <strong>100</strong> iterationsย  :</p> <table> <thead> <tr> <th>$occurence</th> <th>Number of Outcomes That Were TRUE</th> </tr> </thead> <tbody> <tr> <td>1</td> <td>100</td> </tr> <tr> <td>2</td> <td>38</td> </tr> <tr> <td>3</td> <td>35</td> </tr> <tr> <td>4</td> <td>18</td> </tr> <tr> <td>5</td> <td>21</td> </tr> <tr> <td>6</td> <td>9</td> </tr> <tr> <td>7</td> <td>14</td> </tr> </tbody> </table> <p>As you can see theย <strong>TRUE</strong> outcomes didnโ€™t decrease proportionally ie itโ€™s <strong>absolutely random</strong>.</p> Theme Version 2 https://subinsb.com/blog-theme-v2/ Mon, 04 Apr 2016 14:59:33 +0000 https://subinsb.com/blog-theme-v2/ <p>If you are reading this post, you should have seen the new UI of my blog. Itโ€™s a custom made theme created in a week during the exams.</p> <p>Itโ€™s similar to the old theme because, I liked it colorful and dark at the same time. Iโ€™m aย <strong>Batman</strong> fan and black is good for the eyes. <strong>As a programmer, you donโ€™t want to hurt your eyes</strong>.</p> <p>The theme is named &quot;Subinโ€™s Blog V2&quot;. The name says it all. Coincidentally, this new theme comes exactly <a href="//subinsb.com/subins-blog-v1" target="_blank">after 1 year of the last theme update</a>.</p> <p>Itโ€™s responsive โ€“ of course and super light. Even though the UI is similar, the CSS file of the new theme has less lines of code than the old one.</p> <img class="alignnone" src="https://raw.githubusercontent.com/subins2000/blog-theme/v2/screenshot.png" alt="" width="1327" height="680" /> <p>As usual, the source code is Open Source and you can <a href="https://github.com/subins2000/blog-theme" target="_blank">see it on GitHub</a>.</p> Vote For Lobby https://subinsb.com/vote-for-lobby/ Wed, 30 Mar 2016 05:40:45 +0000 https://subinsb.com/vote-for-lobby/ <p>I have mentioned before about my new <a href="//subinsb.com/lobby">project Lobby โ€“ A Web Operating System</a>.</p> <p>I have been developing it for the past 1.5 years in my free time. It has been partially completed. To learn more about it, I request you to read <a href="https://lobby.subinsb.com/docs/about" target="_blank">this</a>.</p> <p>Iโ€™m writing this post to request you to vote for the package Lobby in <a href="http://www.phpclasses.org/package/9591-PHP-Web-OS-to-install-and-run-Web-applications.html" target="_blank">PHPClasses</a>.</p> <p>If Lobby win it, more people would know about Lobby and I can develop the project further. If you have an account on PHPClasses, you can <a href="http://www.phpclasses.org/vote.html" target="_blank">vote here</a>.</p> <p>The voting <strong>ends on March 31st ie Tomorrow</strong>. So, please vote for Lobby as soon as you read this.:-)</p> <div class="padlinks"> <a class="demo" href="http://www.phpclasses.org/vote.html">Please Vote</a> </div> Convert Seconds To Hours, Minutes in PHP https://subinsb.com/php-convert-seconds-hours-minutes-seconds/ Thu, 24 Mar 2016 09:03:52 +0000 https://subinsb.com/php-convert-seconds-hours-minutes-seconds/ <p>Say youโ€™re running a process that runs in the background. Itโ€™s better to not let the user lose their patience and tell them when it will finish.ย But, you have the time remaining inย <strong>seconds</strong>. If we show the user :</p> <pre class="prettyprint"><code>567 seconds to complete</code></pre> <p>He/she (user) would have to take a calculator and convert it into minutes or hours. Or if the guy/gal is not a math genius, he would close the UI and say &quot;What the Hell ?&quot;</p> <p>The primary point in UI is that</p> <pre class="prettyprint"><code>Don't irritate the user </code></pre> <p>Mark my words : &quot;You shouldnโ€™t make the user angry&quot;.</p> <div class="padlinks"> <a class="demo" href="http://demos.subinsb.com/php/seconds-to-human-readable/" target="_blank">Demo</a> </div> <p><a href="//lab.subinsb.com/projects/blog/uploads/2016/03/lobby-downloader-app.png"><img src="//lab.subinsb.com/projects/blog/uploads/2016/03/lobby-downloader-app.png" alt="Seconds is converted to Hours, Minutes" height="207" /></a></p> <p>Here is a simple function to convert seconds to hours, minutes and seconds separately or mixed together :</p> <pre class="prettyprint"><code>function secToHR($seconds) { $hours = floor($seconds / 3600); $minutes = floor(($seconds / 60) % 60); $seconds = $seconds % 60; return "$hours:$minutes:$seconds"; }</code></pre> <p>If youโ€™re wondering why I chose <strong>secToHR</strong> as the function name, itโ€™s the abbreviation ofย <strong>Seconds to Human Readable</strong>.</p> <p>Or if you wanna display like this :</p> <pre class="prettyprint"><code>1 hour, 20 minutes remaining 10 minutes, 20 seconds remaining 15 seconds remaining</code></pre> <p>then, replace theย <strong>return</strong> function with this :</p> <pre class="prettyprint"><code>return $hours &gt; 0 ? "$hours hours, $minutes minutes remaining" : ($minutes &gt; 0 ? "$minutes minutes, $seconds seconds remaining" : "$seconds seconds remaining");</code></pre> <p>BTW, I would suggest you do it like above ^, because itโ€™s more user friendly.</p> <h2 id="usage">Usage</h2> <p>Simple as it is :</p> <pre class="prettyprint"><code>/** * Function with 'h:m:s' form as return value */ echo secToHR(560); echo secToHR(10950); /** * Function with 'remaining' in return value */ echo secToHR();</code></pre> <p>And the corresponding outputs :</p> <pre class="prettyprint"><code>0:9:20 3:2:30 9 minutes, 20 seconds remaining 3 hours, 2 minutes remaining </code></pre> <p>I have used this in the <a href="https://github.com/subins2000/lobby-downloader" target="_blank">Downloader App</a> as I mentioned in the previous post.</p> Convert Bytes To KB, MB, GB in PHP https://subinsb.com/convert-bytes-kb-mb-gb-php/ Wed, 23 Mar 2016 09:09:02 +0000 https://subinsb.com/convert-bytes-kb-mb-gb-php/ <p>Say you were displaying the size of a file in PHP. You obviously get the file size in Bytes by usingย <strong>filesize()</strong>.</p> <p>You wonโ€™t have any idea what the file size is if you read it in Bytes. Bytes is useful for file transmission in a network, but not for human usage. So, itโ€™s better to convert it to human readable form.<figure class="wp-caption aligncenter"></p> <p><a href="//lab.subinsb.com/projects/blog/uploads/2016/03/php-file-size-converter.png"><img class="" src="//lab.subinsb.com/projects/blog/uploads/2016/03/php-file-size-converter.png" alt="The circled areas show the converted size from Bytes. App - Lobby Downloader" width="738" height="207" /></a><figcaption class="wp-caption-text">The circled areas show the converted size from Bytes. App โ€“ Lobby Downloader</figcaption></figure></p> <p>Here is a simple function to convert Bytes toย <strong>KB</strong>,ย <strong>MB</strong>,ย <strong>GB</strong>,ย <strong>TB</strong> :</p> <pre class="prettyprint"><code>function convertToReadableSize($size){ $base = log($size) / log(1024); $suffix = array("", "KB", "MB", "GB", "TB"); $f_base = floor($base); return round(pow(1024, $base - floor($base)), 1) . $suffix[$f_base]; }</code></pre> <p>Note that KB is for Kibibyte. Normal systems uses Kilobyte (1000). If you want to change it, then replace the parameter passed toย <strong>log()</strong>.</p> <p>Note that uptoย <strong>TB</strong> is included in the function. You can extend it by adding more into theย **$suffixย **array.</p> <h2 id="usage">Usage</h2> <p>Just call the functionย :</p> <pre class="prettyprint"><code>echo convertToReadableSize(1024); // Outputs '1KB' echo convertToReadableSize(1024 * 1024); // Outputs '1MB' echo convertToReadableSize(filesize("/home/simsu/good.txt")); </code></pre> <p>I had to use it for a download manager app I created for <a href="http://lobby.subinsb.com">Lobby</a>. You can see the source code of <a href="https://github.com/subins2000/lobby-downloader" target="_blank">&quot;Downloader&quot; app here</a>.</p> Create Table Rows With Alternate Colours in PHP https://subinsb.com/table-rows-with-alternate-colours/ Sat, 13 Feb 2016 04:31:02 +0000 https://subinsb.com/table-rows-with-alternate-colours/ <p>If you have a lot of rows on a table, users will find it difficult to find which cell is in what row. This is because all the rows have the same colour.</p> <p>If we alternate the colours, then the table will be more understandable. We can alternate colours odd-even wise or by 3 rows etc.</p> <p>It can be easily done in PHP. I will tell you two ways to do it.</p> <p>Suppose this is how we output rows :</p> <pre class="prettyprint"><code>for($i=0;$i &lt; 10;$i++){ echo "&lt;tr&gt;&lt;td&gt;What's Up ?&lt;/td&gt;&lt;td&gt;Sky (Troll Face)&lt;/td&gt;&lt;/tr&gt;"; }</code></pre> <h2 id="odd-even">Odd-Even</h2> <p>Now letโ€™s add blue colour to odd rows and green colour to even rows.</p> <pre class="prettyprint"><code>for($i=0;$i &lt; 10;$i++){ $bg_color = $i % 2 === 0 ? "green" : "blue"; echo "&lt;tr style='background-color: ". $bg_color .";'&gt;&lt;td&gt;What's Up ?&lt;/td&gt;&lt;td&gt;Sky (Troll Face)&lt;/td&gt;&lt;/tr&gt;"; } </code></pre> <p>The table will looks something like this (forget the row contents) :<figure class="wp-caption aligncenter"></p> <p><a href="//lab.subinsb.com/projects/blog/uploads/2016/02/table-alternate-color-odd-even.png"><img title="Table with alternate rows having different background colors" src="//lab.subinsb.com/projects/blog/uploads/2016/02/table-alternate-color-odd-even.png" alt="Table with alternate rows having different background colors" width="949" height="470" /></a><figcaption class="wp-caption-text">Table with alternate rows having different background colors</figcaption></figure></p> <p>You can also add class to the row instead of setting the &quot;style&quot; attribute.</p> <h2 id="multiple-of-a-number-8216n8217">Multiple of A Number โ€˜nโ€™</h2> <p>You can change colour of every 3rd element or nth element too :</p> <pre class="prettyprint"><code>$n = 3; for($i=0;$i &lt; 10;$i++){ $bg_color = $i % $n === 0 ? "green" : "blue"; echo "&lt;tr style='background-color: ". $bg_color .";'&gt;&lt;td&gt;What's Up ?&lt;/td&gt;&lt;td&gt;Sky (Troll Face)&lt;/td&gt;&lt;/tr&gt;"; } </code></pre> <p>In the above case, all 3rd rows will have green background color and others would have a blue color :<figure class="wp-caption aligncenter"></p> <p><a href="//lab.subinsb.com/projects/blog/uploads/2016/02/table-alternate-color-multiple-of-3.png"><img title="Table with alternate 3rd rows having different background colors" src="//lab.subinsb.com/projects/blog/uploads/2016/02/table-alternate-color-multiple-of-3.png" alt="Table with alternate 3rd rows having different background colors" width="957" height="412" /></a><figcaption class="wp-caption-text">Table with alternate 3rd rows having different background colors</figcaption></figure></p> <p>You can change the value of $n as you like to change the row which will have the special background color.</p> <p>Life is Good ๐Ÿ™‚</p> 16 Years of Revolving Around The Sun https://subinsb.com/16-years-of-revolving-around-the-sun/ Thu, 21 Jan 2016 02:52:55 +0000 https://subinsb.com/16-years-of-revolving-around-the-sun/ <p>So I revolved around the sun 16 years. Yes, I turned 16. It seems like I just turned 15 yesterday.</p> <p>As age increases, life becomes harder. This direct proportionality is making me closer to the answer of life. This post is an analysis of myself of what I did and what I plan to do.</p> <p>&quot;Birthdays are a constant reminder of how I wasted time&quot;</p> <h2 id="past-1-year-as-a-student">Past 1 Year As A Student</h2> <p>I got full A+ in the 10th grade exam and is now in 11th grade as a C.S student. Got a whole lot of new friends.</p> <p>There is this one friend who is passionate about C.S and crazy about I.T. He is <a href="http://vishnumc7.blogspot.in/" target="_blank">Vishnu M.C</a>ย โ€“ a blogger who does it via a 3 year old smartphone. It is hard to do blogging by phone. I have no idea how he manages it. He totally flunk studies, does work on blog.</p> <p>I have a wish to do what he is doing now. But, as my parents say &quot;You are nothing without a qualification&quot;. Damn this qualification thing. I just wanna work with Open Source.</p> <p>Here are some pics from my current Higher Secondary days :<figure class="wp-caption aligncenter"></p> <p><a href="https://scontent.fdel1-1.fna.fbcdn.net/hphotos-xla1/t31.0-8/fr/cp0/e15/q65/12513843_937885886304750_9138160489355675971_o.jpg"><img class="" src="https://scontent.fdel1-1.fna.fbcdn.net/hphotos-xla1/t31.0-8/fr/cp0/e15/q65/12513843_937885886304750_9138160489355675971_o.jpg" alt="" width="2048" height="1578" /></a><figcaption class="wp-caption-text">From Left : Rejohn, Navaneeth, Vishnu, Delvin, Me, Vikas, Mobin</figcaption></figure> <figure class="wp-caption aligncenter"><a href="https://scontent-hkg3-1.xx.fbcdn.net/hphotos-xta1/v/t1.0-9/fr/cp0/e15/q65/12088091_896293280464011_8881500342318265372_n.jpg?efg=eyJpIjoidCJ9&amp;oh=597749eec82d73ef5c00ffac35e6bcb3&amp;oe=573E96E5"><img class="" src="https://scontent-hkg3-1.xx.fbcdn.net/hphotos-xta1/v/t1.0-9/fr/cp0/e15/q65/12088091_896293280464011_8881500342318265372_n.jpg?efg=eyJpIjoidCJ9&oh=597749eec82d73ef5c00ffac35e6bcb3&oe=573E96E5" alt="" width="720" height="960" /></a><figcaption class="wp-caption-text">From Back Left : Akshay, Godson, Abin, Me, Rejohn and the one who is taking the selfie is Kailas</figcaption></figure></p> <p>It is these pictures that would be make me nostalgic 10 years later.</p> <h2 id="past-1-year-as-a-developer">Past 1 Year As A Developer</h2> <p>I just released <a href="https://lobby.subinsb.com" target="_blank">Lobby</a> today. After 2 years of continuous development, it has reached a STABLE phase.</p> <p>The amount of posts written on blog was so low. Due to the time wastingย school, I donโ€™t have time for fun things.</p> <p>The amount of commits on GitHub has increased and Iโ€™m planning on keeping that long streak of commits :<figure class="wp-caption aligncenter"></p> <p><img class="" src="//imgur.com/Y2yV9Qtl.png" alt="" width="640" height="254" /><figcaption class="wp-caption-text">After January 2, 2016, commits have increased</figcaption></figure></p> <p>I have a lot of hope on Lobby. Itโ€™s one of a kind and I hope you will help it become a success. ๐Ÿ™‚</p> Finding The Value Of Pi https://subinsb.com/finding-the-value-of-pi/ Tue, 05 Jan 2016 13:36:46 +0000 https://subinsb.com/finding-the-value-of-pi/ <p>Everyone must have heard of Pi, the irrational number that never ends. It goes by this :</p> <pre class="prettyprint"><code>3.14159265...</code></pre> <p>I have been learning about Pi since I was in 8th grade. All the time in school, I was curious about to which Pi extends.</p> <p>Now, I know the extend โ€“ <strong>Infinity</strong> :P. I dedicated my precious Christmas vacation for finding the useless value of Pi.</p> <p>Why ? Curiosity. Simply, the curiosity made me want to do this. Besides, itโ€™s always fun to do something interesting.</p> <div class="padlinks"> <a class="demo" href="http://demos.subinsb.com/pi/" target="_blank">Demo</a><a class="download" href="http://demos.subinsb.com/down.php?class=43" target="_blank">Download</a> </div> <p>The source code is on <a href="https://github.com/subins2000/pi" target="_blank">GitHub</a>. Please Star it. Math Enthusiasts, fork it. ๐Ÿ˜‰</p> <h2 id="findings">Findings</h2> <p>1 Million digits and 5 Million digits were successfully found. You can see them <a href="http://demos.subinsb.com/pi/values.php" target="_blank">here</a>.</p> <p>The current World Record isย <strong>&gt; 1 Trillion digits</strong>.ย (I should get a super computer soon).</p> <h2 id="equation">Equation</h2> <p><a href="http://www.craig-wood.com/nick/articles/pi-chudnovsky/" target="_blank">Craig Wood</a> has made a <strong>Python</strong> script to calculate N digits of Pi. Itโ€™s a very complicated script and it took me 2 days to understand it.<figure class="wp-caption aligncenter"></p> <p><img class="" src="//www.craig-wood.com/nick/images/math/13e67da9779a237b0d3b4b0fa5d70d12.png" alt="Pi equation" width="430" height="58" /><figcaption class="wp-caption-text">Pi equation</figcaption></figure></p> <p>What I did is, create the client side and aย <strong>WebSocket</strong> server. The Pi calculation is ran through Python and inserted to the database.</p> <p>Itโ€™s a Live process. Meaning, a person on the client can see the step where the Pi is being calculated. If we look at theย <strong>Python</strong> script :</p> <pre class="prettyprint"><code>import math import os import time import MySQLdb import base64 import zlib import sys digits_to_calculate = int(sys.argv[1]) db = MySQLdb.connect(host=os.environ["OPENSHIFT_MYSQL_DB_HOST"], # your host, usually localhost user=os.environ["OPENSHIFT_MYSQL_DB_USERNAME"], # your username passwd=os.environ["OPENSHIFT_MYSQL_DB_PASSWORD"], # your password db="ws") cur = db.cursor() # The time when program start START_TIME = time.time() cur.execute(""" UPDATE `pi` SET `value` = %s WHERE `key_name` = %s """, (START_TIME, "start")) def output(name, content): cur.execute("UPDATE `pi` SET `value` = %s WHERE `key_name` = %s", (content, name)) db.commit() sq_i = 1 def sqrt(n, one): global sq_i """ Return the square root of n as a fixed point number with the one passed in. It uses a second order Newton-Raphson convergence. This doubles the number of significant figures on each iteration. """ # Use floating point arithmetic to make an initial guess floating_point_precision = 10**16 output("status", "sqrt," + str(sq_i)) n_float = float((n * floating_point_precision) // one) / floating_point_precision x = (int(floating_point_precision * math.sqrt(n_float)) * one) // floating_point_precision n_one = n * one while 1: sq_i+=1 output("status", "sqrt," + str(sq_i)) x_old = x x = (x + n_one // x) // 2 if x == x_old: break return x i = 0 Qab = 0 def pi_chudnovsky_bs(digits): global i """ Compute int(pi * 10**digits) This is done using Chudnovsky's series with binary splitting """ output("status", "init,1") one = 10**digits output("status", "init,2") sqrtC = sqrt(10005*one, one) output("status", "init,3") C = 640320 C3_OVER_24 = C**3 // 24 def bs(a, b): global i, Qab """ Computes the terms for binary splitting the Chudnovsky infinite series a(a) = +/- (13591409 + 545140134*a) p(a) = (6*a-5)*(2*a-1)*(6*a-1) b(a) = 1 q(a) = a*a*a*C3_OVER_24 returns P(a,b), Q(a,b) and T(a,b) """ """ Subin Siby &lt;subinsb.com&gt; """ if i != 0 and i != 1: calculated_digits = str(digits - (digits/i) + 7) output("status", "pi," + str(i) + "," +calculated_digits + "," + str(digits_to_calculate)) """ Calculate """ if b - a == 1: # Directly compute P(a,a+1), Q(a,a+1) and T(a,a+1) if a == 0: Pab = Qab = 1 else: Pab = (6*a-5)*(2*a-1)*(6*a-1) Qab = a*a*a*C3_OVER_24 Tab = Pab * (13591409 + 545140134*a) # a(a) * p(a) if a & 1: Tab = -Tab else: # Recursively compute P(a,b), Q(a,b) and T(a,b) # m is the midpoint of a and b m = (a + b) // 2 # Recursively calculate P(a,m), Q(a,m) and T(a,m) Pam, Qam, Tam = bs(a, m) # Recursively calculate P(m,b), Q(m,b) and T(m,b) Pmb, Qmb, Tmb = bs(m, b) # Now combine Pab = Pam * Pmb Qab = Qam * Qmb Tab = Qmb * Tam + Pam * Tmb i+=1 return Pab, Qab, Tab # how many terms to compute DIGITS_PER_TERM = math.log10(C3_OVER_24/6/2/6) N = int(digits/DIGITS_PER_TERM + 1) # Calclate P(0,N) and Q(0,N) P, Q, S = bs(0, N) return Q*426880*sqrtC // S pi = pi_chudnovsky_bs(digits_to_calculate) # Compress Pi pi = zlib.compress(str(pi)) # Save to DB output("pi", pi) db.close()</code></pre> <p>we can see the call of functionย <strong>output</strong>. This function updates the respective values in DB. The &quot;status&quot; key holds the current status of Pi calculation. It may have values like :</p> <table class="table"> <tr> <td> <h2> <a href="#status"><span id="status">Status</span></a> </h2> </td> <pre><code>&lt;td&gt; &lt;h2&gt; &lt;a href=&quot;#stage&quot;&gt;&lt;span id=&quot;stage&quot;&gt;Stage&lt;/span&gt;&lt;/a&gt; &lt;/h2&gt; &lt;/td&gt; </code></pre> </tr> <tr> <td> init,[I] </td> <pre><code>&lt;td&gt; The initialization stage. Creation of variable etc. &lt;/td&gt; </code></pre> </tr> <tr> <td> sqrt,[I] </td> <pre><code>&lt;td&gt; The loop inside sqrt() function. I indicates the current iteration value. &lt;/td&gt; </code></pre> </tr> <tr> <td> pi,[I],[C],[D] </td> <pre><code>&lt;td&gt; The loop inside bs() function.&lt;br /&gt; I indicates the current iteration value.&lt;br /&gt; C indicates the number of calculated digits (most likely inaccurate)&lt;br /&gt; D indicates the number of digits to be calculated &lt;/td&gt; </code></pre> </tr> </table> <p>The [I], [C], [D] above indicates an integer starting from 1.</p> <h2 id="heading"></h2> <h2 id="technical-spec">Technical Spec</h2> <p>This was also an experiment ofย <strong>WebSocket</strong>. It was a test of Live result obtaining using WebSocket.</p> <p>The server is &quot;ws-subins.rhcloud.com&quot; using the <a href="https://github.com/subins2000/Francium-DiffSocket" target="_blank">Francium DiffSocket library</a>. You can see &quot;ws-subins.rhcloud.com&quot; shows a blank page as the WebSocket server is running. Server :</p> <pre class="prettyprint"><code>PHP 5.4.4 Python 2.6.6 MySQL 5.5.45</code></pre> <p>When someone requests for the full value of Pi, sending 5 MB file (5 Million digits) to client is quite a task. But, WebSocket handles it well.</p> <h2 id="conclusion">Conclusion</h2> <p>The record isย <strong>&gt; 1 Trillion</strong> digits. It will surely require a super computer to calculate that much digits. I can see the processor load in my system when just calculating 1 Million digits.</p> <p>If someone could get me a super computer, we could break the record ๐Ÿ˜‰</p> Parts Of My Life https://subinsb.com/parts-of-my-life/ Sat, 02 Jan 2016 15:55:45 +0000 https://subinsb.com/parts-of-my-life/ <p>A programmer, a teenager, a student, an adventurer โ€“ย 4 components in my life.</p> <p>When you get all of these at once, I feel a little pressure in my life. Let me explain these 4 parts :</p> <h2 id="programmer">Programmer</h2> <p>I have been a programmer for 5 years. I started when I wasย <strong>10</strong> years old. I know these languages :</p> <pre class="prettyprint"><code>PHP, Python, Bash, HTML, CSS, JavaScript</code></pre> <p>My primary language is PHP. Though developers are going away fromย <strong>PHP</strong>, I still like it and would continue that way.</p> <h2 id="teenager">Teenager</h2> <p>Iโ€™m in the 2nd year of teenage life and is on the verge of 3rd year (January 20). Itโ€™s a mystery how someone get through the teenage life.</p> <p>If you get sad, you get very sad. I had days where I listened to music as much as I can to relieve the pressure.</p> <p>If you become happy, you become crazy. You see, if I become happy, I become crazier. Sometimes, I get really excited and does some pretty stupid stuff.</p> <p>The outcomes of these stupid stuff were both devastating and spectacular :</p> <pre class="prettyprint"><code>Devastating - Doing some really embarrassing things which haunts me Spectacular - Wrote a complaint to Prime Minister and got an internet connection</code></pre> <p>Teenage is both crazy and wonderful. Hope it continues like that.</p> <h2 id="student">Student</h2> <p>It is this part that I give my <strong>75%</strong> to. My parents say to give more to it. If I did give more amount to this part, then I couldnโ€™t do my other parts.</p> <p>School makes me busy. Iโ€™m the class leader and that makes my responsibilities more. Studies are the other hardest thing.</p> <p>The &quot;Student&quot; part is what you have to blame for not replying to your comments and not responding to emails.</p> <p>My parents and family members say :</p> <pre class="prettyprint"><code>Without a basic qualification, you're nothing </code></pre> <p>I think itโ€™s sad that people look at qualification more than their ability. Is qualification a value of ability. I donโ€™t think so. Someone must create a better indicator of ability.</p> <h2 id="adventurer">Adventurer</h2> <p>I love to visit new places and meet new people ! Itโ€™s my favorite hobby. I travel using my bicycle.</p> <p>The region I live :</p> <p>is a terrain with many hills and depressions. So, itโ€™s hard to ride a cycle. But despite my parentsโ€™ warning, I travel as much as I want. The longest distance I have covered is <strong>10 Kms</strong> or maybe more than that.</p> <p>And from those places, I got some beautiful images :<figure class="wp-caption aligncenter"></p> <p><a href="//i.imgur.com/1xR1hs3.png"><img class="" src="//i.imgur.com/1xR1hs3.png" alt="Edakkazhiyur Beach. Travelled by motorbike" width="2560" height="1918" /></a><figcaption class="wp-caption-text">Edakkazhiyur Beach. Travelled by motorbike</figcaption></figure></p> <p>Another place (Mangad) :<figure class="wp-caption aligncenter"></p> <p><a href="//imgur.com/wqsfmMl.png"><img class="" src="//imgur.com/wqsfmMl.png" alt="The land that separates Kizhoor and Mangad" width="1708" height="399" /></a><figcaption class="wp-caption-text">The land that separates Kizhoor and Mangad</figcaption></figure></p> <p>My adventures will continue and I have a dream that I can travel around the world one day. Perhaps I can. ๐Ÿ™‚</p> <h2 id="conclusion">Conclusion</h2> <p>So, there you go. My life in a post. Iโ€™m writing this to reference when someone asks for doing a job by email or comment.</p> <p>And ending with a smile :</p> <p>๐Ÿ™‚</p> Uploading Images Using AJAX In HTML5 https://subinsb.com/upload-images-html5-ajax/ Mon, 28 Dec 2015 03:30:19 +0000 https://subinsb.com/upload-images-html5-ajax/ <p>In a post that was published some years ago, I explained how to <a href="//subinsb.com/uploading-an-image-using-ajax-in-jquery-with-php">upload an image using AJAX</a>. But, it is an old trick whenย <strong>HTML5</strong> was not standardized.</p> <p>But, now browsers have evolved and almost every person in the world has anย <strong>HTML5</strong> supported browser. Besides, the old trick used a JS file which is aboutย <strong>15KB</strong>. If we usedย <strong>HTML5</strong> mechanism instead, then you can save aboutย <strong>14KB</strong>.</p> <div class="padlinks"> <a class="demo" href="http://demos.subinsb.com/ajax-image-upload/" target="_blank">Demo</a> </div> <p>We useย <strong>FormData</strong> object inย <strong>JS</strong> to make theย <strong>multipart/form-data</strong>, then the file object retrieved from the input element :</p> <pre class="prettyprint"><code>var data = new FormData(); var files = $("input[type=file]")[0].files; // Append files infos (object) $.each(files, function(i, file) { data.append('file-'+i, file); }); $.ajax(</code></pre> <p>The code usesย <strong>jQuery</strong>. If you want to use plain JS, then use this :</p> <pre class="prettyprint"><code>var data = new FormData(); var files = document.getElementById("inputfile").files; // Append files infos (object) for(i = 0;i &lt; files.length;i++){ data.append('file-'+i, files[i]); }; </code></pre> <p>Each file selected by the user is inserted into the FormData as &quot;file-&quot; followed by the index number of file. That is, if two files are selected, then the files is sent as &quot;file-0&quot; and &quot;file-1&quot;.</p> <p>Here is the server code inย <strong>PHP</strong> where we access the uploaded files :</p> <pre class="prettyprint"><code>&lt;?php function getMIMEType($filename){ $finfo = new finfo; return $finfo-&gt;file($filename, FILEINFO_MIME_TYPE); } function rand_string($length) { $str=""; $chars = "subinsblogabcdefghijklmanopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; $size = strlen($chars); for($i = 0;$i &lt; $length;$i++) { $str .= $chars[rand(0,$size-1)]; } return $str; } $supported_files = array("image/jpg", "image/png", "image/gif", "image/bmp", "image/jpeg", "image/bmp"); if(count($_FILES) != 0 and $_SERVER['REQUEST_METHOD'] == "POST"){ for($i = 0;$i &lt; count($_FILES);$i++){ $name = $_FILES['file-' . $i]['name']; $size = $_FILES['file-' . $i]['size']; $tmp = $_FILES['file-' . $i]['tmp_name']; $type = getMIMEType($tmp); echo "&lt;h3&gt;File # ". ($i+1) ."&lt;/h3&gt;"; if(in_array($type, $supported_files)){ /** * Max size is 1 MB = 1024 KB = 1024 * 1024 Bytes */ if($size &lt; (1024 * 1024)){ $upload_file_name = time() . "-" . rand_string(4); if(move_uploaded_file($tmp, __DIR__ . "/uploads/$upload_file_name")){ echo "File Name : $name"; echo "&lt;br/&gt;File Temporary Location : $tmp"; echo "&lt;br/&gt;File Size : $size"; echo "&lt;br/&gt;File Type : $type"; echo "&lt;br/&gt;Image : &lt;img style='margin-left:10px;' src='uploads/$upload_file_name'&gt;"; }else{ echo "Uploading Failed."; } }else{ echo "Files must have maximum size of 1 MB"; } }else{ echo "Invalid Image file format."; } } }else{ echo "Please select an image."; exit; } ?&gt;</code></pre> <p>We use two functions,ย <a href="//subinsb.com/php-find-file-mime-type" target="_blank">getMIMEType()</a> andย <a href="//subinsb.com/php-generate-random-string" target="_blank">rand_string()</a>. One for getting the uploaded fileโ€™s type and other for generating the uploaded fileโ€™s name.</p> <p>By using the script above, one can uploadย <strong>multiple</strong> files. Status of each file is shown as different section with headings of each files.</p> Ubuntu Dekko https://subinsb.com/ubuntu-dekko/ Tue, 22 Dec 2015 20:11:52 +0000 https://subinsb.com/ubuntu-dekko/ <p>This post is part of theย Google Code in 2015. The task was toย Build the dekko app and run all testsuites. You can see the task <a href="https://codein.withgoogle.com/dashboard/task-instances/6201826592423936/" target="_blank">here</a>.</p> <h2 id="my-system">My System</h2> <p>Xubuntu 15.10 Wily Werewolf :<figure class="wp-caption aligncenter"></p> <p><a href="https://scontent.fmaa1-1.fna.fbcdn.net/hphotos-xat1/t31.0-8/12322860_916853241741348_2794994122051128816_o.jpg"><img class="" src="https://scontent.fmaa1-1.fna.fbcdn.net/hphotos-xat1/t31.0-8/12322860_916853241741348_2794994122051128816_o.jpg" alt="" width="1368" height="768" /></a><figcaption class="wp-caption-text">Xubuntu 15.10 Wily Werewolf</figcaption></figure></p> <h2 id="dependencies-installation">Dependencies Installation</h2> <p>First of all, I downloaded Ubuntu SDK with the help of <a href="https://developer.ubuntu.com/en/start/ubuntu-sdk/installing-the-sdk/" target="_blank">this guide</a>.</p> <p>Then, I got the source code URL from <a href="https://developer.ubuntu.com/en/community/core-apps/dekko/" target="_blank">Ubuntu Developers Site</a>ย :</p> <pre><code>git clone https://git.launchpad.net/dekko </code></pre> <p>The source code was about 29 MB.</p> <p>Next thing I did was read &quot;HACKING.md&quot; file. There was a section called &quot;Building&quot; in it. There were two steps :</p> <ol> <li>ensure we have the armhf click chroot created</li> <li>the click chroot is up to date and has required dependencies installed</li> </ol> <p>The first step was not clear. So, I went to the &quot;<a href="https://git.launchpad.net/dekko/tree/README.md" target="_blank">README.md</a>&quot; file and found that there is a group for <a href="https://telegram.me/joinchat/AyyC-QIH4bXHjpRXpqWWkQ" target="_blank">Dekko in Telegram</a>.</p> <p>I chatted and found <a href="https://dekko.gitbooks.io/development-guide/content/SetupDevEnv.html" target="_blank">this page</a>. Thanks to Dan Chapman. I also learnt that the &quot;HACKING.md&quot; file is no longer valid.</p> <p>To build, the doc saidย :</p> <pre class="prettyprint"><code>If you just want to build & run Dekko on your desktop then you should use the run-desktop script with the --setup option. </code></pre> <pre class="prettyprint prettyprinted"><code class="lang-bash">&lt;span class="pln">$ &lt;/span>&lt;span class="pun">./&lt;/span>&lt;span class="pln">scripts&lt;/span>&lt;span class="pun">/&lt;/span>&lt;span class="pln">run&lt;/span>&lt;span class="pun">-&lt;/span>&lt;span class="pln">desktop &lt;/span>&lt;span class="pun">--&lt;/span>&lt;span class="pln">setup&lt;/span></code></pre> <p><strong>224 MB</strong> of archives need to be retrieved. It were the dependencies. That took a while :<figure class="wp-caption alignnone"></p> <p><img class="" src="https://i.imgur.com/vHZMM8J.png" alt="" width="964" height="410" /><figcaption class="wp-caption-text">Installing dependencies of Dekko</figcaption></figure></p> <p>The dependencies were successfully installed in a single try.</p> <h2 id="building">Building</h2> <p>I ran :</p> <pre class="prettyprint prettyprinted"><code class="lang-bash">&lt;span class="pun">./&lt;/span>&lt;span class="pln">scripts&lt;/span>&lt;span class="pun">/&lt;/span>&lt;span class="pln">run&lt;/span>&lt;span class="pun">-&lt;/span>&lt;span class="pln">desktop &lt;/span>&lt;span class="pun">--&lt;/span>&lt;span class="pln">with&lt;/span>&lt;span class="pun">-&lt;/span>&lt;span class="pln">uitk&lt;/span></code></pre> <p>It started to build :<figure class="wp-caption alignnone"></p> <p><img class="" src="//imgur.com/NfHfJEpl.png" alt="" width="640" height="272" /><figcaption class="wp-caption-text">Bulding Dekko</figcaption></figure></p> <p>There was this awesome little loading icon using ASCII chars to indicate the build process :</p> <pre class="prettyprint"><code>/ - | \ | / </code></pre> <p>Never saw such thing before. I should make a SVG animated image of this.</p> <p>The building caused and error :</p> <pre class="prettyprint"><code>E: You must put some 'source' URIs in your sources.list</code></pre> <p>I looked over the script file and found why the error is coming. It was because I have disabled all the &quot;source code&quot; repositories.</p> <p>So, I reloaded the package list and tried again. This time it worked. After that, I ran :</p> <p>ย </p> <pre class="prettyprint"><code>&lt;span class="pun">./&lt;/span>&lt;span class="pln">scripts&lt;/span>&lt;span class="pun">/&lt;/span>&lt;span class="pln">run&lt;/span>&lt;span class="pun">-&lt;/span>&lt;span class="pln">desktop&lt;/span></code></pre> <p>ย </p> <p>ย </p> <p>to run Dekko app. Now, it was compiling :<figure class="wp-caption alignnone"></p> <p><img class="" src="//imgur.com/OGEivOtl.png" alt="" width="640" height="357" /><figcaption class="wp-caption-text">Dekko app compiling</figcaption></figure></p> <p>And finally Dekko ran :<figure class="wp-caption alignnone"></p> <p><img class="" src="//imgur.com/mR2MBTLl.png" alt="" width="640" height="359" /><figcaption class="wp-caption-text">Dekko on Ubuntu Wily Werewolf</figcaption></figure></p> <h2 id="running-testsuites">Running Testsuites</h2> <p>As per the doc, I ran this :<code class="lang-bash"></code></p> <pre class="prettyprint prettyprinted"><code class="lang-bash">&lt;span class="pun">./&lt;/span>&lt;span class="pln">scripts&lt;/span>&lt;span class="pun">/&lt;/span>&lt;span class="pln">run&lt;/span>&lt;span class="pun">-&lt;/span>&lt;span class="pln">desktop &lt;/span>&lt;span class="pun">--&lt;/span>&lt;span class="pln">tests&lt;/span></code></pre> <p>The tests were started :<figure class="wp-caption alignnone"></p> <p><img class="" src="//imgur.com/q1RqZb2l.png" alt="" width="640" height="357" /><figcaption class="wp-caption-text">Running Dekko Testsuites</figcaption></figure></p> <p>The testsuites was successfully finished :<figure class="wp-caption alignnone"></p> <p><img class="" src="//imgur.com/vk82mN0l.png" alt="" width="640" height="357" /><figcaption class="wp-caption-text">Dekko Testuites Passed</figcaption></figure></p> <h2 id="problems-faced">Problems Faced</h2> <ul> <li> <p>The file &quot;HACKING.md&quot; was outdated in the Git repo. I had to find the better documented page from Dan Chapman โ€“ maintainer of Dekko</p> </li> <li> <pre class="prettyprint prettyprinted"><code class="lang-bash">&lt;span class="pun">./&lt;/span>&lt;span class="pln">scripts&lt;/span>&lt;span class="pun">/&lt;/span>&lt;span class="pln">run&lt;/span>&lt;span class="pun">-&lt;/span>&lt;span class="pln">desktop &lt;/span>&lt;span class="pun">--&lt;/span>&lt;span class="pln">with&lt;/span>&lt;span class="pun">-&lt;/span>&lt;span class="pln">uitk&lt;/span></code></pre> <p>The requirement of ย the above command to work is that the &quot;Source Code&quot; repository should be enabled.</p> <p>I had them disabled and it didnโ€™t work on my system. Everything worked after it was enabled and when package list was updated</li> </ul></p> <h2 id="suggestions">Suggestions</h2> <ul> <li> <p>The &quot;HACKING.md&quot; file should be removed or updated</p> <p>Dan Chapman said that he was planning to remove it. So, thatโ€™s OK</p> </li> <li> <p>The <a href="https://dekko.gitbooks.io/development-guide/content/SetupDevEnv.html" target="_blank">doc</a>ย should mention that the &quot;Source Code&quot; repository should be enabled for the building to be done successfully.</p> </li> </ul> <h2 id="conclusion">Conclusion</h2> <p>Dekko is neat, beautiful and well written. I could only find Dan Chapman active in the project. Still, the Dekko <a href="https://dekko.gitbooks.io/" target="_blank">doc site</a> and project looks awesome.</p> <p>Canโ€™t wait to get an Ubuntu Touch Phone.</p> </li> </ul> The Anagram Game https://subinsb.com/the-anagram-game/ Mon, 21 Sep 2015 07:49:53 +0000 https://subinsb.com/the-anagram-game/ <p>As you know, I have made <a href="//subinsb.com/lobby">Lobby โ€“ The localhost OS</a>. I am in the process of adding more and more apps to it. This post explains how I created theย <strong>Anagram</strong> game and the algorithm used for it.</p> <p>You can download the app <a href="http://lobby.subinsb.com/apps/anagram" target="_blank">from here</a> or search for &quot;Anagram&quot; in the Lobby Store.</p> <p>The full source code is available onย <strong><a href="https://github.com/LobbyOS/app-anagram" target="_blank">GitHub</a></strong>.<figure class="wp-caption aligncenter"></p> <p><a href="//lab.subinsb.com/projects/blog/uploads/2015/09/lobby-app-anagram.png"><img class="" src="//lab.subinsb.com/projects/blog/uploads/2015/09/lobby-app-anagram.png" alt="Anagram Game" width="1368" height="768" /></a><figcaption class="wp-caption-text">Anagram Game</figcaption></figure></p> <h1 id="how-it-works-">How It Works ?</h1> <p>There is a dictionary file containing many english words. When a user requests for a new puzzle, these happens :</p> <ol> <li>Choose random letters</li> <li>Loop through each words of dictionary and see if chosen letters is present in the word. The compatible words are added to an Array.</li> <li>The chosen letters and words are passed to the client side.</li> </ol> <p>The client side (JavaScript) will display the letters and make the boxes for each words.</p> <h1 id="dictionary">Dictionary</h1> <p>The dictionary consists ofย <strong>51,853</strong> words. You can see theย <strong>366KB</strong> <a href="https://github.com/LobbyOS/app-anagram/blob/master/src/Data/wordlist.txt" target="_blank">file here</a>.</p> <p>Each words are separated by a newline (\n).</p> <h1 id="algorithm">Algorithm</h1> <p>Here is how words are found out from the scrambled letters : Each word in the dictionary is looped over an the word is checked for same letters :</p> <pre class="prettyprint"><code>$avail = array(); // An array of scrambled letters $dict = array(); // An array of words in dictionary $pWords = array(); // An array of words that can be formed from the scrambled letters foreach($dict as $word){ $checked = array(); $valid = true; $letters = str_split($word); $wordAvail = $avail; foreach($letters as $letter){ $key = array_search($letter, $wordAvail); if($key === false){ $valid = false; } unset($wordAvail[$key]); } if($valid == true){ $pWords[$word] = 1; } } </code></pre> <p>Theย <strong>$pWords</strong> will contain the words that can be formed from the scrambled letters.</p> <h1 id="hack">Hack!</h1> <p>If you want to see the words before clicking &quot;Solve&quot;, you can use the Developer Tools of your browser to inspect the &quot;data-word&quot; attribute of each box.</p> logSys Admin https://subinsb.com/logsys-admin/ Mon, 14 Sep 2015 03:30:21 +0000 https://subinsb.com/logsys-admin/ <p>After the release of <a href="//subinsb.com/php-logsys">logSys</a> in May 2014, many have been asking for an admin panel ofย <a href="//subinsb.com/php-logsys">logSys</a>. Itโ€™s finally here. Iโ€™m extremely happy to releaseย <strong>logSys Admin</strong> as an app ofย <strong><a href="//subinsb.com/lobby">Lobby</a></strong>.<figure class="wp-caption aligncenter"></p> <p><a href="//googledrive.com/host/0B2VjYaTkCpiQcXh2SUNJSk90Yzg/logo.png"><img class="" src="http://lobby.subinsb.com/api/app/fr-logsys/logo" alt="logSys Admin Logo" width="300" height="300" /></a><figcaption class="wp-caption-text">logSys Admin Logo</figcaption></figure></p> <p>You can find the <a href="http://lobby.subinsb.com/apps/fr-logsys" target="_blank">app here on Lobby</a>.</p> <h1 id="installation">Installation</h1> <ol> <li>Download &amp; Installย <strong><a href="http://lobby.subinsb.com/download" target="_blank">Lobby</a></strong>.</li> <li>Open Lobby</li> <li>Openย **<a href="http://lobby.subinsb.com/apps" target="_blank">Lobby Store</a>ย **and search for &quot;logSys Admin&quot;.</li> <li>Click Install button.</li> </ol> <h1 id="usage">Usage</h1> <ol> <li>Open App from the Lobby Dashboard and click &quot;Go To Admin&quot; button.</li> <li>Click &quot;<strong>Setup logSys Admin</strong>&quot; button.</li> <li>Enter the credentials of your database as well as the table whichย <strong>logSys</strong> uses and Save.</li> <li>Once saved, you can useย <strong>logSys Admin</strong></li> </ol> <p>The dashboard page has some quick facts about your users :<figure class="wp-caption aligncenter"></p> <p><a href="//lab.subinsb.com/projects/blog/uploads/2015/09/fr-logsys-dash.png"><img class="" src="//lab.subinsb.com/projects/blog/uploads/2015/09/fr-logsys-dash.png" alt="logSys Admin Dashboard" width="1197" height="732" /></a><figcaption class="wp-caption-text">logSys Admin Dashboard</figcaption></figure></p> <p>You can manage your users : Add/Edit/Remove + Add New Column + Export Data<figure class="wp-caption aligncenter"></p> <p><a href="//lab.subinsb.com/projects/blog/uploads/2015/09/fr-logsys-users.png"><img class="" src="//lab.subinsb.com/projects/blog/uploads/2015/09/fr-logsys-users.png" alt="logSys Admin Users' Page" width="1317" height="732" /></a><figcaption class="wp-caption-text">logSys Admin Usersโ€™ Page</figcaption></figure></p> <p>See the active tokens that can be used to reset pasword :<figure class="wp-caption aligncenter"></p> <p><a href="//lab.subinsb.com/projects/blog/uploads/2015/09/fr-logsys-tokens.png"><img class="" src="//lab.subinsb.com/projects/blog/uploads/2015/09/fr-logsys-tokens.png" alt="logSys Admin Tokens' Page" width="1317" height="732" /></a><figcaption class="wp-caption-text">logSys Admin Tokensโ€™ Page</figcaption></figure></p> <p>See graphical representation of stats :<figure class="wp-caption aligncenter"></p> <p><a href="//lab.subinsb.com/projects/blog/uploads/2015/09/fr-logsys-stats.png"><img class="" src="//lab.subinsb.com/projects/blog/uploads/2015/09/fr-logsys-stats.png" alt="logSys Admin Stats" width="1317" height="732" /></a><figcaption class="wp-caption-text">logSys Admin Stats</figcaption></figure></p> <p>It is not complete and I will keep continuing add more features. You will be notified in Lobby when a new version is available and you can update it with a single click.</p> <p>Some features Iโ€™m hoping to add :</p> <ul> <li>User Roles</li> <li>Specific Pages For Specific Users</li> </ul> <h1 id="security">Security</h1> <p>By default, <strong>Lobby</strong> can be accessed by anyone. So, yourย <strong>logSys Admin</strong> is accessible to everyone. To prevent this, you can install the <strong>Lobby Admin</strong> app which lets you password protect your Lobby installation.</p> <p>Sidenote: Lobby Admin also usesย <strong>logSys</strong> as itโ€™s login system.ย After you installย <strong>Lobby Admin</strong>, you have to login before accessingย <strong>Lobby</strong>. The default username and password once you install is &quot;admin&quot;.</p> Lobby https://subinsb.com/lobby/ Sat, 12 Sep 2015 03:30:12 +0000 https://subinsb.com/lobby/ <figure class="wp-caption aligncenter">[<img class="" src="http://lobby.subinsb.com/contents/apps/lobby-server/src/image/logo.png" alt="Lobby Logo" width="318" height="114" />][1]<figcaption class="wp-caption-text">Lobby Logo</figcaption></figure> <p><strong><a href="http://lobby.subinsb.com" target="_blank">Lobby</a></strong> is a new project of mine which was under development for more than a year. Iโ€™m proud to release it today with the first versionย <strong>0.2</strong>.ย <strong><a href="http://lobby.subinsb.com" target="_blank">Lobby</a></strong> is a <strong>localhostย Operating System</strong> likeย <strong>Android</strong>,ย <strong>iOS</strong> etc.</p> <h1 id="what-it-is">What It Is</h1> <p>Iโ€™ll explain it to you. There are many OSs in this world. From Ubuntu to Windows to Mac to Android to iOS and so onโ€ฆ Developing an application is tough as you have to port it to different OSs. And the language to develop is also different :</p> <ul> <li>Ubuntu โ€“ C, C++, Python</li> <li>Windows โ€“ C, C++</li> <li>Mac โ€“ C++</li> <li>Android โ€“ Java</li> <li>iOS โ€“ C#</li> </ul> <p>As you can see, a simple developer like you and me have to learn multiple languages for creating a single app. What If, you only have to create a single app with languages that you know such asย <strong>HTML</strong>,ย <strong>CSS</strong>,ย <strong>PHP, JavaScript + jQuery</strong> and the best thingย <strong>it runs on a browser</strong>.ย Life has become easyโ€ฆ This means, the app can be used in various devices as long as it has internet.</p> <p><strong><a href="http://lobby.subinsb.com" target="_blank">Lobby</a></strong> is a software completely written inย <strong>PHP</strong> to simplify the process of creating an app. With Lobby, you will only have to create the app once and you can use that app inย <strong>EVERY</strong>ย system that has a PHP localhost server.</p> <p><strong><a href="http://lobby.subinsb.com" target="_blank">Lobby</a></strong> is a software that runs onย <strong>a web server</strong>, likeย <strong>WordPress</strong>. You can download it from <a href="http://lobby.subinsb.com/download" target="_blank">here</a>, extract it into your localhost folder (<strong>/var/www</strong>) and visit the page in your browser. There is a small installation process and after it, you can download apps from theย <strong><a href="http://lobby.subinsb.com/apps" target="_blank">Lobby Store</a></strong>.</p> <p>Image it likeย <strong>WordPress</strong>, because I created it from the inspiration ofย <strong>WordPress</strong>.</p> <h1 id="why-">Why ?</h1> <p>WordPress had some cool plugins which I would like personally on my computer. Since Iโ€™m using Ubuntu, there arenโ€™t that many apps available like Windows or Mac. And even if I create one, its gonna take a long time. So, to save the time as well as help others who are also in situations like this, I created <a href="http://lobby.subinsb.com" target="_blank">Lobby</a>.</p> <p>For example, I always had a thought in my mind to write diaries. If I did it in a paper, thereโ€™s a big chance for it to be easily lost, destroyed or anything that makes it unusable in future. So, I digitalized the diary as an app in**<a href="http://lobby.subinsb.com" target="_blank">Lobby</a>**. You can download theย <a href="http://lobby.subinsb.com/apps/diary" target="_blank"><strong>Diary</strong> app from here</a>.</p> <p>Another app that I created was a game &quot;<a href="http://lobby.subinsb.com/apps/millionaire" target="_blank">Who Wants to Be A Millionaire ?</a>&quot;.</p> <p>So, to me if I wanted to create a tool that anyone can use it on their computers, I can just upload it toย <strong><a href="http://lobby.subinsb.com" target="_blank">Lobby</a></strong>. Example: The <a href="http://lobby.subinsb.com/apps/fr-logsys" target="_blank">logSys Admin app</a> which helps in managing users using <a href="//subinsb.com/php-logsys" target="_blank">logSys</a>.</p> <h1 id="features">Features</h1> <p>Here are all the features :</p> <ul> <li> <h2 id="one-app-for-all-os">One App For All OS</h2> <p>Create a single app and use it for all systems.</li></p> </li> <li> <h2 id="super-fast-framework-for-apps">Super Fast Framework For Apps</h2> <p>Each line of the 5000+ lines code was created to be super fast and efficient.</li></p> </li> <li> <h2 id="easy-to-learn--use">Easy To Learn &amp; Use</h2> <p>Lobby is not using <strong>MVC</strong> or any other types of existing models. It was created to be fast and easily understandable and hence is a deviation from the current types of softwares created in PHP.</li></p> </li> <li> <h2 id="a-hrefhttpgithubcomsubins2000lobby-target_blankopen-sourcea"><a href="http://github.com/subins2000/lobby" target="_blank">Open Source</a></h2> <p>Like my previous projects, this is Open Source too. It is licensed under <a href="http://www.apache.org/licenses/LICENSE-2.0" target="_blank">Apache License</a>. You can see the <a href="https://github.com/subins2000/lobby" target="_blank">GitHub repo here</a></li></p> </li> <li> <h2 id="safe--secure-apps">Safe &amp; Secure Apps</h2> <p>A central repository of apps is integrated into Lobby meaning all apps that are in theย <strong>Lobby Store</strong> is tested for security as well as privacy. So, no apps can use your personal data to make profit.</li></p> </li> <li> <h2 id="filesystem">FileSystem</h2> <p>Like an OS,ย <strong><a href="http://lobby.subinsb.com" target="_blank">Lobby</a></strong>ย has its own filesystem to access files of the userโ€™s system. And every app is required to use this class. This means,ย <strong><a href="http://lobby.subinsb.com" target="_blank">Lobby</a></strong>ย is aware of what the app is doing ie your privacy is very important toย <strong><a href="http://lobby.subinsb.com" target="_blank">Lobby</a></strong>.</li></p> </li> <li> <h2 id="auto-update">Auto Update</h2> <p>See when a new version comes out and update with a single click.ย <strong><a href="http://lobby.subinsb.com" target="_blank">Lobby</a></strong>ย will update the source code, database and make sure nothing bad happens while updating. This is available to both apps andย <strong><a href="http://lobby.subinsb.com" target="_blank">Lobby</a></strong>ย itself.</li> </ul></p> <p>And many more features to be addedโ€ฆ Here is a snapshot of the dashboard :<figure class="wp-caption aligncenter"></p> <p><a href="//lab.subinsb.com/projects/blog/uploads/2015/09/lobby-dashboard.png"><img class="" src="//lab.subinsb.com/projects/blog/uploads/2015/09/lobby-dashboard.png" alt="Lobby Dashboard" width="1116" height="640" /></a><figcaption class="wp-caption-text">Lobby Dashboard</figcaption></figure></p> </li> </ul> <h2 id="future">Future</h2> <p>I have created many apps usingย <strong><a href="http://lobby.subinsb.com" target="_blank">Lobby</a></strong> and it all works well. I have some great plans for it in the future and I hope it would help you too. You can head straight to the docs for learningย <strong><a href="http://lobby.subinsb.com" target="_blank">Lobby</a></strong>ย and when you create and app, you can submit it toย <strong><a href="http://lobby.subinsb.com" target="_blank">Lobby Repo</a></strong></p> <p><strong><a href="http://lobby.subinsb.com" target="_blank">Lobby</a></strong>ย is an evolving project and the goal is to make stuff SIMPLEST &amp; FASTEST.</p> <p>The documentation is not complete. It is the hardest part to do, not the code. But,ย <strong><a href="http://lobby.subinsb.com" target="_blank">Lobby</a></strong>ย was created to be SIMPLE &amp; POWERFUL and you can easily grasp how it works by looking at the example apps. Here is the source code ofย <strong><a href="https://github.com/subins2000/lobby/tree/master/contents/apps/ledit" target="_blank">lEdit</a></strong>ย โ€“ The official text editor of Lobby.</p> <p><a href="http://lobby.subinsb.com">Go Ahead And See What Lobby Has To Offer</a></p> What Doesnโ€™t Work ? https://subinsb.com/what-doesnt-work/ Wed, 26 Aug 2015 05:58:01 +0000 https://subinsb.com/what-doesnt-work/ <p>I had to write this post, because I have experienced this a lot.</p> <p>When something doesnโ€™t work especially with code, the asker wonโ€™t say the details. He/she just says it doesnโ€™t work. Then it is the duty of mine to find what doesnโ€™t work.</p> <p>To simplify things, when you ask please explain :</p> <ol> <li> <div id="toc_container" class="no_bullets"> <p class="toc_title"> Contents </p> <ul class="toc_list"> <li> <a href="#what-doesn8217t-work"><span class="toc_number toc_depth_1">1</span> What doesn&#8217;t work ?</a> </li> <li> <a href="#any-errors"><span class="toc_number toc_depth_1">2</span> Any Errors ?</a> </li> <li> <a href="#code-samples"><span class="toc_number toc_depth_1">3</span> Code Samples</a> </li> <li> <a href="#explain-clearly"><span class="toc_number toc_depth_1">4</span> Explain Clearly</a> </li> </ul> </li> </ol> <pre><code>&lt;/div&gt; ### What doesn&amp;#8217;t work ? Expected Result vs Actual Result comparison&lt;/li&gt; * ### Any Errors ? Does the compiler or interpreter (as in case of PHP) output any errors. For seeing the errors, you must first enable Error Logging. A sample of the log file would greatly help.&lt;/li&gt; * ### Code Samples Have you made any changes to the code which would result in the error ? If so, please post the code using &lt;a href=&quot;http://pastebin.com&quot; target=&quot;_blank&quot;&gt;Pastebin&lt;/a&gt; or &lt;a href=&quot;http://paste.ubuntu.com&quot; target=&quot;_blank&quot;&gt;Ubuntu Paste&lt;/a&gt;&lt;/li&gt; * ### Explain Clearly The most important thing is to explain clearly about your problem. If you don&amp;#8217;t know English well, say in your own language and translate it using &lt;a href=&quot;http://translate.google.com&quot; target=&quot;_blank&quot;&gt;Google&lt;/a&gt; to English.&lt;/li&gt; &lt;/ol&gt; This post will be used as reference when queries are asked that are not able to be understood by me. </code></pre> Some Plans https://subinsb.com/some-plans/ Tue, 25 Aug 2015 08:51:56 +0000 https://subinsb.com/some-plans/ <p>Itโ€™s been a while since I have written on the blog and there are many reasons for it. Iโ€™m writing now because Iโ€™m on a vacation for 10 days because of Onam, a festival in Kerala.</p> <h1 id="reasons">Reasons</h1> <ol> <li>School</li> <li>Bored Life (These days, Iโ€™m feeling a repulsion)</li> <li>Busy</li> </ol> <p>Iโ€™ll explain :</p> <ol> <li>Since I have passed the 10th grade and is in higher secondary education, the stuff to learn increased. Even the though the subjects to learn have reduced to 6, the size of the books increased.</li> </ol> <pre><code>Though I love all the subject that I learn now (Physics, Chemistry, Computer Science, Maths, English, Malayalam), there is something that prevents me these days to study (Teenage shit ?). </code></pre> <ol start="2"> <li>Yes, life has become boring. The fire I had 4 years ago (2011) has decreased gradually. Why ? I think itโ€™s because of the tough 10th grade. Also, some teenage problem. There is something that controls me these days, a power which I donโ€™t know. Perhaps this is experienced by everyone of my age (or do they ?).Back in 2011, if I had planned to do something, I had this fire in my mind to do it until I reach it. But, now sometimes I feel that fire, but after some time the repulsion force brings me down. I hope this repulsion force will go soon.</li> <li>Iโ€™m so busy these days. School, work and code. GOD ! Itโ€™s frustrating.</li> </ol> <h1 id="plans">Plans</h1> <p>I have new plans to achieve and I hope I can do it. Iโ€™m going to get back the fire I once had. I will.</p> <h2 id="new-company">New Company</h2> <p>Me and some friends are planning to create a company in my locality. We have high hopes for it. It may even grow to be an international company.</p> <p>The name hasnโ€™t been decided. It will be decided after the domain is purchased.</p> <p>I will tell more about it later.</p> <h2 id="logsys">logSys</h2> <p>I have plans to improveย <strong>logSys</strong> and add new features to it.</p> <ol> <li> <h3 id="2-stepfactor-authentication">2 Step/Factor Authentication</h3> </li> </ol> <pre><code>I&amp;#8217;m planning to add a 2 Step Verification on login from a new browser. A secret token will be sent to the user to verify that the user is the original owner. This secret token will be sent by E-Mail or Mobile (your choice). So, anyone want this enhancement ? Do you want this, then see &lt;a href=&quot;https://github.com/subins2000/logSys/issues/7&quot; target=&quot;_blank&quot;&gt;this&lt;/a&gt;ย and comment on it.&lt;/li&gt; * ### logSys Advanced Many of the comments in logSys was the need to have an admin panel to manage users. Though you can do this with **phpMyAdmin**, it will be a nice feature forย **logSys** to have this. I plan to make this by adding user roles. Each user would have special roles. Only certain users with role can access some pages and others. It&amp;#8217;s better if all this is integrated into a new class. So, a new class is going to be created which will be a fork of logSys. It will be called &quot;**logSys Advanced**&quot;. It will be Open Source just like logSys.&lt;/li&gt; &lt;/ol&gt; What do you think ? Do you have any extra suggestions ? Please comment. </code></pre> Set Same Time Zone in PHP & MySQL https://subinsb.com/php-mysql-same-time-zone/ Sun, 21 Jun 2015 20:30:20 +0000 https://subinsb.com/php-mysql-same-time-zone/ <p>Time Zones are important if youโ€™re creating a social app which will include chat, social network and others which is interacted with the society.</p> <p>There are many time zones and you have to choose one to set in your server. I would totally recommend usingย <strong>UTC</strong> instead of your time zone in server.</p> <p><strong>Web Server</strong> andย <strong>Database server</strong> are different and they each have their own configuration. This includes the time zone too. In this short post, Iโ€™m going to show how you can set the same time zone in both of these servers.</p> <h1 id="php">PHP</h1> <p>This is the most simplest one :</p> <pre class="prettyprint"><code>date_default_timezone_set("UTC");</code></pre> <p>Do the above before any other code.</p> <h1 id="mysql">MySQL</h1> <p>You can set timezone inย <strong>MySQL</strong> with this smallย <strong>SQL</strong> code :</p> <pre class="prettyprint"><code>SET GLOBAL time_zone = '+00:00';</code></pre> <p>But in servers likeย <strong>OpenShift</strong>, the above wonโ€™t work as the time zone will be resetted back after a server restart. So, the above is no avail in hosting providers like this.</p> <p>So, we must useย <strong>PHP</strong> itself to set the time zone inย <strong>MySQL</strong> server. Execute the followingย <strong>SQL</strong> code just after the opening of <strong>MySQ****L</strong> connection :</p> <pre class="prettyprint"><code>SET time_zone = '+00:00';</code></pre> <p>An example inย <strong>PDO</strong> :</p> <pre class="prettyprint"><code>$dbh=new PDO('mysql:dbname=mydb;host=localhost;port=3306',$username, $password); $dbh-&gt;exec("SET time_zone='+00:00';");</code></pre> <p>Any otherย <strong>SQL</strong> operations must only follow after the above code execution.</p> Implement 5 Star Rating System With PHP & JavaScript https://subinsb.com/francium-star/ Tue, 16 Jun 2015 03:30:53 +0000 https://subinsb.com/francium-star/ <p>User ratings are important for your site if you provide downloads of files or run an E-Commerce shop. It is the ratings of other users that tempt your siteโ€™s users to buy/download something. So, it is necessary for a site like this to have aย <strong>Rating System</strong>. If you havenโ€™t implemented it yet or want to replace your existing system with a clean one, youโ€™re at the right place.</p> <p>I give to you,ย <strong>Francium Star</strong> : a new member in ourย <strong><a href="//subinsb.com/the-francium-project" target="_blank">Francium Project</a></strong> series. This PHP &amp; JS combined package will provide your site a complete Rating System and itโ€™s very easy to implement.</p> <div class="padlinks"> <a class="download" href="https://github.com/subins2000/Francium-Star/archive/master.zip" target="_blank">Download</a><a class="demo" href="http://demos.subinsb.com/Francium/Star/" target="_blank">Demo</a> </div> <h1 id="php">PHP</h1> <p>The server side consists ofย <strong>4</strong> <strong>PHP</strong> files including the index page. Other files are :</p> <ul> <li>Fr.star.php</li> <li>config.php</li> <li>ajax_rate.php</li> </ul> <h2 id="frstarphp">Fr.star.php</h2> <p>This is theย <strong>heart</strong> of the rating system. Get the complete file from <a href="https://github.com/subins2000/Francium-Star/blob/master/Fr.star.php" target="_blank">here</a>.</p> <h2 id="database">Database</h2> <p>Create a table named &quot;Fr_star&quot; in your database with the SQL code below :</p> <pre class="prettyprint"><code>CREATE TABLE IF NOT EXISTS `Fr_star` ( `id` INT(11) NOT NULL AUTO_INCREMENT, `rate_id` varchar(40) NOT NULL, `user_id` varchar(40) NOT NULL, `rate` float NOT NULL, `rated` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (`id`) ) </code></pre> <h2 id="configphp">config.php</h2> <p>We include the &quot;Fr.star.php&quot; in the file and we provide the database configuration in this file. Example :</p> <pre class="prettyprint"><code>&lt;?php require_once __DIR__ . "/Fr.star.php"; $star = new \Fr\Star(array( "db" =&gt; array( "host" =&gt; getenv('OPENSHIFT_MYSQL_DB_HOST'), "port" =&gt; getenv('OPENSHIFT_MYSQL_DB_PORT'), "username" =&gt; getenv('OPENSHIFT_MYSQL_DB_USERNAME'), "password" =&gt; getenv('OPENSHIFT_MYSQL_DB_PASSWORD'), "name" =&gt; getenv('OPENSHIFT_GEAR_NAME'), "table" =&gt; "Fr_star" ) )); </code></pre> <p>This &quot;config.php&quot; will be included in the AJAX request receiving script as well as the index file.</p> <h2 id="ajax_ratephp">ajax_rate.php</h2> <p>JavaScript sendsย <strong>AJAX</strong> request to this file. This file processes the rating action and tellsย <strong>\Fr\Star</strong> to add a rating.</p> <pre class="prettyprint"><code>&lt;?php // This is where AJAX would sent request to if(isset($_POST['id']) && isset($_POST['rating']) && $_POST['id'] == "index_page"){ session_start(); require_once __DIR__ . "/config.php"; $star-&gt;id = $_POST['id']; $star-&gt;addRating($_SESSION['user_id'], $_POST['rating']); } </code></pre> <p>Let me explain what this file do.</p> <ol> <li>It first checks whether values &quot;id&quot; and &quot;rating&quot; exists in the POST data. Also, it checks whether the <strong>page ID</strong> is &quot;index_page&quot;. It is recomended to check the IDs before rating.</li> <li>The PHP session is started and the &quot;config.php&quot; is included in the script.</li> <li>We tell \Fr\Star the ID of the page. Optionally, you can tell this page ID as the second parameter while making the object.</li> <li>Finally, we call theย <strong>\Fr\Star::addRating()</strong> function to insert the rating data into database.</li> </ol> <h2 id="indexphp">index.php</h2> <p>This is the page that the user will see. It includes the <strong>JavaScript &amp; CSS</strong> components of the Francium Star software and shows examples of the usage :</p> <pre class="prettyprint"><code>&lt;?php // Generate a user ID for the session only session_start(); if(!isset($_SESSION['user_id'])){ $_SESSION['user_id'] = rand(0, 1024); } ?&gt; &lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;link rel="stylesheet" href="css/Fr.star.css" /&gt; &lt;script src="//lab.subinsb.com/projects/jquery/core/jquery-latest.js"&gt;&lt;/script&gt; &lt;script src="//lab.subinsb.com/projects/Francium/star/Fr.star.js"&gt;&lt;/script&gt; &lt;script src="js/rate.js"&gt;&lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;h1&gt;Francim Star&lt;/h1&gt; &lt;p&gt;Rating for "index_page" :&lt;/p&gt; &lt;?php require_once __DIR__ . "/config.php"; $star-&gt;id = "index_page"; echo "Rating :"; echo $star-&gt;getRating("userChoose size-1"); echo "&lt;p&gt;Your Rating :&lt;/p&gt;"; echo $star-&gt;userRating($_SESSION['user_id']); echo "&lt;p&gt;^- You will have to refresh page to update the above value&lt;/p&gt;"; echo "&lt;h2&gt;Different Sizes&lt;/h2&gt;"; echo "&lt;p&gt;170x30" . $star-&gt;getRating("userChoose size-2") . "&lt;/p&gt;"; echo "&lt;p&gt;115x20" . $star-&gt;getRating("userChoose size-3") . "&lt;/p&gt;"; echo "&lt;p&gt;55x10" . $star-&gt;getRating("userChoose size-4") . "&lt;/p&gt;"; echo "&lt;h2&gt;Just Show It !&lt;/h2&gt;"; echo "&lt;p&gt;170x30" . $star-&gt;getRating("size-2") . "&lt;/p&gt;"; echo "&lt;p&gt;115x20" . $star-&gt;getRating("size-3") . "&lt;/p&gt;"; echo "&lt;p&gt;55x10" . $star-&gt;getRating("size-4") . "&lt;/p&gt;"; ?&gt; &lt;!-- NOTICE - http://subinsb.com/francium-star --&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>Note that the above script generates aย <strong>unique user ID</strong> at the beginning of each session. This user ID can be anย <strong>IP</strong> address or the actual user ID of the logged in user.</p> <p>It is the <strong>JavaScript</strong> andย <strong>CSS</strong> part of the software that enables the user to rate in the browser. Hence, it is an important part of the software as well.</p> <h1 id="javascript">JavaScript</h1> <p><strong>jQuery is not needed</strong> for Francium Star, but it is included to easily send theย <strong>AJAX</strong> request.</p> <h2 id="frstarjs">Fr.star.js</h2> <p>You can call this file a libraryย ofย <strong>JavaScript</strong> andย <strong>jQuery</strong>. Because it will work with native JS as well as like a plugin ofย <strong>jQuery</strong>. You will see more about this in theย <strong>API</strong> section of this post.</p> <p>Get this file from <a href="//lab.subinsb.com/projects/Francium/star/Fr.star.js" target="_blank">here</a>ย if you want to include this locally instead of the lab.subinsb.com URL.</p> <p>If you want a minified version, <a href="//lab.subinsb.com/projects/Francium/star/Fr.star.min.js" target="_blank">see this</a>.</p> <h2 id="jsratejs">js/rate.js</h2> <p>This file makes the rating divs functionable. It also sends the <strong>AJAX</strong> request.</p> <pre class="prettyprint"><code>$(function(){ $(".Fr-star.userChoose").Fr_star(function(rating){ $.post("ajax_rate.php", {'id' : 'index_page', 'rating': rating}, function(){ alert("Rated " + rating + " !!"); }); }); }); </code></pre> <p>As I said before,ย <strong>Fr\Star</strong> can be used as aย <strong>jQuery</strong> function too.</p> <h1 id="css">CSS</h1> <p>There is only one file for styling the rating divs. Itโ€™sย <strong>css/Fr.star.css</strong></p> <pre class="prettyprint"><code>*{ box-sizing: border-box; -moz-box-sizing: border-box; -webkit-box-sizing: border-box; } .Fr-star { width: 225px; height: 40px; position: relative; background-color: #ccc; } .Fr-star[data-title]:hover:after { content: attr(data-title); padding: 4px 8px; color: #333; position: absolute; left: 0; top: 100%; z-index: 20; white-space: nowrap; -moz-border-radius: 5px; -webkit-border-radius: 5px; border-radius: 5px; -moz-box-shadow: 0px 0px 4px #222; -webkit-box-shadow: 0px 0px 4px #222; box-shadow: 0px 0px 4px #222; background-image: -moz-linear-gradient(top, #eeeeee, #cccccc); background-image: -webkit-gradient(linear,left top,left bottom,color-stop(0, #eeeeee),color-stop(1, #cccccc)); background-image: -webkit-linear-gradient(top, #eeeeee, #cccccc); background-image: -moz-linear-gradient(top, #eeeeee, #cccccc); background-image: -ms-linear-gradient(top, #eeeeee, #cccccc); background-image: -o-linear-gradient(top, #eeeeee, #cccccc); } .Fr-star .Fr-star-bg{ position: absolute; height: 100%; width: 100%; background: url(../img/Fr-star.png) repeat; background-size: contain; } .Fr-star .Fr-star-value{ height: 100%; position: absolute; background-color: #ffbe10; } .Fr-star.size-2{ width: 170px; height: 30px; } .Fr-star.size-3{ width: 115px; height: 20px; } .Fr-star.size-4{ width: 55px; height: 10px; } </code></pre> <p>There is an image of star that is needed by the above file. Download it from one of the following and move it into a folder called &quot;img&quot; at the root of the site.</p> <ul> <li><a href="https://raw.githubusercontent.com/subins2000/Francium-Star/master/img/Fr-star.png" target="_blank">PNG</a></li> <li><a href="https://raw.githubusercontent.com/subins2000/Francium-Star/master/img/Fr-star.svg" target="_blank">SVG</a></li> <li><a href="https://raw.githubusercontent.com/subins2000/Francium-Star/master/img/Fr-star.svgz">SVGZ</a></li> </ul> <p>When you change the location of the image file, make sure to change the value of the &quot;background&quot; property of &quot;.Fr-star-bg&quot; in the stylesheet too.</p> <h1 id="api">API</h1> <p>What you saw above was an example of the rating system. In here, Iโ€™m going to show the syntax of each functions that is inย <strong>PHP</strong> andย <strong>JavaScript</strong>/<strong>jQuery</strong>.</p> <h2 id="php-1">PHP</h2> <h3 id="frstar__construct">\Fr\Star::__construct()</h3> <pre class="prettyprint"><code>$star = new \Fr\Star($config, $id = null);</code></pre> <p><strong>$id</strong> is the pageโ€™s ID andย <strong>$config</strong> is an array that will be merged with the default configuration (\Fr\Star::$default_config).</p> <h3 id="frstaraddrating">\Fr\Star::addRating()</h3> <pre class="prettyprint"><code>$star-&gt;addRating($user_id, $rating)</code></pre> <p><strong>$user_id</strong> is the userโ€™s ID andย <strong>$rating</strong> is a float value of the rating by the user.</p> <h3 id="frstargetrating">\Fr\Star::getRating()</h3> <pre class="prettyprint"><code>$star-&gt;getRating($html_class = "", $type = "html")</code></pre> <p>If you would like to add extra CSS &quot;class&quot; to the HTML element created by the above function, add the class name toย <strong>$html_class</strong>ย parameter.</p> <p>You can also get the plain rating, instead of anย <strong>HTML</strong> formatted one. The possible values for <strong>$type</strong> are :</p> <ul> <li>rate_value</li> <li>rate_percentage</li> <li>rate_times</li> </ul> <p>I hope you got what the returning values will be when the above values are given.</p> <h3 id="frstaruserrating">\Fr\Star::userRating()</h3> <pre class="prettyprint"><code>$star-&gt;userRating($user_id);</code></pre> <p>Get the rating made by a specific user. The userโ€™s ID should be passed (not optional) by the only parameterย <strong>$user_id</strong>.</p> <h2 id="javascriptjquery">JavaScript/jQuery</h2> <pre class="prettyprint"><code>Fr.star(element, callback_after_rating());</code></pre> <p>`element` is aย <strong>DOM</strong>ย object. `callback_after_rating()` is a function that will be called after the user has rated with a parameter containing the rating value.</p> <p>Example :</p> <pre class="prettyprint"><code>Fr.star(document.querySelector(".Fr-star"), function(rating){ alert("User rated : " + rating); });</code></pre> <p>There is no other functions inย <strong>JavaScript</strong>. There is aย <strong>jQuery</strong> wrapper for this function :</p> <pre class="prettyprint"><code>$(".Fr-star").Fr_star(function(rating){ alert("User rated : " + rating); });</code></pre> <p>That is everything onย <strong>Francium Star</strong>. This is the firstย <strong>Francium</strong> project that uses Object class instead of static. I hope you found what you were looking for.</p> <p>If you have any suggestions or faced a problem, please feel free to comment. Iโ€™ll help ๐Ÿ™‚</p> Advanced Live Group Chat With WebSocket, PHP & jQuery https://subinsb.com/php-websocket-advanced-chat/ Tue, 09 Jun 2015 03:30:51 +0000 https://subinsb.com/php-websocket-advanced-chat/ <p><strong>WebSocket</strong> is one of the awesomest part of theย <strong>HTML5</strong> and we developers should experiment with it as it will be the future of client to server communication.</p> <p>In a recent post, I made a tutorial of <a href="//subinsb.com/live-group-chat-with-php-jquery-websocket" target="_blank">live chat with WebSockets and PHP</a>. It was the basic step into websockets. But, I have created another chat which is more advanced that has the capability toย <strong>upload images</strong> as well asย <strong>record audio</strong> from microphone of the user. Itโ€™s somewhat likeย <strong>WhatsApp</strong> or <strong>Facebook Messenger</strong>.</p> <div class="padlinks"> <a class="demo" href="//demos.subinsb.com/php/advanced-chat-websocket" target="_blank">Demo</a><a class="download" href="//demos.subinsb.com/down.php?class=40" target="_blank">Download</a> </div> <p>For this, you will need aย <strong>WebSocket</strong> server and a web server (localhost).</p> <h1 id="features">Features</h1> <ul> <li>Basic text messaging</li> <li>Anyone can join chat</li> <li>Voice messages</li> <li>Send images</li> <li>Live messaging</li> </ul> <p>This tutorial has two parts, one for setting up the website and the other for setting up the WebSocket server.</p> <h1 id="website">Website</h1> <p>The client doesnโ€™t necessarily need to be PHP, because we arenโ€™t gonna process the data here. But, since we are uploading images as well as audio, we should make files in the client site itself to upload these files.</p> <h2 id="indexphp">index.php</h2> <p>This is the file the users would see to chat :</p> <pre class="prettyprint"><code>&lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;script src="//lab.subinsb.com/projects/jquery/core/jquery-2.1.1.js"&gt;&lt;/script&gt; &lt;script src="//lab.subinsb.com/projects/Francium/voice/recorder.js"&gt;&lt;/script&gt; &lt;script src="//lab.subinsb.com/projects/Francium/voice/Fr.voice.js"&gt;&lt;/script&gt; &lt;script src="js/time.js"&gt;&lt;/script&gt; &lt;script src="js/chat.js"&gt;&lt;/script&gt; &lt;link href="css/chat.css" rel="stylesheet"/&gt; &lt;title&gt;Subin's Blog - Advanced Live Group Chat&lt;/title&gt; &lt;/head&gt; &lt;body&gt; &lt;div id="content"&gt; &lt;center&gt;&lt;h1&gt;Advanced Live Group Chat&lt;/h1&gt;&lt;/center&gt; &lt;p&gt;&lt;a href="//subinsb.com/php-websocket-advanced-chat"&gt;Tutorial&lt;/a&gt;&lt;/p&gt; &lt;div class="chatWindow"&gt; &lt;div style="display: none;postion: absolute;"&gt; &lt;input type="file" id="photoFile" accept="image/*" /&gt; &lt;audio src="cdn/message.wav" controls="false" id="notification"&gt;&lt;/audio&gt; &lt;/div&gt; &lt;div class="users"&gt;&lt;/div&gt; &lt;div class="chatbox"&gt; &lt;div class="topbar"&gt; &lt;span id="status" title="Click to Login/Logout"&gt;Offline&lt;/span&gt; &lt;span id="fullscreen" title="Toggle Fullscreen of Chat Box"&gt;Fullscreen&lt;/span&gt; &lt;/div&gt; &lt;div class="chat"&gt; &lt;div class="msgs"&gt;&lt;/div&gt; &lt;form id="msgForm"&gt; &lt;textarea name="msg" placeholder="Type message here...."&gt;&lt;/textarea&gt; &lt;a class="button" id="voice" title="Click to start recording message"&gt;&lt;/a&gt; &lt;a class="button" id="photo" title="Type in a message and choose image to send"&gt;&lt;/a&gt; &lt;/form&gt; &lt;/div&gt; &lt;div class="login"&gt; &lt;p&gt;Type in your name to start chatting !&lt;/p&gt; &lt;form id="loginForm"&gt; &lt;input type="text" value="" /&gt; &lt;button&gt;Submit&lt;/button&gt; &lt;/form&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/body&gt; &lt;/html&gt;</code></pre> <p>It has a basic layout with some resources loaded in the head.</p> <h2 id="uploadphp">upload.php</h2> <p>This file handles the uploads such as images and audios. It will upload the file into a folder named &quot;uploads&quot; in the root directory of the site. So, you should create that folder and set the permission of it to &quot;Read &amp; Write&quot;.</p> <p>Here is the upload.php file :</p> <pre class="prettyprint"><code>&lt;?php if(isset($_FILES['file'])){ $file = file_get_contents($_FILES['file']['tmp_name']); $f = finfo_open(); $mime_type = finfo_buffer($f, $file, FILEINFO_MIME_TYPE); $supported_types = array( "audio/x-wav" =&gt; "wav", "image/png" =&gt; "png", "image/jpeg" =&gt; "jpg", "image/pjpeg" =&gt; "jpg", "image/gif" =&gt; "gif" ); $extension = isset($supported_types[$mime_type]) ? $supported_types[$mime_type] : false; if($extension !== false){ $fileName = rand(10000, 65000) . "." . $extension; $location = __DIR__ . "/uploads/" . $fileName; move_uploaded_file($_FILES['file']['tmp_name'], $location); echo $fileName; } }</code></pre> <p>You can see that the upload file checks the type of the file and then only it uploads to the server. When it is uploaded, the file name is outputted.</p> <h2 id="heading"></h2> <h2 id="jstimejs">js/time.js</h2> <p>You might have heard about theย <strong>jQuery</strong>ย <strong>Timeago</strong>ย plugin. This file has the plugin with some little modifications. Download it from <a href="http://demos.subinsb.com/php/advanced-chat-websocket/js/time.js" target="_blank">here</a>.</p> <h2 id="jschatjs">js/chat.js</h2> <p>This is the heart of the chat. All functions related to the chat in the client are processed by this file such as connection to the server, sending messages, uploading files and othersโ€ฆ</p> <p>You can get this file from <a href="https://github.com/subins2000/ws-advanced-live-group-chat/blob/master/js/chat.js">here</a>.</p> <h2 id="heading-1"></h2> <h2 id="csschatcss">css/chat.css</h2> <p>This file will decorate the chat box. We are adding just a simple design.</p> <p>You can get this file from <a href="https://github.com/subins2000/ws-advanced-live-group-chat/blob/master/css/chat.css">here</a>.</p> <h2 id="assetsmessagewav">assets/message.wav</h2> <p>There is something else too in this chat. A notification sound. When new messages are retrieved, a sound will be also played. You can download this file from <a href="http://demos.subinsb.com/php/advanced-chat-websocket/assets/message.wav" target="_blank">here</a>. Thanks to the open source softwareย <strong>Pidgin IM</strong> for this sound.</p> <h2 id="assets">assets</h2> <p>The &quot;assets&quot; folderย should contain 3 images :</p> <ul> <li><a href="//demos.subinsb.com/php/advanced-chat-websocket/cdn/img/camera.png" target="_blank">camera.png</a></li> <li><a href="//demos.subinsb.com/php/advanced-chat-websocket/cdn/img/mic.png" target="_blank">mic.png</a></li> <li><a href="//demos.subinsb.com/php/advanced-chat-websocket/cdn/img/mic-active.png" target="_blank">mic-active.png</a></li> </ul> <p>These files are for the advanced part of the chat. With advancement comes more resources !</p> <h1 id="websocket-server">WebSocket Server</h1> <p>Letโ€™s move on to theย <strong>WebSocket</strong>ย <strong>Server</strong>. This part handles the messages and does all the work to make the chat functional and awesome.</p> <h2 id="database">Database</h2> <p>The server has theย <strong>Database</strong>, so create the tables first :</p> <pre class="prettyprint"><code>CREATE TABLE `wsAdvancedChat` ( `id` int(11) NOT NULL PRIMARY KEY AUTO_INCREMENT, `user` varchar(20) NOT NULL, `msg` varchar(100) NOT NULL, `type` varchar(10) NOT NULL, `file_name` varchar(100) NOT NULL, `posted` datetime NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1; </code></pre> <p>Make sure the database <a href="http://stackoverflow.com/questions/5359495/how-to-change-a-mysql-database-to-utc" target="_blank">time zone is set toย <strong>UTC</strong>.</a></p> <p>Then you should create a configuration file that will provide the credentials to connect to the database :</p> <h2 id="configphp">config.php</h2> <p>We are going to useย <strong>PDO</strong> for the connection withย <strong>MySQL</strong> :</p> <pre class="prettyprint"><code>&lt;?php ini_set("display_errors","on"); $docRoot = realpath(dirname(__FILE__)); if( !isset($dbh) ){ session_start(); date_default_timezone_set("UTC"); $musername = "root"; $mpassword = "password"; $hostname = "127.0.0.1"; $dbname = "test"; $port = "3306"; $dbh = new PDO("mysql:dbname={$dbname};host={$hostname};port={$port}", $musername, $mpassword); /** * Change The Credentials to connect to database. */ } ?&gt; </code></pre> <p>We also set the timezone toย <strong>UTC</strong> which is the same for database server and PHP server.</p> <p>We will useย <strong>Francium DiffSocket</strong> to set up our WebSocket server. In the &quot;server&quot; directory, run :</p> <pre class="prettyprint"><code>composer require francium/diffsocket </code></pre> <p>Once DiffSocket is installed, we should set up the server class and the script to run the server.</p> <h2 id="serveradvancedchatserverphp">server/AdvancedChatServer.php</h2> <p>This file gets the sent message from server and inserts it into database. It also sendsย the messages in the database to the users when asked. In fact, this is the server who does everything for its clients.</p> <p>You can get this file fromย <a href="https://github.com/subins2000/ws-advanced-live-group-chat/blob/master/server/AdvancedChatServer.php">here</a>.</p> <h2 id="serverrun-serverphp">server/run-server.php</h2> <p>To add our &quot;Advanced Chat&quot; service and start the server, we must create another file :</p> <pre class="prettyprint"><code>&lt;?php require_once __DIR__ . "/config.php"; require_once __DIR__ . "/vendor/autoload.php"; $ip = "127.0.0.1"; $port = "8000"; $DS = new Fr\DiffSocket(array( "host" =&gt; $ip, "port" =&gt; $port )); $server-&gt;run(); </code></pre> <p>If youโ€™re going to change theย <strong>$ip</strong> andย <strong>$port</strong>ย variables, you should also change the WebSocket URL in theย &quot;chat.js&quot; file.</p> <p>When you need to start the server, just run the &quot;run-server.php&quot; file :</p> <pre class="prettyprint"><code>php run-server.php</code></pre> <p>When new users are connected, a message will be shown in the shell that is something like this :</p> <pre class="prettyprint"><code>New connection! (29)</code></pre> <p>Each users connected (clients) will have a unique ID.</p> <p>Open the website we set up, enter your name and voila !</p> <p>There you go ! You just set up your own advanced chat system.</p> Notebook Paper Design Text Editor With jQuery https://subinsb.com/jquery-paper-design-text-editor/ Mon, 08 Jun 2015 03:30:20 +0000 https://subinsb.com/jquery-paper-design-text-editor/ <p>Hey, all.. itโ€™s been a while since I wrote anything on my blog. Sorry guys, but I was working on a project which will be released soon. ๐Ÿ™‚</p> <p>WYSIWYG editors are used by us all on the web and if we are going to create a site, itโ€™s better if the editor on it is WYSIWYG. There are many text editors, but there are none with a Notebook Paper design. Well, in this post I will guide you in creating a notebook paper withย <strong>CSS3</strong> and making that paper design into a text editor.</p> <div class="padlinks"> <a class="download" href="http://demos.subinsb.com/down.php?class=39" target="_blank">Download</a><a class="demo" href="http://demos.subinsb.com/css/notebook" target="_blank">Demo</a> </div> <p>Yes, this requiresย <strong>HTML5</strong> and you can easily modify it to suit your needs. Letโ€™s begin.</p> <h1 id="html">HTML</h1> <h2 id="indexhtml">index.html</h2> <p>We will be making the layout first. Itโ€™s minimal and there are 5 resources loaded.</p> <pre class="prettyprint"><code>&lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;script src="//lab.subinsb.com/projects/jquery/core/jquery-latest.js"&gt;&lt;/script&gt; &lt;script src="js/jquery.notebook.js"&gt;&lt;/script&gt; &lt;link href="css/font-awesome.css" rel="stylesheet" /&gt; &lt;link href="css/jquery.notebook.css" rel="stylesheet" /&gt; &lt;link href="css/style.css" rel="stylesheet" /&gt; &lt;/head&gt; &lt;body&gt; &lt;div id="content"&gt; &lt;center&gt;&lt;h1&gt;Paper&lt;/h1&gt;&lt;/center&gt; &lt;div class="paper-wrapper"&gt; &lt;div class="paper"&gt; &lt;h2 style="margin: 0px;"&gt;HEADING&lt;/h2&gt; &lt;div class="entry"&gt;&lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>A file called &quot;font-awesome.css&quot; is loaded. This file requires font files which should be stored in a folder called &quot;fonts&quot; in the root directory of website. Here are theย font files to download :</p> <ul> <li><a href="//demos.subinsb.com/css/notebook/fonts/fontawesome-webfont.eot" target="_blank">fontawesome-webfont.eot</a></li> <li><a href="//demos.subinsb.com/css/notebook/fonts/fontawesome-webfont.svg" target="_blank">fontawesome-webfont.svg</a></li> <li><a href="//demos.subinsb.com/css/notebook/fonts/fontawesome-webfont.ttf" target="_blank">fontawesome-webfont.ttf</a></li> <li><a href="//demos.subinsb.com/css/notebook/fonts/fontawesome-webfont.woff" target="_blank">fontawesome-webfont.woff</a></li> </ul> <p>After you placed these into the &quot;fonts&quot; folder, create folders &quot;css&quot; and &quot;js&quot; in the root directory.</p> <p>And then, download <a href="//demos.subinsb.com/css/notebook/css/jquery.notebook.css" target="_blank">jquery.notebook.css</a>ย and <a href="//demos.subinsb.com/css/notebook/css/font-awesome.css" target="_blank">font-awesome.css</a> files and move them into the &quot;css&quot; folder.</p> <p>Donโ€™t forget to make sure that the links to the fonts in the &quot;font-awesome.css&quot; file is correct.</p> <h1 id="css">CSS</h1> <h2 id="cssstylecss">css/style.css</h2> <p>We add our custom styles in to this file and also, the CSS for making the notebook paper design is in this file :</p> <pre class="prettyprint"><code>.paper-wrapper{ position: relative; height: 100%; margin: 20px 0 0; padding: 0; /* gradients - second red border, first red border, top white space, blue lines */ background-image: -webkit-linear-gradient(left, rgba(255,85,91, .2), rgba(255,85,91, .2)), -webkit-linear-gradient(left, rgba(255,85,91, .8), rgba(255,85,91, .8)), -webkit-linear-gradient(top, white 0px, white 69px, rgba(255,255,255,0) 70px), -webkit-repeating-linear-gradient(white 0px, white 18px, #A6FFED 19px, white 20px); background-image: -moz-linear-gradient(left, rgba(255,85,91, .2), rgba(255,85,91, .2)), -moz-linear-gradient(left, rgba(255,85,91, .8), rgba(255,85,91, .8)), -moz-linear-gradient(top, white 0px, white 69px, rgba(255,255,255,0) 70px), -moz-repeating-linear-gradient(white 0px, white 18px, #A6FFED 19px, white 20px); background-image: -ms-linear-gradient(left, rgba(255,85,91, .2), rgba(255,85,91, .2)), -ms-linear-gradient(left, rgba(255,85,91, .8), rgba(255,85,91, .8)), -ms-linear-gradient(top, white 0px, white 69px, rgba(255,255,255,0) 70px), -ms-repeating-linear-gradient(white 0px, white 18px, #A6FFED 19px, white 20px); background-image: -o-linear-gradient(left, rgba(255,85,91, .2), rgba(255,85,91, .2)), -o-linear-gradient(left, rgba(255,85,91, .8), rgba(255,85,91, .8)), -o-linear-gradient(top, white 0px, white 69px, rgba(255,255,255,0) 70px), -o-repeating-linear-gradient(white 0px, white 18px, #A6FFED 19px, white 20px); background-image: linear-gradient(left, rgba(255,85,91, .2), rgba(255,85,91, .2)), linear-gradient(left, rgba(255,85,91, .8), rgba(255,85,91, .8)), linear-gradient(top, white 0px, white 69px, rgba(255,255,255,0) 70px), repeating-linear-gradient(white 0px, white 18px, #A6FFED 19px, white 20px); background-size: 1px, 1px, auto, auto 30px; background-repeat: repeat-y, repeat-y, no-repeat, repeat; background-position: 90% 0px, 10% 0px, 0px 0px, 0px 0px; } .paper { margin: 0; display: block; min-height: 100%; font: 13pt Arial, sans-serif; line-height: 30px; padding-top: 50px; padding-left: 10.5%; padding-right: 10.5%; text-align: justify; } .paper p{ position: relative; min-height: 30px !important; margin: 0; z-index: 2; } .paper p:first-child{ text-indent: 80px; } .paper:after { content: ''; display: block; width: 20px; height: 20px; border-radius: 10px; position: absolute; background: rgba(255,255,255,1); top: 40px; left: 2%; z-index: 10; -webkit-box-shadow: inset 2px 2px 5px rgba(125,125,125,1), 2px 50.1em 5px rgba(255,255,255,1), 0px 50em rgba(125,125,125,.75), 2px 90.1em 5px rgba(255,255,255,1), 0px 90em rgba(125,125,125,.5), 2px 130.1em 5px rgba(255,255,255,1), 0px 130em rgba(125,125,125,.25); -moz-box-shadow: inset 2px 2px 5px rgba(125,125,125,1), 2px 50.1em 5px rgba(255,255,255,1), 0px 50em rgba(125,125,125,.75), 2px 90.1em 5px rgba(255,255,255,1), 0px 90em rgba(125,125,125,.5), 2px 130.1em 5px rgba(255,255,255,1), 0px 130em rgba(125,125,125,.25); box-shadow: inset 2px 2px 5px rgba(125,125,125,1), 2px 50.1em 5px rgba(255,255,255,1), 0px 50em rgba(125,125,125,.75), 2px 90.1em 5px rgba(255,255,255,1), 0px 90em rgba(125,125,125,.5), 2px 130.1em 5px rgba(255,255,255,1), 0px 130em rgba(125,125,125,.25); } .paper:focus { outline: none; } .paper .entry{ min-height: 300px; } </code></pre> <p>There arenโ€™t any resources loaded in the above file. So, leave it as it is.</p> <h1 id="javascript">JavaScript</h1> <p>Download the <a href="//demos.subinsb.com/css/notebook/js/jquery.notebook.js" target="_blank">jquery.notebook.js</a> file and move it into the &quot;js&quot; folder.</p> <p>Add the followingย <strong>script</strong> tag inside theย <strong>index.html</strong> file before </body> :</p> <pre class="prettyprint"><code>&lt;script&gt; $(document).ready(function(){ $(".paper .entry").notebook(); }); &lt;/script&gt;</code></pre> <p>Thatโ€™s all you need. The text editor is powered by <strong>JS</strong>, but the style and most part is because ofย <strong>CSS</strong>. Thank you for reading and I hope it helped.</p> jQuery Popping Up Text Effect https://subinsb.com/jquery-effect-popup-text/ Thu, 23 Apr 2015 03:30:47 +0000 https://subinsb.com/jquery-effect-popup-text/ <p>If you are creating a web app and there is conversation to the user without audio and just text, animations and effect will make the app better.</p> <p>In this short post, Iโ€™m introducing a simple text effect without any trouble at all. All it does is animate the textโ€™s font size. But, the effect is like the text is popping up.</p> <div class="padlinks"> <a class="demo" href="https://jsfiddle.net/subins2000/jx94ecfp/" target="_blank">Demo</a> </div> <p>Hereโ€™s the code. Itโ€™s wrapped in a function and you can easily customize it :</p> <pre class="prettyprint"><code>function pop_up(){ var begin_size = 10; var end_size = 60; var speed = 3000; $("&lt;strong>.container&lt;/strong>").css("font-size", begin_size).animate({"font-size" : end_size}, speed); } pop_up();</code></pre> <p>In the above code, it is assumed that the elementย <strong>.container</strong> has text inside it.</p> <p>What it does is change the font size to a smaller one, then animate the font-size value to a bigger one.</p> Resuming Download In Wget, cURL & aria2c https://subinsb.com/resume-download-wget-curl-aria2c/ Wed, 22 Apr 2015 04:30:32 +0000 https://subinsb.com/resume-download-wget-curl-aria2c/ <p>We all download stuffs and we want it to be perfect. No lagging, just download the fastest way, right ?</p> <p>I donโ€™t download via browsers these days, because it is too slow (&lt; 5 KB/s). Google Chrome downloads are the worst. So, I download via command line now.</p> <p>Not all downloading is easy. Sometimes it will break up. So, we must resume it. Only some servers allow to resume downloads. But, we need client softwares that is able to resume downloads.</p> <p>There are lots of software that can be used to download inย <strong>Linux</strong> andย <strong>Windows</strong>. Most of them are GUIs. But, I like using commands.</p> <p>In this post, Iโ€™m going to say how to resume downloads in <strong>wGet</strong>,ย <strong>cURL</strong> andย <strong>aria2c</strong>. Since, I useย <strong>Ubuntu</strong>, you should read the stuff <strong>Ubuntu Linux</strong>ย โ€“ wise.</p> <h1 id="curl">cURL</h1> <p>If you useย <strong>PHP</strong>, you can see that it has a default <strong>cURL</strong> extension. It is one of the most popular tools to download. But, it is complicated and not as easy asย <strong>wGet</strong> orย <strong>aria2c</strong>.ย <strong>Chrome</strong> usesย <strong>cURL</strong> and you can get theย <strong>cURL</strong> command of a file using the Developer Tools (F12) in Chrome.</p> <p>Install it by :</p> <pre class="prettyprint"><code>sudo apt-get install curl</code></pre> <p>And here is the command to download</p> <pre class="prettyprint"><code>curl -L -C - -o "myfile.zip" "http://example.com/file.zip"</code></pre> <p>Here is what the options mean :</p> <table class="table"> <tr> <td> <h2> <a href="#option"><span id="option">Option</span></a> </h2> </td> <pre><code>&lt;td&gt; &lt;h2&gt; &lt;a href=&quot;#what-it-does&quot;&gt;&lt;span id=&quot;what-it-does&quot;&gt;What It Does&lt;/span&gt;&lt;/a&gt; &lt;/h2&gt; &lt;/td&gt; </code></pre> </tr> <tr> <td> -L </td> <pre><code>&lt;td&gt; Some URLs redirect to some other sites. This option tells cURL to obtain the file from that redirected location. &lt;/td&gt; </code></pre> </tr> <tr> <td> -C &#8211; </td> <pre><code>&lt;td&gt; This option is for telling cURL to resume download and the dash (&quot;-&quot;) that follows it is to automatically detect the size of the file to continue downloading. &lt;/td&gt; </code></pre> </tr> <tr> <td> -o "myfile.zip" </td> <pre><code>&lt;td&gt; This parameter says the output location of the file being downloaded. &lt;/td&gt; </code></pre> </tr> </table> <p>The last quoted value is the URL of the file. This command can be used to download for the first time as well as resuming it later.</p> <h1 id="aria2c">aria2c</h1> <p>What a funny, complicated name, huh ? This command is the easiest one. I use this now to download.</p> <p>You can install it by manually compiling. Forย <strong>Linux</strong>, download the plainย <a href="http://sourceforge.net/projects/aria2/files/stable/aria2-1.18.10/aria2-1.18.10.tar.xz/download" title="Click to download aria2-1.18.10.tar.xz">.tar.xz</a>{.name}ย file. Hereโ€™s the manual compiling commands to use in the directory :</p> <pre class="prettyprint"><code>./configure && sudo make && sudo make install</code></pre> <p>Now, hereโ€™s the command to download files :</p> <pre class="prettyprint"><code>aria2c -c -m 0 -o "myfile.zip" "http://example.com/file.zip"</code></pre> <p>Here is the explanation of each options used in the above command :</p> <table class="table"> <tr> <td> <h2> <a href="#option-2"><span id="option-2">Option</span></a> </h2> </td> <pre><code>&lt;td&gt; &lt;h2&gt; &lt;a href=&quot;#what-it-does-2&quot;&gt;&lt;span id=&quot;what-it-does-2&quot;&gt;What It Does&lt;/span&gt;&lt;/a&gt; &lt;/h2&gt; &lt;/td&gt; </code></pre> </tr> <tr> <td> -c </td> <pre><code>&lt;td&gt; Tells aria2c to resume downloads &lt;/td&gt; </code></pre> </tr> <tr> <td> -m 0 </td> <pre><code>&lt;td&gt; This option will make aria2c retry downloads for unlimited times. Some servers tend to break connection after some time. But, this option makes aria2c to auto retry when such things happen. &lt;/td&gt; </code></pre> </tr> <tr> <td> -o "myfile.zip" </td> <pre><code>&lt;td&gt; This parameter says the output location of the file being downloaded. &lt;/td&gt; </code></pre> </tr> </table> <p>Like before, the last quoted value is the URL of the file.</p> <h1 id="wget">wGet</h1> <p><strong>wGet</strong> is another popular downloading software. Itโ€™s use is similar to that of the other tools. But, one option is different.</p> <p>Install it by :</p> <pre class="prettyprint"><code>sudo apt-get install wget</code></pre> <p>Here is a resumable download command :</p> <pre class="prettyprint"><code>wget -d -c --tries=0 --read-timeout=30 -O "myfile.zip" "http://example.com/file.zip"</code></pre> <p>And here is the explanation of the options used :</p> <table class="table"> <tr> <td> <h2> <a href="#option-3"><span id="option-3">Option</span></a> </h2> </td> <pre><code>&lt;td&gt; &lt;h2&gt; &lt;a href=&quot;#what-it-does-3&quot;&gt;&lt;span id=&quot;what-it-does-3&quot;&gt;What It Does&lt;/span&gt;&lt;/a&gt; &lt;/h2&gt; &lt;/td&gt; </code></pre> </tr> <tr> <td> -d </td> <pre><code>&lt;td&gt; Tells wGet to Download the File &lt;/td&gt; </code></pre> </tr> <tr> <td> -c </td> <pre><code>&lt;td&gt; Tells wGet to resume download &lt;/td&gt; </code></pre> </tr> <tr> <td> &#8211;tries=0 </td> <pre><code>&lt;td&gt; Tells wGet to retry connections unlimitedly when it is interrupted. &lt;/td&gt; </code></pre> </tr> <tr> <td> &#8211;read-timeout=30 </td> <pre><code>&lt;td&gt; If no response is received in 30 seconds, exit and establish a new connection &lt;/td&gt; </code></pre> </tr> <tr> <td> -O "myfile.zip" </td> <pre><code>&lt;td&gt; Sets the output location of the downloaded file. &lt;/td&gt; </code></pre> </tr> </table> <p>Of the above 3, I would certainly recommend usingย <strong>aria2c</strong>, because itโ€™s easy to use and is fast. Have fun downloading .. ๐Ÿ™‚</p> Free Translate Using Google Without API https://subinsb.com/francium-translator/ Mon, 20 Apr 2015 04:30:58 +0000 https://subinsb.com/francium-translator/ <p><strong>Google Translate</strong> is one of the best tools on the internet that translates text to another language. Currently it supports <strong>90+</strong> languages. Google has itsย <strong>API</strong> for translate, but itsย <strong>not</strong> <strong>free</strong> and you have to go through a lot of procedures. Itโ€™s boring, right ? If your app/website needs a translator, this post will help you.</p> <p>As you know <a href="http://translate.google.com" target="_blank">Google Translate</a>ย is a web app and you can monitor the requests it sends to the server. If you look through the Developer Tools during a translation process, you will get theย <strong>URL</strong> !</p> <p>I did this and made a <a href="//subinsb.com/the-francium-project" title="The Francium Project">Francium class</a> called &quot;Translator&quot; (of course it is). You can see theย <a href="https://github.com/subins2000/francium-translator" target="_blank"><strong>GitHub</strong> project here</a>.</p> <div class="padlinks"> <a class="download" href="https://github.com/subins2000/francium-translator/archive/master.zip" target="_blank">Download</a> <a class="demo" href="http://demos.subinsb.com/Francium/Translator/" target="_blank">Demo</a> </div> <p>It is not a big project (&lt; 300 lines) and it has only 1 function to be used by you.</p> <h1 id="requirements">Requirements</h1> <ul> <li><a href="http://php.net/manual/en/curl.installation.php" target="_blank">PHP cURL Extension</a></li> </ul> <h1 id="configuration">Configuration</h1> <p>One thing to note is that, we donโ€™t mention language by its full name. But, with short forms. You can find these short forms in the class file itself. It is an array in <a href="https://github.com/subins2000/francium-translator/blob/master/class.translator.php#L52" target="_blank"><code>config</code>-&gt;<code>languages</code></a>. Example :</p> <p>There is only one sub config that you have to edit. It is `config`-&gt;`default`. What it contains is the default translation languages. Again, you have to use the short form of languages here. This is useful when you are going to use the translator for a single lang-to-lang translation.</p> <h1 id="translate">Translate</h1> <p>Now, letโ€™s translate something. Here is the syntax ofย <strong>\Fr\Translator::translate()</strong> :</p> <pre class="prettyprint"><code>\Fr\Translator::translate($text, $translateTo, $translateFrom);</code></pre> <p>If theย <strong>$translateFrom</strong> is null, the value &quot;auto&quot; is used which means that Google will detect the language of the text.</p> <p>And ifย <strong>$translateTo</strong> is null, the default value from `config`-&gt;`default` is used.</p> <h2 id="examples">Examples</h2> <p>Translating &quot;Hello&quot; into Malayalam :</p> <pre class="prettyprint"><code>echo \Fr\Translator::translate("Hello", "ml", "en"); // Outputs "เดนเดฒเต‡เดพ"</code></pre> <p>Translating &quot;My House&quot; to French :</p> <pre class="prettyprint"><code>echo \Fr\Translator::translate("Hello", "fr", "en"); // Outputs "Ma Maison"</code></pre> <p>Translating &quot;Internet&quot; to Arabic :</p> <pre class="prettyprint"><code>echo \Fr\Translator::translate("Hello", "ar", "en"); // Outputs "Ma Maison"</code></pre> <p>This Francium class supports error logging too. The most likely error youโ€™re going to get will be ofย <strong>cURL</strong>โ€˜s.</p> <p>For support, you can see <a href="//subinsb.com/ask/francium/translator">this page</a>.</p> Francium https://subinsb.com/francium/ Sat, 18 Apr 2015 18:08:55 +0000 https://subinsb.com/francium/ <p>The support forum for theย <strong><a href="//subinsb.com/the-francium-project" title="The Francium Project">Francium Projects</a></strong>.</p> <p>Please follow the <a href="//subinsb.com/ask">guidelines</a> and ask for support in the corresponding pages.</p> <p>This page is for the support regarding theย <strong>Francium</strong> base class. This doesnโ€™t mean that you should ask support for a specific Francium project here. You should ask for that in their corresponding Ask pages.</p> Getting IP Address of Your Friend Through Chat https://subinsb.com/get-friend-ip-address-through-chat/ Mon, 30 Mar 2015 03:30:46 +0000 https://subinsb.com/get-friend-ip-address-through-chat/ <p>Itโ€™s awesome to get into the depth of the network, especially when itโ€™s the internet. Anย <strong>IP address</strong> can get you to a person far away from your home. It will make you mind blown when you dig deeper into the internet network.</p> <p>As you may have read,ย <strong>netstat -an</strong> command gave you the <strong>IP address</strong> of user throughย <strong>Facebook</strong> chat. But, this works no more. But, there are still ways to do this.</p> <p>**Facebookย **uses theย <a href="http://en.wikipedia.org/wiki/XMPP#Strengths" target="_blank"><strong>XMPP</strong></a> protocol for chatting which does not disclose theย <strong>IP</strong> address of the chatters. So, what way is there to get theย <strong>IP</strong> address of your friend ? Well, you can :</p> <ol> <li>Ask him/her to give his/herย <strong>IP address</strong></li> <li>Trick him/her into disclosing theย <strong>IP address</strong></li> </ol> <p>The 1st method is simple if the friend is a dearest one. If youโ€™re trying to catch a cracker, 2nd is the most suited way.</p> <h2 id="trick-the-friend">Trick The Friend</h2> <p>Itโ€™s very easy and if youโ€™re a good programmer, you probably know how to do this. Every time when a user visits a website, the user is know by his/herย <strong>IP address</strong>. So, theย <strong>IP address</strong> will be known by the server.</p> <p>We will use this basicย <strong>HTTP</strong> protocol concept to obtain theย <strong>IP</strong> <strong>address</strong> of the friend. Itโ€™s really simple if you already have a site running on aย <strong>PHP</strong> server. Hereโ€™s how weโ€™re going to do it :</p> <ul> <li>Make a fake page in a website that redirects somewhere else.</li> <li>Send the link to the friend through chat.</li> <li>See the log file of site and get the IP address.</li> </ul> <p>Make a file in the root location of the site called &quot;redirect.php&quot;. We name it &quot;redirect.php&quot;, because we donโ€™t want the firend to be suspicious about it.</p> <pre class="prettyprint"><code>&lt;p&gt;Please Wait...&lt;/p&gt; &lt;script&gt;window.location = "&lt;?php echo $_GET['redirect'];?&gt;";&lt;/script&gt;</code></pre> <p>What the above script does is simple : redirects user to the URL given through theย **GETย **parameter &quot;redirect&quot;.</p> <p>Next we got to do is, send the friend to this page. But before that, itโ€™s better to make the URL you need to send to the friend :</p> <pre class="prettyprint"><code>http://mysite.com/redirect.php?redirect=http%3A%2F%2Fsubinsb.com&user=friend+name</code></pre> <p>Why we add theย &quot;user&quot; parameter is to identify the user from which we got the IP when we check the server log.</p> <p>You should mention a redirect URL in the &quot;redirect&quot; parameter. I recommend a great article, one which the friend will enjoy.</p> <p>Now, shorten the URL using <a href="http://goo.gl" target="_blank">goo.gl</a>ย or any other URL shortening services, so that the friend doesnโ€™t get suspicious about the URL.</p> <p>Send this URL by saying that itโ€™s about a great article. Youโ€™re not lying (BTW, I hate lying), because the URL youโ€™re going to send will redirect to that &quot;great article&quot;. This is done by mentioning the article URL in the &quot;redirect&quot; parameter of theย <strong>GET</strong> request. AND CLICK SEND !</p> <p>The user will be taken to the server and then redirected to the article that he likes picked by you.</p> <p>Nextย the thing you want is recorded in the server.</p> <p>The script is short, then how is theย <strong>IP address</strong> got ? Pretty simple. All web servers have anย <strong>access</strong> log file. On aย <strong>Linux</strong> system runningย **Apacheย **server, the location is :</p> <pre class="prettyprint"><code>/var/log/apache/access.log</code></pre> <p>Open the log file and search for your friendโ€™s name. Alongside the name, you will see theย <strong>IP address</strong>. All web servers logs the visitors reached with theย <strong>IP address</strong> and the page visited.</p> <p>So, now you got theย <strong>IP address</strong>. Amaze your friend. But, try to do good things and not beย <strong>EVIL !</strong></p> <p>You can do this in all chats and emails as long as the friend visits your server.</p> The Francium Project https://subinsb.com/the-francium-project/ Tue, 24 Mar 2015 06:51:19 +0000 https://subinsb.com/the-francium-project/ <p>I have made lots of classes and plan to create more and more. But, all of these are just scrambled all over. Hereโ€™s what Iโ€™m talking about :</p> <pre class="prettyprint"><code>new LoginSystem(); new FDM();</code></pre> <p>If you use another class named the same, then it will bring conflicts within your code. So, I decided them to group it with the namespace <strong>Fr</strong>, short forย <strong>Francium</strong>ย โ€“ย one of the least electronegative elements in the periodic table. Iโ€™m calling this theย <strong>Francium</strong>ย project. It has nothing to do with the chemical element though.</p> <p>As per this project, all my current and future classes will become a child class of theย <strong>Fr</strong>ย parent :</p> <pre class="prettyprint"><code>new Fr\LoginSystem(); new Fr\FDM()</code></pre> <p>This post is about how you work withย <strong>Francium</strong>. You can see the base class <a href="https://github.com/subins2000/Francium/blob/master/class.php" target="_blank">here</a>.</p> <h2 id="configuration">Configuration</h2> <p>There is a static variable inside it called &quot;default_config&quot; containing an array with the default configuration. In that array, database information and a main info about who is using the software is written. You can either change the default configuration or set custom ones without changing the default config.</p> <h3 id="1-custom-config">1. Custom Config</h3> <p>For this, you pass your config array to the <strong>config()</strong> method. You do this by making another file like &quot;config.php&quot; and including it instead of the class file. Here is an example of &quot;<strong>config.php</strong>&quot; file :</p> <pre class="prettyprint"><code>require "ClassName.php"; new Fr\ClassName(array( ย  "info" =&gt; array( "company" =&gt; "Test", "email" =&gt; "[email protected]" ) ));</code></pre> <p>Then, you include the above file in pages :</p> <pre class="prettyprint"><code>require_once "&lt;strong>config.php&lt;/strong>" </code></pre> <p>I recommend this custom config, because you can then easily update the class when a new version come out.</p> <h3 id="2-change-default-config">2. Change Default Config</h3> <p>You can directly change the values of the &quot;\Fr\ClassName::$default_config&quot; in the class file, so you wonโ€™t need to make another file for custom configuration. But beware, when youโ€™re updating to a newer version of the class, be sure to reupdate the default configuration again.</p> <p>Now, what Fr does is merge the default config with the config you provided when making the object.</p> <h2 id="debugging">Debugging</h2> <p>\Fr\ClassName::log() function is used for entering log messages which is useful for debugging. These messages are sent by various functions and it is recorded in a file called &quot;<strong>Francium.log</strong>&quot;.</p> <p>To enable log messages, create a file named &quot;<strong>Francium.log</strong>&quot; in the <strong>folder where the class file exists</strong>. You should also make the fileย <strong>writable</strong> by changing the permissions.</p> <p>Then set config-&gt;debug-&gt;enable to TRUE :</p> <pre class="prettyprint"><code>new Fr\ClassName(array( ย  "debug" =&gt; array( "enable" =&gt; true ) ));</code></pre> <p>ย </p> <p>You can also change the path of log file by givingย <strong>absolute</strong> path of the new log file to config-&gt;debug-&gt;log_file :</p> <pre class="prettyprint"><code>new Fr\ClassName(array( ย  "debug" =&gt; array( "enable" =&gt; true, "log_file" =&gt; __DIR__ . "/custom-log-file.log" ) )); </code></pre> <p>After doing the above, log messages will be written to the file automatically.</p> <p>Here is an example of a log message :</p> <pre class="prettyprint"><code>[2015-03-28 20:41:24] Couldn't connect to database. Check config-&gt;db credentials [2016-04-23 12:13:41] two_step_login: Token Callback not present </code></pre> <p>It is also to be noted that PHPโ€™s error log will also be helpful in debugging.ย When you enable debugging in a Francium class, it also does this :</p> <pre class="prettyprint"><code>ini_set("display_errors", "on");</code></pre> <p>Itโ€™s recommended that you see both the logs for perfect debugging.</p> <h2 id="javascript">JavaScript</h2> <p>Francium Project also applies to my JavaScrpt projects. My current projects are being slowly ported to the Francium Object. Note that myย <strong>jQuery</strong> plugins will also be moving toย <strong>Francium</strong> object. Example :</p> <pre class="prettyprint"><code>Fr.voice.record();</code></pre> <p>The debugging is not currently set for JS projects, but someย messages are shown in console.</p> Iโ€™m Back https://subinsb.com/iam-back/ Sun, 22 Mar 2015 06:30:36 +0000 https://subinsb.com/iam-back/ <p>Itโ€™s been 3 months since I became less active on the blog. It is because of the S.S.L.C 10th grade exams. Itโ€™s all over now and Iโ€™m really happy to get back to my blog.</p> <p>In between this long period from January 2015 to March 2015, I had checked my mail sometimes and found a lot of comments asking for solutions.</p> <p>Since I was busy studying and all that stuff, I never had time to reply. But, since now I haveย <strong>77</strong> days left for the school to reopen again, Iโ€™m going to reply to all those comments in ascending order according to date.</p> <h2 id="4th-year">4th Year</h2> <p>Onย <strong>January 30</strong>, my blog completes its fourth year. I couldnโ€™t post on that day, because I was busy studying and almost forgot. ๐Ÿ˜›</p> <p>The total views has crossed <strong>445,000</strong>ย with unique visitors more than <strong>315,000</strong>ย and returning visits &gt;ย <strong>45,000</strong>.<figure class="wp-caption aligncenter"></p> <p><img class="" src="//lab.subinsb.com/projects/blog/uploads/2015/03/0129.png" alt="All Time Statistics" width="787" height="300" /><figcaption class="wp-caption-text">All Time Statistics</figcaption></figure></p> <h2 id="future">Future</h2> <p>I have an idea to makeย <strong>logSys</strong>ย a static class and not an object way. A lot of improvements are going to be made in all the projects I created.</p> <p>Another thing is the launching of a new software which I think would be done in May 1.</p> <p>I will be referring to this post for posting a late reply to comments to say that Iโ€™m sorry and thanks for waiting.</p> Coding Standards https://subinsb.com/coding-standards/ Fri, 02 Jan 2015 07:16:36 +0000 https://subinsb.com/coding-standards/ <p>Writing programs should be meaningful and in a long future, if you or anyone looks back at the code, then he/she must understand it. We all write codes, but do weย have a standard of writing the code ? If we write codes without any standards and just go for it, then the program would be messy and no other programmer would like to read it.</p> <p>Hereโ€™s what Iโ€™m talking about : A guy writes code as he like :</p> <pre class="prettyprint"><code>&lt;? //A function to forget. Just a demo function for showing code standards. Nothing is Nothing. function forget ($get=false) { echo $get===true ? "Yes":"No"; } ?&gt;</code></pre> <p>The above code is messy and doesnโ€™t look good and hereโ€™s how it is made better :</p> <pre class="prettyprint"><code>&lt;?php /** * A function to forget. Just a demo function for * showing code standards. Nothing is Nothing. */ function forget($get = false) { echo $get === true ? "Yes" : "No"; } ?&gt;</code></pre> <p>You can see that, now the code looks better and gives a temptation to read it. Not only does it help you, but others who might read the code in the future as well.</p> <p>This post is about the coding standards that I use and maybe you could use it too ! This coding standards is loosely based on the <a href="http://pear.php.net/manual/en/standards.php" target="_blank">PEAR coding standards</a>.</p> <h2 id="the-php-file">The PHP File</h2> <p>On most PHP systems,ย <strong>&lt;?php</strong> works perfectly, but on others the short code is not enabled. In this case,ย <strong>&lt;?</strong> wonโ€™t work. So, starting ofย <strong>PHP</strong> code should be by <strong>&lt;?php</strong> :</p> <pre class="prettyprint"><code>&lt;?php echo "Hello World"; ?&gt; </code></pre> <p>If the file is fullย <strong>PHP</strong>, then it need not be closed byย <strong>?&gt;</strong>. All files should end with a newline (\n) and not Windows newline (\r\n).</p> <p>Semicolons is important. It should be placed. Do this :</p> <pre class="prettyprint"><code>&lt;?php echo "hello"; ?&gt;</code></pre> <p>and not this :</p> <pre class="prettyprint"><code>&lt;?php echo "hello" ?&gt;</code></pre> <h2 id="indents--spacing">Indents &amp; Spacing</h2> <p>The indents should be ofย <strong>2 spaces</strong> and no tabs. Tabs wonโ€™t work equally perfect in all text editors. Hence, instead of tabs, whitespaces should be used.</p> <p>Lines should not have trailing whitespaces at the end. A space should be in between operators such as :</p> <pre class="prettyprint"><code>+, =, -, !=, !==, &gt;</code></pre> <p>etcโ€ฆ Examples :</p> <pre class="prettyprint"><code>$myVariable = "myContent"; if(5 &lt; 4) { }</code></pre> <p>rather than :</p> <pre class="prettyprint"><code>$myVariable="myContent"; if(5&lt;4){} </code></pre> <p>Also, a space after &quot;,&quot; should be made.</p> <h2 id="control-structures">Control Structures</h2> <p>Control structures include if, for, while, switch, etcโ€ฆ Here is an example ofย <strong>if</strong> statement :</p> <pre class="prettyprint"><code>if (5 &gt; 4 || 9 &gt; 8) { ย  doAction1(); }elseif ("a" == "a") { ย  doAction2(); }else{ ย  doAction3(); }</code></pre> <p>Always useย <strong>elseif</strong>ย and notย <strong>else if</strong>. Forย <strong>siwtch</strong>ย statements :</p> <pre class="prettyprint"><code>switch (condition) { ย  case 1: ย ย ย  action1; ย ย ย  break; ย  case 2: ย ย ย  action2; ย ย ย  break; ย  default: ย ย ย  defaultaction; }</code></pre> <h2 id="lines">Lines</h2> <p>All lines should not exceed 80 characters. If it does, make the overflowing chars into next line :</p> <pre class="prettyprint"><code>if($array['this']['that']['here']['pen'] == $array['there']['that']['myBigHat']['insideAPen']) { doAction1(); }</code></pre> <p>This applies to comments too :</p> <pre class="prettyprint"><code>/** * A function to forget. Just a demo function for * showing code standards. Nothing is Nothing. */</code></pre> <p>There might be a need to extend from 80 characters if it is a control structure. In this case, we can on one condition : it must be understandable.</p> <p>Another thing is that all lines that are kept out for prettiness mustnโ€™t have any characters, even whitespaces.</p> <h2 id="variables--functions">Variables &amp; Functions</h2> <p>As said before, a space should be in between โ€˜=โ€™ in variables :</p> <pre class="prettyprint"><code>$var = "content"; $var .= "content";</code></pre> <p>In case of variables that are together of different sizes, adding more space will help to read it better :</p> <pre class="prettyprint"><code>$name = ""; $fullName = ""; $aLitttleLongVariable = "";ย </code></pre> <p>In the case of functions :</p> <pre class="prettyprint"><code>myFunction($var1, $var2);</code></pre> <p>Functions should return meaningful data. Itโ€™s better to avoidย <strong>NULL</strong> as return and instead useย <strong>boolean false</strong>. Use :</p> <pre class="prettyprint"><code>function myFunction() { return true; }</code></pre> <p>and not :</p> <pre class="prettyprint"><code>function myFunction() { return "true"; }</code></pre> <p>or :</p> <pre class="prettyprint"><code>function myFunction() { return TRUE; }</code></pre> <h2 id="arrays">Arrays</h2> <p>The items of arrays should be separated with whitespace and inbetween &quot;=&gt;&quot; :</p> <pre class="prettyprint"><code>$myArray = array('hello', 'world', 'me' =&gt; 'him');</code></pre> <p>It can be also made more pretty by :</p> <pre class="prettyprint"><code>$myArray = array( 'hello' =&gt; 'a', 'world' =&gt; 'b', 'me' =&gt; 'him' );</code></pre> <h2 id="quotes">Quotes</h2> <p>Itโ€™s better to use double quotes (&quot;) inย <strong>PHP</strong>, but both single quote and double quote have good uses.</p> <h2 id="comments">Comments</h2> <p>Comments should start by &quot;/<em>*&quot; and end with &quot;*/&quot;. Each line of comment must start with &quot;</em>&quot; too :</p> <pre class="prettyprint"><code>/** * Reads configuration & set Software according to it * All lines must start with * */</code></pre> <p>This also have theย <strong>80 chars</strong> limit.</p> <h2 id="naming">Naming</h2> <p>All function names and variable names must be in lowercase and words should be separated by underscore (_) or you can do the caps way :</p> <pre class="prettyprint"><code>myFunction() my_function()ย </code></pre> <p>But, your project must only use one of the above methods.</p> <h2 id="conclusion">Conclusion</h2> <p>Itโ€™s better if all your projects follow the same coding standards as it will help you and other who read the code as well. This coding standards are my opinion only. You can choose your own and write it down in a document or on your mind and follow it forever in your coding life.</p> Sample Page https://subinsb.com/sample-page/ Wed, 31 Dec 2014 12:07:31 +0000 https://subinsb.com/sample-page/ <p>This is an example page. Itโ€™s different from a blog post because it will stay in one place and will show up in your site navigation (in most themes). Most people start with an About page that introduces them to potential site visitors. It might say something like this:</p> <blockquote> <p>Hi there! Iโ€™m a bike messenger by day, aspiring actor by night, and this is my blog. I live in Los Angeles, have a great dog named Jack, and I like piรฑa coladas. (And gettinโ€™ caught in the rain.)</p> </blockquote> <p>โ€ฆor something like this:</p> <blockquote> <p>The XYZ Doohickey Company was founded in 1971, and has been providing quality doohickeys to the public ever since. Located in Gotham City, XYZ employs over 2,000 people and does all kinds of awesome things for the Gotham community.</p> </blockquote> <p>As a new WordPress user, you should go to <a href="https://blog-subins.rhcloud.com/wp-admin/">your dashboard</a> to delete this page and create new pages for your content. Have fun!</p> Drupal 8 HTML5 Initiative https://subinsb.com/drupal8-html5-initiative/ Sun, 07 Dec 2014 13:43:57 +0000 https://subinsb.com/drupal8-html5-initiative/ <p><a href="https://html5.org/" target="_blank"><strong>HTML</strong><strong>5</strong></a>ย is the newestย <strong>HTML</strong> version and it has tons of new features. New input types, output &amp; input (audio, video) and many more. It is now absolutely necessary for projects to move toย <strong>HTML5</strong> to enjoy new features.</p> <p><a href="http://www.drupal.org" target="_blank"><strong>Drupal</strong></a> is also converting toย <strong>HTML5</strong>ย in the upcoming stableย <strong>8.0</strong> release. <strong>Drupal</strong> has started theย <a href="https://groups.drupal.org/html5/drupal-8" target="_blank"><strong>HTML5 Initiative</strong></a> to convertย <strong>Drupal</strong> toย <strong>HTML5</strong>.ย Now, this will upgradeย <strong>Drupal</strong> into new heights.</p> <h2 id="html5figure-classwp-caption-aligncenter">HTML5<figure class="wp-caption aligncenter"></h2> <p><img class="" src="https://www.w3.org/html/logo/downloads/HTML5_Badge_512.png" alt="HTML5 Logo" width="378" height="378" /><figcaption class="wp-caption-text">HTML5 Logo</figcaption></figure></p> <p>The latest version ofย <strong>HTML</strong> upgrades the oldย <strong>HTML</strong> to new technology. Most latest browsers already supportsย <strong>HTML5</strong> which includes :</p> <ul> <li>Google Chrome</li> <li>Chromium</li> <li>Firefox</li> <li>Safari</li> <li>Opera</li> <li>IE 10+</li> </ul> <p>Whatโ€™s awesome aboutย <strong>HTML5</strong> is that it contains lots of new stuff that makes Web more like an OS. More integration with the Hardware is one of the core features ofย <strong>HTML5</strong>. This means that you can :</p> <ul> <li>Record With Web Camera</li> <li>Record With Microphone</li> <li>Play Songs &amp; Videos</li> <li>Animations (2D &amp; 3D)</li> <li>Access Userโ€™s File information with restrictions</li> <li>Create &amp; Access Local Site Data</li> <li>Create Offline Websites</li> </ul> <p><strong>JavaScript</strong> is also updated along withย <strong>HTML5</strong> which also has theย <strong>Canvas API</strong> that replaces the use ofย <strong>Flash</strong> in websites. This meansย <strong>Adobe</strong> will lose its monopoly overย web browsers and no more need toย <strong>install Flash</strong> !</p> <p>Iโ€™ve choseย <strong>HTML5</strong>ย initiative to blog, because itโ€™s simply the best and most needed improvement forย <strong>Drupal</strong> as it will improveย <strong>Drupal</strong> very much.</p> <h2 id="the-initiativefigure-classwp-caption-aligncenter">The Initiative<figure class="wp-caption aligncenter"></h2> <p><img class="" src="https://groups.drupal.org/files/drupalhtml5logo_1.png" alt="Drupal HTML5 Initiative Logo" width="223" height="223" /><figcaption class="wp-caption-text">Drupal HTML5 Initiative Logo</figcaption></figure></p> <p>The initiative is made to convert the existingย <strong>Drupal</strong> toย <strong>HTML5</strong>.ย As part of this initiative <strong>Drupal</strong>ย willย be revamping most of the templates and theme functions and implementing new form input types and elements. Itโ€™s a big challenge, but also a great opportunity to make <strong>Drupal</strong>โ€˜s markup and <strong>CSS</strong> the best it can be.</p> <p>The organizers of the Initiative are :</p> <ul> <li><a href="https://groups.drupal.org/user/42814">bleen18</a></li> <li><a href="https://groups.drupal.org/user/22656">mitchell</a></li> <li><a href="https://groups.drupal.org/user/2771">jenlampton</a></li> <li><a href="https://groups.drupal.org/user/21703">ericduran</a></li> <li><a href="https://groups.drupal.org/user/1358">jackalope</a></li> <li><a href="https://groups.drupal.org/user/69534">jhood</a></li> <li><a href="https://groups.drupal.org/user/5867">Jacine</a></li> </ul> <p>The initiative is organizing discussions and meetings on what to implement inย <strong>Drupal 8</strong> and how it should be implemented. They plan to make the themes responsive withย <strong>CSS</strong> and style with newย <strong>CSS 3</strong> transitions, animations and new effects.</p> <p>They are also planning to restyle all of currentย <strong>Drupal GUI</strong> to something more modern and stylish. This includes comments, site body, themes and others. Mobile is becoming the most used device to access the internet and thereforeย <strong>Drupal</strong> should be ready to welcome the mobile users. The initiative organizers have agreed that theย <strong>Drupal</strong> themes are not compatible with mobile and it should be made responsive.</p> <p>Responsive images and updation ofย <strong>jQuery</strong> toย <strong>2.0</strong> has been done inย <strong>Drupal 8</strong>. This means that the newย <strong>Drupal 8</strong> frontend <a href="https://groups.drupal.org/node/298753" target="_blank">wonโ€™t supportย <strong>IE</strong></a> versions of less than <strong>9</strong>. This is a good thing, because support of older browsers mean more sized files and if the code is only made for the modern browsers, less size inย <strong>JS</strong> andย <strong>CSS</strong> files can be achieved.</p> <p><a href="https://groups.drupal.org/mobile/drupal-8" target="_blank"><strong>Mobile</strong> initiative</a> is an another initiative linked with this :</p> <ul> <li><a href="https://groups.drupal.org/node/308208" target="_blank">Update on Mobile initiative #43 โ€“ Component Naming convention</a></li> <li><a href="https://groups.drupal.org/node/302353" target="_blank">Update on Mobile Initiative #40</a></li> <li><a href="https://groups.drupal.org/node/298753" target="_blank">Update on D8 Mobile Initiative โ€“ further to meeting #38</a></li> </ul> <h2 id="my-contribution">My Contribution</h2> <p>I joined the group and went over itโ€™sย <a href="https://twitter.com/drupal8html5" target="_blank"><strong>Twitter Page</strong></a> and found an issue. It was &quot;<a href="https://twitter.com/drupal8html5/status/541482876919746560" target="_blank">Border on &quot;details&quot; element in system.theme.css producing weird artifact</a>&quot;. I checked the problem and it existed. Apparently, in theย <strong>Configuration -&gt; Extend</strong> page, if the description of each modules are over a specific limit, then it wonโ€™t be shown.</p> <p>I fixed the problem byย removing the height limit of &quot;.system-modules td details&quot;, changing &quot;white-space&quot; property and by adding &quot;word-wrap&quot; property. As a whole, it became :</p> <pre class="prettyprint"><code>.system-modules td details { border: 0; margin: 0; display: flex; min-height: 20px; white-space: pre-line; word-wrap: break-word; }</code></pre> <p>Now, the bug is gone and the description is shown even if itโ€™s long. Hereโ€™s <a href="https://www.drupal.org/node/2158421#comment-9412735" target="_blank">my patch</a> on the issue page.</p> <p>UPDATE : With the patch, there was another problem.ย <strong>Flexbox</strong> is not supported onย <strong>IE 9</strong>. I hate IE. But, I think since <strong>Flex</strong> wonโ€™t work inย <strong>IE</strong>,ย <strong>block</strong> will be the <strong>display</strong> property value. So, it will work normally like inย <strong>Chrome</strong>. What made me addย <strong>flex</strong> value is that, inย <strong>Firefox</strong> and extra height is added sinceย <strong>white-space</strong> is &quot;pre-line&quot;.</p> <h2 id="contribute">Contribute</h2> <p>Anyone can contribute to thisย <a href="https://groups.drupal.org/html5/drupal-8" target="_blank"><strong>HTML</strong>ย <strong>Initiative</strong></a> by going to the <a href="https://groups.drupal.org/html5" target="_blank">Group Page</a>ย and Join. The officialย <strong>IRC</strong> channelย <a href="irc://irc.freenode.net/drupal-html5">#drupal-html5</a>ย is there to help anyone who want to contribute. There is also aย <a href="http://twitter.com/drupal8html5" target="_blank"><strong>Twitter</strong> page of <b>Drupal HTML5</b>ย <strong>Initiative</strong>.</a></p> <p><a href="irc://irc.freenode.net/drupal-html5" rel="nofollow">#drupal-html5</a> is smaller crowd, dedicated to discussions about <strong>HTML5</strong> and <strong>Drupal</strong>. Anย <strong>IRC</strong> meeting is conducted every two weeksย to discuss priorities, progress and issues. The meeting announcements are posted in the <a href="http://groups.drupal.org/html5" rel="nofollow">HTML5 group</a>, which sends e-mail notifications for new posts/events.</p> Reproducing Drupal Contact Module Issue https://subinsb.com/drupal-contact-module-issue-patch/ Sat, 06 Dec 2014 17:44:25 +0000 https://subinsb.com/drupal-contact-module-issue-patch/ <p>This post containsย information regarding the Drupal Core <a href="https://www.drupal.org/node/2348119" target="_blank">issue</a>. This post will explain how the bug was reproduced and how the test patch was created.</p> <p>The bug was &quot;Wrong message displayed after contact form mail(s) cannot be sent&quot;.</p> <h2 id="requires">Requires</h2> <ul> <li>Drupal 8.0</li> <li>Contact Module</li> </ul> <p>Note that URLs mentioned in this post &quot;http://mydrupalsite.com/&quot; is the URL of yourย <strong>Drupal</strong> installation and &quot;/mydrupalsite&quot; is the folder location of <strong>Drupal</strong> installation.</p> <h2 id="reproducing-bug">Reproducing Bug</h2> <ol> <li>First of all we need to make a contact form page. Go to the Contact Module configuration page :</li> </ol> <pre class="prettyprint"><code>http://mydrupalsite.com/admin/structure/contact</code></pre> <p>Click on &quot;Add Contact Form&quot; button and in the new window that you go to, fill up the form with the askedย information. Example :<figure id="attachment_3004" class="wp-caption aligncenter"></p> <p><a href="//lab.subinsb.com/projects/blog/uploads/2014/12/0123.png"><img class="size-large wp-image-3004" src="//lab.subinsb.com/projects/blog/uploads/2014/12/0123-1024x471.png" alt="Drupal Contact Form Config Page" width="640" height="294" /></a><figcaption class="wp-caption-text">Drupal Contact Form Config Page</figcaption></figure></p> <p>In the Recipients filed, type in an email address that <strong>doesnโ€™t exist</strong>. Tick the &quot;Make this the default form&quot; and submit the form by &quot;Save&quot; button.</p> <ol start="2"> <li>Go to the Contact Page of your site :</li> </ol> <pre class="prettyprint"><code>http://mydrupalsite.com/contact</code></pre> <p>Fill up the contact form with some data and submit the form :<figure id="attachment_3005" class="wp-caption aligncenter"></p> <p><a href="//lab.subinsb.com/projects/blog/uploads/2014/12/0124.png"><img class="size-large wp-image-3005" src="//lab.subinsb.com/projects/blog/uploads/2014/12/0124-1024x435.png" alt="Filling up the Drupal Contact Form" width="640" height="271" /></a><figcaption class="wp-caption-text">Filling up the Drupal Contact Form</figcaption></figure></p> <ol start="3"> <li>Now, we will see the bug :<figure id="attachment_3006" class="wp-caption aligncenter"></li> </ol> <p><a href="//lab.subinsb.com/projects/blog/uploads/2014/12/0125.png"><img class="size-large wp-image-3006" src="//lab.subinsb.com/projects/blog/uploads/2014/12/0125-1024x299.png" alt="Drupal Bug" width="640" height="186" /></a><figcaption class="wp-caption-text">Drupal Bug</figcaption></figure></p> <p>As you can see, the success message is shown even when the email was failed to send.</p> <h2 id="reproducing-bug-intests">Reproducing Bug inย Tests</h2> <ol> <li>Createย following test file :</li> </ol> <pre class="prettyprint"><code>/mydrupalsite/core/modules/contact/src/Tests/FailedContactPersonalTest.php</code></pre> <ol start="2"> <li>I made a new test class by extending &quot;WebTestBase&quot; class and made theย <strong>testPersonalContactFail()</strong> method to reproduce bug :</li> </ol> <pre class="prettyprint"><code>function testPersonalContactFail() { // Create a valid form. $this-&gt;admin_user = $this-&gt;drupalCreateUser(array('access site-wide contact form', 'administer contact forms', 'administer permissions', 'administer users')); $this-&gt;drupalLogin($this-&gt;admin_user); $this-&gt;addContactForm($id = Unicode::strtolower($this-&gt;randomMachineName(16)), $label = $this-&gt;randomMachineName(16), "[email protected]", '', TRUE); $this-&gt;assertRaw(t('Contact form %label has been added.', array('%label' =&gt; $label))); // Submit the contact form. $this-&gt;drupalLogout(); $this-&gt;drupalGet('/contact'); user_role_grant_permissions(DRUPAL_ANONYMOUS_RID, array('access site-wide contact form')); $this-&gt;submitContact("Test", "[email protected]", "Sample Message", $id, "Just a sample message"); // Check the bug messages $this-&gt;assertText(t('Your message has been sent.'), 'Displayed "Message sent"'); /* The following code only works if emails can be sent in tests */ //$this-&gt;assertText(t('Unable to send email. Contact the site administrator if the problem persists.'), 'Displayed "Unable to send email..."'); }</code></pre> <p>The messages due to the bug that are these :</p> <pre class="prettyprint"><code>Unable to send email. Contact the site administrator if the problem persists. Your message has been sent.</code></pre> <p>was checked in the output usingย <strong>$this-&gt;assertText()</strong>ย function. But, checking of the &quot;Unable to send email. Contact the site administrator if the problem persists.&quot; is not possible, because email is not actually sent in testing phase, so to output that message. Therefore that line is commented.</p> <ol start="3"> <li>Go to &quot;http://mydrupalsite.com/admin/config/development/testing&quot;, expand &quot;contact&quot; and tick the checkbox aside to &quot;DrupalcontactTestsNotExistEmailContactTest&quot; :<figure id="attachment_3013" class="wp-caption aligncenter"></li> </ol> <p><a href="//lab.subinsb.com/projects/blog/uploads/2014/12/0126.png"><img class="wp-image-3013 size-full" src="//lab.subinsb.com/projects/blog/uploads/2014/12/0126.png" alt="Choose the contact module for testing" width="984" height="607" /></a><figcaption class="wp-caption-text">Choose the contact module for testing</figcaption></figure></p> <ol start="4"> <li> <p>Click on &quot;Run Tests&quot; button at the end of the page. Now the testing is started. It will take some time to finish.</p> </li> <li> <p>Now, the success test page is shown :<figure id="attachment_3014" class="wp-caption aligncenter"></p> </li> </ol> <p><a href="//lab.subinsb.com/projects/blog/uploads/2014/12/0127.png"><img class="size-full wp-image-3014" src="//lab.subinsb.com/projects/blog/uploads/2014/12/0127.png" alt="Success Test Page" width="910" height="473" /></a><figcaption class="wp-caption-text">Success Test Page</figcaption></figure></p> <h2 id="patching">Patching</h2> <ol> <li>By usingย <strong>git</strong>, create a patch. For this, go to the root ofย <strong>Drupal</strong> installation, open terminal and commit the changed file :</li> </ol> <pre class="prettyprint"><code>git branch 2348119-Reproduce-bug-test-case git checkout 2348119-Reproduce-bug-test-case git add core/modules/contact/src/Tests/NotExistEmailContactTest.php git commit core/modules/contact/src/Tests/NotExistEmailContactTest.php -m "Reproduced the bug https://www.drupal.org/node/2348119"</code></pre> <ol start="2"> <li>Create the patch file :</li> </ol> <pre class="prettyprint"><code>git diff 8.0.x &gt; Reproduce-bug-test-case-2348119-38.patch</code></pre> <h2 id="uploading-to-issue-page">Uploading to Issue page</h2> <p>Went to the issue page and added a new comment with the Patch file &quot;Reproduce-bug-test-case-2348119-38.patch&quot; :<figure id="attachment_3015" class="wp-caption aligncenter"></p> <p><a href="//lab.subinsb.com/projects/blog/uploads/2014/12/0128.png"><img class="size-full wp-image-3015" src="//lab.subinsb.com/projects/blog/uploads/2014/12/0128.png" alt="Uploading the Patch to Issue Page" width="668" height="326" /></a><figcaption class="wp-caption-text">Uploading the Patch to Issue Page</figcaption></figure></p> <p>Here is the comment link :ย <a href="https://www.drupal.org/node/2348119#comment-9409977" target="_blank"><a href="https://www.drupal.org/node/2348119#comment-9409977">https://www.drupal.org/node/2348119#comment-9409977</a></a></p> <h2 id="conclusion">Conclusion</h2> <p>This experience gave me new information about Testing in Drupal. I realised that emails being sent in tests doesnโ€™t actually get sent. Instead it is gone into the Drupal mail inbox. I agree with this method as if it was not like this, many emails will go into the recipientโ€™s or adminโ€™s inbox.</p> <p>This was my first patch intoย the Drupal Core. Felt a little scary before doing it as Iโ€™m taking part in the CORE of DRUPAL !</p> <p>With this little experience, I gained the confidence to make patches for the Drupal Core more !</p> Into The Drupal Community https://subinsb.com/into-drupal/ Fri, 05 Dec 2014 02:31:55 +0000 https://subinsb.com/into-drupal/ <p>I have been usingย <strong>WordPress</strong> for 2 years and havenโ€™t tried out otherย <strong>CMS</strong> platforms. I heard aboutย <a href="https://www.drupal.org/" target="_blank"><strong>Drupal</strong></a>ย through the internet and via myย <strong>I.T</strong> textbook of my school. But never got the time to try it out.</p> <p>Now, Iโ€™m a participant ofย <strong>Google Code In, 2014</strong> andย <strong>Drupal</strong> was one of the Open Source organization in it. I tried Wikimedia last year butย it was hard, because it was really big for me to work on. This year, I choseย <strong>Drupal</strong>, because that it is aย <strong>CMS</strong> platform used by millions around the world and I thought if many other programmers can work with it, Why canโ€™t I ? Since I already have experience withย <strong>WordPress</strong>, it wouldnโ€™t be hard to understand too.</p> <p>So, I claimed a task and worked on making a patch of a Test for a module. What really got me thinking and exciting was that, how <strong>awesome</strong>ย testing is. You donโ€™t get testing stuff onย <strong>WordPress</strong> or any otherย <strong>CMS</strong> platforms that I use. A module can test itself to see whether it will work with the version ofย <strong>Dupal</strong>. How cool is that ?</p> <p>All you have to do to make a test file is to make a class, add code into it and Test ! The test file behaves like what a user would do in a browser andย <strong>Drupal</strong> will make that code into action โ€“ browsing like a user.</p> <h2 id="community-is-big-really-big">Community is Big, really BIG</h2> <p>The best feature ofย <strong>Drupal</strong>ย is that it have a strong, able and <a href="https://www.drupal.org/community" target="_blank">big community</a>. If you have any problems withย <strong>Drupal</strong> or one of itโ€™s modules, you can ask it up in the issues page as well as in theย <a href="http://drupal.org/irc" target="_blank"><strong>IRC</strong></a>. Since you have a live communication, solving the problems is very easy.</p> <p>If I needed any help, the community is always there to help and there are many places where I could knock on to get help. Itโ€™s this community that makesย <strong>Drupal</strong> what it is right now.</p> <h2 id="drupalorg">Drupal.org</h2> <p>Though there are many good things about <strong>Drupal</strong> which I experienced in a single task, there are also some stuff that I think would need to be improved.</p> <h3 id="look--feel">Look &amp; Feel</h3> <p>The homepage ofย <a href="https://www.drupal.org/"><strong>Drupal</strong></a> is good. Though it would be nice to have a slideshow of the screenshots of websites created withย <strong>Drupal</strong>. It would make a visitor going to the homepage thinking that &quot;Wow, That {site} I go often was made with Drupal !&quot;. This will attract lots of web developers, especially newbies who are looking to learn aย <strong>CMS</strong>.</p> <p><a href="https://www.drupal.org/" target="_blank"><strong>Drupal.org</strong></a> is a very fast site. Loading and performance is the best and I know itโ€™s fast, because I have a slow internet connection. If any improvement is going to be made in the styling of the site, then the changes shouldnโ€™t affect the speed of the site what is right now.</p> <h3 id="module-install">Module Install</h3> <p>If you want to install <a href="https://www.drupal.org/project/project_module/categories" target="_blank">modules</a> onย <strong>Drupal</strong>, you have to get the download file URL or upload he file by yourself. This is an annoying thing. Instead likeย <strong>WordPress</strong>, a page insideย <strong>Drupal</strong>, where you can search and install with a single button is needed. See <a href="https://www.drupal.org/project/menu_import" target="_blank">this example</a> yourself.</p> <h3 id="documentation">Documentation</h3> <p>The docs are too long and would take forever to completely read it. Instead, less words and more examples (tiny) will help to understand way better. Long docs should be moved into another section rather than as the main one. If you look into the docs, you can see what I mean.</p> <p>Docs like <a href="https://www.drupal.org/documentation/modules/simpletest" target="_blank">this</a> are good. But long docs with crowded texts like <a href="https://www.drupal.org/documentation/install/modules-themes/modules-7" target="_blank">this</a> should be separated into different sections.</p> <h3 id="dashboard">Dashboard</h3> <p>By default, the admin dashboard of aย <strong>Drupal</strong> site is empty with 3 blocks. Instead a default dashboard should be made and then allow the user to customize rather than forcing the user to create one himself like in WordPress.</p> <h3 id="database">Database</h3> <p>If you look at the database ofย <strong>Drupal</strong>, you will be absolutely confused. In my database only, there areย <strong>77</strong> tables where as inย <strong>WordPress</strong>, there will be onlyย <strong>11</strong>. I think this is because thatย <strong>Drupal</strong> is more advanced. But, for a developer to understand what happens in the background, he canโ€™t. Because, itโ€™s absolutely confusing and you wonโ€™t have any idea what is in the background. Check this out :</p> <img class="alignnone" src="https://www.drupal.org/files/Drupal8_UPsitesWeb_Schema_10-19-2013.png" alt="" width="2914" height="1364" /> <h2 id="conclusion">Conclusion</h2> <p>I would like to make a website myself withย <strong>Drupal</strong> and see how it goes. Maybe, if itโ€™s good then Iโ€™ll move this website fromย <strong>WordPress</strong> toย <strong>Drupal</strong> itself. I learnt may aboutย <strong>Drupal</strong> with a single task and what all could I learn if I do more tasks ?ย <strong>Drupal is great</strong>,ย <strong>but it should be greater</strong>.</p> Variables in Bash ": command not found" https://subinsb.com/bash-variables-command-not-found/ Mon, 24 Nov 2014 03:30:51 +0000 https://subinsb.com/bash-variables-command-not-found/ <p><strong>Bash</strong> is like the very complicated language, even a space can make a syntax error. But, when you get into it often, you will get a hang of it and it will be easy.</p> <p>This post is a solution to one of the most common problems that happen to a newbie inย <strong>Bash</strong> and itโ€™s about a single whitespace.</p> <p>Here is a sampleย <strong>Bash</strong> file :</p> <pre class="prettyprint"><code>a = 50 echo $a</code></pre> <p>and when you execute it, the error will be as follows :</p> <pre class="prettyprint"><code>script.sh: line 1: a: command not found</code></pre> <p>This error is produced by the error in defining the variable &quot;a&quot;. There should be no space before or after the &quot;=&quot;. If you remove it, then the script will run successfully.</p> <p>When there is a space after &quot;a&quot;,ย <strong>Bash</strong> thinks that &quot;a&quot; is a command followed by itโ€™s attributes. Since there is no command named &quot;a&quot;, it will produce a &quot;command not found&quot; error.</p> Append Contents to Files in Bash https://subinsb.com/bash-file-append-content/ Wed, 19 Nov 2014 03:30:08 +0000 https://subinsb.com/bash-file-append-content/ <p>Inย <strong>Bash</strong>, we can add contents to file easily using theย <strong>&gt;</strong>ย character. Like this :</p> <pre class="prettyprint"><code>echo "myContents" &gt; ~/myfile.txt</code></pre> <p>What if you want to append contents to the file without overwriting ? The easiest way to do this is change the &quot;&gt;&quot; to &quot;&gt;&gt;&quot;. Just by making this small change, appending will be done :</p> <pre class="prettyprint"><code>echo "myContents" &gt;&gt; ~/myfile.txt</code></pre> <p>Even if the file doesnโ€™t exist,ย <strong>Bash</strong> will create one with the contents given to append.</p> <p>You can also useย <strong>cat</strong> to append :</p> <pre class="prettyprint"><code>cat &gt;&gt; ~/file.txt &lt;&lt; EOF This is a content that can have any type of characters single quotes and double quotes can be included. EOF</code></pre> <p>ย </p> if, else, elif Conditions in Bash https://subinsb.com/bash-if-else-elif-conditions/ Tue, 18 Nov 2014 03:30:10 +0000 https://subinsb.com/bash-if-else-elif-conditions/ <p>All programming languages have theย <strong>if</strong> &amp;ย <strong>else</strong> conditions and theyโ€™re different in syntax according to each programming languages. Inย <strong>Bash</strong>,ย itโ€™s really different and even a small space can cause syntax errors. So, you have to be careful while writing Bash code.</p> <p>In this post, Iโ€™ll give you many examples on how to useย <strong>if</strong> andย <strong>else</strong> conditions inย <strong>Bash</strong>.</p> <h2 id="if-else">if, else</h2> <pre class="prettyprint"><code>a="AC" if [ $a = "AC" ]; then echo "yes" else echo "no" fi</code></pre> <p>Notice the usage ofย <strong>then</strong>. Itโ€™s necessary to letย <strong>Bash</strong> know that if the condition returns <strong>TRUE</strong>,ย do the code below it.</p> <p>The <strong>if</strong> condition is closed byย <strong>fi</strong>. Itโ€™s the way of using &quot;}&quot; to close the condition in other languages andย <strong>then</strong>, the way of starting &quot;{&quot; in other languages.</p> <p>But,ย <strong>else</strong> doesnโ€™t have special closing command; theย <strong>fi</strong> will do. Unlike &quot;==&quot; in other languages, in Bash just an &quot;=&quot; will do to check if a variable contain a string.</p> <p>The space between &quot;[&quot; is really necessary. If you remove it, syntax errors like these will occur :</p> <pre class="prettyprint"><code>file.sh: line 2: [AC: command not found file.sh: line 2: syntax error near unexpected token `then' file.sh: line 2: `if[ $a = "a" ]; then</code></pre> <h3 id="examples">Examples</h3> <p>Check if the variable &quot;a&quot; doesnโ€™t have the value &quot;AC&quot; :</p> <pre class="prettyprint"><code>a="a" if [ ! $a = "AC" ]; then echo "yes, a is not 'AC'" fi</code></pre> <p>Check if the file &quot;/dev/null&quot; exist :</p> <pre class="prettyprint"><code>if [ -a /dev/null ]; then echo "File Exists" else echo "File doesn't exist" fi</code></pre> <p>Check if the directory &quot;/dev&quot; exist :</p> <pre class="prettyprint"><code>if [ -d /dev ]; then echo "Directory Exists" else echo "Directory doesn't exist" fi</code></pre> <h2 id="elif">elif</h2> <p>This commandย <strong>elif</strong> is the same asย <strong>else if</strong>ย used in other programming languages. It should be used afterย <strong>if</strong> and beforeย <strong>fi</strong>.</p> <pre class="prettyprint"><code>a="AC" if [ $a = "a" ]; then echo "it's 'a'" elif [ $a = "AC" ]; then echo "it's 'AC'" fi</code></pre> <p>Theย <strong>else</strong> command also can be used within this :</p> <pre class="prettyprint"><code>a="k" if [ $a = "a" ]; then echo "it's 'a'" elif [ $a = "AC" ]; then echo "it's 'AC'" else echo "it's none of it" fi</code></pre> <h3 id="examples-1">Examples</h3> <p>Check if variable &quot;a&quot; contains &quot;a&quot;, else check if the value is &quot;false&quot; :</p> <pre class="prettyprint"><code>a=false if [ $a = "a" ]; then echo "it's 'a'" elif [ $a = false ]; then echo "it's FALSE" fi</code></pre> <p>Check if the value of variable &quot;a&quot; is greater than or less than 51 :</p> <pre class="prettyprint"><code>a=50 if [ $a -gt 51 ]; then echo "it's more than 50" elif [ $a -lt 51 ]; then echo "it's less than 51" fi</code></pre> Creating a File with Contents in Bash https://subinsb.com/bash-create-file-with-contents/ Mon, 17 Nov 2014 03:30:50 +0000 https://subinsb.com/bash-create-file-with-contents/ <p>Itโ€™s really easy to create a file in Bash with <strong>cat</strong> and &gt; :</p> <pre class="prettyprint"><code>cat "/home/simsu/file.txt" &gt; "/home/simsu/file.txt"</code></pre> <p>But, what if you want to add contents to file too ? In this case, we can use <strong>cat</strong> and <strong>echo</strong>. Hereโ€™s how we do it in <strong>echo</strong> :</p> <pre class="prettyprint"><code>echo "My File, My Choice" &gt; "/home/simsu/file.txt"</code></pre> <p>But, thereโ€™s a problem with doing like this. Since there is an option to limit the characters of a <strong>Terminal</strong> command, adding large contents is not possible. In this case, we need to use <strong>cat</strong>.</p> <p>The usage is very simple and can have different kinds of quotes and the ending of the contents is determined by a string you mention.</p> <pre class="prettyprint"><code>cat &gt; /home/simsu/file.txt &lt;&lt; ENDOFFILE My File, My Choice I have the right to write what I want in this file and no NSA can stop me from doing it. I had privacy before NSA and the whole internet and now I'm just a tiny little book that was read by everyone.... ENDOFFILE</code></pre> <p>In the above case, we tell <strong>cat</strong> to add the contents until the string &quot;ENDOFFILE&quot; comes up. This ending string is mentioned in the first line as well as at the ending of the contents.</p> <p>Since, we donโ€™t use any quotes, you can use quotes in the content without any syntax problem at all.</p> <p>Note that the ending string you mentioned should only occur at the end of the contents. Otherwise, the full content wonโ€™t be added to the file.</p> Check if Bash Script is ran by Root User https://subinsb.com/bash-script-root-check/ Thu, 13 Nov 2014 03:30:56 +0000 https://subinsb.com/bash-script-root-check/ <p>Root users have the privilege to do administrative stuff in Linux and if youโ€™re creating aย <strong>Bash</strong> script to install something or change something in the system, you needย <strong>root</strong>. So, checking whether the script was ran byย <strong>root</strong> is very important.</p> <pre class="prettyprint"><code>if [ "$EUID" -ne 0 ] then echo "Please run as root" exit fi</code></pre> <p>There is noย <strong>else</strong> condition. You can add the code which will does stuff in root after the above. If root didnโ€™t ran the script, then the script will terminate itself without continuing after &quot;Please run as root&quot; message is displayed.</p> <p>Example :</p> <pre class="prettyprint"><code>if [ "$EUID" -ne 0 ] then echo "Please run as root" exit fi print "The script is continuing" </code></pre> <p>ย </p> Newton Color Disc in jQuery https://subinsb.com/newton-color-disc/ Tue, 11 Nov 2014 03:30:05 +0000 https://subinsb.com/newton-color-disc/ <p>Newton Color Disc is used to find the color got by the combination of multiple colors. The color is not actually formed, but the eye identifies the combination as another color due to persistence of vision.</p> <p>Normally, Newtonโ€™s Color disk is made by marking sectors filled with color on a circular shaped disc. When this disc is rotated at high speed, we see the circle as another color. This principle led to the method of creating different colors by the combination of some primary colors at different percentage compositions.</p> <p>We use this principle in the web too. The <strong>RGB</strong> combination is used in web pages to make colors too. If the colors <strong>Red</strong>, <strong>Green</strong> and <strong>Blue</strong> is mixed together, we get <strong>White</strong> color.</p> <p>I have decided to convert the <strong>Newton Color Disc</strong> in to the digital state which led to the creation of the <strong>Newton Color Discย jQuery</strong> plugin. With this plugin, a Newton Color Disc can be made with combinations of any colour !</p> <div class="padlinks"> <a class="download" href="http://demos.subinsb.com/down.php?id=s/7u8ll589fs48w6czs206&class=33" target="_blank">Download</a><a class="demo" href="http://demos.subinsb.com/jquery/color-disc" target="_blank">Demo</a> </div> <h2 id="components">Components</h2> <p>It mainly use <strong>jQuery</strong> and for creating the circle with sectors, the plugin usesย **<a href="http://raphaeljs.com/">Raphaรซl JS</a>ย **library. It is a great library for creating <strong>SVG</strong> images by <strong>JavaScript</strong> itself.</p> <p>For animation, we completely use <strong>CSS</strong>. The new <strong>CSS 3.0</strong> specially helps to rotate the disc by animation.</p> <h2 id="how-it-works">How It Works</h2> <p>When the plugin function is called on an element, then a <strong>div</strong> element containing a <strong>SVG</strong> image is appended to the element from which it was called.</p> <p>The <strong>SVG</strong> image is of a circle with sectors filled with colors that was given to the plugin. Then, the disc is rotated by the calling of another functions. What this function does is that starts the animation using <strong>CSS</strong> after setting the speed using <strong>animation-speed</strong> property.</p> <p>As the value of <strong>animation-speed</strong> property <strong>decreases</strong>, the speed of rotation <strong>increases</strong>. So, itโ€™s inversely proportional.</p> <h2 id="usage">Usage</h2> <pre class="prettyprint"><code>$("#holder").colorDisc()</code></pre> <p>Adds the color disc into <strong>#holder</strong> element. But, does not start rotating.</p> <pre class="prettyprint"><code>$("#holder").colorDisc("speed", "0.0001")</code></pre> <p>Sets the speed of the disc to &quot;0.0001&quot;. As the value of the speed decreases, the rotation of disc in creases. So, the rotation of disc with the speed value &quot;1&quot; will be very slower than that of the disc which have value of &quot;0.01&quot;.</p> <p>The speed of the disc can be changes anytime even when itโ€™s rotating. But, the disc will restart rotation from the beginning.</p> <pre class="prettyprint"><code>$("#holder").colorDisc("remove")</code></pre> <p>Stops the animation and removes the color disc inside the <strong>#holder</strong> element.</p> <p>Thatโ€™s all the usages which I think is enough to manage a color disc. Note that the color disc will work greater on computers which have a good <strong>Graphics Processing Unit โ€“ GPU</strong>.</p> Replace Strings in Files With PHP & Python https://subinsb.com/replace-strings-in-files-php-python/ Thu, 30 Oct 2014 03:30:58 +0000 https://subinsb.com/replace-strings-in-files-php-python/ <p>There are softwares already that helps to replace a string in a file. Suppose, if youโ€™re making a program that requires savingย some data in to a file. Byย &quot;adding&quot;, the programย is actually replacing a word. Letโ€™s see how itโ€™s done inย <strong>PHP</strong> &amp;ย <strong>Python</strong>.</p> <p>This is the file where we are going to replace the word :</p> <pre class="prettyprint"><code>thisWord I got thisWord for making it thatWord replace thisWord already my friend.</code></pre> <p>We replace the word &quot;thisWord&quot; to &quot;thatWord&quot;ย containing in this file.</p> <h2 id="php">PHP</h2> <pre class="prettyprint"><code>&lt;?php $file = "/home/simsu/Other/projects/Programs/PHP/test.txt"; $contents = file_get_contents($file); $newContent = str_replace("thisWord", "thatWord", $contents); file_put_contents($file, $newContent); ?&gt;</code></pre> <p>Iโ€™mย not usingย <strong>fopen</strong> for this, because to make the code short.</p> <h2 id="python">Python</h2> <pre class="prettyprint"><code>import os file = "/home/simsu/Other/projects/Programs/PHP/test.txt" fp = open(file, "r+") contents = fp.read(os.path.getsize(file)) newContent = contents.replace("thisWord", "thatWord") fp.seek(0) fp.truncate() fp.write(newContent) fp.close()</code></pre> <p>We useย <strong>open</strong> for getting the contents of the file as well as to write to it. We truncate the file because otherwise the original content will be repeated again and finally the file connection is closed.</p> Folder Recursion in PHP & Python https://subinsb.com/folder-recursion-php-python/ Tue, 28 Oct 2014 03:30:54 +0000 https://subinsb.com/folder-recursion-php-python/ <p>A folder has files and sometimes sub directories. If we use the normal function for obtaining contents of a folder, we wonโ€™t get the details of the files in the sub directories. In this case, we have to look over into the sub folders and into other sub folders within this sub folder. This looking up of files deep down is calledย <strong>Recursive Folder Searching</strong>.</p> <p>By doing this, we can search for a file or do various actions with each files thus recursed. An example case of this is the replacing softwares likeย <strong>regexxer</strong>. It uses recursion to replace a string to another in multiple files in the same directory even under any sub folders.</p> <p>In this tutorial, you will see how to do this <strong>Recursion search</strong> of a folder in theย **PHPย **&amp; <strong>Python</strong> programming languages.ย <strong>PHP</strong> have a builtinย <strong>class</strong> for doing this, but complicated and forย <strong>Python</strong>, itโ€™s easier but have 2 loops.</p> <h2 id="php">PHP</h2> <p>Itโ€™s very short and effective. An array of files is made and itโ€™s looped. Each file array will also have aย <a href="http://php.net/manual/en/class.splfileinfo.php" target="_blank"><strong>SplFileInfo object</strong></a> to easily get the file info.</p> <pre class="prettyprint"><code>&lt;?php $path = realpath("/var/www/html"); $objects = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path), RecursiveIteratorIterator::SELF_FIRST); // Objects of different files foreach($objects as $location =&gt; $object){ $name = $object-&gt;getFileName(); // Get the file name echo "{$name} - {$location}n"; } ?&gt;</code></pre> <p>The key of the returned array is the location and the value is theย <strong>SplFileInfo</strong> object. Note that we useย <strong>getFileName()</strong> function of the <strong>SplFileInfo</strong> objectย to retrieve the name of the file. We can use many others.</p> <h2 id="python">Python</h2> <pre class="prettyprint"><code>import os path = "/var/www/html" for root, dirs, filenames in os.walk(path): for file in filenames: location = os.path.join(root, file) print file, "-", location</code></pre> <p>As you can see, we have two loops. One of the directories and the second of the files.</p> <p>The first loop withย <strong>os.walk(path)</strong> will fetch all the directories and the files in each of them. Then we loop over the files and prints the location and name of file.</p> Word Palindrome Check in PHP & Python https://subinsb.com/palindrome-check-php-python/ Mon, 27 Oct 2014 03:30:50 +0000 https://subinsb.com/palindrome-check-php-python/ <p><a href="http://en.wikipedia.org/wiki/Palindrome" target="_blank">Palindromes</a> are unique words that are read the same forward and backward. We can identify them using out eyes and brain. How about we identify using a simple program inย <strong>PHP</strong> &amp;ย <strong>Python</strong> ?</p> <h2 id="php">PHP</h2> <pre class="prettyprint"><code>&lt;?php $word = strtolower("Malayalam"); $splitted = str_split($word); $reversedWord = ""; $length = strlen($word); for($i = 0; $i &lt; $length; $i++) $reversedWord .= $splitted[$length - $i - 1]; echo $word == $reversedWord ? "It's a palindrome !n" : "It's not a palindromen"; ?&gt; </code></pre> <p>Instead of the loop to reverse the word, you can also use :</p> <pre class="prettyprint"><code>$reversedWord = strrev($word) </code></pre> <p>instead of :</p> <pre class="prettyprint"><code>$splitted = str_split($word); $reversedWord = ""; $length = strlen($word); for($i = 0; $i &lt; $length; $i++) $reversedWord .= $splitted[$length - $i - 1]; </code></pre> <p>A line break is added to the output to make output neat if the program is ran via terminal.</p> <h2 id="python">Python</h2> <pre class="prettyprint"><code>word = "Malayalam" word = word.lower() reversedWord = ""; for i in range(1, len(word) + 1, 1): reversedWord += word[-i] if word == reversedWord : print "It's a palindrome !" else: print "It's not a palindrome"</code></pre> <p>The input word should be given to the variable &quot;word&quot; in both the programs and both will output &quot;Itโ€™s a palindrome&quot; if the given word is a palindrome and if not, outputs &quot;Itโ€™s not a palindrome&quot;.</p> Executing Terminal Commands in Python & PHP https://subinsb.com/execute-commands-in-python-php/ Thu, 23 Oct 2014 03:30:55 +0000 https://subinsb.com/execute-commands-in-python-php/ <p class=""> Python & PHP are great languages and there are many similarities between them. In this short post, you will learn how to execute terminal commands in PHP & Python. </p> <h2 id="php">PHP</h2> <p>As I said before many times in other posts, there areexec andsystem command to execute commands :</p> <pre class="prettyprint"><code>exec("firefox โ€˜http://subinsb.comโ€™");</code></pre> <p>Or in the other way :</p> <pre class="prettyprint"><code>system("firefox โ€˜http://subinsb.comโ€™");</code></pre> <h2 id="python">Python</h2> <p>In Python, there is no <strong>exec</strong> or <strong>system</strong> function. But there is a <strong>system</strong> function in the <strong>os</strong> nodule. So, you have to include the <strong>os</strong>ย module first and then execute the command :</p> <pre class="prettyprint"><code>import os os.system("firefox โ€˜http://subinsb.comโ€™")</code></pre> Infinite loop in PHP & Python https://subinsb.com/infinite-loop-in-php-python/ Wed, 22 Oct 2014 03:30:38 +0000 https://subinsb.com/infinite-loop-in-php-python/ <p><strong>Infinite loops</strong> are loops that doesnโ€™t have a defined ending. It will continue to run until the program itโ€™s running in is terminated. Normally an <strong>infinite loop</strong> is created usingย <strong>while</strong> loop and is used for continuity of the same program.</p> <p>In this short tutorial, you will learn how to make anย <strong>infinite loop</strong> inย bothย <strong>PHP</strong> &amp;ย <strong>Python</strong>.</p> <h2 id="php">PHP</h2> <p>There is no need of defining any variables.</p> <pre class="prettyprint"><code>while(1){ ย  print "Hello" }</code></pre> <p>ย </p> <p>It can be done in two other ways :</p> <pre class="prettyprint"><code>while(True){ ย  print "Hello" }</code></pre> <pre class="prettyprint"><code>for (;;) { ย ย print "Hello" }</code></pre> <h2 id="python">Python</h2> <p>Same as before, but with some minor changes :</p> <pre class="prettyprint"><code>while(True) : ย  ย print "Hello"</code></pre> Configuring SSH to Enter a Password Automatically https://subinsb.com/sshpass-auto-enter-ssh-password/ Tue, 21 Oct 2014 03:30:46 +0000 https://subinsb.com/sshpass-auto-enter-ssh-password/ <p class=""> As you know, when you <strong>SSH</strong> into a system, it will ask for the password which you have to enter everytime. But in cases where youโ€™re <strong>SSH</strong>ing in a script or in a loop, its a really time consuming and boring thing to enter password everytime. </p> <p>So, in this case you have to configure <strong>SSH</strong> to use a password to enter when asked. But, there is no default option in the <strong>ssh</strong> command to set this due to security reasons I think. Therefore we should use another way to automatically enter the password.</p> <p>Fortunately, there is a program calledย <strong>sshpass</strong> that will enter the password automatically and logs in. All you have to do is, give the password and the normalย <strong>ssh</strong> command.</p> <p>You can installย theย <strong>sshpass</strong> command in anย <strong>Ubuntu</strong> system using this :</p> <pre class="prettyprint"><code>sudo apt-get install sshpass</code></pre> <p>Yes, itโ€™s in the officialย <strong>Ubuntu</strong> repository.ย <strong>sshpass</strong> works by foolingย <strong>ssh</strong> into thinking that the password was entered by an interactive user.</p> <p>The password should be given in theย <strong>-p</strong> parameter and the following should be theย <strong>ssh</strong> command. No separate host name should be given toย <strong>sshpass</strong>. Hereโ€™s an example :</p> <p>This is the normalย <strong>ssh</strong> command which is used for opening firefox browser in system of <strong>IP</strong> addressย <strong>192.168.10.1</strong> :</p> <pre class="prettyprint"><code>ssh [email protected] "firefox http://subinsb.com"</code></pre> <p>And this is how theย above command become inย <strong>sshpass</strong> assuming the password as &quot;subin&quot;ย :</p> <pre class="prettyprint"><code>sshpass -p "subin"ย ssh [email protected] "firefox http://subinsb.com"</code></pre> <p>You can also useย <strong>sshpass</strong> to use a file to read the password and more.</p> <p>Note thatย <strong>sshpass</strong> is its infacy at the moment and therefore bugs are highly possible. But, for me it worked like a charm. You can read the manual ofย <strong>sshpass</strong> <a href="http://linux.die.net/man/1/sshpass" target="_blank">here at the online man page</a>.</p> Blog Changes https://subinsb.com/blog-changes-1/ Mon, 20 Oct 2014 03:30:12 +0000 https://subinsb.com/blog-changes-1/ <p>Itโ€™s been some time since I made some changes to the blog apart from new posts. It took me this much time because of school, of course. Here are the main changes that I hope to add to the blog :</p> <ul> <li>HTTPS</li> <li>No Ads</li> <li>Short Posts</li> </ul> <h2 id="https">HTTPS</h2> <p>Thereโ€™s nothing like feeling secure in Internet. So, I have decided to addย <strong>HTTPS</strong> support to the site. Itโ€™s made possibleย <strong>free of cost</strong>, becauseย <strong>CloudFlare</strong> actually givesย <strong>HTTPS</strong> feature with certificate for absolutely free and it doesnโ€™t require for your server to have a certificate orย <strong>SSL</strong> support.</p> <p>Check theย <strong>HTTPS</strong> enabled <a href="https://subinsb.com">site</a>ย and the <a href="//blog-subins.rhcloud.com/" target="_blank">direct server one</a>.</p> <h2 id="no-more-ads">No More Ads</h2> <p>I have decided to remove the ads when the ad earnings reach <strong>20$</strong> (currently 18.5$).ย You might think Iโ€™m crazy for disabling ads. But I got pretty reasons for this :</p> <ol> <li>I got more donation money than from ad revenue</li> <li>Ads are not cool</li> <li>I hate ads</li> <li>It slows down the site</li> <li>Invasion of privacy</li> </ol> <p>These 5 reasons and more made me wanted to stop showing ads. The ads wonโ€™t be showed in any of the sites on this domain including Demos, Open, Search &amp; Labs.</p> <h2 id="short-posts">Short Posts</h2> <p>Since Iโ€™m constantly busy, I donโ€™t have time to write long, long posts. So I decided to share useful stuff in less words. The first post will be published on 22nd October.</p> <p>The short posts can be seenย <a href="//subinsb.com/category/short-post" target="_blank">here</a>. With this feature, I can publish more posts easily and efficiently.</p> <h2 id="theme-round-border">Themeย : Round Border</h2> <p>Before, there was no round border. Instead, it was just flat. To make it more modern, I have added &quot;border-radius&quot; property with value &quot;10px&quot; to the widgets of sidebar and the article holder.</p> Blocking Brute Force in PHP Website https://subinsb.com/php-block-brute-force/ Tue, 14 Oct 2014 03:30:25 +0000 https://subinsb.com/php-block-brute-force/ <p>Brute Force is a time consuming cracking process to log in to a userโ€™s account of a web site. Itโ€™s not common and requires very high resources including the most important factor : TIME.</p> <h2 id="what8217s-brute-force">Whatโ€™s Brute Force</h2> <p>Suppose, your email website have an account of username &quot;abel&quot;. His big enemy who is a nerd, wants to sendย rubbish stuff to Abelโ€™s friends to make his friends angry. Your site is heavily protected except for Brute Force and the enemy is willing to give as much time to log in to Abelโ€™s account.</p> <p>Enemy makes a file with possible passwords and made a script that send login POST data to siteโ€™s login page. The script is continuously ran with passwords made in every possible way and finally after some hours or days, the enemy entered in to the userโ€™s account.</p> <p>A brute force attack makes millions of requests to your site which eventually makes your site down or heats up your server.</p> <h2 id="solution">Solution</h2> <p>One of the many solutions is to block the user from doing login action for some time after 3 or 5 incorrect login attempts.</p> <p>Another solution is to do aย <strong>captcha</strong> verification every time for login action after 3 or 5 incorrect login attempts.</p> <p>Another way is to temporarily blocking the user account after 3 or 5 incorrect login attempts and that user can only access his / her account after clicking a link that was sent to their email address.</p> <h2 id="efficient-solution">Efficient Solution</h2> <p>There are more solutions which are superbly effective, but requires more usage of database. So, the most efficient way is to take as much less usage of database and at the same time, prevent brute forcing.</p> <p>So, hereโ€™s what weโ€™re going to do :</p> <ul> <li>Create a new column in the users table for storing the current login status of the account</li> <li>Update that column of user everytime the user attempts login whether itโ€™s successful or not</li> <li>Does action according to the value of the column</li> </ul> <p>Letโ€™s add the column with the name &quot;attempt&quot; withย **varchar(15)ย **:</p> <pre class="prettyprint"><code>ALTER TABLE `users` ย ADD `attempt` VARCHAR(15) NOT NULL ;</code></pre> <p>Now, on the code of login processing, we collect the currentย <strong>attempt</strong> value of the user :</p> <pre class="prettyprint"><code>$status = $rows['attempt']; </code></pre> <p>Before we continue, think of theย <strong>$this-&gt;updateUser()</strong> function as a mechanism to update the user details according to theย <strong>array</strong> as the first parameter of the function and the user is mentioned as itโ€™s ID in second parameter.</p> <p>Add this after the code of incorrect password :</p> <pre class="prettyprint"><code>if($status == ""){ // User was not logged in before $this-&gt;updateUser(array( "attempt" =&gt; "1" // Tried 1 time ), $userID); }else if($status == 5){ $this-&gt;updateUser(array( "attempt" =&gt; "b-" . strtotime("+5 minutes", time()) // Blocked, only available for re-login at the time in UNIX timestamp ), $userID); }else if(substr($status, 0, 2) == "b-"){ // Account blocked }else if($status &lt; 5){ // If the attempts are less than 5 and not 5 $this-&gt;updateUser(array( "attempt" =&gt; $status + 1 // Tried current tries + 1 time ), $userID); }</code></pre> <p>What the above code does is update theย <strong>attempt</strong> field of the users table according to existing value in it :</p> <ul> <li>if status is null, then update it with &quot;1&quot;</li> <li>if status is less than &quot;5&quot;, then update it with adding &quot;1&quot; to the existing value</li> <li>if status is &quot;5&quot;, then update it with &quot;b-&quot; plus the timestamp of current time + 5 minutes. eg : &quot;b-1412580325&quot;</li> <li>if status is starting with character &quot;b-&quot;, do nothing</li> </ul> <p>Add this before we check if password hash is that of the login password hash :</p> <pre class="prettyprint"><code>if(substr($status, 0, 2) == "b-"){ $blockedTime = substr($status, 2); if(time() &lt; $blockedTime){ $block = true; }else{ // remove the block, because the time limit is over $this-&gt;updateUser(array( "attempt" =&gt; "" // No tries at all ), $us_id); } }</code></pre> <p>The above code will check if the account is blocked and if it is, then the variableย **$blockย **will have value booleanย <strong>TRUE</strong>. Also, if the time of blocking is over, then theย <strong>attempt</strong> field is updated with a null value.</p> <p>So, before when you check whether password is correct or not, see if theย <strong>$block</strong> variable is set :</p> <pre class="prettyprint"><code>if(!isset($block)){ ย // Check login }</code></pre> <p>If it is set, then donโ€™t process login and display a message to the user that the account is blocked. You can also retrieve the time when the blocking is over fromย <strong>$blockedTime</strong> variable. It is aย **UNIXย **timestamp value, so it can be changed to something like this :</p> <pre class="prettyprint"><code>echo date("Y-m-d H:i:s", $blockedTime); // 2014-10-20 12:00:00</code></pre> <p>This method for blocking brute force attack is used in the login system I created <a href="//subinsb.com/php-logsys">logSys</a>.</p> Accessing /var/log Files in PHP https://subinsb.com/php-access-log-files/ Tue, 07 Oct 2014 03:30:48 +0000 https://subinsb.com/php-access-log-files/ <p>If you have tried to access a log file inย <strong>/var/log</strong> using PHP in Linux, you will see the &quot;Permission denied&quot; error. This is because,ย <strong>Apache</strong> doesnโ€™t have read permission on the log file.</p> <p>Letโ€™s look at the user groups that have permission to access the log files : itโ€™sย <strong>root</strong> and the program which created the file. Suppose, letโ€™s say the log file is &quot;/var/log/squid/access.log&quot;. That fileโ€™s group and owner will be &quot;proxy&quot; and others wonโ€™t even have the read permission on it exceptย **rootย **ofcourse.</p> <p>Since, <strong>Apache</strong> is not in the group ofย <strong>proxy</strong>, it donโ€™t have permission to read or write the file. Here are the 3 ways to grant <strong>Apache</strong>ย access to the file :</p> <ol> <li>Addย <strong>www-data</strong> user into theย <strong>proxy</strong> group</li> <li>Make the group of the log fileย <strong>www-data</strong></li> <li>Change permission of log file toย <strong>0666</strong></li> </ol> <p>But, if theย <strong>Squid</strong> server is restarted, the log file is removed and re created. So, permission are reset to what it should have been. Hence the way 2 &amp; 3 is not permanent.</p> <p>You can addย <strong>www-data</strong> into theย <strong>proxy</strong> group by using this :</p> <pre class="prettyprint"><code>sudo usermod -G proxyย www-data && sudo service apache2 restart</code></pre> <p>The above command also restarts the Apache server to update itโ€™s cache of file permissions or something else (I exactly donโ€™t know why).</p> <p>Note that by doing the above command, you give all permissions thatย <strong>proxy</strong> group has toย <strong>Apache</strong>, even the write permission. This is not exactly required, if you just want to read the log file.</p> <p>In this case, we can use theย <strong>adm</strong> group (itโ€™s not &quot;admin&quot;).ย <strong>adm</strong> group only has read permission to some log files. The group was specifically created to read log files. Note that in versions ofย <strong>Ubuntu</strong> &gt;= 12.04, this was renamed toย <strong>admin</strong>ย (I read it somewhere, but in Lubuntu 14.04, itโ€™s not renamed).</p> <p>Hence, itโ€™s better to addย <strong>www-data</strong> user to theย <strong>adm</strong> group :</p> <pre class="prettyprint"><code>sudo usermod -G admย www-data && sudo service apache2 restart</code></pre> <p>Now, all you have to do is, change the log fileโ€™s group toย <strong>adm</strong>, by using :</p> <pre class="prettyprint"><code>sudo chown proxy:adm /var/log/squid/access.log</code></pre> <p>and the owner of the log file is proxy. The first string before &quot;:&quot; is the user and the second, the group.</p> <p>In this tutorial, we used theย <strong>Squid Web Server</strong>โ€˜s log file as example. Itโ€™s just an example and can be used for any other log files. It can also be used for other files, but be careful โ€“ youโ€™re messing with the coreย of <strong>Linux</strong>.</p> Create HTML Chess Game With jQuery https://subinsb.com/jquery-chess-game/ Tue, 30 Sep 2014 03:30:24 +0000 https://subinsb.com/jquery-chess-game/ <p>We all love to play Chess, the most fascinating game that absolutely needs good thinking powers. You know that, comparing a human to a computer logically and arithmetically, computer has the superior power. So, certainly if you play a chess game with computer as opponent, a 90% chance is for the computer to be the winner. But, it is not sure.</p> <p>It was actually inย <strong>C</strong> language by <a href="https://en.wikipedia.org/wiki/Toledo_Nanochess" target="_blank">Oscar Toledo Gutiรฉrrez</a>, who created chess game program in less than 2 KB. Since, itโ€™sย <strong>C</strong>, compiling is necessary. But, who have time for that. Letโ€™s make it in the web.</p> <div class="padlinks"> <a class="download" href="http://demos.subinsb.com/down.php?id=s/6295t23lh4vj2qk6dz0h&class=32" target="_blank">Download</a><a class="demo" href="http://demos.subinsb.com/jquery/chess" target="_blank">Demo</a> </div> <p>We only needย <strong>jQuery</strong> and a plugin I created for making the game. You can see the plugin code <a href="//lab.subinsb.com/projects/jquery/chess/jquery.chess.js" target="_blank">here</a> and the minified version <a href="//lab.subinsb.com/projects/jquery/chess/jquery.chess.min.js" target="_blank">here</a>.</p> <p>The first thing you need to do is make aย <strong>HTML</strong> file and select the element where you want to addย the game into :</p> <pre class="prettyprint"><code>&lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;script src="//lab.subinsb.com/projects/jquery/core/jquery-latest.js"&gt;&lt;/script&gt; &lt;script src="//lab.subinsb.com/projects/jquery/chess/jquery.chess.min.js"&gt;&lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;div id="content"&gt; &lt;h2&gt;jQuery Chess Game&lt;/h2&gt; &lt;div id="game"&gt;&lt;/div&gt; &lt;/div&gt; &lt;!-- http://subinsb.com/jquery-chess-game --&gt; &lt;/body&gt; &lt;/html&gt;</code></pre> <p>We are loading the latestย <strong>jQuery</strong>ย version and the minified version of the plugin.</p> <p>Now, we tell the plugin to make the game in theย <strong>#game</strong> element :</p> <pre class="prettyprint"><code>$(document).ready(function(){ $("#game").chess(); });</code></pre> <p>Insert the above code in aย <strong><script></strong>ย tag or in a separateย <strong>JS</strong> file and the game will be started on the element.</p> <h2 id="thegame">Theย Game</h2> <p>You will see the 8ร—8 blocks of the chess board with slightly brown and yellow colours. The moulds of the board is not images, but characters ofย <strong>UTF-8</strong> format.</p> <p>When each moulds of game are clicked and moved,ย <strong>JS</strong> processes if the move is valid and makes the move. The chess game code is created inย <strong>JS</strong> byย <a href="http://1kchess.an3.es/" target="_blank">Andrรฉs Moreno</a>ย by porting from theย <strong>C</strong> code byย ร“scar Toledo G.</p> <p>My plugin makes the game board, places the moulds and handle events.</p> <p>Hope you have enjoyed this. Iโ€™m planning to create a multiplayerย <strong>AJAX</strong> version of this in the future. Stay tuned.</p> Finding Exact Document Root in PHP https://subinsb.com/php-find-exact-document-root/ Tue, 23 Sep 2014 03:30:55 +0000 https://subinsb.com/php-find-exact-document-root/ <p>You might know the <strong>DOCUMENT_ROOT</strong> value of theย <strong>$_SERVER</strong> array. This value indicates the absolute location of the site directory where pages are served. In short, itโ€™s the public folder of site as defined in the serverโ€™s configuration. Hereโ€™s a quick example :</p> <p>If you have a site inย <strong>/home/me/site</strong> and can access it byย <strong><a href="http://site.dev">http://site.dev</a></strong>, then theย <strong>$_SERVER[โ€˜DOCUMENT_ROOTโ€™]</strong> isย &quot;/home/me/site&quot;.</p> <p>If any page in the server, even if it is in many sub folders, theย <strong>DOCUMENT_ROOT</strong> value will be the same.</p> <p>This is totally depended on the siteโ€™s configuration. This value wonโ€™t be the same in your localhost server and on the server in the web.</p> <p>In an other case, if you have a project or library that requires accessing files inside it which will be used in many server environments, accessing files byย <strong>$_SERVER[โ€˜DOCUMENT_ROOTโ€™]</strong> is not efficient and possible. In this case, we have to find another way to precisely calculate the libraryโ€™s document path.</p> <p>Any library will have a file thatโ€™s loaded first. As an example, we assume it as &quot;load.php&quot; in the &quot;library&quot; directory and this is the file which includes it :</p> <pre class="prettyprint"><code>&lt;?php include "library/load.php"; ?&gt; </code></pre> <p>and inย <strong>load.php</strong>, we include an other file which is in the libraryโ€™s directory called &quot;file2.php&quot;. Here is how we do it withย <strong>$_SERVER[โ€˜DOCUMENT_ROOTโ€™]</strong> :</p> <pre class="prettyprint"><code>&lt;?php include $_SERVER["DOCUMENT_ROOT"] . "/library/file2.php"; ?&gt;</code></pre> <p>But, we cannot be sure that the directory containing the library is named &quot;library&quot;. So, we should calculate it in the correct way :</p> <pre class="prettyprint"><code>&lt;?php include realpath( dirname(__FILE__) )ย . "/file2.php"; ?&gt;</code></pre> <p>The above will work in all server environments which runย <strong>PHP 5</strong>. The above code can be shortened in another way :</p> <pre class="prettyprint"><code>&lt;?php include realpath(__DIR__)ย . "/file2.php"; ?&gt;</code></pre> <p>Both the ways is the same. Note that we are obtaining the absolute path of the &quot;library&quot; directory from the &quot;load.php&quot; file. So, we donโ€™t need to add &quot;library&quot; before &quot;/file2.php&quot;.</p> <p>Be sure to use this when you are creating a library inย <strong>PHP</strong> for more efficiency and perfect performance in various environments,</p> Create Live Group Chat With PHP, jQuery & WebSocket https://subinsb.com/live-group-chat-with-php-jquery-websocket/ Tue, 16 Sep 2014 03:30:23 +0000 https://subinsb.com/live-group-chat-with-php-jquery-websocket/ <p>With the introduction ofย <strong>HTML5</strong>, a new technology was evolved inย <strong>2011</strong>ย calledย <strong>WebSockets</strong>. This technology enables live connection with the server even after the page finished loading. Itโ€™s a better, replaceable version ofย <strong>AJAX</strong> for client to server communication in the background.</p> <p>With WebSocket technology, its possible to have a direct communication between server and client without any interruption and faster data transmission.</p> <p>So, to demonstrate this to me and for you, Weโ€™re going to create a live group chat withย <strong>PHP</strong>,ย <strong>jQuery</strong>ย with the help ofย <strong>WebSockets</strong>.</p> <div class="padlinks"> <a class="download" href="http://demos.subinsb.com/down.php?id=s/qkuz7ln0zloqslfvzs67&class=30" target="_blank">Download</a><a class="demo" href="http://demos.subinsb.com/php/websocketChat" target="_blank">Demo</a> </div> <h2 id="introduction">Introduction</h2> <p>Here are the main components of the chat weโ€™re going to create :</p> <ul> <li><a href="http://code.jquery.com/jquery-2.1.1.min.js" target="_blank">jQuery 2.1.1</a></li> <li><a href="http://demos.subinsb.com/php/websocketChat/cdn/ws.js" target="_blank">jQuery WebSocket plugin</a></li> <li>PHP 5.3.9 or later</li> <li><a href="http://socketo.me/docs/hello-world" target="_blank">PHP Ratchetย Library</a></li> </ul> <p>You should download the libraries from the hyperlinks of the above components. You should useย <strong>Composer</strong> for downloading the Socketo library.</p> <h2 id="directory-tree">Directory tree</h2> <p>There are only two directories, &quot;cdn&quot; and &quot;inc&quot;. The client side files likeย <strong>JavaScript</strong> andย <strong>CSS</strong> are in the &quot;cdn&quot; directory. Theย <strong>PHP</strong> files for theย <strong>WebSocket</strong> server is in the &quot;inc&quot; directory.</p> <p>Note that, you should downloadย <strong>Ratchet</strong> library usingย <strong>Composer</strong> in the &quot;inc&quot; directory. So, there will be a subfolder in the &quot;inc&quot; directory called &quot;vendor&quot;.</p> <h2 id="database">Database</h2> <p>We only need one table for storing messages called &quot;wsMessages&quot; :</p> <pre class="prettyprint"><code>CREATE TABLE IF NOT EXISTS `wsMessages` ( `name` varchar(20) NOT NULL, `msg` text NOT NULL, `posted` varchar(20) NOT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1;</code></pre> <h2 id="the-interface">The Interface</h2> <p>First, we are going to make the interface ie the <strong>HTML</strong>. This is theย <strong>index.php</strong> file :</p> <pre class="prettyprint"><code>&lt;?php include "config.php"; ?&gt; &lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;script src="cdn/jquery.js"&gt;&lt;/script&gt; &lt;script src="cdn/ws.js"&gt;&lt;/script&gt; &lt;script src="cdn/chat.js"&gt;&lt;/script&gt; &lt;link href="cdn/chat.css" rel="stylesheet"/&gt; &lt;title&gt;PHP Group Chat With jQuery & WebSocket&lt;/title&gt; &lt;/head&gt; &lt;body&gt; &lt;div id="content" style="margin-top:10px;height:100%;"&gt; &lt;center&gt;&lt;h1&gt;Live Group Chat In PHP&lt;/h1&gt;&lt;/center&gt; &lt;div class="chatWindow"&gt; &lt;div class="users"&gt;&lt;/div&gt; &lt;div class="chatbox"&gt; &lt;div class="status"&gt;Offline&lt;/div&gt; &lt;div class="chat"&gt; &lt;div class="msgs"&gt;&lt;/div&gt; &lt;form id="msgForm"&gt; &lt;input type="text" size="30" /&gt; &lt;button&gt;Send&lt;/button&gt; &lt;/form&gt; &lt;/div&gt; &lt;div class="login"&gt; &lt;p&gt;Type in your name to start chatting !&lt;/p&gt; &lt;form id="loginForm"&gt; &lt;input type="text" /&gt; &lt;button&gt;Submit&lt;/button&gt; &lt;/form&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/body&gt; &lt;/html&gt;</code></pre> <p>As you can see, thereโ€™s a chat box and a login box with online usersโ€™ display box. We loadย <strong>jQuery</strong>,ย <strong>ws.js</strong>,ย <strong>chat.js</strong> andย <strong>chat.css</strong> in this page. Also, this is the only page the user needs to see for everything.</p> <h2 id="jquery">jQuery</h2> <p>jQuery must be of versionย <strong>2.1.1</strong>. But, I think it will be compatible with versionsย <strong>1.7</strong> or more.</p> <h2 id="wsjs">ws.js</h2> <p>Theย <strong>jQuery</strong> websocket plugin we mentioned in the Introduction of this post must be in this file.</p> <h2 id="chatjs">chat.js</h2> <p>This is the file which connect to WebSocket server, login the user, sends messages and all the things that does on the client side.</p> <pre class="prettyprint"><code>window.scTop = function(){ $(".chatWindow .chatbox .msgs").animate({ scrollTop : $(".chatWindow .chatbox .msgs")[0].scrollHeight }); }; window.connect = function(){ window.ws = $.websocket("ws://127.0.0.1:8080/", { open: function() { $(".chatWindow .chatbox .status").text("Online"); ws.send("fetch"); }, close: function() { $(".chatWindow .chatbox .status").text("Offline"); }, events: { fetch: function(e) { $(".chatWindow .chat .msgs").html(''); $.each(e.data, function(i, elem){ $(".chatWindow .chat .msgs").append("&lt;div class='msg' title='"+ elem.posted +"'&gt;&lt;span class='name'&gt;"+ elem.name +"&lt;/span&gt; : &lt;span class='msgc'&gt;"+ elem.msg +"&lt;/span&gt;&lt;/div&gt;"); }); scTop(); }, onliners: function(e){ $(".chatWindow .users").html(''); $.each(e.data, function(i, elem){ $(".chatWindow .users").append("&lt;div class='user'&gt;"+ elem.name +"&lt;/div&gt;"); }); }, single: function(e){ var elem = e.data; $(".chatWindow .chat .msgs").append("&lt;div class='msg' title='"+ elem.posted +"'&gt;&lt;span class='name'&gt;"+ elem.name +"&lt;/span&gt; : &lt;span class='msgc'&gt;"+ elem.msg +"&lt;/span&gt;&lt;/div&gt;"); scTop(); } } }); }; $(document).ready(function(){ $(".chatWindow .chat #msgForm").on("submit", function(e){ e.preventDefault(); var form = $(this); var val = $(this).find("input[type=text]").val(); if(val != ""){ ws.send("send", {"msg": val}); form[0].reset(); } }); $(".chatWindow .login #loginForm").on("submit", function(e){ e.preventDefault(); var val = $(this).find("input[type=text]").val(); if(val != ""){ ws.send("register", {"name": val}); ws.send("fetch"); $(".chatWindow .login").fadeOut(1000, function(){ $(".chatWindow .chat").fadeIn(1000, function(){ scTop(); $(".chatWindow .chat #msgForm input[type=text]").focus(); }); }); } }); $(".chatWindow .chatbox .status").on("click", function(){ if($(this).text() == "Offline"){ connect(); } }); setInterval(function(){ ws.send("onliners"); }, 4000); connect(); });</code></pre> <p>We connect to server usingย <strong>window.connect()</strong> function which can also be called asย <strong>connect()</strong> function and theย <strong>WebSocket</strong>ย plugin object is stored inย <strong>window.ws</strong> variable.</p> <p>The URL of the server is mentioned in the above script as &quot;127.0.0.1:8080&quot;. We will get to it later.</p> <p>There is a function that is called every 4 seconds, to update the userโ€™s online presence and fetching the online users from the server.</p> <p>But, there might be some errors in the console, because this interval function is sometimes called before the connection to the server is established. So, donโ€™t care about those errors.</p> <p>There is also a small box which shows the status of the connection between server and client. If itโ€™s &quot;Offline&quot; and the user clicks it, <strong>connect()</strong> function is called to try again to establish a connection.</p> <p>This file also has code that responds with the messages the server sends to the client like online status of users, messages sent by other users etc.. This can be seen in the value ofย <strong>events</strong>ย key of <strong>JSON</strong> array inย <strong>$.websocket</strong> function.</p> <h2 id="chatcss">chat.css</h2> <p>Now, letโ€™s style the chat page :</p> <pre class="prettyprint"><code>.chatWindow .users, .chatWindow .chatbox{ display:inline-block; vertical-align:top; height:330px; padding: 0px 15px; position:relative; } .chatWindow .users{ background: #6AAEEC; color:white; width: 100px; padding: 10px 15px; overflow-y:auto; } .chatWindow .chatbox{ color:black; width: 330px; } .chatWindow .chatbox .status{ background: #ABC8F8; padding: 5px 15px; } .chatWindow .chatbox .chat { display: none; background:#fff; } .chatWindow .chatbox .chat .msgs{ border-top: 1px solid black; border-bottom: 1px solid black; overflow-y: auto; height: 300px; } .chatWindow .chatbox #msgForm{ padding-top: 1.5px; } .chatWindow .msgs .msg, .chat .users .user{ border-bottom:1px solid black; padding:4px 10px; white-space:pre-line; word-break:break-word; }</code></pre> <p>All the element selectors in the stylesheet starts withย <strong>.chatWindow</strong> to avoid applyingย <strong>CSS</strong> rules to other elements.</p> <h2 id="configphp">config.php</h2> <p>The configuration for connecting to database is in here. Also, this file is used / required by some of the otherย <strong>PHP</strong> files. Each time, this file is called, it sends a request to start theย <strong>WebSocket</strong> server if itโ€™s not already started.</p> <pre class="prettyprint"><code>&lt;?php // ini_set("display_errors","on"); $docRoot = realpath(dirname(__FILE__)); if( !isset($dbh) ){ session_start(); date_default_timezone_set("UTC"); $musername = "root"; $mpassword = "backstreetboys"; $hostname = "localhost"; $dbname = "test"; $dbh = new PDO("mysql:dbname={$dbname};host={$hostname};port={$port}",$musername, $mpassword); /* Change The Credentials to connect to database. */ include_once "$docRoot/inc/startServer.php"; } ?&gt;</code></pre> <p>The files youโ€™re going to see below should be in the &quot;inc&quot; directory.</p> <h2 id="serverstatustxt">serverStatus.txt</h2> <p>A normal text file. This file is used to determine whether the server was started (1) or it isnโ€™t running currently (0). As a default value, set the file content toย &quot;0&quot;. It is required for this file to have the permission ofย <strong>Read &amp; Write</strong> (0666).</p> <h2 id="classchatphp">class.chat.php</h2> <p>The operations done when a user connects to the server and all the actions done between the server and client is in this file :</p> <pre class="prettyprint"><code>&lt;?php use RatchetMessageComponentInterface; use RatchetConnectionInterface; class ChatServer implements MessageComponentInterface { protected $clients; private $dbh; private $users = array(); public function __construct() { global $dbh, $docRoot; $this-&gt;clients = new SplObjectStorage; $this-&gt;dbh = $dbh; $this-&gt;root = $docRoot; } public function onOpen(ConnectionInterface $conn) { $this-&gt;clients-&gt;attach($conn); $this-&gt;send($conn, "fetch", $this-&gt;fetchMessages()); $this-&gt;checkOnliners(); echo "New connection! ({$conn-&gt;resourceId})n"; } public function onMessage(ConnectionInterface $from, $data) { $id = $from-&gt;resourceId; $data = json_decode($data, true); if(isset($data['data']) && count($data['data']) != 0){ $type = $data['type']; $user = isset($this-&gt;users[$id]) ? $this-&gt;users[$id]['name'] : false; if($type == "register"){ $name = htmlspecialchars($data['data']['name']); $this-&gt;users[$id] = array( "name" =&gt; $name, "seen" =&gt; time() ); }elseif($type == "send" && $user !== false){ $msg = htmlspecialchars($data['data']['msg']); $sql = $this-&gt;dbh-&gt;prepare("INSERT INTO `wsMessages` (`name`, `msg`, `posted`) VALUES(?, ?, NOW())"); $sql-&gt;execute(array($user, $msg)); foreach ($this-&gt;clients as $client) { $this-&gt;send($client, "single", array("name" =&gt; $user, "msg" =&gt; $msg, "posted" =&gt; date("Y-m-d H:i:s"))); } }elseif($type == "fetch"){ $this-&gt;send($from, "fetch", $this-&gt;fetchMessages()); } } $this-&gt;checkOnliners($from); } public function onClose(ConnectionInterface $conn) { if( isset($this-&gt;users[$conn-&gt;resourceId]) ){ unset($this-&gt;users[$conn-&gt;resourceId]); } $this-&gt;clients-&gt;detach($conn); } public function onError(ConnectionInterface $conn, Exception $e) { $conn-&gt;close(); } /* My custom functions */ public function fetchMessages(){ $sql = $this-&gt;dbh-&gt;query("SELECT * FROM `wsMessages`"); $msgs = $sql-&gt;fetchAll(); return $msgs; } public function checkOnliners($curUser = ""){ date_default_timezone_set("UTC"); if( $curUser != "" && isset($this-&gt;users[$curUser-&gt;resourceId]) ){ $this-&gt;users[$curUser-&gt;resourceId]['seen'] = time(); } $curtime = strtotime(date("Y-m-d H:i:s", strtotime('-5 seconds', time()))); foreach($this-&gt;users as $id =&gt; $user){ $usertime = $user['seen']; if($usertime &lt; $curtime){ unset($this-&gt;users[$id]); } } /* Send online users to evryone */ $data = $this-&gt;users; foreach ($this-&gt;clients as $client) { $this-&gt;send($client, "onliners", $data); } } public function send($client, $type, $data){ $send = array( "type" =&gt; $type, "data" =&gt; $data ); $send = json_encode($send, true); $client-&gt;send($send); } } ?&gt;</code></pre> <p>Since the server is always running, we store the online users in an array variable inside the <strong>ChatServer</strong> class called &quot;users&quot;. Each user that connects to the server has a unique connection code. This is also added within the array of variable. But, a new item is only added when the registration data is sent to server. An example item ofย <strong>ChatServer::users</strong> array :</p> <pre class="prettyprint"><code>15 =&gt; array( ย "name" =&gt; "Subin", "seen" =&gt; 1410624788 )</code></pre> <p>The &quot;seen&quot; key is for storing the timestamp of the usersโ€™ last online presence. If this time is less than that of 5 seconds of current time, the user is removed as he is offline. Seeย <strong>ChatServer::checkOnliners()</strong> function for seeing this.</p> <p>The user registration, message sending and message fetching are all taken care by theย <strong>ChatServer::onMessage()</strong> function.</p> <p>The messages sent by the user and the name of user is filtered forย <strong>HTML</strong>ย code to preventย <strong>XSS</strong> injection.</p> <p>There are no cookie or session in this. If the user closes the browser window, then he/she is eliminated from the online users and have to re register for chatting again.</p> <p><strong>ChatServer::checkOnliners()</strong> also updates theย &quot;seen&quot; timestamp value of the current user each time itโ€™s called.</p> <h2 id="serverphp">server.php</h2> <p>This is the script that starts theย <strong>WebSocket</strong> server :</p> <pre class="prettyprint"><code>&lt;?php use RatchetServerIoServer; use RatchetHttpHttpServer; use RatchetWebSocketWsServer; function shutdown(){ global $docRoot; file_put_contents("$docRoot/inc/serverStatus.txt", "0"); require_once "$docRoot/inc/startServer.php"; } register_shutdown_function('shutdown'); if( isset($startNow) ){ require_once "$docRoot/inc/vendor/autoload.php"; require_once "$docRoot/inc/class.chat.php"; $server = IoServer::factory( new HttpServer( new WsServer( new ChatServer() ) ), 8080, "127.0.0.1" ); $server-&gt;run(); } ?&gt;</code></pre> <p>The above script listens requests to the portย <strong>8080</strong> of IPย <strong>127.0.0.1</strong> or localhost. So, any request toย <strong>127.0.0.1:8080</strong> is processed by the above script. If you want to change the port and URL, change it in this file and also in theย <strong>cdn/chat.js</strong> file.</p> <p>In any case the above script was terminated, it automatically starts back due to the callbackย used in theย <strong>register_shutdown_function()</strong>. This file canโ€™t operate on itโ€™s own, because it needsย <strong>config.php</strong> which has been not yet included in this file, because actually this file is used by another one calledย <strong>bg.php</strong>.</p> <h2 id="bgphp">bg.php</h2> <p>To run the server, this file should be ran :</p> <pre class="prettyprint"><code>&lt;?php require_once realpath(__DIR__) . "/../config.php"; $startNow = 1; include_once "$docRoot/inc/server.php"; ?&gt;</code></pre> <p>You can run this file by the following command inย <strong>Linux</strong> :</p> <pre class="prettyprint"><code>php bg.php</code></pre> <h2 id="startserverphp">startServer.php</h2> <p>The server is automatically started when the user visits the chat page if itโ€™s not already started. This file starts the server if itโ€™s not started in the background. This file is called by theย <strong>config.php</strong> file.</p> <pre class="prettyprint"><code>&lt;?php require_once realpath(dirname(__DIR__)) . "/config.php"; $statusFile = "$docRoot/inc/serverStatus.txt"; $status = file_get_contents($statusFile); if($status == "0"){ /* This means, the WebSocket server is not started. So we, start it */ function execInbg($cmd) { if (substr(php_uname(), 0, 7) == "Windows"){ pclose(popen("start /B ". $cmd, "r")); } else { exec($cmd . " &gt; /dev/null &"); } } execInbg("php $docRoot/inc/bg.php"); file_put_contents($statusFile, 1); } ?&gt;</code></pre> <p>If the content of the &quot;serverStatus.txt&quot; file is &quot;0&quot;, then a command is executed by this file to run theย <strong>bg.php</strong> file in the background. This means that the server started running in the background. If it started running, then the fileโ€™s contents is changed to &quot;1&quot; and this file wonโ€™t do anything if the value is &quot;1&quot;.</p> <p>The command executed by this script is different for bothย <strong>Linux</strong> and**ย Windows**.</p> <p>Thus the server is started and the client can start communicating with the server and the chatting works. This tutorial is completed. If you encountered any problems, please comment and Iโ€™ll be here (most of the times) to help you. Cheers ! ๐Ÿ™‚</p> Record, Play, Download Microphone Sound With HTML5 https://subinsb.com/html5-record-mic-voice/ Sun, 14 Sep 2014 18:12:23 +0000 https://subinsb.com/html5-record-mic-voice/ <p><strong>HTML5</strong> has tons of new stuff that are exciting and very interesting. It arrived with features that would replace the need ofย <strong>Flash</strong> in browsers. Since the features that were available in Flash is coming into the nativeย <strong>JavaScript</strong>, soon we wonโ€™t have to update our Flash player plugin and depend onย <strong>Adobe</strong> for new awesome features.</p> <p>More integration with hardware technologies to the Web is the main important thing. We can now access the audio &amp; video hardware of the userโ€™s system efficiently with less code.</p> <p>In this tutorial, I will introduce you to a small plugin I created to record, play &amp; download the microphone input voice of the user. This is made possible by theย <strong>Web Audio API</strong>.</p> <div class="padlinks"> <a class="download" href="https://github.com/subins2000/Francium-voice/archive/master.zip" target="_blank">Download</a><a class="demo" href="http://demos.subinsb.com/Francium/voice" target="_blank">Demo</a> </div> <h1 id="project-abandoned">Project Abandoned</h1> <p>Iโ€™m abandoning Francium Voice due to lack of interest in maintaining it. No more support will be given in comments or email.</p> <p>As an alternative you may use Yuji Miyaneโ€™sย <a href="https://github.com/higuma/web-audio-recorder-js">WebAudioRecorderJS</a>.</p> <h1 id="notice">NOTICE</h1> <p>Since Chrome 47, Web Audio API works only on HTTPS sites and localhost.</p> <p>When Audio API is used for recording sound on non HTTPS sites and non localhost, console would say :</p> <pre><code class="php">getUserMedia() no longer works on insecure origins. To &lt;span class="keyword">use&lt;/span> &lt;span class="keyword">this&lt;/span> feature, you should consider switching your application to a secure origin, such &lt;span class="keyword">as&lt;/span> HTTPS. See https:&lt;span class="comment">//goo.gl/rStTGz for more details. &lt;/span></code></pre> <p>and the Fr.voice would alert the message :</p> <pre class="prettyprint"><code>No Live Audio Input</code></pre> <p>So to use Fr.voice, your site must have anย <strong>SSL</strong> certificate. But it will work in localhost even if it doesnโ€™t have an HTTPS connection.</p> <h1 id="features">Features</h1> <ul> <li>Record, Play, Download recorded audio</li> <li>Ability to Pause Recording &amp; Resume (Thanks <a href="//subinsb.com/html5-record-mic-voice#comment-2344087099" target="_blank">Gaurav</a>)</li> <li><a href="#article-record-for-a-specific-time">Record for a specific time</a></li> <li>Convertย <strong>WAV audio to MP3</strong> which will help reduce the size of recorded audio</li> <li>Upload recorded audio to server as BLOB or base64 etc.</li> </ul> <h1 id="introduction">Introduction</h1> <p>We will only useย <strong>HTML</strong>,ย <strong>JS</strong> &amp;ย <strong>CSS</strong>. There arenโ€™t any server side stuff in this one. We only have one sub folder for theย <strong>JS</strong> files called &quot;cdn&quot;.</p> <p>As I said before, I have created a <strong>jQueryย plugin</strong> for recording the voice and managing it. It needsย <strong>RecorderJS</strong> for working. You can get it from <a href="https://github.com/mattdiamond/Recorderjs" target="_blank">here</a>. Note that the plugin also needs &quot;recorderWorker.js&quot; which is in the same GitHub repository.</p> <p>You can get my Voice plugin from <a href="//lab.subinsb.com/projects/jquery/voice/jquery.voice.js" target="_blank">here</a> and name it as &quot;jquery.voice.js&quot; in the &quot;cdn&quot; directory.</p> <h1 id="main-page">Main Page</h1> <p>We have only one page to display to the user :</p> <pre class="prettyprint"><code>&lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;script src="//lab.subinsb.com/projects/jquery/core/jquery-2.1.1.js"&gt;&lt;/script&gt; &lt;script src="//lab.subinsb.com/projects/jquery/voice/recorder.js"&gt;&lt;/script&gt; &lt;script src="//lab.subinsb.com/projects/jquery/voice/jquery.voice.min.js"&gt;&lt;/script&gt; &lt;script src="cdn/record.js"&gt;&lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;div id="content"&gt; &lt;h2&gt;Record, Play & Download Microphone Voice&lt;/h2&gt; &lt;audio controls src="" id="audio"&gt;&lt;/audio&gt; &lt;div style="margin:10px;"&gt; &lt;a class="button" id="record"&gt;Record&lt;/a&gt; &lt;a class="button disabled one" id="stop"&gt;Reset&lt;/a&gt; &lt;a class="button disabled one" id="play"&gt;Play&lt;/a&gt; &lt;a class="button disabled one" id="download"&gt;Download&lt;/a&gt; &lt;a class="button disabled one" id="base64"&gt;Base64 URL&lt;/a&gt; &lt;a class="button disabled one" id="mp3"&gt;MP3 URL&lt;/a&gt; &lt;/div&gt; &lt;input class="button" type="checkbox" id="live"/&gt; &lt;label for="live"&gt;Live Output&lt;/label&gt; &lt;style&gt; .button{ display: inline-block; vertical-align: middle; margin: 0px 5px; padding: 5px 12px; cursor: pointer; outline: none; font-size: 13px; text-decoration: none !important; text-align: center; color:#fff; background-color: #4D90FE; background-image: linear-gradient(top,#4D90FE, #4787ED); background-image: -ms-linear-gradient(top,#4D90FE, #4787ED); background-image: -o-linear-gradient(top,#4D90FE, #4787ED); background-image: linear-gradient(top,#4D90FE, #4787ED); border: 1px solid #4787ED; box-shadow: 0 1px 3px #BFBFBF; } a.button{ color: #fff; } .button:hover{ box-shadow: inset 0px 1px 1px #8C8C8C; } .button.disabled{ box-shadow:none; opacity:0.7; } &lt;/style&gt; &lt;/div&gt; &lt;/body&gt; &lt;/html&gt;</code></pre> <p>As you can see, we only use CSS for styling the button and nothing else. We also donโ€™t include the &quot;recorderWorker.js&quot;, because itโ€™s loaded by the &quot;recorder.js&quot; which we have included in the page.</p> <h1 id="recordjs">record.js</h1> <p>This file adds event listeners to the buttons to control recording and initiates the functions :</p> <pre class="prettyprint"><code>function restore(){ $("#record, #live").removeClass("disabled"); $(".one").addClass("disabled"); Fr.voice.stop(); } $(document).ready(function(){ $(document).on("click", "#record:not(.disabled)", function(){ elem = $(this); Fr.voice.record($("#live").is(":checked"), function(){ elem.addClass("disabled"); $("#live").addClass("disabled"); $(".one").removeClass("disabled"); }); }); $(document).on("click", "#stop:not(.disabled)", function(){ restore(); }); $(document).on("click", "#play:not(.disabled)", function(){ Fr.voice.export(function(url){ $("#audio").attr("src", url); $("#audio")[0].play(); }, "URL"); restore(); }); $(document).on("click", "#download:not(.disabled)", function(){ Fr.voice.export(function(url){ $("&lt;a href='"+url+"' download='MyRecording.wav'&gt;&lt;/a&gt;")[0].click(); }, "URL"); restore(); }); $(document).on("click", "#base64:not(.disabled)", function(){ Fr.voice.export(function(url){ console.log("Here is the base64 URL : " + url); alert("Check the web console for the URL"); $("&lt;a href='"+ url +"' target='_blank'&gt;&lt;/a&gt;")[0].click(); }, "base64"); restore(); }); $(document).on("click", "#mp3:not(.disabled)", function(){ alert("The conversion to MP3 will take some time (even 10 minutes), so please wait...."); Fr.voice.export(function(url){ console.log("Here is the MP3 URL : " + url); alert("Check the web console for the URL"); $("&lt;a href='"+ url +"' target='_blank'&gt;&lt;/a&gt;")[0].click(); }, "mp3"); restore(); }); });</code></pre> <p>Theย <strong>restore()</strong>ย function reverts the action buttons to itโ€™s original state ( Record โ€“ enabled, other buttons โ€“ disabled).</p> <h1 id="configure">Configure</h1> <p>The location of theย &quot;recorderWorker.js&quot; should be mentioned in the <strong>Fr.workerPath</strong> itemย of &quot;jquery.voice.js&quot; file. This is really necessary for the working. By default, itโ€™s value is :</p> <pre class="prettyprint"><code>cdn/recorderWorker.js</code></pre> <p>Itโ€™s a relative path from the file itโ€™s ran. If the file location is <a href="http://mySite.com/project/index.html">http://mySite.com/project/index.html</a> and &quot;recorderWorker.js&quot; is in <a href="http://mySite.com/project/cdn/recorderWorker.js">http://mySite.com/project/cdn/recorderWorker.js</a> , then the value should be the above &quot;cdn/recorderWorker.js&quot;.</p> <p>From versionย <strong>0.3</strong> onwards, if youโ€™re going to useย <strong>MP3</strong> conversion, you have to configure the value ofย <strong>Fr.mp3WorkerPath</strong> item. The default value is :</p> <pre class="prettyprint"><code>cdn/mp3Worker.js</code></pre> <p>Also, for <strong>MP3</strong> you have to define the path ofย <strong><a href="//lab.subinsb.com/projects/jquery/voice/libmp3lame.min.js" target="_blank">libmp3lame.min.js</a></strong> in the first line ofย <strong><a href="//lab.subinsb.com/projects/jquery/voice/mp3Worker.js" target="_blank">mp3Worker.js</a></strong>.</p> <h1 id="recording">Recording</h1> <p>We start recording by calling the functionย <strong>Fr</strong>**.voice.record();** and the user will be asked for authorizing the use of microphone. if the user accepts it, recording will start and if user declined, an alert box will be opened.</p> <pre class="prettyprint"><code>Fr.voice.record(false, callback());</code></pre> <p>There is also a feature to live output the recording voice to the speaker. You can do this by making the first parameter ofย <strong>Fr.voice.record()</strong> to booleanย <strong>true</strong>.</p> <p>The recording is stopped usingย :</p> <pre class="prettyprint"><code>Fr.voice.stop(); </code></pre> <p>It doesnโ€™t accept any parameters and the return value will beย <strong>Fr.voice</strong> object itself.</p> <h1 id="pausing--resuming">Pausing &amp; Resuming</h1> <p>You can pause the audio recording and resume later with Fr.voice.ย To pause recording, just do this :</p> <pre class="prettyprint"><code>Fr.voice.pause();</code></pre> <p>and sometime later, you can resume the recording by :</p> <pre class="prettyprint"><code>Fr.voice.resume();</code></pre> <p>This feature was added in versionย <strong>0.4</strong></p> <h1 id="record-for-a-specific-time">Record For A Specific Time</h1> <p>You can record audio for a specific time :</p> <pre class="prettyprint"><code>Fr.voice.record(...); Fr.voice.stopRecordingAfter(5000, function(){ alert("Time limit reached."); }); </code></pre> <p>Do the recording normally and callย <strong>Fr.voice.stopRecordingAfter()</strong>ย with the limiting time. The time should be in milliseconds. The above example uses &quot;5000&quot; = 5 seconds.</p> <h1 id="export">Export</h1> <p><strong>Fr.voice.export</strong> can be used for obtaining the recorded audioย <strong>URL</strong> and the blob data of the recorder audio. Example of obtaining blob data :</p> <pre class="prettyprint"><code>Fr.voice.export(function(blob){ console.log(blob); // The blob data }, "blob");</code></pre> <p>It is not necessarily required to make the 2nd parameter value to &quot;blob&quot;, because by default itโ€™s set as &quot;blob&quot;.</p> <p>You can also get the <strong>blob URL</strong> of the recorded audio :</p> <pre class="prettyprint"><code>Fr.voice.export(function(url){ console.log(url); // The blob URL }, "URL");</code></pre> <p>An example of making an audio element to play the audio file :</p> <pre class="prettyprint"><code>Fr.voice.export(function(url){ $("&lt;audio src='"+ url +"'&gt;&lt;/audio&gt;").appendTo("body"); $("body audio:last")[0].play(); }, "URL");</code></pre> <h2 id="base64">Base64</h2> <p>(This feature has been suggested by the user <a href="//subinsb.com/html5-record-mic-voice#comment-1813336374"><strong>payam</strong></a>ย in the comments)</p> <p>You can obtain theย <strong>base64</strong> data of the audio withย <strong>$.voice.export</strong> and this data can be used to store the audio in theย <strong>database</strong>.</p> <pre class="prettyprint"><code>Fr.voice.export(function(base64){ $.post("server.php", {"audio" : base64}, function(){ // Sent To Server }); }, "base64"); </code></pre> <p>All you got to do in the server is to store the sent data in the database.</p> <h2 id="send-blob-directly">Send BLOB Directly</h2> <p>You can also upload the BLOB file usingย <strong>HTML5</strong>โ€˜sย <strong>FormData</strong>ย function. Example :</p> <pre class="prettyprint"><code>Fr.voice.export(function(blob){ var data = new FormData(); data.append('file', blob); $.ajax({ url: "server.php", type: 'POST', data: data, contentType: false, processData: false, success: function(data) { // Sent to Server } }); }, "blob");</code></pre> <h1 id="export-mp3">Export MP3</h1> <p>You can exportย <strong>MP3</strong>ย (from version 0.3) as blob, base64 or blob URL just like exporting WAV :</p> <pre class="prettyprint"><code>Fr.voice.exportMP3(function(blob){ console.log(blob); }); Fr.voice.exportMP3(function(base64){ console.log(base64); }, "base64"); Fr.voice.exportMP3(function(url){ console.log(url); // The blob URL }, "URL"); </code></pre> <h1 id="server">Server</h1> <h2 id="save-in-database">Save In Database</h2> <p>Here is an example of the server side script using <strong>PDO</strong>ย :</p> <pre class="prettyprint"><code>&lt;?php if(isset($_POST['audio'])){ $audio = $_POST['audio']; $sql = $PDO-&gt;prepare("INSERT INTO `myTable` VALUES (?)"); $sql-&gt;execute(array($audio)); }</code></pre> <p>Now, the database table will have a value like this :</p> <pre class="prettyprint"><code>data:audio/wav;base64,UklGRiQAAgBXQVZFZm10IBAAAAABAAIARKwAABCxAgAEABAAZGF0YQAAAgAAAAAAAAAAAAAAA.......</code></pre> <p>This will be a long long value. So, make sure the database columnโ€™s type is set to &quot;LONGTEXT&quot; in <strong>MySQL</strong>.</p> <p>When you want to play it, make an audio element with `src` attribute with this base64 value obtained from database. Example :</p> <pre class="prettyprint"><code>&lt;?php $sql = $PDO-&gt;query("SELECT `audio` FROM `myTable` WHERE `id` = 'whatever'"); $base64 = $sql-&gt;fetchColumn(); echo "&lt;audio src='". $base64 ."'&gt;&lt;/audio&gt;";</code></pre> <h2 id="saving-as-files">Saving as Files</h2> <p>This is the same as the previous one. Send the base64 data to the server and in the server, do as follows :</p> <pre class="prettyprint"><code>&lt;?php if(isset($_POST['audio'])){ $audio = $_POST['audio']; $audio = str_replace('data:audio/wav;base64,', '', $audio); $decoded = base64_decode($audio); $file_location = "./save_folder/recorded_audio.wav"; file_put_contents($file_location, $decoded); }</code></pre> <p>And when you need to retrieve audio, just link the src value of the audio object to the file location in server.</p> <h2 id="saving-as-blob-in-database">Saving As BLOB In Database</h2> <p>Another method to save is storing the original audio data as blob in MySQL database. For this create a uploads table :</p> <pre class="prettyprint"><code>CREATE TABLE IF NOT EXISTS `uploads` ( `id` int(11) NOT NULL, `audio` longblob NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ; </code></pre> <p>Then, get the blob from browser and save it. Example :</p> <pre class="prettyprint"><code>&lt;?php if(isset($_FILES['file'])){ $audio = file_get_contents($_FILES['file']['tmp_name']); require_once __DIR__ . "/db.php"; $sql = $dbh-&gt;prepare("INSERT INTO `uploads` (`audio`) VALUES(?)"); $sql-&gt;execute(array($audio)); $sql = $dbh-&gt;query("SELECT `id` FROM `uploads` ORDER BY `id` DESC LIMIT 1"); $id = $sql-&gt;fetchColumn(); echo "play.php?id=$id"; }</code></pre> <p>The &quot;db.php&quot; contains variableย <strong>$PDO</strong> that contains the PDO object to access database. Then when you need to get it back, use this as &quot;play.php&quot; file :</p> <pre class="prettyprint"><code>&lt;?php if(isset($_GET['id'])){ require_once __DIR__ . "/db.php"; $sql = $dbh-&gt;prepare("SELECT `audio`, LENGTH(`audio`) FROM `uploads` WHERE `id` = ?"); $sql-&gt;execute(array($_GET['id'])); $result = $sql-&gt;fetch(); $audio = $result[0]; $size = $result[1]; header("Content-Length: $size"); header("Content-Type: audio/wav"); echo $audio; }</code></pre> <p>If you used theย <strong>HTML5</strong>โ€˜s <strong>FormData()</strong> method, then useย <strong>$_FILES[โ€˜fileโ€™]</strong> variable to access the file. You can see this example above.</p> <p>Thatโ€™s it. The Voice plugin contains only <strong>90</strong> lines of code, because most of the work is done by &quot;recorder.js&quot;. The Voice plugin is just for making the complicated &quot;recorder.js&quot; file to a simple one.</p> Animated AJAX Login Form With jQuery https://subinsb.com/jquery-animated-ajax-login-form/ Tue, 12 Aug 2014 03:30:40 +0000 https://subinsb.com/jquery-animated-ajax-login-form/ <p>The Web is growing rapidly. Each day, new features are arriving. With the coming ofย <strong>AJAX</strong>, many websites became more easy to handle. Withย <strong>jQuery</strong>, websites became more attractive with animations and styles. In this tutorial, we are going to create a stylish animated Login Form withย <strong>jQuery</strong>,ย <strong>CSS</strong>ย &amp;ย <strong>AJAX</strong>. With this, the login time for the user is greatly reduced as the page shouldnโ€™t be loader all over again.</p> <div class="padlinks"> <a class="download" href="http://demos.subinsb.com/down.php?id=s/qlv8a8lje4ktjpjfkke3&class=29" target="_blank">Download</a><a class="demo" href="http://demos.subinsb.com/jquery/ajaxLogin" target="_blank">Demo</a> </div> <h2 id="the-login-page">The Login Page</h2> <p>We make a login page first loading withย <strong>jQuery</strong> and the stylesheet :</p> <pre class="prettyprint"><code>&lt;!DOCTYPE html&gt; &lt;html&gt; ย  ย &lt;head&gt; ย  ย ย  ย &lt;script src="http://code.jquery.com/jquery-1.9.0.min.js"&gt;&lt;/script&gt; ย  ย ย  ย &lt;script src="form.js"&gt;&lt;/script&gt; ย  ย ย  ย &lt;link href="form.css" rel="stylesheet" /&gt; ย  ย &lt;/head&gt; ย  ย &lt;body&gt; ย  ย ย  ย &lt;div id="content"&gt; ย  ย ย  ย ย  ย &lt;div class="loginForm"&gt; ย  ย ย  ย ย  ย ย  ย &lt;label&gt; ย  ย ย  ย ย  ย ย  ย ย  ย &lt;span&gt;Username&lt;/span&gt; ย  ย ย  ย ย  ย ย  ย ย  ย &lt;input type="text" name="username" /&gt; ย  ย ย  ย ย  ย ย  ย &lt;/label&gt; ย  ย ย  ย ย  ย  ย ย &lt;label&gt; ย  ย ย  ย ย  ย ย  ย ย  ย &lt;span&gt;Password&lt;/span&gt; ย  ย ย  ย ย  ย ย  ย ย  ย &lt;input type="password" name="password" /&gt; ย  ย ย  ย ย  ย ย  ย &lt;/label&gt; ย  ย ย  ย ย  ย ย  ย &lt;div class="submit"&gt;Log In&lt;/div&gt; ย  ย ย  ย ย  ย ย  ย &lt;div class="overlay"&gt; ย  ย ย  ย ย  ย ย  ย ย  ย &lt;div class="message processing"&gt; ย  ย ย  ย ย  ย ย  ย ย  ย ย  ย &lt;h2&gt;Logging In&lt;/h2&gt; ย  ย ย  ย ย  ย ย  ย ย  ย &lt;/div&gt; ย  ย ย  ย ย  ย ย  ย ย  ย &lt;div class="message error"&gt; ย  ย ย  ย ย  ย ย  ย ย  ย ย  ย &lt;h2&gt;Incorrect Credentials&lt;/h2&gt; ย  ย ย  ย ย  ย ย  ย ย  ย ย  ย &lt;p&gt;The username or password you entered was not correct&lt;/p&gt; ย  ย ย  ย ย  ย ย  ย ย  ย &lt;/div&gt; ย  ย ย  ย ย  ย ย  ย ย  ย &lt;div class="message success"&gt; ย  ย ย  ย ย  ย ย  ย ย  ย ย  ย &lt;h2&gt;Logged In&lt;/h2&gt; ย  ย ย  ย ย  ย ย  ย ย  ย ย  ย &lt;p&gt;You have been logged in&lt;/p&gt; ย  ย ย  ย ย  ย ย  ย ย  ย &lt;/div&gt; ย  ย ย  ย ย  ย ย  ย &lt;/div&gt; ย  ย ย  ย ย  ย &lt;/div&gt; ย  ย ย  ย &lt;/div&gt; ย  ย &lt;/body&gt; &lt;/html&gt;</code></pre> <p>We have a login form with two fields : username and password with a login button. We also have an overlay showing messages on each actions. Note that the login form is not wrapped in the nativeย <strong><form></strong> tag.</p> <h2 id="formcss">form.css</h2> <p>Weย style the login form, make it attractive using this stylesheet :</p> <pre class="prettyprint"><code>.loginForm{ display:table; margin: 20px auto; padding: 6px 24px 26px; position:relative; font-weight: 400; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.13); } .loginForm .overlay{ position: absolute; top: 0px; left: 0px; right: 0px; bottom: 0px; padding: 50px 30px; display: none; background: rgba(204, 204, 204, 0.7); text-align: center; } .loginForm .overlay .message{ display: none; } .loginForm label{ display: block; margin-top: 20px; } .loginForm label span{ color: #777; display: block; font-size: 14px; } .loginForm input[type=text], .loginForm input[type=password]{ margin-top: 5px; background: #fbfbfb; padding: 3px; border: 1px solid #ddd; box-shadow: inset 0 1px 2px rgba(0,0,0,.07); font-size: 24px; } .loginForm .submit{ display: inline-block; padding: 7px 15px; margin-top: 15px; background: #23A3F8; color: white; cursor: pointer; box-shadow: 0 1px 3px rgba(0,0,0,.13); } .loginForm .submit:hover{ box-shadow: inset 0 1px 2px rgba(0,0,0,.07); } .loginForm .submit:active{ box-shadow: rgba(0, 0, 0, 0.498039) 0px 2px 10px -3px inset; }</code></pre> <h2 id="formjs">form.js</h2> <p>The core component of the login form lies within this JavaScript file :</p> <pre class="prettyprint"><code>var settings = { ย  ย checkURL : "login.php", ย  ย form : ".loginForm", ย  ย username : ".loginForm input[name=username]", ย  ย password : ".loginForm input[name=password]", ย  ย overlay : ".loginForm .overlay", ย  ย success : ".loginForm .overlay .success", ย  ย error ย  ย : ".loginForm .overlay .error", ย  ย process : ".loginForm .overlay .processing", }; function overlayDisplay(elem, type){ ย  ย if( type == "hide" ){ ย  ย ย  ย $(elem).fadeOut(1000, function(){ ย  ย ย  ย ย  ย $(settings.overlay).hide(); ย  ย ย  ย }); ย  ย }else{ ย  ย ย  ย $(settings.overlay).show(); ย  ย ย  ย $(elem).fadeIn(1000); ย  ย ย  ย /* Auto fade the error overlay and clear the password field after 3 seconds */ ย  ย ย  ย if( elem == settings.error ){ ย  ย ย  ย ย  ย $(settings.password).val(""); ย  ย ย  ย ย  ย setTimeout(function(){ ย  ย ย  ย ย  ย ย  ย overlayDisplay(settings.error, "hide"); ย  ย ย  ย ย  ย }, 3000); ย  ย ย  ย } ย  ย } } $(document).ready(function(){ ย  ย $(settings.form).find(".submit").on("click", function(){ ย  ย ย  ย var data = { ย  ย ย  ย ย  ย "username" : $(settings.username).val(), ย  ย ย  ย ย  ย "password" : $(settings.password).val(), ย  ย ย  ย }; ย  ย ย  ย overlayDisplay(settings.overlay); ย  ย ย  ย $(settings.process).fadeIn(1000, function(){ ย  ย ย  ย ย  ย $.post(settings.checkURL, data, function(response){ ย  ย ย  ย ย  ย ย  ย $(settings.overlay).children().hide(); // Hide all Overlay windows ย  ย ย  ย ย  ย ย  ย if(response == "incorrect" || response == ""){ ย  ย ย  ย ย  ย ย  ย ย  ย overlayDisplay(settings.error); ย  ย ย  ย ย  ย ย  ย }else if(response == "correct"){ ย  ย ย  ย ย  ย ย  ย ย  ย overlayDisplay(settings.success); ย  ย ย  ย ย  ย ย  ย ย  ย /* Do What Else you want here */ ย  ย ย  ย ย  ย ย  ย  } ย  ย ย  ย ย  ย }).fail(function(){ ย  ย ย  ย ย  ย ย  ย overlayDisplay(settings.error); ย  ย ย  ย ย  ย }); ย  ย ย  ย }); ย  ย ย  ย $(settings.form + "#tryAgain").on("click", function(){ ย  ย ย  ย ย  ย $(settings.error).fadeOut(500, function(){ ย  ย ย  ย ย  ย ย  ย $(settings.overlay).hide(); ย  ย ย  ย ย  ย }); ย  ย ย  ย }); ย  ย  }); });</code></pre> <p>You can change the configuration of how the login form work in theย <strong>settings</strong> variable that contains a <strong>JSON Object</strong>. <strong>login.php</strong>ย is the file that process the login according to the username and password sent to it. It should respond &quot;correct&quot; if the login credentials were correct and if not, it should respond &quot;incorrect&quot;.ย <strong>jQuery</strong> will make the necessary changes in the display according to the response. You can change the messages of each action from theย <strong>HTML</strong>ย elements in theย <strong>.overlay</strong> element.</p> Auto Login Without Form in phpMyAdmin https://subinsb.com/phpmyadmin-auto-login/ Mon, 11 Aug 2014 03:30:57 +0000 https://subinsb.com/phpmyadmin-auto-login/ <p>If youโ€™re usingย **phpMyAdminย **(PMA), you know that every time you use the application, you have to log in and when the cookie expires, you have to log in again. Itโ€™s an annoying thing to log in every time for a developer who needs to do work fast. There is a way to stop this annoying thing. Itโ€™s by disabling the login form and auto login when you visitย <strong>phpMyAdmin</strong>.</p> <p>As an applicationย <strong>PMA</strong> also have a configuration file though itโ€™s not defaultly created in PMA. Itโ€™s aย <strong>PHP</strong> file where settings are entered into an Array.</p> <p>You can find this configuration file with the nameย <strong>config.inc.php</strong> in the installationย <strong>PMA</strong> directory. Itโ€™s possible that this file doesnโ€™t exist in the directory. If it doesnโ€™t, make a copy of theย <strong>config.sample.inc.php</strong> file in the same directory with the nameย <strong>config.inc.php</strong>.</p> <p>Open theย <strong>config.inc.php</strong> file with your text editor. As you can see, the settings are added to an array contained in the variableย <strong>$cfg</strong>. Many of the settings in it are not active because they are all commented. You can explore more settings from it.</p> <p>Now, we should addย new settings to disable the login by form and set the login automatically. For this, first weย add 2 new items to the settings array :</p> <pre class="prettyprint"><code>$cfg['Servers'][$i]['user'] = '&lt;span style="color: rgb(255, 0, 0);">MySQLusername&lt;/span>'; $cfg['Servers'][$i]['password'] = '&lt;span style="color: rgb(255, 0, 0);">MySQLpassword&lt;/span>';</code></pre> <p>You should include the above code with the values changed in theย <strong>Authentication type</strong> section of the file. Itโ€™s better if you keep the code as the first one in the <strong>Authentication type</strong> section.</p> <p>Now, we should let PMA know that the login username and password is include in the configuration file and it should use it to login rather than displaying the login form. For this, you only have to change the value of the key &quot;auth_type&quot;. By default, it will be &quot;cookie&quot; or something else. Here is how the new code with the value should be :</p> <pre class="prettyprint"><code>$cfg['Servers'][$i]['auth_type'] = 'config';</code></pre> <p>Save the file and when you visit PMA now, the login form wonโ€™t be seen and it will be automatically redirected to the Home page.</p> <p>ย </p> Install Softwares With Dependencies Without Internet https://subinsb.com/debian-ubuntu-install-software-offline/ Sat, 19 Jul 2014 06:08:36 +0000 https://subinsb.com/debian-ubuntu-install-software-offline/ <p>Debian Systems like Ubuntu and othersโ€™ software packages has the extensionย <strong>.deb</strong>. With the file, you can install softwares on your system. While you click the &quot;Install&quot; button on Ubuntu Software Center or on Synaptic Package Manger, what the system actually do is downloading the .deb file from the server and installing it.</p> <p>These .deb files are installed using theย <strong>dpkg</strong> software. Itโ€™s not necessarily required for you to have internet to install softwares, but if you donโ€™t have the dependencies of the software, internet is required for the software to download and install it.</p> <h2 id="introduction">Introduction</h2> <p>If youโ€™re a newbie to the Debian, Linux Platform, hereโ€™s what some of the terms mean :</p> <ul> <li>Package โ€“ The Software File that is used to install a software. In Windows, it will be a file called &quot;setup.exe&quot;</li> <li>Dependency โ€“ For working of some softwares, other softwares are needed. An Example : Google Chrome needs the WebKit Package for rendering Web pages</li> <li>&quot;.deb&quot; files โ€“ The install Package is of the extension &quot;.deb&quot; as opposed to &quot;.exe&quot; in Windows</li> <li>dpkg โ€“ A command line (Terminal) tool / software to install &quot;.deb&quot; packages.</li> <li>Synaptic Package Manager โ€“ A Graphical (GUI) application for installing softwares in Linux systems. Will take care of everything for the installation of software</li> <li>Command Line โ€“ The Terminal. On some systems, it can be opened using CTRL + ALT + T key combination.</li> </ul> <p>This tutorial will help you to do these following things :</p> <ul> <li>Install Softwares in your Debian (Ubuntu) system Without Internet (Offline)</li> <li>Install Dependencies with Original Software Offline</li> <li>Getting the Offlineย <strong>.deb</strong> Packages</li> </ul> <h2 id="obtaining-thestrongdebstrongpackage">Obtaining Theย <strong>.deb</strong>ย Package</h2> <p>As I said before, Software Center &amp; Synaptic Package Manger downloads theย <strong>.deb</strong> files to a folder on your system. The folder is :</p> <pre class="prettyprint"><code>/var/cache/apt/archives</code></pre> <p>If the packages are completely downloaded, itโ€™s file is seen there. If itโ€™s only partially downloaded, itโ€™s seen in the <strong>partial</strong> folder.</p> <p>We only need the fully downloaded packages. On installing a fresh System, this folder will be empty. So, you can install a softwareย via Software Center and see itโ€™s package ย and dependency packages (maybe) in the folder.</p> <p>If it have dependencies, you have to copy the whole .deb files and paste it in a single folder or if itโ€™s a single file, you only have to copy that file.</p> <p>An another way (complicated) is to get the &quot;.deb&quot; file from internet. Though it is risky, because you need to know the architecture of your system and find &amp; download dependencies manually. Here are the site addresses :</p> <ul> <li>Debian โ€“ย https://www.debian.org/distrib/packages</li> <li>Ubuntu โ€“ย http://packages.ubuntu.com/</li> </ul> <p>Debian &amp; Ubuntu have some major differences although they have many similarities. Donโ€™t install packages of Debian in Ubuntu, because it can cause unexpected Results.</p> <p>I highly recommend you use Synaptic Package Manger. If your system doesnโ€™t have it, install it using the following terminal command :</p> <pre class="prettyprint"><code>sudo apt-get install synaptic</code></pre> <h2 id="install-a-single-software-offline">Install a Single Software Offline</h2> <p>Suppose, the software youโ€™re going to install is <strong>Firefox</strong>. Gladly, it doesnโ€™t require any dependencies, because itโ€™s already in the system.</p> <p>The Package File name is &quot;firefox-30-lucid-32.deb&quot; and itโ€™s situated in the &quot;/home/simsu&quot; directory. We will use the following command in Terminal to install this software :</p> <pre class="prettyprint"><code>sudo dpkg -i /home/simsu/firefox-30-lucid-32.deb</code></pre> <p>The installation status will be automatically printed. If thereโ€™s any dependency issue, it will also be printed out. So, you have to install the dependency package name mentioned using Synaptic.</p> <h2 id="install-software-with-dependencies-offline">Install Software With Dependencies Offline</h2> <p>We have a folder named &quot;firefox&quot; in the directory &quot;/home/simsu&quot; with dependenciesโ€™ packages and the mainย &quot;firefox-30-lucid-32.deb&quot; package files. We will pint the terminal directory to the folder and use a single command to install software with the dependencies that are in the same folder.</p> <p>First, point the terminal to the directory :</p> <pre class="prettyprint"><code>cd /home/simsu/firefox</code></pre> <p>and tell <strong>dpkg</strong> to install all softwares that are in the directory :</p> <pre class="prettyprint"><code>dpkg -i *.deb</code></pre> <p>The softwares will be installed one by one. Though, there may be some dependency issues, because some files wonโ€™t be installed in the right order. In this case, do the command again one or 3 times until everything is OK.</p> Installing Laravel In Sub Directory & Deny Access To It https://subinsb.com/laravel-in-sub-directory-without-web-access/ Fri, 04 Jul 2014 16:55:23 +0000 https://subinsb.com/laravel-in-sub-directory-without-web-access/ <p>Laravel is a <strong>PHP</strong> framework that reduces the work load of creating PHP applications. As it is a framework, there are limitations and some problems just like any other PHP program.</p> <p>Laravel framework has a &quot;public&quot; folder. The HTML files that are going to be displayed on Web Server will be from this folder. Since it is a sub directory of the framework, to access the real site, we would have to go to the following URL :</p> <pre class="prettyprint"><code>http://example.com/public</code></pre> <p>Actually, with some server configuration you can change the Document Root to the &quot;public&quot; folder, but only ย some hosting providers provide this. Also, in cases that youโ€™re running an Open Source application, you canโ€™t just update the repo / open source code with a single click. This is one of the big problem of the Laravel framework.</p> <p>I didnโ€™t like this and decided to cope up with a way to make the site under ย a single tree instead of separate branches. I first thought of routing the requests from the root to the public folder, but it wonโ€™t deny the access of the other folders of the framework.</p> <p>So, I made a sub folder inside the document root and put all the files of the Laravel framework inside that sub directory. The with someย htaccess code on the root, everything was working with 403 access denied to the Laravel installation sub directory.</p> <h2 id="move--create-laravel-installation">Move / Create Laravel Installation</h2> <p>Create a sub directory on your site root. For this tutorial we use &quot;laravel&quot;. If your site root already have Laravel files, move it to the new sub directory. Other wise create the Laravel installation in the sub directory we created. Any changes to Laravel code must be done in this sub directory.</p> <h2 id="at-the-root">At The Root</h2> <p>Now we make aย <strong>.htaccess</strong> file (Apache Web Server) in the site root with the following content :</p> <pre class="prettyprint"><code>&lt;IfModule mod_rewrite.c&gt; Options -MultiViews RewriteEngine On RewriteBase /laravel RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*?)$ public/$1 [L] &lt;/IfModule&gt;</code></pre> <p>What the above code do is, redirect all requests from the site root to the &quot;public&quot; folder of the Laravel sub directory. In this case itโ€™s &quot;laravel&quot;.</p> <h2 id="at-the-sub-directory">At The Sub Directory</h2> <p>We make anotherย <strong>.htaccess</strong> file in the &quot;laravel&quot; sub directory with the following code :</p> <pre class="prettyprint"><code>RewriteEngine on RewriteRule $ - [F]</code></pre> <p>The above rules will showย <strong>403 Access Denied</strong> error when a native browser or external client access the &quot;laravel&quot; web URL directly. But wonโ€™t show the error when some script on the site itself access this folder. In our case itโ€™s theย <strong>.htaccess</strong> at root.</p> StatCounter Popular Posts Plugin For WordPress https://subinsb.com/wp-statcounter-popular-posts-plugin/ Sun, 22 Jun 2014 15:39:03 +0000 https://subinsb.com/wp-statcounter-popular-posts-plugin/ <p>StatCounter doesnโ€™t really have a Popular Posts plugin for WordPress. Though many WordPress blog uses SC, it doesnโ€™t have a widget that shows the Popular Posts. I uses it and wanted to have this feature. So, I created a plugin calledย <strong>StatCounter Popular Posts</strong> written in short adย <strong>SPP</strong>.</p> <p>Itโ€™s a plugin that adds a widget to WordPress which can be added to the WordPress Site layout (sidebar, footer, header โ€ฆ). Itโ€™s a simple plugin and doesnโ€™t overheat your WP installation.</p> <p>All you have to do is give plugin the project ID of your StatCounter Project and make the project Public which should be Visible for all, so that the plugin can access this like normal person and get the popular posts.</p> <p>By Posts, it doesnโ€™t mean just posts. All stuff that come in the &quot;Popular Pages&quot; section of your SC stats will be in the widget too.</p> <h2 id="features">Features</h2> <ul> <li>Lightweight</li> <li>All Popular Pages (posts, pages etc..)</li> <li>Customization (items limit, type of counting [Pageviews, Visits])</li> </ul> <h2 id="installation">Installation</h2> <p>Download the plugin fromย <a href="https://github.com/subins2000/wp-spp/archive/master.zip" target="_blank">GitHub</a>.</p> <p>Extract the folder &quot;sc-popular-posts&quot; from the archive you downloaded into &quot;/wp-content/plugins&quot; directory.</p> <p>Activate the plugin through theย โ€˜Pluginsโ€™ menu in WordPress</p> <h2 id="configure">Configure</h2> <p>The Settings page of SPP can be accessed fromย **Settingsย **-&gt; <strong>StatCounter Popular Posts</strong></p> <p>You can see an input field asking for the ID of your StatCounter project. Paste it and save the settings. Thatโ€™s the only field that you need to configure.</p> <p>Hereโ€™s how you find the project ID :</p> <ul> <li>Go to your Project Summary Stats Page</li> <li>See the URL</li> </ul> <p>Hereโ€™s a URL :</p> <pre class="prettyprint"><code>http://statcounter.com/p1234567/summary/</code></pre> <p><span style="color: #444444;">In the above URL &quot;p1234567&quot;</span><span style="color: #444444;">ย is theย Project ID.</span></p> <h2 id="add-widget">Add Widget</h2> <p>Go to your Widgets Page (Appearance -&gt; Widgets). You will see the new &quot;<span style="color: #666666;">StatCounter Popular Posts&quot; widget there :</span><figure id="attachment_2850" class="wp-caption aligncenter"></p> <p><a href="//lab.subinsb.com/projects/blog/uploads/2014/06/0121.png"><img class="wp-image-2850 size-full" src="//lab.subinsb.com/projects/blog/uploads/2014/06/0121.png" alt="StatCounter Popular Posts Widget" width="229" height="81" /></a><figcaption class="wp-caption-text">StatCounter Popular Posts Widget</figcaption></figure></p> <p>You can add it wherever you like. You can also set the following options on the Widget :</p> <ul> <li>Type of Counting</li> <li>Items to be displayed</li> </ul> <p>The Type of counting gives the plugin to get the stats based on the pageviews or the visits.</p> <p>The items that should be displayed is the second option. Any integer from 1 is acceptable to it.</p> <h2 id="extra">Extra</h2> <p>You can ask support for this plugin <a href="//subinsb.com/ask/statcounter-popular-posts">here</a>. You can develop the plugin <a href="https://github.com/subins2000/wp-spp" target="_blank">here on GitHub</a>.</p> How To Set Same Cookie On Different Domains https://subinsb.com/set-same-cookie-on-different-domains/ Fri, 20 Jun 2014 16:59:54 +0000 https://subinsb.com/set-same-cookie-on-different-domains/ <p>You might have seen sites like Google setting the login status cookie on the various domains of theirs (YouTube, Blogger). As you may know, cookie canโ€™t be set in a different domain from another domain directly.</p> <p>If youโ€™re having multiple sites in where you need to set a cookie from a parent site, you can use basic **HTMLย **andย <strong>JS</strong>ย to set the cookies. Google is using this same way.</p> <h2 id="domains">Domains</h2> <p>For this tutorial, we will refer to three domains :</p> <pre class="prettyprint"><code>www.example.com www.mysite.com www.india.com</code></pre> <p>We will set cookies onย <strong>mysite.com</strong> andย <strong>india.com</strong> fromย <strong>example.com</strong>.</p> <h2 id="other-domains">Other Domains</h2> <p>You should make aย dynamicย page named &quot;setCookie.php&quot;ย on your server where youโ€™re going to create the cookie. If itโ€™s <strong>PHP</strong>, then add the following code to set the cookie :</p> <pre class="prettyprint"><code>&lt;? setcookie("MyCookie", "subinsb.com", time()+3600); ?&gt;</code></pre> <p>In the above case weโ€™re not mentioning the path or domain because PHP automatically sets it.</p> <h2 id="main-domain">Main Domain</h2> <p>On the main domain (example.com) where youโ€™re going to ask the other two domains to set the cookie, create an HTML page with the following content :</p> <pre class="prettyprint"><code>&lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;script&gt; function loadComplete(){ alert("Completed Setting Cookies"); } &lt;/script&gt; &lt;/head&gt; &lt;body onload="loadComplete()"&gt; &lt;p&gt; Please Wait... &lt;/p&gt; &lt;img src="http://www.mysite.com/setCookie.php" style="display:none;" /&gt; &lt;img src="http://www.india.com/setCookie.php" style="display:none;" /&gt; &lt;/body&gt; &lt;/html&gt;</code></pre> <p>When the client visits the above page, a pageย is requested from theย <strong>mysite.com</strong> domain as image source, but the page is not an image. This page that is on the other domain will set the cookie on that domain.</p> <p>We also add an event listener on the document, so that we will know when the cookies are set completely. This is equal to document loaded listener because when the images are loaded, cookies are set.</p> <h2 id="other-things">Other Things</h2> <p>You can also send data to the other domains as GET parameters so that cookies based on that data can be created. But, when you send passwords or other secure content, be sure to encrypt the string.</p> <p>The images should be hidden because, since itโ€™s not valid images, the ugly image icon will appear in the browser.</p> <p>You can change the content of the event listener callbackย <strong>loadComplete()</strong> to do something else according to your choice, like redirecting back to the main domain.</p> <h2 id="how-google-do-it">How Google Do It</h2> <p>If you have account on Blogger &amp; YouTube which are on external domains, when you log in viaย <strong>accounts.google.com</strong> you are redirected to a page that says &quot;Please Waitโ€ฆ&quot;, right ? If you look at the source code of the page, you can see the <strong><img></strong> tags of <strong>youtube.com</strong> andย <strong>blogger.com</strong> domain. Yes, Google is using the same way to set login information cookie on YouTube and Blogger.</p> <p>Microsoft does in this same way to set cookies on their services likeย <strong>Hotmail</strong>,ย <strong>live.com</strong>,ย <strong>msn.com</strong> etc.. So many domains, right ?</p> Compress PHP Site โ€“ HTML, CSS & JS https://subinsb.com/compress-php-website-html-css-js/ Sun, 15 Jun 2014 15:13:35 +0000 https://subinsb.com/compress-php-website-html-css-js/ <h2 id="update">UPDATE</h2> <p>Site Compressor is now an app on <a href="//subinsb.com/lobby" target="_blank">Lobby</a>. To use Site Compressor, <a href="https://lobby.subinsb.com/download" target="_blank">download Lobby</a> and install <a href="https://lobby.subinsb.com/apps/site-compressor" target="_blank">Site Compressor app</a>.</p> <p>Compressing / minifying a siteโ€™s code will improve the data transfer from server to the client. The browser will be easily able to get the content from server. There are a lot of benefits that comes with site compression. I use compression too in my own way. My site <a href="http://open.subinsb.com" target="_blank">Open</a> is heavily compressed.</p> <p>I compressed sites usingย <strong>Python</strong> by using loops to iterate over files and replace strings, compress according to my needs. But, every time I had to open a Terminal to give the request and there will be some kind of errors when something new is added to the site.</p> <p>So, I decided to create a Graphical Compressor. The best thing I thought was, it will be easier to create the application in localhost rather than creating a software. This is because that software creation is not platform independent, but <strong>PHP</strong> and localhost is.</p> <p>And I created one. Itโ€™s termed asย <strong>siteCompressor</strong>. All you have to do is give the location of the local site and the output path, choose some options and youโ€™re ready to go. With the help of some external libraries like <strong>JSqueeze</strong> andย <strong>CssMin</strong>, it was easy.</p> <h2 id="features">Features</h2> <ul> <li>Compress HTML</li> <li>Minify JavaScript &amp; CSS files</li> <li>Minify Inline JavaScript, jQuery &amp; CSS in HTML pages (<script>, <style>)</li> <li>Replace Multiple Strings like &quot;localsite.dev&quot; to &quot;mydomain.com&quot;</li> <li>Save, Restore &amp; Remove Configurations</li> <li>Choose Site Location &amp; Output folder</li> <li>Real Time Status of site compression</li> <li>Execute **Terminal** / **Shell** commands before or after compression</li> <li>Can Run in any localhost server</li> <li>No Database needed</li> <li>Leaves alone PHP files that doesnโ€™t have HTML, so that nothing messes up the PHP code</li> </ul> <p>A <a href="https://github.com/subins2000/siteCompressor" target="_blank">GitHub repository</a> is opened for the software under <strong>MIT</strong> license.</p> <h2 id="installation">Installation</h2> <p>Download the full source code from GitHub :</p> <div class="padlinks"> <a class="download" href="https://github.com/subins2000/siteCompressor/archive/master.zip" target="_blank">Download Software</a> </div> <p>Extract the contents of the Zip file to your localhost destination and by your browser visit that location and you will access the software.</p> <h2 id="usage">Usage</h2> <p>The siteCompressor window will look like this :<figure id="attachment_2831" class="wp-caption aligncenter"></p> <p><a href="//lab.subinsb.com/projects/blog/uploads/2014/06/0119.png"><img class="wp-image-2831 size-large" title="The siteCompressor Window" src="//lab.subinsb.com/projects/blog/uploads/2014/06/0119-1024x340.png" alt="0119" width="640" height="212" /></a><figcaption class="wp-caption-text">The siteCompressor Window</figcaption></figure></p> <p>There are 6 sections in the software which is as follows :</p> <ol> <li>Site Details</li> <li>Compression Options</li> <li>Replacer</li> <li>Before Compression</li> <li>After Compression</li> <li>Compression Status</li> </ol> <p>Each section has different options except for theย <strong>Compression Status</strong> which is just an output section for printing the compression status.</p> <h3 id="site-details">Site Details</h3> <p>There are 2 fields in this section. In theย <strong>Site Location</strong> field, paste the full location of the local siteโ€™s source code.ย <strong>No &quot;/&quot; should be placed in the end</strong>.</p> <p>And in the <strong>Output</strong>ย field, input the full location of the output directory which also shouldnโ€™t have &quot;/&quot; at the end.</p> <h3 id="compression-options">Compression Options</h3> <p>You can choose which to compress, what to compress in here. Some of the options are :</p> <ul> <li>Minimize HTML</li> <li>Minimize HTML in .php Files</li> <li>Remove Comments</li> <li>Minimize CSS</li> <li>Minimize JS</li> </ul> <p>As the Features said, PHP files that doesnโ€™t have HTML content wonโ€™t be minimized.</p> <h3 id="replacer">Replacer</h3> <p>Since the site is being converted from local to the real deal, some strings should be replaced with new ones. This section allows you to do that. To add a newย <strong>From &amp; To</strong> field, just click the &quot;Add New Field&quot; button.</p> <p>All kind of strings is replaced. Note thatย <strong>RegEx</strong> is not supported.</p> <h3 id="before-compression">Before Compression</h3> <p>In here, you can optionally type in a Shell command that should be executed before the compression starts. Itโ€™s value is according to the Operating System the software is being ran.</p> <p><strong>Please</strong> avoid using of &quot;+&quot; character in the command, because it can produce unexpected results.</p> <h3 id="after-compression">After Compression</h3> <p>Just like theย <strong>Before Compression</strong>, a Terminal / Shell command can be executed after the compression is finished. Rules ofย theย <strong>Before Compression</strong> is applicable here too.</p> <h3 id="compression-status">Compression Status</h3> <p>When you give the request to compress the site, the status of the compression is outputted real time in here. It will automatically scroll into the last line as each lines are outputted.</p> <h2 id="start-compression">Start Compression</h2> <p>You can find theย <strong>Letโ€™s Start Compressing</strong> button just after <strong>After Compression</strong> section. This button will submit the form and a compression request with the values is sent to the proper file.</p> <p>Live Output of the compression is seen in theย <strong>Compression Status</strong> section. When the compression is finished, the last line of it will be :</p> <pre class="prettyprint"><code>(Timestamp) - Finished Site Compression. Thank you. Hope everything went OK.</code></pre> <p>and the time taken to compress will also be outputted just after the above one. Here is an example :<figure id="attachment_2832" class="wp-caption aligncenter"></p> <p><a href="//lab.subinsb.com/projects/blog/uploads/2014/06/0120.png"><img class="size-large wp-image-2832" src="//lab.subinsb.com/projects/blog/uploads/2014/06/0120-1024x284.png" alt="After site compression is finished" width="640" height="177" /></a><figcaption class="wp-caption-text">After site compression is finished</figcaption></figure></p> <p>The end source code of the site will be outputted in the Output Directory given.</p> <p>You can ask for support or discuss at <a href="//subinsb.com/ask/php-sitecompressor" target="_blank">this page</a> or for project related matters such as code, ask it on <a href="https://github.com/subins2000/siteCompressor/issues" target="_blank">GitHub</a>.</p> Minify JavaScript Using PHP https://subinsb.com/php-minify-js-code/ Sat, 07 Jun 2014 05:34:46 +0000 https://subinsb.com/php-minify-js-code/ <p>Making <strong>JavaScript</strong> codes is difficult and long. In Web projects, we try our maximum to minify JavaScript andย <strong>CSS</strong> to serve content better. There are many sites on the Web that helps to compress/minify JS code. There is even a PHP Software to do this. In this post, Iโ€™ll tell you how to use the PHPย <strong>jSqueeze</strong> library to minify JavaScript code.</p> <div class="padlinks"> <a class="download" href="http://demos.subinsb.com/down.php?id=b5wg3mjz3ba1/s/1xmre7m5wwys7lms6651&class=28" target="_blank">Download</a><a class="demo" href="http://demos.subinsb.com/php/jsMin" target="_blank">Demo</a> </div> <h2 id="setting-up">Setting Up</h2> <p><del>You can get the class code of <strong>JSqueeze</strong> from <a href="https://github.com/nicolas-grekas/JSqueeze" target="_blank">here</a>. Paste the code into a file called &quot;min-js.php&quot;. We will include this file to compress our code.</del></p> <p>The author ofย <strong>JSqueeze</strong> has made it a Composer Package. You can install it by :</p> <pre class="prettyprint"><code>composer require patchwork/jsqueeze&lt;br /></code></pre> <h2 id="compress-code">Compress Code</h2> <p>Theย <strong>JSqueeze</strong> class is underย <strong>Patchwork</strong> namspace.ย We should first make the object :</p> <pre class="prettyprint"><code>&lt;?php use Patchwork\JSqueeze; $jSqueeze = new JSqueeze();&lt;br /></code></pre> <p>We will now add the JavaScript code into a variable called &quot;$jsCode&quot; :</p> <pre class="prettyprint"><code>$jsCode = "function lop(number){ alert(number + 2); } lop(2);";</code></pre> <p>Or you can include the POST form data in to the variable :</p> <pre class="prettyprint"><code>$jsCode = $_POST["code"];</code></pre> <p>Now, we ask the class to compress the code by calling theย <strong>$JSqueeze-&gt;squeeze()</strong> function and include it in the &quot;$minified&quot; variable :</p> <pre class="prettyprint"><code>$minified = $jSqueeze-&gt;squeeze($jsCode, true, false);</code></pre> <p>Now, when you echo the &quot;$minified&quot; variable, you will get the minified code which will be something like this :</p> <pre class="prettyprint"><code>;function lop(o){alert(o+2)};lop(2);</code></pre> <p>As you can see, itโ€™s shorter than the original code. This is how compression works. It changed the variables used to shorter ones and used less semi colons.</p> Find MIME Type of File in PHP https://subinsb.com/php-find-file-mime-type/ Sun, 01 Jun 2014 07:22:59 +0000 https://subinsb.com/php-find-file-mime-type/ <p>**MIMEย **type is needed to know what kind of file weโ€™re looking at.ย <strong>HTML</strong> files have the MIME typeย <strong>text/html</strong>ย , for gif image, itโ€™sย <strong>image/gif</strong> and so on.</p> <p>Sinceย <strong>PHP</strong> is a dynamic content creator language, MIME type is a very important thing you should know about in PHP. In this small post, Iโ€™ll tell you how to find the MIME type of a local file in your server.</p> <h2 id="enable-fileinfo-extension">Enable Fileinfo Extension</h2> <p>For this, we need to enable theย <strong>PHP</strong> fileinfo extension inย <strong>php.ini</strong>. Add this into yourย <strong>php.ini</strong> file it doesnโ€™t already exist :</p> <pre class="prettyprint"><code>extension=php_fileinfo.dll</code></pre> <p>And restart the Web Server. The restarting is different on various web servers. If itโ€™s Apache you can do this command :</p> <pre class="prettyprint"><code>sudo service apache2 restart</code></pre> <h2 id="get-the-mime-type">Get the MIME Type</h2> <p>We will make a function to get the MIME type easily. Weโ€™ll call it &quot;getMIMEType&quot; :</p> <pre class="prettyprint"><code>function getMIMEType($filename){ $finfo = finfo_open(); $fileinfo = finfo_file($finfo, $filename, FILEINFO_MIME_TYPE); finfo_close($finfo); return $fileinfo; }</code></pre> <p>Or you can make it easy by using theย <strong>finfo</strong> object :</p> <pre class="prettyprint"><code>function getMIMEType($filename){ $finfo = new finfo; return $finfo-&gt;file($filename, FILEINFO_MIME_TYPE); }</code></pre> <p>But, I think the OO (Object Oriented) way will be slower than the other. Itโ€™s your choice, but they will both work in the same way.</p> <p>And hereโ€™s how you can use it. Just pass the location of the file to it and it will return the MIME type :</p> <pre class="prettyprint"><code>echo getMIMEType("myfile.html");</code></pre> <p>In the above case, it will return :</p> <pre class="prettyprint"><code>text/html</code></pre> <p>Here are some more examples :</p> <pre class="prettyprint"><code>getMIMEType("myimage.jpeg"); // Returnsย image/jpeg getMIMEType("myfile.js"); // Returnsย application/x-javascript getMIMEType("myCss.css"); // Returns text/css</code></pre> <p>Use it as you wish.</p> Call Parent Class construct Before Childโ€™s In PHP https://subinsb.com/php-parent-class-construct-before-child/ Thu, 29 May 2014 15:32:09 +0000 https://subinsb.com/php-parent-class-construct-before-child/ <p>If in <strong>PHP</strong>, you are making a child class of a parent class in which both have theย <strong>__construct</strong>ย function and you want to call both of them when the child object is made, it wonโ€™t work.</p> <p>This is because, when you make the child class object, itโ€™s construct function is called. The parentโ€™s construct function is being overridden by the child. The PHP manual on OOP (Object Oriented Programming) notes this :</p> <pre class="prettyprint"><code>Note: Parent constructors are not called implicitly if the child class defines a constructor. In order to run a parent constructor, a call to parent::__construct() within the child constructor is required. If the child does not define a constructor then it may be inherited from the parent class just like a normal class method (if it was not declared as private).</code></pre> <p>So, the parentโ€™s construct function is not called if wโ€™re making the child object.</p> <h2 id="classes">Classes</h2> <p>This is the parent class named &quot;MyParentClass&quot; :</p> <pre class="prettyprint"><code>class MyParentClass { ย public $myVal = 0; ย function __construct(){ ย  $this-&gt;myVal = 1; ย } }</code></pre> <p>And we extend it to make the child class named &quot;MyChildClass&quot; :</p> <pre class="prettyprint"><code>classย MyChildClass extends MyParentClass { ย function __construct(){ ย  echo $this-&gt;myVal; ย } }</code></pre> <p>Now, when you make the child object, the output made byย <strong>echo</strong> will be nothing butย **** :</p> <pre class="prettyprint"><code>new MyChildClass()</code></pre> <p>(Weโ€™re using direct echo and not return).</p> <h2 id="reason">Reason</h2> <p>In the parent class, we make a public variable calledย &quot;myVal&quot; which is set to 0. When the parent class is made by this :</p> <pre class="prettyprint"><code>new MyParentClass()</code></pre> <p>the value of <strong>MyParentClass::myVal</strong> is changed to &quot;1&quot;. This change only takes effect if the parent class is made and not the child class. So, when you make the child class, the output will be **** and notย <strong>1</strong>.</p> <h2 id="solution">Solution</h2> <p>But, you can also make changes first in the parent class and then do the code inย <strong>MyChildClass::__construct()</strong>. For this, we add the following code as the first code inย <strong>MyChildClass::__construct()</strong> :</p> <pre class="prettyprint"><code>parent::__construct();</code></pre> <p>And the whole child class will become :</p> <pre class="prettyprint"><code>class MyChildClass extends MyParentClass { function __construct(){ parent::__construct(); echo $this-&gt;myVal; } }</code></pre> <p>Donโ€™t be worried about the constantย <strong>parent</strong>, because itโ€™s built in and it defines the parent class from which we are extending the main class.</p> <p>Now, when you make the child class, the output will beย <strong>1</strong> because the parentย <strong>__construct()</strong> is called before the code in childโ€™sย <strong>__construct()</strong> is ran.</p> <p>You can apply the same solution in your child classes, so that parent and class is linked instead of going separate ways.</p> Define Array as Value of Constants in PHP https://subinsb.com/php-define-array-as-constant-value/ Tue, 27 May 2014 15:41:09 +0000 https://subinsb.com/php-define-array-as-constant-value/ <p>Constants are something that is needed for every computer languages. In <strong>PHP</strong>, too you can set constants. But you can only setย <strong>string</strong> values which is a pity, because if you want to set arrays for making it easy for obtaining multiple values, you canโ€™t do it. In this case, we explore the unimaginable possibilities of programming languages. As like any other language, PHP too has a secret weapon to accomplish this task.</p> <h2 id="long-things-short">Long Things Short</h2> <p>Weโ€™ll useย PHPโ€™sย <strong>serialize</strong> function to make an <strong>Array</strong> look like string and this string is defined as the constant value. For making the string back to the original Array, weโ€™ll useย <strong>unserialize</strong> function. Itโ€™s very easy and works in bothย **PHP 4ย **andย <strong>PHP 5</strong>.</p> <h2 id="the-array">The Array</h2> <p>We make the array first. Hereโ€™s the array containing some sample values :</p> <pre class="prettyprint"><code>$array = array( ย "Subin" =&gt; "Siby", ย "John" =&gt; "Resig", ย "Larry" =&gt; "Page", ย "Coding" =&gt; "Horror" );</code></pre> <p>As you can see, the index is the first name of persons and the values are the last name of the persons.</p> <h2 id="a-hrefhttpin3phpnetmanualenfunctionserializephp-target_blankserializea"><a href="http://in3.php.net/manual/en/function.serialize.php" target="_blank">Serialize</a></h2> <p>Now, we serialize the Array and put it in to a variable :</p> <pre class="prettyprint"><code>$serialized = serialize($array);</code></pre> <p>The above variableย <strong>$serialized</strong> will now contain a string something like this :</p> <pre class="prettyprint"><code>a:4:{s:5:"Subin";s:4:"Siby";s:4:"John";s:5:"Resig";s:5:"Larry";s:4:"Page";s:6:"Coding";s:6:"Horror";}</code></pre> <p>You can see that the index and values of the array are in the above serialized output. Weโ€™ll make this as the value to be set for constant.</p> <h2 id="set-constant">Set Constant</h2> <p>We define the constant :</p> <pre class="prettyprint"><code>define("MyArray", $serialized);</code></pre> <p>Now, you can access the string from anywhere, just like this :</p> <pre class="prettyprint"><code>echo MyArray;</code></pre> <h2 id="get-back-the-array">Get back the Array</h2> <p>To get back the array, we unserialize the string and an array value is returned :</p> <pre class="prettyprint"><code>$BackArray = unserialize(MyArray);</code></pre> <p><strong>unserialize()</strong> will return values according to the value first serialized. So, if you serialize a string the return value of the unserialize function will be a string. This applies to all cases like Arrays, booleans, integers etcโ€ฆ In this case, we can directly get values from the array now :</p> <pre class="prettyprint"><code>echo $BackArray["Larry"]; // Prints Page</code></pre> <p>And now you know how setting Array as Constant values work. Hope you understood the procedure. If you have a problem with this, you can ask by the comments or <a href="http://stackoverflow.com" target="_blank">SO</a>.</p> PHP Secure, Advanced Login System https://subinsb.com/php-logsys/ Tue, 20 May 2014 16:40:49 +0000 https://subinsb.com/php-logsys/ <p>We all get new ideas every day. With the idea, we build more and more sites. Mostly, the sites would have a login system, right ? So, when we create new projects (sites) every time, we will have to create login systems for each one. I do the same thing and Iโ€™m tired of creating the same thing over and over again. So, I decided to create a login system that can be integrated to any <strong>PHP</strong> powered sites.</p> <div class="padlinks"> <a class="download" href="http://demos.subinsb.com/down.php?id=nu98sx5w7y5l/s/6m5cmj3vznxubiou9zem&class=27" target="_blank" rel="noopener">Download</a><a class="demo" href="http://demos.subinsb.com/php/loginSystem" target="_blank" rel="noopener">Demo</a> </div> <h2 id="latest-version">Latest Version</h2> <p>The latest version is <strong>1.0.1</strong>ย released on February 11, 2018. <a href="https://github.com/subins2000/logSys/blob/master/CHANGELOG.md#09" target="_blank" rel="noopener">See changelog</a>.</p> <h3 id="how-to-upgrade">How To Upgrade</h3> <p>logSys can now be installed with composer :</p> <blockquote> <p>composer require francium/logsys</p> </blockquote> <p>NOTE โ€“ If youโ€™re upgrading from versions less than <strong>0.6</strong>, your users wonโ€™t be able to login with their password. They would have to reset it to a new one.</p> <p>If youโ€™re upgrading toย <strong>0.7</strong> fromย <strong>0.6</strong>, your users can login normally like before.</p> <h2 id="logsys-admin">logSys Admin</h2> <p><strong>logSys</strong>ย has an administrator app (Graphic Application) for managing users, statistics and moreโ€ฆ See <a href="//subinsb.com/logsys-admin">this post</a>.</p> <h2 id="features">Features</h2> <p>Iโ€™m introducing you to the PHP class <strong>logSys</strong>. This class will help you to set up a login System on any PHP site. logSys have the following features :</p> <ul> <li> <p>Supports <strong>MySQL</strong>,ย <strong>SQLite</strong> andย <strong>PostgreSQL</strong></p> <p>logSys uses PDO for database connection</p> </li> <li> <p>Lightweight</p> <p>Almost no dependenices โ€“ logSys does not require additional dependencies</p> </li> <li> <p>Login &amp; Registering</p> </li> <li> <p>&quot;Remember Me&quot;</p> </li> <li> <p>2 Step Verification</p> <p>SMS or E-Mail</p> </li> <li> <p>Secure</p> <p>Uses password_hash() for hashing passwords</p> <p>Protection from Brute Force attacks by disabling login attempts for fixed time after 5 failed login attempts</p> <p>Device Management โ€“ Log Out from a device remotely</p> </li> <li> <p>&quot;Forgot Password ?&quot;</p> </li> <li> <p>Custom fields for storing usersโ€™ details</p> </li> <li> <p>Easily get and update user details</p> </li> <li> <p>Auto redirection based on the login status of user</p> </li> <li> <p>Extra functionsย such as</p> <p>E-mail validation and random string generator</p> <p>Show time since user joined</p> </li> </ul> <p>Yes, itโ€™s BIG ! The source code is more than <strong>700</strong> lines long and you customize it so much. Hereโ€™s a full guideย on how to use <strong>logSys</strong>.</p> <h2 id="requirements">Requirements</h2> <ul> <li> <p>PHP 5.5 or later</p> <p>If you want to use it in an older PHP version, get the <strong>password.php</strong> file from <a href="https://github.com/ircmaxell/password_compat/blob/master/lib/password.php">here</a> and include it before loading <code>LS.php</code> file.</p> </li> <li> <p>MySQL server or PostgreSQL server or SQLite</p> </li> </ul> <h2 id="download--install">Download &amp; Install</h2> <p>Use composer for installing logSys in your project.</p> <pre class="prettyprint"><code>composer require francium/logsys</code></pre> <p>Previously logSys could have been used with just a single class file. But as features got added, the dependencies also increased. Hence now it's only possible to install logSys with <a href="https://getcomposer.org/">composer</a>.</p> <h2 id="introduction">Introduction</h2> <p>For this tutorial, we use the table as &quot;users&quot; (which is changable).</p> <p>The user can either use E-Mail or username for logging in.ย An example database structure :</p> <pre class="prettyprint"><code style="text-align: center;">id | username | email | password | name | created | attempt </code></pre> <p>The columns &quot;id&quot;, &quot;username&quot; and &quot;password&quot; is absolutely required for the basic setup of logSys. Other columns are for optional features like &quot;Login with E-Mail &amp; Username&quot;, &quot;Time Since User Joined&quot; and &quot;Brute Force Protection&quot;. You can also change the column names if you want.</p> <p>You can easily set up the Database table by reading the &quot;<a href="#Database-Table-Setup">Database Table Setup</a>&quot; section of this tutorial.</p> <p>Return values of logSys functions are booleans. So use <strong>===</strong> operator instead of <strong>==</strong>.</p> <p>In this post, we assume that you use &quot;custom configuration&quot; and not the other method to configure. Therefore there will be no including &quot;LS.php&quot; file, but &quot;config.php&quot;. Donโ€™t know what Iโ€™m talking about ? <a title="The Francium Project" href="//subinsb.com/the-francium-project" target="_blank" rel="noopener">Read this</a>.</p> <p>Make sure you read the next portion carefully and change the config values accordingly.</p> <h2 id="configuration">Configuration</h2> <p>You have to configure logSys first to continue. You have two options to change configurations. See <a title="The Francium Project" href="//subinsb.com/the-francium-project#1-Custom-Config" target="_blank" rel="noopener">about it here</a> on the &quot;configuration&quot; section.</p> <p>Here are some of the main options you can set in logSys :</p> <h3 id="basic">basic</h3> <table class="table"> <tr> <td> Option </td> <pre><code>&lt;td&gt; Description &lt;/td&gt; &lt;td&gt; Example &lt;/td&gt; </code></pre> </tr> <tr> <td> company </td> <pre><code>&lt;td&gt; Your site/company name. Used for including in E-Mails to be sent &lt;/td&gt; &lt;td&gt; Subin&amp;#8217;s Blog &lt;/td&gt; </code></pre> </tr> <tr> <td> email </td> <pre><code>&lt;td&gt; Used for &quot;From&quot; header in E-Mails sent &lt;/td&gt; &lt;td&gt; [email protected] &lt;/td&gt; </code></pre> </tr> </table> <h3 id="db">db</h3> <table class="table"> <tr> <td> type </td> <pre><code>&lt;td&gt; Database to use : mysql or sqlite or postgresql &lt;/td&gt; &lt;td&gt; mysql &lt;/td&gt; </code></pre> </tr> <tr> <td> sqlite_path </td> <pre><code>&lt;td&gt; Absolute path to SQLite database file &lt;/td&gt; &lt;td&gt; /home/simsu/mydb.sqlite &lt;/td&gt; </code></pre> </tr> <tr> <td> host </td> <pre><code>&lt;td&gt; The database Hostname. &lt;/td&gt; &lt;td&gt; localhost &lt;/td&gt; </code></pre> </tr> <tr> <td> port </td> <pre><code>&lt;td&gt; The database Port &lt;/td&gt; &lt;td&gt; 3306 &lt;/td&gt; </code></pre> </tr> <tr> <td> username </td> <pre><code>&lt;td&gt; The database username &lt;/td&gt; &lt;td&gt; root &lt;/td&gt; </code></pre> </tr> <tr> <td> password </td> <pre><code>&lt;td&gt; The database password for the username &lt;/td&gt; &lt;td&gt; mypassword &lt;/td&gt; </code></pre> </tr> <tr> <td> name </td> <pre><code>&lt;td&gt; The database name &lt;/td&gt; &lt;td&gt; projects &lt;/td&gt; </code></pre> </tr> <tr> <td> table </td> <pre><code>&lt;td&gt; The database table to store users&amp;#8217; data &lt;/td&gt; &lt;td&gt; users &lt;/td&gt; </code></pre> </tr> <tr> <td> token_table </td> <pre><code>&lt;td&gt; The database table to store tokens used for &quot;Forgot Password&quot; etc. &lt;/td&gt; &lt;td&gt; user_tokens &lt;/td&gt; </code></pre> </tr> <tr> <td> <a href="#columns">columns</a> </td> <pre><code>&lt;td&gt; Array of column names to be used &lt;/td&gt; &lt;td&gt; See &lt;a href=&quot;#columns&quot;&gt;below&lt;/a&gt; &lt;/td&gt; </code></pre> </tr> </table> <h3 id="columns">columns</h3> <p>You can change the column names used by logSys. Just pass the alternative column name as value to the array :</p> <pre class="prettyprint"><code>array( "id" =&gt; "user_id", "username" =&gt; "my_column_username", "password" =&gt; "col_password", "email" =&gt; "user_email", "attempt" =&gt; "brute_force_check" ) </code></pre> <p>The above code will make logSys useย the column &quot;user_id&quot; instead of &quot;id&quot; and others likewise.</p> <h3 id="keys">keys</h3> <table class="table"> <tr> <td> cookie </td> <pre><code>&lt;td&gt; A secure key that is used to encrypt cookie values &lt;/td&gt; &lt;td&gt; sadauj3n(#ff)#%$ &lt;/td&gt; </code></pre> </tr> <tr> <td> salt </td> <pre><code>&lt;td&gt; The common password salt (site salt) that is used to hash all the users&amp;#8217; passwords.&lt;br /&gt; This should not be changed after a user isย created &lt;/td&gt; &lt;td&gt; vdsjn3md%##$*5 &lt;/td&gt; </code></pre> </tr> </table> <p>Make sure the secure keys for both hashing passwords and cookies are <strong>different</strong> and secure. Donโ€™t let anyone know them.</p> <p>If youย change the <strong>salt</strong> value later, users wonโ€™t be able to login with their existing passwords.</p> <p>If you change the <strong>cookie</strong> value later, all cookies will become invalid and user sessions will be terminated which will make them login again.</p> <h3 id="features-1">features</h3> <table class="table"> <tr> <td> start_session </td> <pre><code>&lt;td&gt; Should the class call session_start(); &lt;/td&gt; &lt;td&gt; true (boolean) &lt;/td&gt; </code></pre> </tr> <tr> <td> email_login </td> <pre><code>&lt;td&gt; Should the class allows logging in with both E-Mail &amp; Username ? &lt;/td&gt; &lt;td&gt; true (boolean) &lt;/td&gt; </code></pre> </tr> <tr> <td> remember_me </td> <pre><code>&lt;td&gt; If value is provided to Fr\LS::login(), should user be automatically logged in even after the end of PHP session. &lt;/td&gt; &lt;td&gt; true (boolean) &lt;/td&gt; </code></pre> </tr> <tr> <td> auto_init </td> <pre><code>&lt;td&gt; Should Fr\LS::init() be ran automatically on the first logSys function called in any page ? &lt;/td&gt; &lt;td&gt; false (boolean) &lt;/td&gt; </code></pre> </tr> <tr> <td> block_brute_force </td> <pre><code>&lt;td&gt; Prevent Brute Forcing.&lt;br /&gt; By enabling this, logSys will deny login for the time mentioned in the config value &quot;brute_force&quot;-&gt;&quot;time_limit&quot; seconds after config value &quot;brute_force&quot;-&gt;&quot;tries&quot; incorrect login tries. &lt;/td&gt; &lt;td&gt; true &lt;/td&gt; </code></pre> </tr> </table> <h3 id="brute_force">brute_force</h3> <table class="table"> <tr> <td> tries </td> <pre><code>&lt;td&gt; Number of login tries alloted to users &lt;/td&gt; &lt;td&gt; 5 &lt;/td&gt; </code></pre> </tr> <tr> <td> time_limit </td> <pre><code>&lt;td&gt; The time IN SECONDS for which block from login action should be done after incorrect login attempts. Use &lt;a href=&quot;http://www.easysurf.cc/utime.htm#m60s&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;this tool&lt;/a&gt; for converting minutes to seconds. Default : 5 minutes &lt;/td&gt; &lt;td&gt; 300 &lt;/td&gt; </code></pre> </tr> <tr> <td> max_tokens </td> <pre><code>&lt;td&gt; Maximum number of tokens the user can request. &lt;/td&gt; &lt;td&gt; 5 &lt;/td&gt; </code></pre> </tr> </table> <h3 id="pages">pages</h3> <table class="table"> <tr> <td> no_login </td> <pre><code>&lt;td&gt; An array containing the relative pathname of pages that doesn&amp;#8217;t require logging in like the index page of site &lt;/td&gt; &lt;td&gt; array(&quot;/&quot;) &lt;/td&gt; </code></pre> </tr> <tr> <td> everyone </td> <pre><code>&lt;td&gt; An array containing the relative pathname of pages that can be accessed byย logged in and logged out users &lt;/td&gt; &lt;td&gt; array() &lt;/td&gt; </code></pre> </tr> <tr> <td> login_page </td> <pre><code>&lt;td&gt; The relative pathname of login page &lt;/td&gt; &lt;td&gt; /login.php &lt;/td&gt; </code></pre> </tr> <tr> <td> home_page </td> <pre><code>&lt;td&gt; The relative pathname of home page that the class should redirect to after logging in &lt;/td&gt; &lt;td&gt; /home.php &lt;/td&gt; </code></pre> </tr> </table> <p>Itโ€™s not necessary to include the login page and home page in &quot;no_login&quot; array, because logSys automatically adds it into that array.</p> <h3 id="cookies">cookies</h3> <table class="table"> <tr> <td> expire </td> <pre><code>&lt;td&gt; The expire time of the 2 cookies created during login process. This value is used for making the time using strtotime() function. So, the value must be compatible with &lt;a href=&quot;http://php.net/manual/en/function.strtotime.php&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;strtotime()&lt;/a&gt; &lt;/td&gt; &lt;td&gt; +30 days &lt;/td&gt; </code></pre> </tr> <tr> <td> path </td> <pre><code>&lt;td&gt; The `path` value of cookies. &lt;/td&gt; &lt;td&gt; / &lt;/td&gt; </code></pre> </tr> <tr> <td> domain </td> <pre><code>&lt;td&gt; The `domain` value of cookies. See &lt;a href=&quot;http://php.net/manual/en/function.setcookie.php&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;setcookie()&lt;/a&gt; &lt;/td&gt; &lt;td&gt; subinsb.com &lt;/td&gt; </code></pre> </tr> </table> <h3 id="two_step_login">two_step_login</h3> <table class="table"> <tr> <td> instruction </td> <pre><code>&lt;td&gt; Message to show before displaying &quot;Enter Token&quot; form. &lt;/td&gt; &lt;td&gt; A token was sent to your mobile number as SMS. Please enter it below : &lt;/td&gt; </code></pre> </tr> <tr> <td> send_callback </td> <pre><code>&lt;td&gt; Callback that sends the token to user &lt;/td&gt; &lt;td&gt; function($LS, $userID, $token){} &lt;/td&gt; </code></pre> </tr> <tr> <td> devices_table </td> <pre><code>&lt;td&gt; Table in database where users&amp;#8217; device information are stored &lt;/td&gt; &lt;td&gt; user_devices &lt;/td&gt; </code></pre> </tr> <tr> <td> token_length </td> <pre><code>&lt;td&gt; The length of token that is generated &lt;/td&gt; &lt;td&gt; 4 &lt;/td&gt; </code></pre> </tr> <tr> <td> token_tries </td> <pre><code>&lt;td&gt; Maximum number of incorrect tries for Two Step Login token the user can do &lt;/td&gt; &lt;td&gt; 3 &lt;/td&gt; </code></pre> </tr> <tr> <td> numeric </td> <pre><code>&lt;td&gt; Whether the token generated should be numeric only &lt;/td&gt; &lt;td&gt; true &lt;/td&gt; </code></pre> </tr> <tr> <td> expire </td> <pre><code>&lt;td&gt; The expire duration of the device cookie.&lt;br /&gt; This value is used for making the time using strtotime() function. So, the value must be compatible with &lt;a href=&quot;http://php.net/manual/en/function.strtotime.php&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;strtotime()&lt;/a&gt; &lt;/td&gt; &lt;td&gt; +45 days &lt;/td&gt; </code></pre> </tr> <tr> <td> first_check_only </td> <pre><code>&lt;td&gt; Should logSys checks if device is valid, everytime logSys is initiated ie everytime a page loads. If you want to check only the first time a user loads a page, then set the value to TRUE, else FALSE &lt;/td&gt; &lt;td&gt; true &lt;/td&gt; </code></pre> </tr> </table> <h3 id="debug">debug</h3> <p>You can make logSys write log files to debug.</p> <table class="table"> <tr> <td> enable </td> <pre><code>&lt;td&gt; Should debugging be enabled &lt;/td&gt; &lt;td&gt; false &lt;/td&gt; </code></pre> </tr> <tr> <td> log_file </td> <pre><code>&lt;td&gt; The absolute path to log file &lt;/td&gt; &lt;td&gt; / &lt;/td&gt; </code></pre> </tr> </table> <p>Make sure the log file is situated outside the public directory of server. Messages are appended to log files and not overwritten.</p> <p>You can find a sample configuration fileย <a href="https://github.com/subins2000/logSys/blob/master/examples/basic/config.php">here</a>.</p> <h2 id="database-table-setup">Database Table Setup</h2> <h3 id="mysql">MySQL</h3> <p>You can find the <strong>SQL</strong> codeย to create the table <strong>users</strong>ย <a href="https://github.com/subins2000/logSys/blob/master/sql/mysql.sql#L8">here</a>.</p> <p>logSys remembers the table name through &quot;db&quot;-&gt;&quot;table&quot;. By default itโ€™s set to &quot;users&quot;. You can add extra columns according to your choice. After all, you can ask many info from users.</p> <p><strong>Note</strong> : As you can see in the `users` table mentioned above as SQL, the username column has a limit of &quot;10&quot; characters. So, you wonโ€™t be able to register users with usernames more than 10 chars. So, increase the limit to allow more characters in username.</p> <p>For storing the reset password tokens, you need to create an extra table called &quot;user_tokens&quot;. This table name can be changed with config -&gt; db -&gt; tokens_table option.</p> <p>You can find the SQL code for creating it <a href="https://github.com/subins2000/logSys/blob/master/sql/mysql.sql#L23">here</a>.</p> <p>The reset password token saving table should be called &quot;resetTokens&quot;. It is <strong>not changeable</strong>. If you really want to change it, find the SQL queries in the class file that uses the &quot;resetTokens&quot; table and replace it.</p> <h3 id="postgresql">PostgreSQL</h3> <p>You can find the SQL code <a href="https://github.com/subins2000/logSys/blob/master/sql/postgresql.sql">here</a>ย to create the 3 tables.</p> <h3 id="sqlite">SQLite</h3> <p>The SQL code for creating the 3 tables is different forย <strong>SQL****ite</strong>.ย You can find it <a href="https://github.com/subins2000/logSys/blob/master/sql/sqlite.sql">here</a>.</p> <h2 id="timezone">Timezone</h2> <p>Timezone is an important factor in any system that uses time in both database and server. In a login system itโ€™s extensively used. So donโ€™t screw it up.</p> <p>I recommend usingย <strong>UTC</strong> as the timezone for all your applications. logSys by default doesnโ€™t set a timezone. You should do it in your servers. See these pages to learn how to set it :</p> <ul> <li><a href="https://stackoverflow.com/a/7587637/1372424" target="_blank" rel="noopener">Set timezone to UTC in PHP</a></li> <li><a href="https://stackoverflow.com/a/19075291/1372424" target="_blank" rel="noopener">Set timezone to UTC in MySQL</a></li> <li><a href="https://stackoverflow.com/a/11443155/1372424" target="_blank" rel="noopener">Set timezone to UTC in PostgreSQL</a></li> </ul> <h2 id="initialize">Initialize</h2> <p>Redirection based on the login status is needed for a login system. You should call the <strong>$LS-&gt;init();</strong> at the start of every page on your site to redirect according to the login status. You can do this automatically without calling the function manually by setting <code>config</code> -&gt; <code>features</code> -&gt; <code>auto_init</code>ย to boolean TRUE.</p> <p>Here is an example :</p> <pre class="prettyprint"><code>&lt;?php require "config.php"; $LS-&gt;init(); ?&gt; &lt;html&gt;</code></pre> <p>and continue with your HTML code. When a user who is not logged in visits a page that is <strong>not</strong> in the <code>config</code>ย -&gt; <code>pages</code> -&gt; <code>no_login</code> array, the user gets redirected to the login page mentioned in <code>config</code>ย -&gt; <code>pages</code> -&gt; <code>login_page</code>.</p> <p>If the user is logged in and is on a page mentioned in the <code>config</code>ย -&gt;ย <code>pages</code> -&gt; <code>no_login</code> array, he/she will be redirected to the <code>config</code>ย -&gt; <code>pages</code> -&gt; <code>home_page</code> URI.</p> <p>All users who is logged in and not logged in can see the pages mentioned in <code>config</code> -&gt; <code>pages</code> -&gt; <code>everyone</code>. They wonโ€™t be redirected in those pages.</p> <h2 id="login-page">Login Page</h2> <p>Now, weโ€™ll set up a login page. All you have to do is make a form and call the <strong>$LS-&gt;login()</strong> function with details at starting of the page. Example :</p> <pre class="prettyprint"><code>&lt;html&gt; &lt;head&gt; &lt;title&gt;Log In&lt;/title&gt; &lt;/head&gt; &lt;body&gt; &lt;div class="content"&gt; &lt;form method="POST"&gt; &lt;label&gt;Username / E-Mail&lt;/label&gt;&lt;br/&gt; &lt;input name="login" type="text"/&gt;&lt;br/&gt; &lt;label&gt;Password&lt;/label&gt;&lt;br/&gt; &lt;input name="pass" type="password"/&gt;&lt;br/&gt; &lt;label&gt; &lt;input type="checkbox" name="remember_me"/&gt; Remember Me &lt;/label&gt; &lt;button name="act_login"&gt;Log In&lt;/button&gt; &lt;/form&gt; &lt;/div&gt; &lt;/body&gt; &lt;/html&gt;</code></pre> <p>Now, we process the submitted login data. Place this code at the top of the page before <strong><html></strong> :</p> <pre class="prettyprint"><code>&lt;?php require "config.php"; $LS-&gt;init(); if(isset($_POST["action_login"])){ $identification = $_POST['login']; $password = $_POST['password']; if($identification == "" || $password == ""){ $msg = array("Error", "Username / Password Wrong !"); }else{ $login = $LS-&gt;login($identification, $password, isset($_POST['remember_me'])); if($login === false){ $msg = array("Error", "Username / Password Wrong !"); }else if(is_array($login) && $login['status'] == "blocked"){ $msg = array("Error", "Too many login attempts. You can attempt login after ". $login['minutes'] ." minutes (". $login['seconds'] ." seconds)"); } } } ?&gt;</code></pre> <p>The syntax for using the <strong>$LS-&gt;login()</strong> function is this :</p> <pre class="prettyprint"><code>boolean|array Fr\LS::login($username, $password, $remember_me, $cookies)</code></pre> <p>The <strong>$username</strong> parameter can be either the <strong>E-Mail</strong> (if <code>config</code> -&gt; <code>features</code> -&gt; <code>email_login</code>ย config value is boolean <strong>TRUE</strong>) or the username of user.</p> <p>The <strong>$remember_me</strong> parameter (default FALSE) should be set to boolean <strong>TRUE</strong>, if the user needs to be remembered even after the end of the PHP session that is the user is automatically logged in after he/she visits the page again. But, to enable this, the config value <code>features</code> -&gt; <code>remember_me</code> must be set to boolean <strong>TRUE</strong>.</p> <p>The <strong>$cookies</strong> parameter (default TRUE) makes the decision whether cookies should be created or not. This is useful, when you have to check if a username and password is correct without creating any cookies and redirects. This too needs a boolean value.</p> <p>User will be redirected after logging in if <strong>$cookies</strong> is set to TRUE which is the default value.</p> <p>You can also login by passing the password value as <strong>NULL</strong> (Thanks <a href="https://disqus.com/home/user/adikedem/" target="_blank" rel="noopener">Adi Kedem</a>). This is useful when you have to login a user without knowing the password like in OAuth login process :</p> <pre class="prettyprint"><code>$LS-&gt;login($username, null)</code></pre> <p>But there is a <strong>danger</strong> to this โ€“ a user can enter just by entering the username and no password. To avoid this issue, a checking whether the password is blank is done in <strong>login.php</strong> page :</p> <pre class="prettyprint"><code>$user = $_POST['login']; $pass = $_POST['pass']; if($user == "" || $pass == ""){ $msg = array("Error", "Username / Password Is Blank !"); }</code></pre> <p>If brute force check is enabled and if the account is blocked from incorrect login attempts, then an <strong>array</strong> is returned. Here is how the array look like :</p> <pre class="prettyprint"><code>array( "status" =&gt; "blocked", "minutes" =&gt; 5 "seconds" =&gt; 300 )</code></pre> <p>Both minutes and seconds will be shown. Note that the minutes value is rounded. So, if itโ€™s actually 4.10 seconds, the minutes value will still be &quot;5&quot;.</p> <p>If the user login is successful, a boolean <strong>TRUE</strong> is returned, otherwise a boolean <strong>FALSE</strong> unless the account is blocked for which an array is returned instead of a boolean value.</p> <h2 id="register--create-account">Register / Create Account</h2> <p>Now, we move forward to the register page. We use <strong>Fr\LS::register()</strong> function for creating accounts. Here is the syntax :</p> <pre class="prettyprint"><code>boolean Fr\LS::register($username, $password, $extraValues);</code></pre> <p>The <strong>$extraValues</strong> variable is an array containing keys and values that are inserted with the username and password. Suppose, you made an extra column named &quot;name&quot; that is used for storing the userโ€™s name. Here is how you make the <strong>$extraValues</strong> array :</p> <pre class="prettyprint"><code>array("name" =&gt; $personName)</code></pre> <p>Note that email value is not passed directly to the <strong>register()</strong> function. You should include it with **$extraValues **array and the whole array becomes :</p> <pre class="prettyprint"><code>array( "email" =&gt; $email, "name" =&gt; $name )</code></pre> <p>You create the HTML form and pass the values got from the form to this function and it will take care of everything else. <strong>Fr\LS::register()</strong> returns &quot;exists&quot; if the username is already taken or if an account with the email given exists. Otherwise, if everything is successful, it returns boolean <strong>TRUE</strong>.</p> <h2 id="check-if-user-exists">Check If User Exists</h2> <p>There is an in-built function to check if there is an account with the username or email exist already. Here is the syntax :</p> <pre class="prettyprint"><code>boolean Fr\LS::userExists($username)</code></pre> <p>You can also pass e-mail as the value if <code>config</code> -&gt; <code>features</code>ย -&gt; <code>email_login</code>ย is set to TRUE.</p> <h3 id="check-if-user-id-exists">Check If User ID Exists</h3> <p>Instead of username, you can check if a user ID exist using <code>userIDExists()</code>ย :</p> <pre class="prettyprint"><code>booleanย Fr\LS::userIDExists($userID);</code></pre> <p>Example :</p> <pre class="prettyprint"><code>if ($LS-&gt;userIDExists(1)) { // User with ID '1' exists }</code></pre> <h2 id="check-if-user-is-logged-in">Check If User is Logged In</h2> <p>You can check if user is logged in with the function <strong>Fr\LS::isLoggedIn()</strong>ย :</p> <pre tabindex="0"><code>if($LS-&gt;isLoggedIn()){ // User logged in } else { // User not logged in } </code></pre><h2 id="log-out">Log Out</h2> <p>You just need to call <strong>Fr\LS::logout()</strong> for clearing the browser cookies and PHP session which means the user is logged out :</p> <pre class="prettyprint"><code>$LS-&gt;logout();</code></pre> <p>You donโ€™t have to do anything else.</p> <h2 id="sending-e-mails">Sending E-Mails</h2> <p>When any components of logSys needs to send emails, it calls the <strong>Fr\LS::sendMail()</strong> function with email address, subject and body in the corresponding order.</p> <p>You can change the methodย used to send mails by adding a callback function to <code>config</code> -&gt; <code>basic</code> -&gt; <code>email_callback</code>. Example :</p> <pre class="prettyprint"><code>"email_callback" =&gt; function($LS, $email, $subject, $body){ mail($email, $subject . " - My Company", $body); }</code></pre> <p>Sometimes <strong>mail()</strong> function wonโ€™t work and email wonโ€™t be received by the users. In that case, try using an Email API like <a href="http://subinsb.com/send-free-emails-using-mailgun-api-in-php">Mailgun</a>. Then use that API in theย <code>config</code> -&gt; <code>basic</code> -&gt; <code>email_callback</code>ย function.</p> <h2 id="forgotreset-password">Forgot/Reset Password</h2> <p>Normally, almost every user forgets their password. logSys have a special function that takes care of everything for you. Just call <strong>Fr\LS::forgotPassword()</strong> at the place where you want to display the Forgot Password form :</p> <pre class="prettyprint"><code>&lt;?php require "config.php"; ?&gt; &lt;html&gt; &lt;head&gt;&lt;/head&gt; &lt;body&gt; &lt;div class="content"&gt; &lt;?php $LS-&gt;forgotPassword(); ?&gt; &lt;/div&gt; &lt;/body&gt; &lt;/html&gt;</code></pre> <p>You may call <strong>LS-&gt;init()</strong> in the above page if you are sensitive about logged in users accessing the page. This function returns different strings according to the status of the resetting password process. Here are they :</p> <table style="height: 320px;" width="717"> <tr> <td> Return String </td> <pre><code>&lt;td&gt; Description &lt;/td&gt; </code></pre> </tr> <tr> <td> identityNotProvided </td> <pre><code>&lt;td&gt; Identity (email/username) is not provided &lt;/td&gt; </code></pre> </tr> <tr> <td> userNotFound </td> <pre><code>&lt;td&gt; No user with given identity was found &lt;/td&gt; </code></pre> </tr> <tr> <td> resetPasswordForm </td> <pre><code>&lt;td&gt; The Reset Password form is currently shown. &lt;/td&gt; </code></pre> </tr> <tr> <td> invalidToken </td> <pre><code>&lt;td&gt; The token given for changing password is invalid/wrong. &lt;/td&gt; </code></pre> </tr> <tr> <td> changePasswordForm </td> <pre><code>&lt;td&gt; The change Password Form is currently shown. &lt;/td&gt; </code></pre> </tr> <tr> <td> fieldsLeftBlank </td> <pre><code>&lt;td&gt; The fields of change password form were left blank. &lt;/td&gt; </code></pre> </tr> <tr> <td> passwordDontMatch </td> <pre><code>&lt;td&gt; The new password field and retype password field doesn&amp;#8217;t match &lt;/td&gt; </code></pre> </tr> <tr> <td> emailSent </td> <pre><code>&lt;td&gt; An email was sent to the account holder&amp;#8217;s email address &lt;/td&gt; </code></pre> </tr> <tr> <td> passwordChanged </td> <pre><code>&lt;td&gt; The Password was changed/resetted successfully &lt;/td&gt; </code></pre> </tr> </table> <h2 id="change-password">Change Password</h2> <p><del>Just like forgot password, all you have to do is call <strong>$LS-&gt;changePassword()</strong> function to display the form and do the tasks needed for changing the password. As like before, logSys will take care of everything here too.</del></p> <p>Update : As of version 0.4, logSys doesnโ€™t take care of everything. You have to make the form and pass the values to the <strong>Fr\LS::changePassword()</strong> function. Here is an example :</p> <pre class="prettyprint"><code>&lt;?php require "config.php"; $LS-&gt;init(); ?&gt; &lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;title&gt;Change Password&lt;/title&gt; &lt;/head&gt; &lt;body&gt; &lt;?php if(isset($_POST['change_password'])){ if(isset($_POST['current_password']) && $_POST['current_password'] != "" && isset($_POST['new_password']) && $_POST['new_password'] != "" && isset($_POST['retype_password']) && $_POST['retype_password'] != "" && isset($_POST['current_password']) && $_POST['current_password'] != ""){ $curpass = $_POST['current_password']; $new_password = $_POST['new_password']; $retype_password = $_POST['retype_password']; if($new_password !== $retype_password){ echo "&lt;p&gt;&lt;h2&gt;Passwords Doesn't match&lt;/h2&gt;&lt;p&gt;The passwords you entered didn't match. Try again.&lt;/p&gt;&lt;/p&gt;"; }else if($LS-&gt;login($LS-&gt;getUser("username"), "", false, false) == false){ echo "&lt;h2&gt;Current Password Wrong!&lt;/h2&gt;&lt;p&gt;The password you entered for your account is wrong.&lt;/p&gt;"; }else{ $change_password = $LS-&gt;changePassword($new_password); if($change_password === true){ echo "&lt;h2&gt;Password Changed Successfully&lt;/h2&gt;"; } } }else{ echo "&lt;p&gt;&lt;h2&gt;Password Fields was blank&lt;/h2&gt;&lt;p&gt;Form fields were left blank&lt;/p&gt;&lt;/p&gt;"; } } ?&gt; &lt;form action="&lt;?php echo Fr\LS::curPageURL();?&gt;" method='POST'&gt; &lt;label&gt; &lt;p&gt;Current Password&lt;/p&gt; &lt;input type='password' name='current_password' /&gt; &lt;/label&gt; &lt;label&gt; &lt;p&gt;New Password&lt;/p&gt; &lt;input type='password' name='new_password' /&gt; &lt;/label&gt; &lt;label&gt; &lt;p&gt;Retype New Password&lt;/p&gt; &lt;input type='password' name='retype_password' /&gt; &lt;/label&gt; &lt;button style="display: block;margin-top: 10px;" name='change_password' type='submit'&gt;Change Password&lt;/button&gt; &lt;/form&gt; &lt;/body&gt; &lt;/html&gt;</code></pre> <p>Here is the syntax of the function :</p> <pre class="prettyprint"><code>boolean Fr\LS::changePassword($new_password, $userID);</code></pre> <p>You may optionally mention the user ID. If not, the currently logged in user is used.ย This function returns boolean TRUE if the password was changed.</p> <p>You will now have to check whether the current password is right or not with <strong>Fr\LS::login()</strong>ย before changing the password.</p> <pre class="prettyprint"><code>$LS-&gt;login("username", "current_password", false, false) </code></pre> <p>The 4th parameter should be set to FALSE, otherwise redirection will occur as like a normal login.</p> <h2 id="get-user-detailsinfo">Get User Details/Info</h2> <p>As I said in the introduction, you can add more columns to the table. This means that you have to get values from every columns. For this, I added an extra function to get all the fields of a particular row. To get the fields of current user, all you have to do is call <strong>Fr\LS::getUser()</strong>. Syntaxย :</p> <pre class="prettyprint"><code>string|array Fr\LS::getUser("column_name", $userID);</code></pre> <p>Note that, we are using <strong>$userID</strong> which is the <strong>id</strong> field of the row. If you use the column name as &quot;*&quot;, you will get an array as the return value like this :</p> <pre class="prettyprint"><code>array( "id" =&gt; 1, "username" =&gt; "subins2000", "email" =&gt; "[email protected]", "password" =&gt; "asd4845ghnvbmvolfpsdpsa0ffkfoeww89d9d25f1f56", "password_salt" =&gt; "mv5r7(4565v" )</code></pre> <p>More fields will be obtained once you add more columns to the table. If you need to get only a single field, you can use :</p> <pre class="prettyprint"><code>$LS-&gt;getUser("column_name"); </code></pre> <h2 id="update-user-detailsinfo">Update User Details/Info</h2> <p>As a suggestion of adding this feature from <a href="http://disqus.com/kevinhamil/" target="_blank" rel="noopener">Kevin Hamil</a>, I have added a function to update the usersโ€™ details. Syntax :</p> <pre class="prettyprint"><code>boolean Fr\LS::updateUser($values, $userID);</code></pre> <p>The variable <strong>$values</strong> is an array containing the information about updation of values. If you need to update the &quot;name&quot; field to &quot;Vishal&quot;, you can make the array like this :</p> <pre class="prettyprint"><code>$values = array( "name" =&gt; "Vishal" );</code></pre> <p>And the <strong>$userID</strong> variable contains the userโ€™s ID. By default, the value of it is the currently logged in user. Here is an example of updating the current userโ€™s information :</p> <pre class="prettyprint"><code>$LS-&gt;updateUser(array( "name" =&gt; "Subin", "birth" =&gt; "20/01/2000" )); </code></pre> <h2 id="two-step-login">Two Step Login</h2> <p>Two Step Login is a new feature added to logSys in version 0.5. Here is how it works :</p> <ol> <li>User logs in with his/her username-password</li> <li>If the device the user used to login is not authorized, then a form is shown asking the user to enter a code</li> </ol> <pre><code>This code should be sent by your login system. You can choose the medium for sending : E-Mail/SMS You should implement a callback that will send the token. </code></pre> <ol start="3"> <li>The form also has a &quot;Remember Device&quot; option if enabled wouldnโ€™t show the form again upon further logins in the future.</li> </ol> <pre><code>If the user gets the token right (note that it cannot be brute forced), then login is finished If not, then the user would have to login again starting from username-password form </code></pre> <p>First of all enable Two Step Login by setting the value of <code>config</code> -&gt; <code>features</code> -&gt; <code>two_step_login</code> to TRUE.</p> <p>Hereโ€™s a skeleton of the process :</p> <pre class="prettyprint"><code>try { if (isset($_POST['login']) && isset($_POST['password'])) { /** * Try login */ $LS-&gt;twoStepLogin($_POST['login'], $_POST['password'], isset($_POST['remember_me'])); } else { /** * Handle Two Step Login */ $LS-&gt;twoStepLogin(); } } catch (Fr\LS\TwoStepLogin $TSL) { if ($TSL-&gt;getStatus() === 'login_fail') { // Username/password wrong } elseif ($TSL-&gt;getStatus() === 'blocked') { $blockInfo = $TSL-&gt;getBlockInfo(); // Account blocked } elseif ($TSL-&gt;getStatus() === 'enter_token_form' || $TSL-&gt;getStatus() === 'invalid_token') { // Wrong token $hideLoginForm = true; } elseif ($TSL-&gt;getStatus() === 'login_success') { // login success. If auto init is enabled, redirection will be automatically done } elseif ($TSL-&gt;isError()) { // Some other error } } if (!isset($hideLoginForm))ย { // Show login form here }</code></pre> <p>See a complete example <a href="https://github.com/subins2000/logSys/blob/dev/examples/two-step-login/login.php" target="_blank" rel="noopener">here</a>.</p> <p>The login form is placed under an if condition so that it is not displayed when the &quot;Enter Token&quot; form of Two step Login is shown. Orย you can separate the login form page and the Two Step Login process page.</p> <p>Calling <code>twoStepLogin()</code>ย with no parameters will make it automatically handle the Two Step Login part of the login process. The username and password parameter should be passed only once when the user submits the login form. This is what you see in the <code>try</code>{} block.</p> <p>The parameters are the same as <code>login()</code>:</p> <p><code>$LS-&gt;twoStepLogin($_POST['login'], $_POST['password'], isset($_POST['remember_me']));</code></p> <h3 id="exception">Exception</h3> <p>Exceptions are thrown by <code>twoStepLogin()</code>for handling the Two Step Login process. There are two type of exceptions here :</p> <ul> <li>Two Step Login process exception</li> <li>Two Step Login error exception</li> </ul> <p>Note that the first exception in the above is actually good and not an error. You can test whether itโ€™s an error using <code>isError()</code>.</p> <h3 id="iserror">isError()</h3> <p>Returns whether the exception is about an error. Example :</p> <pre class="prettyprint"><code>catch (Fr\LS\TwoStepLogin as $TSL) { var_dump($TSL-&gt;isError()); // A boolean value }</code></pre> <h3 id="getoption">getOption()</h3> <p>For some statuses, there will be additional values associated with it. This can be obtained with this function. Example :</p> <p>When the &quot;Enter Token&quot; form should be displayed, there are 3 values available. These are obtained like this :</p> <pre class="prettyprint"><code>$TSL-&gt;getOption('uid'); // User ID $TSL-&gt;getOption('remember_me'); // Whether user checked 'Remember Me' $TSL-&gt;getOption('tries_left');ย //ย Numberย ofย triesย leftย forย enteringย token</code></pre> <h3 id="getstatus">getStatus()</h3> <p>Returns the status code of exception. This includes both error status and the Two Step Login process status. Example :</p> <pre class="prettyprint"><code>catch (Fr\LS\TwoStepLogin as $TSL) { var_dump($TSL-&gt;getStatus()); // String }</code></pre> <p>The following table shows the different status values returned by <code>Fr\LS\TwoStepLogin-&gt;getStatus()</code> :</p> <table class="table"> <tbody> <tr> <td>Type</td> <td>Value</td> <td>What It Means</td> </tr> <tr> <td>process</td> <td>enter_token_form</td> <td>Show the enter token form. Read the section after this table.</td> </tr> <tr> <td>process</td> <td>login_success</td> <td>The Two Step Login token was correct and the user can be logged in. <p>This exception can only be caught if 4th parameter to <code>twoStepLogin()</code>ย is FALSE i.e. no cookies should be set.</p> <p>Because if cookies are set the user is redirected to the home page.</p> </td> </tr> <tr> <td>error</td> <td>login_fail</td> <td>The username or password was incorrect. The Two Step Login process cannot be started.</td> </tr> <tr> <td>error</td> <td>blocked</td> <td>The user is blocked. Read [this](#getblockstatus).</td> </tr> <tr> <td>error</td> <td>invalid_token</td> <td>The Two Step Login token submitted was incorrect.</td> </tr> <tr> <td>error</td> <td>invalid_csrf_token</td> <td>CSRF Security token failed. [Read this](#csrf-security).</td> </tr> </tbody> </table> <h5 id="enter_token_form">enter_token_form</h5> <p>This status is returned to show the Two Step Login &quot;Enter Token&quot; form. This form should be made by you with the only condition that the token input field should have the name <code>two_step_login_token</code>:</p> <pre tabindex="0"><code>&lt;input type=&#39;text&#39; name=&#39;two_step_login_token&#39; /&gt; </code></pre><p>This is how the form should look :</p> <pre tabindex="0"><code>&lt;form action=&#34;&lt;?php echo Fr\LS::curPageURL(); ?&gt;&#34; method=&#34;POST&#34;&gt; &lt;p&gt;A token was sent to your E-Mail address. Paste the token in the box below :&lt;/p&gt; &lt;input type=&#34;text&#34; name=&#34;two_step_login_token&#34; /&gt;&lt;br/&gt; &lt;span&gt;Remember this device ?&lt;/span&gt; &lt;input type=&#34;checkbox&#34; name=&#34;two_step_login_remember_device&#34; /&gt;&lt;br/&gt; &lt;input type=&#34;hidden&#34; name=&#34;two_step_login_uid&#34; value=&#34;&lt;?php echo $TSL-&gt;getOption(&#39;uid&#39;); ?&gt;&#34; /&gt; &lt;?php echo $LS-&gt;csrf(&#39;i&#39;); if ($TSL-&gt;getOption(&#39;remember_me&#39;)) { ?&gt; &lt;input type=&#34;hidden&#34; name=&#34;two_step_login_remember_me&#34; /&gt; &lt;?php } ?&gt; &lt;button&gt;Verify&lt;/button&gt; &lt;a onclick=&#34;window.location.reload();&#34; href=&#34;#&#34;&gt;Resend Token&lt;/a&gt; &lt;/form&gt; </code></pre><p>NOTE that the input fieldsโ€™ <strong>name</strong>ย attribute in your form SHOULD BE THE SAME AS SHOWN ABOVE.</p> <p>Here are the additional input fields used :</p> <ul> <li>two_step_login_remember_device<br> Should the device be remembered. If itโ€™s remembered, when the user logs in again later, Two Step Login process is skipped and user is logged in if he enters the correct username and password.</li> <li>two_step_login_remember_me<br> If the user had chosen &quot;Remember Me&quot; checkbox in the previous step (log in with username/password), then this field must be present to remember the user.<br> Whether the user had chosenย &quot;Remember Me&quot; checkbox in the previous step is determined by <code>$TSL-&gt;getOption('remember_me')</code></li> <li>two_step_login_uid<br> Stores the userโ€™s ID who is now attempting to log in. If this value is tampered with, then the login process fails.</li> </ul> <h5 id="blocked">blocked</h5> <p>When the user is blocked, the exception status will be โ€˜blockedโ€™. You can get the information about the block using <code>getBlockInfo()</code>. The data returned will be same as in the <a href="#login-page">normal login process</a>.</p> <p>Once again, I request you to see the complete example <a href="https://github.com/subins2000/logSys/blob/dev/examples/two-step-login/login.php">here</a>ย to understand better.</p> <h3 id="database">Database</h3> <p>Now we must create a table in database that will store the devices of users :</p> <h4 id="mysql-1">MySQL</h4> <p>See <a href="https://github.com/subins2000/logSys/blob/master/sql/mysql.sql">this</a></p> <h4 id="postgresql-1">PostgreSQL</h4> <p>See <a href="https://github.com/subins2000/logSys/blob/master/sql/postgresql.sql">this</a></p> <h4 id="sqlite-1">SQLite</h4> <p>See <a href="https://github.com/subins2000/logSys/blob/master/sql/sqlite.sql">this</a></p> <p>You can change the table name if you want to, but you must mention the new name in <code>config</code> -&gt; <code>two_step_login</code> -&gt; <code>devices_table</code>.</p> <h3 id="configure">Configure</h3> <p>We still havenโ€™t added the callback that will send the token. Add a callback function in <code>config</code>ย -&gt; <code>two_step_login</code> -&gt; <code>send_callback</code> :</p> <pre tabindex="0"><code>&#39;send_callback&#39; =&gt; function($LS, $userID, $token){ // Send Token as email $email = Fr\LS::getUser(&#34;email&#34;, $userID); $subject = &#39;Verify Yourself - 2 Step Verification&#39;; $body = &#39;&lt;p&gt;Someone tried to login to your account. If it was you, then use the following token to complete logging in : &lt;blockquote&gt;&#39;. $token .&#39;&lt;/blockquote&gt;If it was &lt;b&gt;not you&lt;/b&gt;, then ignore this email and please consider to change your account\&#39;s password.&lt;/p&gt;&#39;; mail($email, $subject, $body); } </code></pre><p>You can use any mechanism to send the token. If you have access to SMS API, then use it because it is much more secure than E-Mail.</p> <h4 id="token_length">token_length</h4> <p>You can also change the tokenโ€™s length. Just change the integer value of <code>config</code> -&gt; <code>two_step_login</code> -&gt; <code>token_length</code>.</p> <h4 id="token_tries">token_tries</h4> <p>You can set a limit on how many incorrect tries the user can make while entering the Two Step Login token. For this, change the integer value of <code>config</code> -&gt; <code>two_step_login</code> -&gt; <code>token_tries</code>.</p> <h4 id="numeric">numeric</h4> <p>By default, the randomly generated token will have alphanumeric characters. In case youโ€™re using SMS mechanism, it will be simpler for user to type numericals. You can make logSys generate numeric tokens for Two Step Login by setting the value of <code>config</code> -&gt; <code>two_step_login</code> -&gt; <code>numeric</code> to TRUE.</p> <h4 id="expiry">expiry</h4> <p>If the user chooses the &quot;Remember Device&quot; option, then a cookie is created in that browser that recognises the authorised device. You can set the validity of this cookie by changing the value of <code>config</code> -&gt; <code>two_step_login</code> -&gt; <code>expiry</code>. The value is used in <a href="http://php.net/manual/en/function.strtotime.php">strtotime()</a> function, so enter values that are valid for the function.</p> <h4 id="first_check_only">first_check_only</h4> <p>If a user did &quot;Remember Device&quot; and visit a page, logSys will check if the device cookie matches the device ID stored in database. If it does not, then the user is logged out. This is done so, because if the original user revokes a device, the session on that device must be logged out wherever it is. But, checking this every time a page loads can decrease performance. To avoid this, you can set the value of <code>config</code> -&gt; <code>two_step_login</code>ย -&gt; <code>first_check_only</code> to TRUE.</p> <h3 id="getdeviceid">getDeviceID()</h3> <p>The ID of the device currently logged in by the user. Actually it returns the device cookie value.</p> <p>This only works if the user is logged in.</p> <h2 id="csrf-security">CSRF Security</h2> <p>To protect against CSRF, a token system is implemented in logSys. For handling CSRF security <code>csrf()</code>ย function is used.</p> <h3 id="get-token-as-string">Get Token As String</h3> <pre tabindex="0"><code>echo $LS-&gt;csrf(&#39;s&#39;); </code></pre><h3 id="check-if-csrf-token-is-correct">Check If CSRF Token Is Correct</h3> <p>When a form is submitted it is necessary to check if CSRF token is correct. For this simply call <code>csrf()</code>ย with no parameters :</p> <pre tabindex="0"><code>ifย ($LS-&gt;csrf()){ // All good } </code></pre><h3 id="get-csrf-token-as-an-input-field">Get CSRF Token As An Input Field</h3> <pre tabindex="0"><code>echo $LS-&gt;csrf(&#39;i&#39;); </code></pre><p>This returns something like this :</p> <pre tabindex="0"><code>&lt;inputย type=&#39;hidden&#39;ย name=&#39;csrf_token&#39;ย value=&#39;w9cvK&#39;ย /&gt; </code></pre><h2 id="extra-functionstools">Extra Functions/Tools</h2> <p>Along with the main functions in logSys, some extra tools or functions are included.</p> <h3 id="time-since-user-joined">Time Since User Joined</h3> <p>If you would like to display to the user how much time he has been a member of the site, you have to do the following : Create a column named &quot;created&quot; in your users database table and add the created value in registration :</p> <pre tabindex="0"><code>$LS-&gt;register($username, $password, array( &#34;created&#34; =&gt; date(&#34;Y-m-d H:i:s&#34;) )); </code></pre><p>Now, you can use the built inย <strong>joinedSince()</strong> function of logSys to display the time since joined :</p> <pre tabindex="0"><code>echo $LS-&gt;joinedSince(); </code></pre><p>Some example outputs :</p> <pre tabindex="0"><code>10 Seconds 2 Minutes 4 Hours 25 days 7 Weeks 15 Months </code></pre><h3 id="check-if-email-is-valid">Check if email is valid</h3> <p>Use <strong>Fr\LS::validEmail()</strong> function for checking if an email address is valid or not. Usage :</p> <pre tabindex="0"><code>Fr\LS::validEmail(&#34;[email protected]&#34;) </code></pre><h3 id="current-page-url">Current Page URL</h3> <p>Get the full URL of the current page. Usage :</p> <pre tabindex="0"><code>echo Fr\LS::curPageURL() </code></pre><h3 id="generate-random-string">Generate Random String</h3> <p>As seen on <a href="//subinsb.com/php-generate-random-string">http://subinsb.com/php-generate-random-string</a>, Generates a unique string. Usage :</p> <pre tabindex="0"><code>Fr\LS::randStr(20) </code></pre><h3 id="current-page-pathname">Current Page Pathname</h3> <p>Get the path name of the current page. Usage :</p> <pre tabindex="0"><code>echo Fr\LS::curPage() </code></pre><p>Some sample outputs :</p> <pre tabindex="0"><code>/ /myfolder/mysubfolder/mypage.php </code></pre><h3 id="redirect-with-http-status">Redirect With HTTP Status</h3> <p>Redirects with the HTTP status such as 301, 302. Usage :</p> <pre tabindex="0"><code>Fr\LS::redirect(&#34;http://subinsb.com&#34;, 302) </code></pre><p>Thatโ€™s all the extra tools.</p> <h2 id="common-problems">Common Problems</h2> <p>I should have made this section long time ago. Here are some of the most common problems and the solution to them :</p> <h3 id="fatal-error-call-to-a-member-function-prepare-on-a-non-object">Fatal error: Call to a member function prepare() on a non-object</h3> <p>This error happens because logSys couldnโ€™t connect to the database. Either your server doesnโ€™t have <strong>PHP PDO Extension</strong> or the database credentials given in <code>config</code>ย -&gt; <code>db</code> is not correct.</p> <p>So, install <strong>PDO</strong> extension and check if the database credentials given is correct.</p> <h3 id="redirect-loop--cant-access-pages">Redirect Loop / Canโ€™t Access Pages</h3> <p>This is the most common problem and the solution is simple. Why this error happened is because that the relative path names put in the <code>config</code>ย -&gt;ย <code>pages</code>ย -&gt; <code>no_login</code>ย array is wrong or the <code>config</code>ย -&gt;ย <code>pages</code>-&gt;<code>login_page</code> is wrong or <code>pages</code> -&gt; <code>home_page</code> has an invalid value. Here are some valid path names :</p> <pre tabindex="0"><code>/ /index.php /mypage/myfile.php /login.php /home.php </code></pre><p>But, these path names are <strong>wrong</strong> :</p> <pre tabindex="0"><code>index.php http://mysite.com/mypage/myfile.php //mysite.com/login.php mysite.com/home.php </code></pre><p>An easy way to find out the relative pathname of a page is to output <strong>$_SERVER[โ€˜REQUEST_URIโ€™]</strong> in that page.</p> <h3 id="session_start--headers-already-sent">session_start() โ€“ headers already sent</h3> <p>This is a common problem seen from the <strong>0.4</strong> version. It is because that the session is not started [session_start()] before the content is outputted.</p> <p>logSys will start the session if <code>config</code> -&gt; <code>features</code> -&gt; <code>start_session</code> is set to <strong>TRUE</strong>. If you enable this, you must construct the logSys object before any output is made like this :</p> <pre tabindex="0"><code>&lt;?php $LS = new Fr\LS; ?&gt; &lt;html&gt; </code></pre><h3 id="cookies-not-created">Cookies Not Created</h3> <p>When the cookies are not created, user is not logged in after submitting the form. He/she wonโ€™t be redirected to the home page and will still see the login page.</p> <p>This is probably because of faults in the configuration. Check the values of <code>config</code> -&gt; <code>cookies</code> array. Try removing the <code>domain</code> value or <code>path</code> value. Try messing with the values of it.</p> <p>Also, try keeping the values of <code>domain</code> and <code>path</code> blank. It might work.</p> <h3 id="cannot-modify-header-information">Cannot modify header information</h3> <p>You may have to <a href="//subinsb.com/php-output-buffering">enable Output Buffering</a> to solve this problem.ย Or you should move all your logSys and redirection function calls at the top of the page before any output is made.</p> <h3 id="user-roles">User Roles</h3> <p>Setting User Roles is a feature asked by many. I have plans to implement it, but it will take time. If you want to do it manually, this is what I recommend :</p> <ul> <li>Add a column named &quot;role&quot; containing user access level in DB table</li> <li>In the page where you display stuff on your site, add checking if the user has the level to access the page or display information in it. Example :</li> </ul> <pre tabindex="0"><code>if($LS-&gt;getUser(&#34;role&#34;) == &#34;admin&#34;){ // Show Admin stuff }else if($LS-&gt;getUser(&#34;role&#34;) == &#34;editor&#34;){ // Show Editor Stuff }else if($LS-&gt;getUser(&#34;role&#34;) == &#34;contributor&#34;){ // Show Contributor Stuff } </code></pre><p>assuming that the user is logged in.</p> <h2 id="security">Security</h2> <p><a href="//subinsb.com/php-logsys#comment-1777655700">Chet</a> has said that including sensitive credentials in a <strong>PHP</strong> file is not secure. Iโ€™m agreeing with him. But, a possible way to make it secure is not to include malicious/untrusted scripts in your server. See <a href="http://security.stackexchange.com/questions/35492/is-it-possible-for-a-hacker-to-download-a-php-file-without-executing-it-first">this post</a> to see about how an attacker gets your configuration credentials such as databaseโ€™s.</p> <p><strong>file_get_contents()</strong> is a function that can be exploited by an attacker to retrieve sensitive information from a server. Here is a <a href="http://stackoverflow.com/a/3697776/1372424">list of the exploitable PHP functions</a>.</p> <p>If youโ€™re going to report a problem, tell the version of logSys using, explain the problem clearly and put in some example codes.</p> <p>This tutorial is completed. I will update logSys in the future if I can. After all, Iโ€™m a kid who is in 11th grade โ€“ a grade where studies should be taken seriously. Good Luck and I hope you found what you are looking for.</p> Global Warming, you here yet ? https://subinsb.com/global-warming-yet/ Wed, 07 May 2014 16:17:58 +0000 https://subinsb.com/global-warming-yet/ <p>We all have been hearing aboutย <strong>Global Warming</strong> and itโ€™s consequences. The studies tell us that the effects of it will soon be experienced by us. In my place (Kerala), I say itโ€™s already started. Millions of Trees are going down each day and people push out harmful Carbon compunds into the atmosphere without thinking. On a cruel world like this, I feel really sad.</p> <p>Kerala faces heavy summer and heavy monsoon. On summer days, rain is very often. But, now in the year 2014, it rains like monsoon in the middle of summer. Throughout Kerala, itโ€™s raining heavily. The cost of the damage is estimated to be 70 crore rupees and may increase more.</p> <p>In my 14 years of life, I have never seen a rain like this in the summer, that too in the middle. Climate change was one of the effect of Global Warming and now Iโ€™ve seen it. If this is what it;s going to be, then I wonder if the monsoon season will be the summer season (:O).</p> <p>The Western Ghats issue was all over India. The vast rain forests are getting destroyed and the Carbon compounds in the atmosphere could not be controlled. When the controlling vanishes, weโ€™re all dead.</p> <p>The modernization, the transition to a new industrial world will only destroy the nature. Either we take action now or we will extinct ourselves. In the coming years, we will all experience the effects of Global Warming and hopefully weโ€™ll see 2030 with a living heart.</p> <p>PS : I hate going to school on a rainy day</p> Create An Advanced Crawler In PHP https://subinsb.com/php-create-advanced-web-crawler/ Sun, 04 May 2014 17:06:47 +0000 https://subinsb.com/php-create-advanced-web-crawler/ <p>Crawlers are everywhere. They move on and on to many webpages each second. The most biggest of them are Googleโ€™s. It already crawled almost 90% of the web and is still crawling. If youโ€™re like me and want to create a more advanced crawler with options and features, this post will help you.</p> <div class="padlinks"> <a class="download" href="http://demos.subinsb.com/down.php?class=26" target="_blank">Download</a><a class="demo" href="http://demos.subinsb.com/php/advanced-crawler" target="_blank">Demo</a> </div> <p>When I created my Search Engine test project, it needed an awesome crawler. I knew that developing one on my own will be hard especially when you have to followย <strong>robots.txt</strong> and other rules. So, I googled and found this <a href="http://phpcrawl.cuab.de/" target="_blank">great library</a> which is 10 years old !</p> <p>I tested it and it was great. It had all the cool features. It followsย <strong>robots.txt</strong>, it acts like a browser when visiting sites. So, the site owner wonโ€™t know what visited just then.</p> <h2 id="download--install">Download &amp; Install</h2> <p>You first have to download the library from the <a href="http://sourceforge.net/projects/phpcrawl/files/PHPCrawl/" target="_blank">projectsโ€™ website</a>. The latest versions fromย <strong>0.82</strong> is recommended. After downloading, extract the main folderย <strong>PHPCrawl_{version_number}</strong> to your siteโ€™s source root. Rename this folder to &quot;PHPCrawl&quot;, so that when new version code are extracted, the folder name remains the same.</p> <p>Weโ€™ll use the files in this extracted folder to create our crawler.</p> <p>Hereโ€™s a Directory tree :</p> <pre class="prettyprint"><code>PHPCrawl ย  ย  ... Crawler Library Files Here index.php</code></pre> <p>We will make our crawler in theย <strong>index.php</strong> file.</p> <h2 id="customize-crawler">Customize Crawler</h2> <p>As I said before, weโ€™ll write the code for the crawler inย <strong>index.php</strong> file. You can type it on another file if you want.</p> <p>We include the crawler library file first inside PHP Tags :</p> <pre class="prettyprint"><code>&lt;? include("/PHPCrawl/libs/PHPCrawler.class.php");</code></pre> <p>Then, we extend theย <strong>PHPCrawl</strong> class as to suit our needs. By using this code, we replace the default function that is called when a document is loaded by the crawler :</p> <pre class="prettyprint"><code>class SBCrawler extends PHPCrawler { function handleDocumentInfo(PHPCrawlerDocumentInfo $p){ $pageurl= $p-&gt;url; $status = $p-&gt;http_status_code; $source = $p-&gt;source; if($status==200 && $source!=""){ // Page Successfully Got echo $pageurl."&lt;br/&gt;"; } } }</code></pre> <p>Note that in the above code, we check if the HTTP status code of the page is 200 which isย <strong>OK</strong> and if the source (page HTML code) is not null. If the conditions are met, then the URL then crawled is printed.</p> <p>If you want to manipulate or extract contents from the DOM, you can use PHP libraries likeย <strong>Simple HTML DOM</strong>. Here is an example of using Simple HTML DOM to get the contents of the &quot;<title>&quot; tag :</p> <pre class="prettyprint"><code>if($status == 200 && $source != ""){ // Page Successfully Got $html = str_get_html($source ); if(is_object($html)){ $t = $html-&gt;find("title", 0); if($t){ $title = $t-&gt;innertext; } echo $title." - ".$pageurl."&lt;br/&gt;"; $html-&gt;clear(); unset($html); } }</code></pre> <p>Note that, you have to include theย <strong>Simple HTML DOM</strong> library and you include the above code in the custom classย <strong>SBCrawler</strong> we created before.</p> <p>If you want to make customizations to the document info got from the crawler, see the full document info you can <a href="phpcrawl.cuab.de/classreferences/PHPCrawlerDocumentInfo/overview.html" target="_blank">get from it here</a>ย and itโ€™s recommended that you put the code inside the status code checking we did onย <strong>SBCrawler</strong> class.</p> <h2 id="create-crawler">Create Crawler</h2> <p>Now, we make the functionย <strong>crawl</strong> which creates the class object and set the options for crawling :</p> <pre class="prettyprint"><code>function crawl($u){ $C = new SBCrawler(); $C-&gt;setURL($u); $C-&gt;addContentTypeReceiveRule("#text/html#"); $C-&gt;addURLFilterRule("#(jpg|gif|png|pdf|jpeg|svg|css|js)$# i"); /* We don't want to crawl non HTML pages */ $C-&gt;setTrafficLimit(2000 * 1024); $C-&gt;obeyRobotsTxt(true); /* Should We follow robots.txt */ $C-&gt;go(); }</code></pre> <p>You can set <a href="http://phpcrawl.cuab.de/classreferences/PHPCrawler/overview.html" target="_blank">more options too</a>. Here are some of the main options that I think youโ€™ll need :</p> <table class="table"> <tr> <td> Code </td> <pre><code>&lt;td&gt; Description &lt;/td&gt; </code></pre> </tr> <tr> <td> $C-><a href="http://phpcrawl.cuab.de/classreferences/PHPCrawler/method_detail_tpl_method_obeyRobotsTxt.htm" target="_blank">obeyRobotsTxt</a>(true) </td> <pre><code>&lt;td&gt; Whether the crawler should obey the robots.txt file of domain &lt;/td&gt; </code></pre> </tr> <tr> <td> $C-><a href="http://phpcrawl.cuab.de/classreferences/PHPCrawler/method_detail_tpl_method_setFollowMode.htm" target="_blank">setFollowMod</a>e(2) </td> <pre><code>&lt;td&gt; The type of follow mode. Default 2 (crawls only URLs in the same domain). 0 for all domain URLs. &lt;/td&gt; </code></pre> </tr> <tr> <td> $C-><a href="http://phpcrawl.cuab.de/classreferences/PHPCrawler/method_detail_tpl_method_setPageLimit.htm" target="_blank">setPageLimit</a>(0) </td> <pre><code>&lt;td&gt; How many pages should the crawler crawl. Default 0 (no limit) &lt;/td&gt; </code></pre> </tr> <tr> <td> $C-><a href="http://phpcrawl.cuab.de/classreferences/PHPCrawler/method_detail_tpl_method_setUserAgentString.htm" target="_blank">setUserAgentString</a>("PHPCrawl") </td> <pre><code>&lt;td&gt; The User Agent String. Crawler visits site with this string so that the owner knows what visited. &lt;/td&gt; </code></pre> </tr> <tr> <td> $C-><a href="http://phpcrawl.cuab.de/classreferences/PHPCrawler/method_detail_tpl_method_enableCookieHandling.htm" target="_blank">enableCookieHandling</a>(true) </td> <pre><code>&lt;td&gt; Whether the crawler should acts like a browser (storing cookies). &lt;/td&gt; </code></pre> </tr> </table> <p>The possibilities are endless. As you can see, you can make many customizations of how the crawler should be and act like.</p> <h2 id="start-crawling">Start Crawling</h2> <p>Itโ€™s time to give a URL toย <strong>crawl()</strong> and start the crawling processes. Hereโ€™s how you start crawling the site &quot;http://subinsb.com&quot; :</p> <pre class="prettyprint"><code>crawl("http://subinsb.com");</code></pre> <p>Crawling process can be time consuming and donโ€™t worry that the script takes too much to load. If you want to display the results immediately after each crawl, useย <strong>flush()</strong> after theย <strong>echo</strong> inย <strong>SBCrawler</strong> class. Hereโ€™s a sample :</p> <pre class="prettyprint"><code>if($status == 200 && $source != ""){ // Page Successfully Got echo $pageurl."&lt;br/&gt;"; flush(); }</code></pre> <p>You can see the demo of this <strong>flush()</strong>ย <a href="http://demos.subinsb.com/php/advanced-crawler/" target="_blank">here</a>.</p> <p>PHPCrawl library will be updated in course of time and itโ€™s features will rise and rise in time. Hope you succeeded through this tutorial and had a great result. If you had a problem with something, feel free to comment and Iโ€™ll be here to help you out. ๐Ÿ˜€</p> Create a localhost Website in Ubuntu 11.04 & Up https://subinsb.com/ubuntu-linux-create-localhost-website/ Sun, 20 Apr 2014 03:45:14 +0000 https://subinsb.com/ubuntu-linux-create-localhost-website/ <p>In a post, I told <a title="How To Create A Localhost Web Site In Linux Using Apache Web Server" href="//subinsb.com/linux-apache-localhost" target="_blank">how to create a localhost website using Apache server in Ubuntu</a>. It worked on all versions up to Ubuntuโ€™sย <strong>10.10</strong>th version. But onย Ubuntu versions 11.04 and the versions released after it, there were some changes to theย <strong>Apache</strong> server.</p> <p>So, by this post Iโ€™m going to update the way to create a localhost hosted website in Ubuntu versionsย <strong>11.04</strong> and the versions that came afterย <strong>11.04</strong> orย <strong>2011 April</strong>. Some of them are :</p> <ul> <li>11.04</li> <li>11.10</li> <li>12.04</li> <li>12.10</li> <li>13.04</li> <li>13.10</li> <li>14.04</li> <li>14.10</li> </ul> <h2 id="install-apache-server">Install Apache Server</h2> <p>First of all, we will install the Apache server. Open the terminal (<strong>CTRL + ALT + T</strong>) and do the following command :</p> <pre class="prettyprint"><code>sudo apt-get install apache2</code></pre> <p>Sayย <strong>Yes</strong> when the program asks for confirmation. In a while, the packageย <strong>apache2</strong> will be downloaded and installed automatically. Folders and configuration files ofย <strong>Apache</strong> will automatically be created. To make sure thatย <strong>Apache</strong> has installed properly, visit <a href="http://localhost" target="_blank">the localhost website</a>.</p> <p>If installed properly and successfully, you will get a page like this :<figure id="attachment_2753" class="wp-caption aligncenter"></p> <p><a href="//lab.subinsb.com/projects/blog/uploads/2014/04/0118.png"><img class="size-full wp-image-2753" src="//lab.subinsb.com/projects/blog/uploads/2014/04/0118.png" alt="Apache localhost Default Page" width="771" height="233" /></a><figcaption class="wp-caption-text">Apache localhost Default Page</figcaption></figure></p> <p><strong>&quot;It works</strong>&quot;. What a feeling, right ? You just completed the first step successfully</p> <h2 id="create-a-site">Create a Site</h2> <p>Now letโ€™s create a site that is hosted by the <strong>Apache</strong> server we just installed on your computer which is a accessible only by you.</p> <p>For this tutorial, we are going to create a site called &quot;mysite&quot; which is accessible byย the domain &quot;mysite.com&quot;.</p> <p>The Siteโ€™s configuration file is stored in the following directory :</p> <pre class="prettyprint"><code>/etc/apache2/sites-available</code></pre> <p>As you can see, you needย <strong>Root Access</strong> for making changes in the directory. So, open the terminal and do this command :</p> <pre class="prettyprint"><code>sudo -i</code></pre> <p>You will be asked for the root password. Type it and press Enter (The password wonโ€™t be showed at all in Terminal while you type). You will now enter the root shell.</p> <p>Now, letโ€™s create the configuration file of the site &quot;mysite&quot; we are going to create. As I said before, the siteโ€™s configuration file should be kept in &quot;sites-available&quot; directory.</p> <p>On the root shell, do this command to create an empty file in &quot;sites-available&quot; directory :</p> <pre class="prettyprint"><code>touch /etc/apache2/sites-available/mysite.conf</code></pre> <p>Now, letโ€™s add some text to the file we created. Usingย <strong>gEdit</strong> or other text editors, edit the file we created using root :</p> <pre class="prettyprint"><code>geditย /etc/apache2/sites-available/mysite.conf</code></pre> <p>Using the text editorย <strong>leafpad</strong>, we edit the file with the following command :</p> <pre class="prettyprint"><code>leafpadย /etc/apache2/sites-available/mysite.conf</code></pre> <p>Whatever the text editor is, the contents of the file will be the same. Here is the content that you should copy &amp; paste to the file :</p> <pre class="prettyprint"><code>&lt;VirtualHost *:80&gt; ServerAdmin webmaster@localhost ServerName &lt;span style="color: #ff0000;">mysite.com&lt;/span> DocumentRoot &lt;span style="color: #ff0000;">/home/username/websites/mysite&lt;/span> &lt;Directory &lt;span style="color: #ff0000;">/home/username/websites/mysite&lt;/span>/&gt; Options Indexes FollowSymLinks AllowOverride All Order allow,deny allow from all Require all granted &lt;/Directory&gt; ErrorLog /var/log/apache2/error.log LogLevel warn CustomLog /var/log/apache2/access.log combined &lt;/VirtualHost&gt;</code></pre> <p>The highlighted text of color <span style="color: #ff0000;">red</span> should be changed according to you. Here is a summary of the changes that should be done in the file :</p> <table style="height: 133px;" width="821"> <tr> <td> String </td> <pre><code>&lt;td&gt; Description &lt;/td&gt; </code></pre> </tr> <tr> <td> <span style="color: #ff0000;">mysite.com</span> </td> <pre><code>&lt;td&gt; The site&amp;#8217;s domain &lt;/td&gt; </code></pre> </tr> <tr> <td> <span style="color: #ff0000;">/home/username/websites/mysite</span> </td> <pre><code>&lt;td&gt; The location of site&amp;#8217;s source code &lt;/td&gt; </code></pre> </tr> <tr> <td> /var/log/apache2/error.log </td> <pre><code>&lt;td&gt; Change this if you need a special error log file for your site &lt;/td&gt; </code></pre> </tr> <tr> <td> /var/log/apache2/access.log </td> <pre><code>&lt;td&gt; Change this if you need a special access log file for your site &lt;/td&gt; </code></pre> </tr> </table> <p>The red highlighted text in the table above is the most important strings. It should be changed by you or not if you want the siteโ€™s domain as &quot;mysite.com&quot;.</p> <p>If you changed the location of the log files, make sure that the location exists. If itโ€™s to a new directory, you should create the new directory. The &quot;access.log&quot; and &quot;error.log&quot; file will be automatically created byย <strong>Apache</strong> even if it doesnโ€™t exist. Save the configuration file and close the text editor.</p> <p>Now, we should enable the site. Do the following command in root shell :</p> <pre class="prettyprint"><code>a2ensite &lt;span style="color: #ff0000;">mysite.conf&lt;/span></code></pre> <p>The red highlighted text above is the name of the file we created in the &quot;sites-available&quot; directory. If you chose a different name, change it when you enter the command in Terminal.</p> <p>A restart of theย <strong>Apache</strong> server is needed after enabling the site. So, do this command :</p> <pre class="prettyprint"><code>/etc/init.d/apache2 restart</code></pre> <p>or do the following command :</p> <pre class="prettyprint"><code>service apache2 restart</code></pre> <p>The site is created in localhost. But, still when you visit &quot;mysite.com&quot;, the browser will go to the original &quot;mysite.com&quot; that is in the web. Browser or the network of your system doesnโ€™t know that there is a &quot;mysite.com&quot; hosted in localhost. So, we should make it understand. For this, on the root shell do this command to edit the &quot;hosts&quot; file :</p> <pre class="prettyprint"><code>gedit /etc/hosts</code></pre> <p>At the end of the file, add the following line :</p> <pre class="prettyprint"><code>127.0.0.1 mysite.com</code></pre> <p>&quot;127.0.0.1&quot; is the IP Address of localhost and the other string we typed aside it is the domain name. Save the file and close the terminal.</p> <p>Now, open a browser and go to the site &quot;<a href="http://mysite.com" target="_blank"><a href="http://mysite.com">http://mysite.com</a></a>&quot; and you will see your own localhost site. You can add the siteโ€™s files to the directory you mentioned in the configuration file we created.ย <strong>index.html</strong> will be the main file of the site. This main file will be shown when the site is directly visited (<a href="http://mysite.com">http://mysite.com</a>).</p> <p>Happy coding. ๐Ÿ™‚</p> Identify Remote OS By IP Address In PHP https://subinsb.com/php-identify-remote-os/ Tue, 15 Apr 2014 14:32:34 +0000 https://subinsb.com/php-identify-remote-os/ <p>In the <a title="Default TTL (Time To Live) Values of Different OS" href="//subinsb.com/default-device-ttl-values" target="_blank">recent post</a>, I gave the default TTL value of different devices. As you can see, when you ping a host you can roughly identify the operating system the remote serverโ€™s running. I saw a question on Stack Overflow about this. Sadly it was down voted and was removed later. I tested if it is possible and I found that it is possible.</p> <p>In this post, I will give a function that automatically pings the remote host and find out the possible Operating Systems the remote server is running. For this, we have aย **JSONย **file that contains the TTL of different devices / OSs.</p> <div class="padlinks"> <a class="demo" href="http://demos.subinsb.com/php/identify-remote-os" target="_blank">Demo</a> </div> <p>Note that the remote server with theย <strong>IP Address</strong> should be online the time the checking is done. Otherwise pinging the host will fail.</p> <h2 id="get-json-data">Get JSON Data</h2> <p>I made the JSON file and is available at <a href="http://demos.subinsb.com/php/identify-remote-os/ttlValues.txt" target="_blank">this URL</a>. This JSON file is needed for the identification of the device. Here is how an item in the JSON file looks like :</p> <pre class="prettyprint"><code>{ "device" : "Linux", "version" : "2.0.x kernel", "protocol" : "ICMP", "ttl" : "64" }</code></pre> <p>It contains theย <strong>TTL</strong> value, the device name and its version. Also the protocol which is not needed necessarily.</p> <h2 id="detectosip">detectOs($ip)</h2> <p>Now, letโ€™s get to the function that identifies the OS. Itโ€™s an easy function that needs the following :</p> <ul> <li>IP Address</li> <li>JSON file with the name &quot;ttlValues.txt&quot; on the same directory as the file containing the function</li> <li>shell_exec function to execute (PHP Safe Mode should be Off)</li> </ul> <p>We use theย <strong>ping</strong> command to ping the remote IP address and get the TTL. This is the function code :</p> <pre class="prettyprint"><code>function detectOs($ip, $returnArray=true){ if(filter_var($ip, FILTER_VALIDATE_IP)){ $cmd="ping -c 2 $ip"; $shell=shell_exec($cmd); preg_match("/ttl=(.*?)stime/", $shell, $m); if(isset($m[1])){ $ttl=$m[1]; $list=file_get_contents("./ttlValues.txt"); $list=json_decode($list, true); $oses=array(); if($ttl==64){$oses[]="Mostly A *nix Device (Linux, Unix etc..)";} if($ttl==128){$oses[]="Mostly A Windows Device";} if($ttl==254){$oses[]="Mostly A Solaris/AIX Device";} foreach($list as $vals) { if($vals['ttl']==$ttl){ $oses[]=$vals['device']." ".$vals['version']; } } return $returnArray===true ? $oses:implode(",", $oses); }else{ return "connectionFailed"; } }else{ return "invalidIP"; } }</code></pre> <p>You can change the location of the JSON file by replacing the file pathย &quot;./ttlValues.txt&quot;. The function will return either one of the following :</p> <table class="table"> <tr> <td> invalidIP </td> <pre><code>&lt;td&gt; If the IP address given is not valid &lt;/td&gt; </code></pre> </tr> <tr> <td> connectionFailed </td> <pre><code>&lt;td&gt; If the pinging failed or TTL value wasn&amp;#8217;t accessbile &lt;/td&gt; </code></pre> </tr> </table> <p>If either one of the following didnโ€™t return, then the return value is an array. You have the option to decide whether the return output should be an array or a string of possible devices separated by &quot;,&quot;.</p> <p>Also, if the hops between the connection of your machine and the remote server is too much, itโ€™s better to widen the search by, replacing the following code in the function</p> <pre class="prettyprint"><code>if($vals['ttl']==$ttl)</code></pre> <p>to :</p> <pre class="prettyprint"><code>if($vals['ttl']&lt;=$ttl)</code></pre> <h2 id="usage">Usage</h2> <pre class="prettyprint"><code>$os=detectOs("127.0.0.1"); // Localhost OS, please if($os=="invalidIP"){ echo "Invalid IP address"; }elseif($os=="connectionFailed"){ echo "Unable to connect to external server"; }else{ echo "&lt;br/&gt;The Operating System Can Be one of the following : &lt;ul&gt;"; foreach($os as $v){ echo "&lt;li&gt;$v&lt;/li&gt;"; } echo "&lt;/ul&gt;"; }</code></pre> <p>The above code checks all the return values of the function and finally output the array of possible devices.</p> <p>You can also output string instead of array :</p> <pre class="prettyprint"><code>echo detectOs("127.0.0.1", false);</code></pre> <p>The above sample code will output something like this :</p> <pre class="prettyprint"><code>Linuxย 2.2.14 kernel,MacOS/MacTCP 2.0.x,NetBSD</code></pre> <p>Simple usage, right ? Well, use it for your own various purposes.</p> Default TTL (Time To Live) Values of Different OS https://subinsb.com/default-device-ttl-values/ Mon, 14 Apr 2014 14:48:37 +0000 https://subinsb.com/default-device-ttl-values/ <p>TTL (Time To Live) is a timer value included in packets sent over networks that tells the recipient how long to hold or use the packet before discarding and expiring the data (packet). TTL values are different for different Operating Systems. So, you can determine the OS based on the TTL value. You can get the TTL value by pinging an address. Here is the output got by pinging &quot;subinsb.com&quot; on my system :</p> <pre class="prettyprint"><code>PING subinsb.com (108.162.199.61) 56(84) bytes of data. 64 bytes from 108.162.199.61: icmp_seq=1 ttl=57 time=503 ms 64 bytes from 108.162.199.61: icmp_seq=2 ttl=57 time=416 ms</code></pre> <p>As you can see from the output, you got theย <strong>TTL</strong> value. Since this website is hosted on a Red Hat system, it returned 57 which is close to 64 (TTL default value of Linux system). So, from this we can understand the OS of the remote system. Here are the default <strong>TTL</strong>ย values of different devices / Operating Systems :</p> <table class="table"> <tr> <td> Device / OS </td> <td> Version </td> <td> Protocol </td> <td> TTL </td> </tr> <tr> <td> AIX </td> <td> </td> <td> TCP </td> <td> 60 </td> </tr> <tr> <td> AIX </td> <td> </td> <td> UDP </td> <td> 30 </td> </tr> <tr> <td> AIX </td> <td> 3.2, 4.1 </td> <td> ICMP </td> <td> 255 </td> </tr> <tr> <td> BSDI </td> <td> BSD/OS 3.1 and 4.0 </td> <td> ICMP </td> <td> 255 </td> </tr> <tr> <td> Compa </td> <td> Tru64 v5.0 </td> <td> ICMP </td> <td> 64 </td> </tr> <tr> <td> Cisco </td> <td> </td> <td> ICMP </td> <td> 254 </td> </tr> <tr> <td> DEC Pathworks </td> <td> V5 </td> <td> TCP and UDP </td> <td> 30 </td> </tr> <tr> <td> Foundry </td> <td> </td> <td> ICMP </td> <td> 64 </td> </tr> <tr> <td> FreeBSD </td> <td> 2.1R </td> <td> TCP and UDP </td> <td> 64 </td> </tr> <tr> <td> FreeBSD </td> <td> 3.4, 4.0 </td> <td> ICMP </td> <td> 255 </td> </tr> <tr> <td> FreeBSD </td> <td> 5 </td> <td> ICMP </td> <td> 64 </td> </tr> <tr> <td> HP-UX </td> <td> 9.0x </td> <td> TCP and UDP </td> <td> 30 </td> </tr> <tr> <td> HP-UX </td> <td> 10.01 </td> <td> TCP and UDP </td> <td> 64 </td> </tr> <tr> <td> HP-UX </td> <td> 10.2 </td> <td> ICMP </td> <td> 255 </td> </tr> <tr> <td> HP-UX </td> <td> 11 </td> <td> ICMP </td> <td> 255 </td> </tr> <tr> <td> HP-UX </td> <td> 11 </td> <td> TCP </td> <td> 64 </td> </tr> <tr> <td> Irix </td> <td> 5.3 </td> <td> TCP and UDP </td> <td> 60 </td> </tr> <tr> <td> Irix </td> <td> 6.x </td> <td> TCP and UDP </td> <td> 60 </td> </tr> <tr> <td> Irix </td> <td> 6.5.3, 6.5.8 </td> <td> ICMP </td> <td> 255 </td> </tr> <tr> <td> juniper </td> <td> </td> <td> ICMP </td> <td> 64 </td> </tr> <tr> <td> MPE/IX (HP) </td> <td> </td> <td> ICMP </td> <td> 200 </td> </tr> <tr> <td> Linux </td> <td> 2.0.x kernel </td> <td> ICMP </td> <td> 64 </td> </tr> <tr> <td> Linux </td> <td> 2.2.14 kernel </td> <td> ICMP </td> <td> 255 </td> </tr> <tr> <td> Linux </td> <td> 2.4 kernel </td> <td> ICMP </td> <td> 255 </td> </tr> <tr> <td> Linux </td> <td> Red Hat 9 </td> <td> ICMP and TCP </td> <td> 64 </td> </tr> <tr> <td> MacOS/MacTCP </td> <td> 2.0.x </td> <td> TCP and UDP </td> <td> 60 </td> </tr> <tr> <td> MacOS/MacTCP </td> <td> X (10.5.6) </td> <td> ICMP/TCP/UDP </td> <td> 64 </td> </tr> <tr> <td> NetBSD </td> <td> </td> <td> ICMP </td> <td> 255 </td> </tr> <tr> <td> Netgear FVG318 </td> <td> </td> <td> ICMP and UDP </td> <td> 64 </td> </tr> <tr> <td> OpenBSD </td> <td> 2.6 & 2.7 </td> <td> ICMP </td> <td> 255 </td> </tr> <tr> <td> OpenVMS </td> <td> 07.01.2002 </td> <td> ICMP </td> <td> 255 </td> </tr> <tr> <td> OS/2 </td> <td> TCP/IP 3.0 </td> <td> </td> <td> 64 </td> </tr> <tr> <td> OSF/1 </td> <td> V3.2A </td> <td> TCP </td> <td> 60 </td> </tr> <tr> <td> OSF/1 </td> <td> V3.2A </td> <td> UDP </td> <td> 30 </td> </tr> <tr> <td> Solaris </td> <td> 2.5.1, 2.6, 2.7, 2.8 </td> <td> ICMP </td> <td> 255 </td> </tr> <tr> <td> Solaris </td> <td> 2.8 </td> <td> TCP </td> <td> 64 </td> </tr> <tr> <td> Stratus </td> <td> TCP_OS </td> <td> ICMP </td> <td> 255 </td> </tr> <tr> <td> Stratus </td> <td> TCP_OS (14.2-) </td> <td> TCP and UDP </td> <td> 30 </td> </tr> <tr> <td> Stratus </td> <td> TCP_OS (14.3+) </td> <td> TCP and UDP </td> <td> 64 </td> </tr> <tr> <td> Stratus </td> <td> STCP </td> <td> ICMP/TCP/UDP </td> <td> 60 </td> </tr> <tr> <td> SunOS </td> <td> 4.1.3/4.1.4 </td> <td> TCP and UDP </td> <td> 60 </td> </tr> <tr> <td> SunOS </td> <td> 5.7 </td> <td> ICMP and TCP </td> <td> 255 </td> </tr> <tr> <td> Ultrix </td> <td> V4.1/V4.2A </td> <td> TCP </td> <td> 60 </td> </tr> <tr> <td> Ultrix </td> <td> V4.1/V4.2A </td> <td> UDP </td> <td> 30 </td> </tr> <tr> <td> Ultrix </td> <td> V4.2 โ€“ 4.5 </td> <td> ICMP </td> <td> 255 </td> </tr> <tr> <td> VMS/Multinet </td> <td> </td> <td> TCP and UDP </td> <td> 64 </td> </tr> <tr> <td> VMS/TCPware </td> <td> </td> <td> TCP </td> <td> 60 </td> </tr> <tr> <td> VMS/TCPware </td> <td> </td> <td> UDP </td> <td> 64 </td> </tr> <tr> <td> VMS/Wollongong </td> <td> 1.1.1.1 </td> <td> TCP </td> <td> 128 </td> </tr> <tr> <td> VMS/Wollongong </td> <td> 1.1.1.1 </td> <td> UDP </td> <td> 30 </td> </tr> <tr> <td> VMS/UCX </td> <td> </td> <td> TCP and UDP </td> <td> 128 </td> </tr> <tr> <td> Windows </td> <td> for Workgroups </td> <td> TCP and UDP </td> <td> 32 </td> </tr> <tr> <td> Windows </td> <td> 95 </td> <td> TCP and UDP </td> <td> 32 </td> </tr> <tr> <td> Windows </td> <td> 98 </td> <td> ICMP </td> <td> 32 </td> </tr> <tr> <td> Windows </td> <td> 98, 98 SE </td> <td> ICMP </td> <td> 128 </td> </tr> <tr> <td> Windows </td> <td> 98 </td> <td> TCP </td> <td> 128 </td> </tr> <tr> <td> Windows </td> <td> NT 3.51 </td> <td> TCP and UDP </td> <td> 32 </td> </tr> <tr> <td> Windows </td> <td> NT 4.0 </td> <td> TCP and UDP </td> <td> 128 </td> </tr> <tr> <td> Windows </td> <td> NT 4.0 SP5- </td> <td> </td> <td> 32 </td> </tr> <tr> <td> Windows </td> <td> NT 4.0 SP6+ </td> <td> </td> <td> 128 </td> </tr> <tr> <td> Windows </td> <td> NT 4 WRKS SP 3, SP 6a </td> <td> ICMP </td> <td> 128 </td> </tr> <tr> <td> Windows </td> <td> NT 4 Server SP4 </td> <td> ICMP </td> <td> 128 </td> </tr> <tr> <td> Windows </td> <td> ME </td> <td> ICMP </td> <td> 128 </td> </tr> <tr> <td> Windows </td> <td> 2000 pro </td> <td> ICMP/TCP/UDP </td> <td> 128 </td> </tr> <tr> <td> Windows </td> <td> 2000 family </td> <td> ICMP </td> <td> 128 </td> </tr> <tr> <td> Windows </td> <td> Server 2003 </td> <td> </td> <td> 128 </td> </tr> <tr> <td> Windows </td> <td> XP </td> <td> ICMP/TCP/UDP </td> <td> 128 </td> </tr> <tr> <td> Windows </td> <td> Vista </td> <td> ICMP/TCP/UDP </td> <td> 128 </td> </tr> <tr> <td> Windows </td> <td> 7 </td> <td> ICMP/TCP/UDP </td> <td> 128 </td> </tr> <tr> <td> Windows </td> <td> Server 2008 </td> <td> ICMP/TCP/UDP </td> <td> 128 </td> </tr> <tr> <td> Windows </td> <td> 10 </td> <td> ICMP/TCP/UDP </td> <td> 128 </td> </tr> </table> <p>I will update this table in the future when thereโ€™s a release of new important OS whenever I get the time. You can get the short version of defaultย <strong>TTL</strong> values by this table :</p> <table class="table"> <tr> <td> Device / OS </td> <td> TTL </td> </tr> <tr> <td> *nix (Linux/Unix) </td> <td> 64 </td> </tr> <tr> <td> Windows </td> <td> 128 </td> </tr> <tr> <td> Solaris/AIX </td> <td> 254 </td> </tr> </table> <p>You can find it yourself by pinging localhost as mentioned byย <span class="author publisher-anchor-color"><a href="http://disq.us/p/1er4k1l" data-action="profile" data-username="gbhackers" data-role="username">Gurubaran</a></span>ย :</p> <pre class="prettyprint"><code>ping -4 localhost</code></pre> Create SVG Images In Inkscape Without Transforms https://subinsb.com/svg-in-inkscape-without-transform/ Mon, 14 Apr 2014 06:21:12 +0000 https://subinsb.com/svg-in-inkscape-without-transform/ <p><a href="http://inkscape.org" target="_blank">Inkscape</a> is a beautiful Open Source Image editing software. It can be used to create PNG images, JPG images and even SVG images. But, when you export an SVG image, it will have some kind of transform style in it such as translate. This will make the SVG image code so long. To make it short, itโ€™s better to remove the transform on the image and save it as it should be.</p> <p>But, Inkscape doesnโ€™t provide a option on the save dialog for this. You have to do it on your own. In this post, Iโ€™ll tell you the manual way to remove the transform on SVG images created using Inkscape.</p> <p>This the SVG image code where w are going to remove the transform property :</p> <pre class="prettyprint"><code>&lt;?xml version="1.0" encoding="UTF-8" standalone="no"?&gt; &lt;!-- Created with Inkscape (http://www.inkscape.org/) --&gt; &lt;svg height="48px" width="48px" style="background:black;"&gt; &lt;g id="layer1" transform="translate(7,17.428571)"&gt; &lt;path style="stroke-linejoin:miter;stroke:#000;stroke-linecap:butt;stroke-width:1px;fill:#ffffff;" d="m15.571,7.2857c0.86668,0.25785,0.08001,1.2955-0.42857,1.4405-1.3782,0.39293-2.4292-1.0759-2.4524-2.2976-0.0415-2.1854,2.1429-3.6267,4.1667-3.4643,2.97,0.23833,4.8481,3.2202,4.4762,6.0357-0.495,3.753-4.3,6.079-7.904,5.488-4.5359-0.744-7.3153-5.3823-6.5004-9.7737,0.98692-5.3186,6.4649-8.5534,11.643-7.5119,6.1021,1.2273,9.7936,7.5478,8.5238,13.512-1.467,6.886-8.632,11.035-15.382,9.536-7.6693-1.704-12.277-9.715-10.547-17.25,1.9402-8.4536,10.798-13.52,19.119-11.56,9.2377,2.1763,14.763,11.882,12.571,20.988" /&gt; &lt;/g&gt; &lt;/svg&gt;</code></pre> <p>As you can see there is a transform property on the &quot;g&quot; tag of the image. Here is how the image look like :</p> <center> <svg height="48px" width="48px" style="background:black;"><g id="layer1" transform="translate(7,17.428571)"><path style="stroke-linejoin:miter;stroke:#000;stroke-linecap:butt;stroke-width:1px;fill:#ffffff;" d="m15.571,7.2857c0.86668,0.25785,0.08001,1.2955-0.42857,1.4405-1.3782,0.39293-2.4292-1.0759-2.4524-2.2976-0.0415-2.1854,2.1429-3.6267,4.1667-3.4643,2.97,0.23833,4.8481,3.2202,4.4762,6.0357-0.495,3.753-4.3,6.079-7.904,5.488-4.5359-0.744-7.3153-5.3823-6.5004-9.7737,0.98692-5.3186,6.4649-8.5534,11.643-7.5119,6.1021,1.2273,9.7936,7.5478,8.5238,13.512-1.467,6.886-8.632,11.035-15.382,9.536-7.6693-1.704-12.277-9.715-10.547-17.25,1.9402-8.4536,10.798-13.52,19.119-11.56,9.2377,2.1763,14.763,11.882,12.571,20.988" /></g></svg> </center>Now, we&#8217;re going to remove the transform property on the image without any changes to the image. <p>Open the image in Inkscape. Chooseย <strong>XML Editor</strong> fromย <strong>Edit</strong> menu. The SVG code will be opened in a dialog box :</p> <p><a href="//lab.subinsb.com/projects/blog/uploads/2014/04/0116.png"><img class="aligncenter size-full wp-image-2736" alt="0116" src="//lab.subinsb.com/projects/blog/uploads/2014/04/0116.png" width="646" height="418" /></a></p> <p>You can see the nodes of the SVG image in the tree. You can also see the transfrom property of the &quot;g&quot; tag on right side window when you click the node. Our goal is to remove this transfrom attribute of the image.</p> <p>For this, click on theย <strong>&lt;svg:path</strong> inside theย <strong>#layer1</strong>ย SVG tag. Click and drag it upwards and drop it above the parent (ย **&lt;svg:g id=&quot;layer1โ€ณย **). Now the node tree will look like this :<figure id="attachment_2737" class="wp-caption aligncenter"></p> <p><a href="//lab.subinsb.com/projects/blog/uploads/2014/04/0117.png"><img class="size-full wp-image-2737" alt="Inkscape XML Editor" src="//lab.subinsb.com/projects/blog/uploads/2014/04/0117.png" width="647" height="419" /></a><figcaption class="wp-caption-text">Inkscape XML Editor when path became the parent of g.</figcaption></figure></p> <p>Since, the node which had the <strong>transform</strong> attribute was removed as the parent of theย <strong>path</strong> tag, theย <strong>transform</strong>ย styles wonโ€™t be applied to theย <strong>path</strong> anymore. So, the image will be on a different position than before. Like this :</p> <center> <svg height="48px" width="48px" style="background:black;"><path style="stroke-linejoin:miter;stroke:#000;stroke-linecap:butt;stroke-width:1px;fill:#ffffff;" d="m15.571,7.2857c0.86668,0.25785,0.08001,1.2955-0.42857,1.4405-1.3782,0.39293-2.4292-1.0759-2.4524-2.2976-0.0415-2.1854,2.1429-3.6267,4.1667-3.4643,2.97,0.23833,4.8481,3.2202,4.4762,6.0357-0.495,3.753-4.3,6.079-7.904,5.488-4.5359-0.744-7.3153-5.3823-6.5004-9.7737,0.98692-5.3186,6.4649-8.5534,11.643-7.5119,6.1021,1.2273,9.7936,7.5478,8.5238,13.512-1.467,6.886-8.632,11.035-15.382,9.536-7.6693-1.704-12.277-9.715-10.547-17.25,1.9402-8.4536,10.798-13.52,19.119-11.56,9.2377,2.1763,14.763,11.882,12.571,20.988" id="path3081"/></svg> </center>You can now align the image back to it&#8217;s original position using the mouse and save it. The image code won&#8217;t have any moreย  <p><strong>transfrom</strong> attributes. Like this :</p> <center> <svg height="48px" width="48px" style="background:black;"><path style="fill:#ffffff;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter" d="m 21.882419,25.389506 c 0.86668,0.25785 0.08001,1.2955 -0.42857,1.4405 -1.3782,0.39293 -2.4292,-1.0759 -2.4524,-2.2976 -0.0415,-2.1854 2.1429,-3.6267 4.1667,-3.4643 2.97,0.23833 4.8481,3.2202 4.4762,6.0357 -0.495,3.753 -4.3,6.079 -7.904,5.488 -4.5359,-0.744 -7.3153,-5.3823 -6.5004,-9.7737 0.98692,-5.3186 6.4649,-8.5534 11.643,-7.5119 6.1021,1.2273 9.7936,7.5478 8.5238,13.512 -1.467,6.886 -8.632,11.035 -15.382,9.536 -7.6693,-1.704 -12.2770003,-9.715 -10.5470003,-17.25 1.9402,-8.4536 10.7980003,-13.5199998 19.1190003,-11.5599998 9.2377,2.1762998 14.763,11.8819998 12.571,20.9879998" id="path3081"/></svg> </center> Delete Items From JSON or Remove Variables in JavaScript https://subinsb.com/js-remove-item-from-json-array-variables/ Sun, 13 Apr 2014 06:20:13 +0000 https://subinsb.com/js-remove-item-from-json-array-variables/ <p>Inย <strong>PHP</strong>, you can directly remove an item from an array usingย <strong>unset</strong> function. But there is noย <strong>unset</strong> function inย JavaScript. But there is another function that will remove a variable. Itโ€™s calledย <strong>delete</strong>. Removing variables isnโ€™t the only thing it does. It can also remove items from aย <strong>JSON</strong> array inย <strong>JavaScript</strong>.</p> <p>Itโ€™s usage is simple. Just pass the array variable with the name of the key. Like this :</p> <pre class="prettyprint"><code>delete arr[keyname];</code></pre> <h2 id="examples">Examples</h2> <p>This is the array weโ€™ll use for examples :</p> <pre class="prettyprint"><code>var arr = { ย "Gohan" : "Yipee", ย "Vegeta" : "Goku" }</code></pre> <p>We first delete the key &quot;Gohan&quot; :</p> <pre class="prettyprint"><code>delete arr["Gohan"];</code></pre> <p>Now, when you output the arrayย <strong>arr</strong>, you will not see the key &quot;Gohan&quot; with the value &quot;Yipee&quot;. Hereโ€™s how the array will become after the above code is executed :</p> <pre class="prettyprint"><code>{ "Vegeta" : "Goku" }</code></pre> <p>Easy as that. You can also useย <strong>delete</strong> for removing variables and functions. But you canโ€™t remove the variable &quot;window&quot;. Example :</p> <pre class="prettyprint"><code>var uid = "abc"; delete uid;</code></pre> <p>Now when you access the variable &quot;uid&quot;, you will get the &quot;undefined&quot; error :</p> <pre class="prettyprint"><code>console.log(uid); //ย ReferenceError: uid is not defined</code></pre> <p><strong>delete</strong> returnsย &quot;true&quot; when the deleting was successful and &quot;false&quot; when not successful. You will get &quot;false&quot; when you try to delete variables likeย <strong>window</strong>.</p> Add Spell Check With PHP Using Google https://subinsb.com/add-spell-check-using-google/ Fri, 11 Apr 2014 14:22:05 +0000 https://subinsb.com/add-spell-check-using-google/ <p>If you google something that has spelling mistakes, Google will automatically correct it for you or if the bot isnโ€™t sure, it will give theย <strong>Did You Mean ?</strong> clause. If youโ€™re developing a search engine for your site, this spell check will come in handy. If the user had made a mistake and he was shown a &quot;No Results Found&quot; page, user will be annoyed. So, itโ€™s better to have a spell check for your site.</p> <p>Google until 2013 had the Spell Check service available to all developers by accessing a URL. Sadly, they discontinued and we were forced to look up on other methods. Bing supports Spell check and Yahoo too. But itโ€™s not as good &amp; perfect as Google.</p> <p>Google Translate also has theย <strong>Did You Mean</strong> functionality. So, I looked at the AJAX request and response and got the URL for getting the suggestions. Itโ€™s simple, weโ€™ll send the request with the word to get suggestions. If there is one, we will display it as &quot;Did you mean {word} ?&quot;. Weโ€™ll use <strong>cURL</strong> andย <strong>RegEx</strong> for accomplishing our task.</p> <div class="padlinks"> <a class="demo" href="http://demos.subinsb.com/Francium/SpellCheck/" target="_blank">Demo</a><a class="download" href="https://github.com/subins2000/francium-spellcheck/archive/master.zip" target="_blank">Download</a> </div> <p>Note that this trick or &quot;hack&quot; is not publicly made available by Google and Iโ€™m not responsible for the actions you make with this trick and thank you Google for your awesome products and requests like this.</p> <p>Here is the function that weโ€™ll use to check with Google about the word and what the Google Dictionary Bot thinks. If there isnโ€™t any thing itโ€™ll return <strong>null</strong> and if there is, itโ€™ll return the word as corrected by Google.</p> <p>Itโ€™s very necessary that your web server supportsย <strong>cURL</strong>.</p> <h1 id="update">UPDATE</h1> <p>Spell Check is now under <a href="//subinsb.com/the-francium-project">The Francium Project</a> and it has become a static class.</p> <h1 id="usage">Usage</h1> <p>The usage of the functionย <strong>\Fr\SC::check()</strong> is very easy, you just pass the word to it and it will return the corrected word. It wonโ€™t return anything ย if the word you gave is of more than the lengthย <strong>49</strong>. So thatโ€™s the limit.</p> <p>In this example, I give the wrong word &quot;googel&quot; and it will output &quot;google&quot;.</p> <pre class="prettyprint"><code>$word = \Fr\SC::check("googel"); if($word == null){ echo "No Suggestion"; }else{ echo "Corrected Word - " . $word; }</code></pre> <p>Here, I give a sentence of exactlyย the lengthย <strong>49</strong> to the function and itโ€™ll give the corrected output :</p> <pre class="prettyprint"><code>$word = \Fr\SC::check("soemthign's wrnog. If there's omething wqrong wit"); if($word == null){ echo "No Suggestion"; }else{ echo "Corrected Word - " . $word; }</code></pre> <p>Ainโ€™t that cool ? It is very strongly recommended that you include this trick on your search engine, because it will increase page visits and userโ€™s experienceย with your site.</p> Create a Search Engine In PHP, MySQL | Part 3 https://subinsb.com/search-engine-in-php-part-3/ Thu, 10 Apr 2014 05:41:35 +0000 https://subinsb.com/search-engine-in-php-part-3/ <p>This is the Part 3 of &quot;How To Create A Search Engine In PHP&quot;. In this part, We make additional adjustments and make the search engine more awesome and cool.</p> <div class="padlinks"> <a class="download" href="https://github.com/subins2000/search/archive/master.zip" target="_blank">Download</a><a class="demo" href="http://search.subinsb.com" target="_blank">Demo</a> </div> <h2 id="bot-page">Bot Page</h2> <p>Our crawler leaves a mark on every pages it visit. In other words a custom User Agent String goes with each requests to web pages. In the previous part, we set the user agent string as :</p> <pre class="prettyprint"><code>DingoBot (http://search.subinsb.com/about/bot.php)</code></pre> <p>We add a URL with it, because if the site owner sees this in their stats, they would think &quot;whatโ€™s that ?&quot;. So, to answer that question we add our bot info link. Also to promote our site.</p> <p>The site owner can put this in to theirย <strong>robots.txt</strong> file to block a certain page for theย <strong>Dingo!</strong> crawler :</p> <pre class="prettyprint"><code>User-agent: DingoBot Disallow: /dontgohere/</code></pre> <p>So, what Iโ€™m saying is that you should add a &quot;Bot Info&quot; page.</p> <h2 id="stats">Stats</h2> <p>Whatโ€™s more great than showcasing the crawlerโ€™s job ? Hereโ€™s the stat page of Web Search :</p> <pre class="prettyprint"><code>&lt;?include("../inc/functions.php");?&gt; &lt;html&gt; &lt;head&gt; &lt;?head("Stats");?&gt; &lt;/head&gt; &lt;body&gt; &lt;?headerElem();?&gt; &lt;div class="container" style="width:100px;"&gt; &lt;h2&gt;Stats&lt;/h2&gt; &lt;p&gt;See information about the crawled URLs by DingoBot.&lt;/p&gt; &lt;h3&gt;Total URLs Crawled&lt;/h3&gt; &lt;strong&gt; &lt;? $sql=$dbh-&gt;query("SELECT COUNT(id) FROM `search`"); echo $sql-&gt;fetchColumn(); ?&gt; &lt;/strong&gt; &lt;h3&gt;Last Crawled URLs&lt;/h3&gt; &lt;ul style="width: 400px;overflow: auto;"&gt; &lt;? $sql=$dbh-&gt;query("SELECT `url` FROM `search` ORDER BY id DESC LIMIT 5"); while($r=$sql-&gt;fetch()){ echo "&lt;li style='margin-bottom:5px;'&gt;".$r['url']."&lt;/li&gt;"; } ?&gt; &lt;/ul&gt; &lt;/div&gt; &lt;?footer();?&gt; &lt;/body&gt; &lt;/html&gt;</code></pre> <h2 id="did-you-mean--spell-check">Did You Mean ? (Spell Check)</h2> <p>Google and other search engines gives you a suggestion when thereโ€™s a typo on the query you submitted. I have found a way to implement this using Google. Itโ€™s a very easy implementation.</p> <p>Create a file namedย <strong>spellcheck.php</strong> inย <strong>inc</strong> folder and add this code to it :</p> <pre class="prettyprint"><code>&lt;? class SpellCheck{ private $url="http://translate.google.com/translate_a/t"; function __construct(){ return true; } private function makeURL($s){ $s=urlencode($s); $url=$this-&gt;url."?client=t&sl=en&tl=en&hl=en&sc=2&ie=UTF-8&oe=UTF-8&uptl=en&oc=1&otf=1&ssel=3&tsel=0"; $url.="&q=$s"; return $url; } public function check($s){ $a=""; $c=file_get_contents($this-&gt;makeURL($s)); $c=substr_replace($c, "", 0, 41); preg_match('/u003e","(.*?)",[1]/', $c, $m); if(isset($m[1])){ $a=$m[1]; $a=str_replace('",', '', $a); } return $a; } } ?&gt;</code></pre> <p>Now, weโ€™ll add the code in the <strong>search.php</strong> file that displays theย &quot;Did You Mean&quot; suggestion. Actually, In Part 2 where we made theย <strong>search.php</strong> file, we already added the code. So, no need for codes.</p> <h2 id="starting-the-crawler">Starting the Crawler</h2> <p>When you visit the pageย **crawler/**<strong>runCrawl.php</strong> on your browser, the crawler starts. But, if you keep visiting the page the crawler wonโ€™t start again and again. It will only start the first time you visit the page. When visited, the page prints whether the crawler is currently running or just started running.</p> <p>The only thing you have to make sure is that the fileย <strong>crawler/crawlStatus.txt</strong> have permissions toย <strong>Read &amp; Write</strong>.</p> <h2 id="htaccess">.htaccess</h2> <p>You can make all error pages to a single file like Google showing the same page for all errors :</p> <pre class="prettyprint"><code>DirectoryIndex index.php /inc/error.php ErrorDocument 403 /inc/error.php ErrorDocument 404 /inc/error.php ErrorDocument 405 /inc/error.php ErrorDocument 408 /inc/error.php ErrorDocument 410 /inc/error.php ErrorDocument 411 /inc/error.php ErrorDocument 412 /inc/error.php ErrorDocument 413 /inc/error.php ErrorDocument 414 /inc/error.php ErrorDocument 415 /inc/error.php ErrorDocument 500 /inc/error.php ErrorDocument 501 /inc/error.php ErrorDocument 502 /inc/error.php ErrorDocument 503 /inc/error.php ErrorDocument 506 /inc/error.php</code></pre> <p>In Part 1, we already created one Error Page File. Weโ€™re just linking that file path inย <strong>.htaccess</strong>.</p> <h2 id="stats-1">Stats</h2> <p>If you would like to track visitors and count pageviews using Google Analytics or StatCounter, you should paste the code inย <strong>inc/track.php</strong> file. If the file is not present, create the file and add your Tracking code inside it.</p> <p>If you donโ€™t want tracking, you should remove this line fromย <strong>inc/functions.php</strong> :</p> <pre class="prettyprint"><code>include("track.php");</code></pre> <p>Thatโ€™s about it. The Search Engine is completed. You can enhance the search engine more with your coding skills like I did on <a href="http://search.subinsb.com" target="_blank">search.subinsb.com</a></p> <p>It is possible that I missed out things from the 3 part tutorial. If you found one, Iโ€™ll be really glad that you point the problem in the comments. Thank you and hope you get it well.</p> Create a Search Engine In PHP, MySQL | Part 2 https://subinsb.com/search-engine-in-php-part-2/ Wed, 09 Apr 2014 07:37:37 +0000 https://subinsb.com/search-engine-in-php-part-2/ <p>This is the Part 2 of &quot;How To Create A Search Engine In PHP&quot;. In this part, Weโ€™ll add code to files that are being displayed to the users. We make the database and the table in this part.</p> <div class="padlinks"> <a class="download" href="https://github.com/subins2000/search/archive/master.zip" target="_blank">Download</a><a class="demo" href="http://search.subinsb.com" target="_blank">Demo</a> </div> <h2 id="indexphp">index.php</h2> <p>The main page of our Web Search is index.php. It has a simple design and is not very advanced as Yahoo or something else.</p> <pre class="prettyprint"><code>&lt;?include("inc/functions.php");?&gt; &lt;html&gt; &lt;head&gt; &lt;?head("", array("index"));?&gt; &lt;/head&gt; &lt;body&gt; &lt;?headerElem();?&gt; &lt;div class="container"&gt; &lt;center&gt; &lt;h1&gt;Web Search&lt;/h1&gt; &lt;form class="searchForm" action="search.php" method="GET"&gt; &lt;input type="text" autocomplete="off" name="q" id="query"/&gt; &lt;div&gt; &lt;button&gt; &lt;svg class='shape-search' viewBox="0 0 100 100" class='shape-search'&gt;&lt;use xlink:href='#shape-search'&gt;&lt;/use&gt;&lt;/svg&gt; &lt;/button&gt; &lt;/div&gt; &lt;p&gt;Free, Open Source & Anonymous&lt;/p&gt; &lt;/form&gt; &lt;/center&gt; &lt;/div&gt; &lt;?footer();?&gt; &lt;/body&gt; &lt;/html&gt;</code></pre> <p>We use simple functions for every files.ย <strong>head()</strong> function accepts two parameters. The first parameter is the title of the web page. The main site title will automatically be appended to the title you give in the first parameter when itโ€™s displayed asย <strong><title></title></strong>.</p> <p>We also use <strong>SVG</strong> images to speed up the site. The &quot;#shape-search&quot; path is mentioned in theย <strong>functions.php</strong> file which is dynamically added below the footer.**</p> <p>**</p> <h2 id="urlphp">url.php</h2> <p>When a user clicks on a link of search result, the user actually goes to this page. This page will redirect back to the original URL. When the site owner sees the stats log, he will find our Search Engine URL as a referrer link and our site is promoted.</p> <pre class="prettyprint"><code>&lt;? $url=isset($_GET['u']) ? urldecode($_GET['u']):""; if(filter_var($url, FILTER_VALIDATE_URL) === FALSE || $url==""){ header("Location: http://".$_SERVER['HTTP_HOST'], 302); exit; }else{ header("Location: ".$url); exit; } ?&gt;</code></pre> <p>We check if the URL is valid too, because we donโ€™t want any douche bags messing with our site (No Offence).</p> <h2 id="searchphp">search.php</h2> <p>We show the search results here in this page. Search results are obtained fromย <strong>functions.php</strong> and it is only displayed here.</p> <pre class="prettyprint"><code>&lt;?include("inc/functions.php");?&gt; &lt;html&gt; &lt;head&gt; &lt;?head($GLOBALS['displayQ'], array("search"));?&gt; &lt;/head&gt; &lt;body&gt; &lt;?headerElem();?&gt; &lt;div class="container"&gt; &lt;script&gt;document.getElementById('query').focus();&lt;/script&gt; &lt;? if($GLOBALS['q']==""){ echo "A query please..."; }else{ require "inc/spellcheck.php"; $SC=new SpellCheck(); $corSp=$SC-&gt;check($GLOBALS['q']); if($corSp!=""){ echo "&lt;p style='color:red;font-size:15px;margin-bottom:10px'&gt;Did you mean ? &lt;br/&gt;&lt;a href='?q=$corSp'&gt;".$corSp."&lt;/a&gt;&lt;/p&gt;"; } $res=getResults(); if($res==0){ echo "&lt;p&gt;Sorry, no results were found&lt;/p&gt;&lt;h3&gt;Search Suggestions&lt;/h3&gt;"; echo "&lt;ul&gt;"; echo "&lt;li&gt;Check your spelling&lt;/li&gt;"; echo "&lt;li&gt;Try more general words&lt;/li&gt;"; echo "&lt;li&gt;Try different words that mean the same thing&lt;/li&gt;"; echo "&lt;/ul&gt;"; }else{ ?&gt; &lt;div class="info"&gt; &lt;strong&gt;&lt;?echo $res['count'];?&gt;&lt;/strong&gt; &lt;?echo $res['count']==1 ? "result" : "results";?&gt; found in &lt;?echo $res['time'];?&gt; seconds. Page &lt;?echo $GLOBALS['p'];?&gt; &lt;/div&gt; &lt;div class="results"&gt; &lt;? foreach($res['results'] as $re){ $t=htmlFilt($re[0]); $u=htmlFilt($re[1]); $d=htmlFilt($re[2]); if(strlen($GLOBALS['q']) &gt; 2){ $d=str_replace($GLOBALS['q'], "&lt;strong&gt;{$GLOBALS['q']}&lt;/strong&gt;", $d); } ?&gt; &lt;div class="result"&gt; &lt;h3 class="title"&gt; &lt;a target="_blank" onmousedown="this.href='&lt;?echo HOST;?&gt;/url.php?u='+encodeURIComponent(this.getAttribute('data-href'));" data-href="&lt;?echo $u;?&gt;" href="&lt;?echo $u;?&gt;"&gt;&lt;?echo strlen($t)&gt;59 ? substr($t, 0, 59)."..":$t;?&gt;&lt;/a&gt; &lt;/h3&gt; &lt;p class="url" title="&lt;?echo $u;?&gt;"&gt;&lt;?echo $u;?&gt;&lt;/p&gt; &lt;p class="description"&gt;&lt;?echo $d;?&gt;&lt;/p&gt; &lt;/div&gt; &lt;? } ?&gt; &lt;/div&gt; &lt;div class="pages"&gt; &lt;? $count=(ceil($res['count']/10)); $start=1; if($GLOBALS['p'] &gt; 5 && $count &gt; ($GLOBALS['p'] + 4)){ $start=$GLOBALS['p']-4; $count=$count &gt; ($start+8) ? ($start+8):$count; }elseif($GLOBALS['p'] &gt; 5){ if($GLOBALS['p']==$count){ $start=$GLOBALS['p']-8; }elseif($GLOBALS['p']==($count-1)){ $start=$GLOBALS['p']-7; }elseif($GLOBALS['p']==($count-2)){ $start=$GLOBALS['p']-6; }elseif($GLOBALS['p']==($count-3)){ $start=$GLOBALS['p']-5; }elseif($GLOBALS['p']==($count-4)){ $start=$GLOBALS['p']-4; } }elseif($GLOBALS['p'] &lt;= 5 && $count &gt; ($GLOBALS['p'] + 5)){ $count=$start+8; } for($i=$start;$i&lt;=$count;$i++){ $isC=$GLOBALS['p']==$i ? 'current':''; echo "&lt;a href='?p=$i&q={$GLOBALS['q']}' class='button $isC'&gt;$i&lt;/a&gt;"; } ?&gt; &lt;/div&gt; &lt;? } } ?&gt; &lt;/div&gt; &lt;?footer();?&gt; &lt;/body&gt; &lt;/html&gt;</code></pre> <p>Itโ€™s a tremendous file. As you can see in theย <strong><head></strong> tag, we useย <strong>head()</strong> function. We display theย <strong>query</strong> as the title of the page. If the query is empty, main title will be shown and the string &quot;A query pleaseโ€ฆ&quot; is shown insideย <strong>.container</strong>.</p> <h2 id="database--tables">Database &amp; Tables</h2> <p>Itโ€™s time to create the database and tables. You can create the database you like and Iโ€™ll give you theย <strong>SQL</strong> query to create the table. BTW, the name of the table isย <strong>search</strong>.</p> <pre class="prettyprint"><code>CREATE TABLE IF NOT EXISTS `search` ( `id` int(11) NOT NULL AUTO_INCREMENT, `title` varchar(60) NOT NULL, `url` text NOT NULL, `description` varchar(160) NOT NULL, PRIMARY KEY (`id`), UNIQUE KEY `id` (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;</code></pre> <p>We add theย <strong>title</strong> of the page,ย <strong>URL</strong> of the page andย <strong>description</strong> of the page to this table.</p> <h2 id="crawler">Crawler</h2> <p>Now, letsโ€™ build the crawler which runs in the background. In the previous part of the tutorial, we added the PHPCrawl &amp; Simple HTML Dom library to theย <strong>crawler</strong> folder. In this part, we add code to some of the files we created before.</p> <h3 id="crawlstatustxt">crawlStatus.txt</h3> <p>The status of the crawling (0 / 1) is added inside this file. If itโ€™sย ****,ย <strong>runCrawl.php</strong> will start calling the <strong>bgCrawl.php</strong> which runs the crawler in the background. For starting the crawler, weโ€™ll addย **** inside this file.</p> <pre class="prettyprint"><code></code></pre> <h3 id="crawlphp">crawl.php</h3> <pre class="prettyprint"><code>&lt;? if(!isset($crawlToken) || $crawlToken!=798821){ die("Error"); } $dir=realpath(dirname(__FILE__)); function shutdown(){ global $dir; $a=error_get_last(); if($a==null){ echo "No errors"; }else{ file_put_contents($dir."/crawlStatus.txt", "0"); include($dir."/runCrawl.php"); } } register_shutdown_function('shutdown'); set_time_limit(30); include($dir."/../inc/config.php"); include($dir."/PHPCrawl/libs/PHPCrawler.class.php"); include($dir."/simple_html_dom.php"); function addURL($t, $u, $d){ global $dbh; if($t!="" && filter_var($u, FILTER_VALIDATE_URL)){ $check=$dbh-&gt;prepare("SELECT `id` FROM `search` WHERE `url`=?"); $check-&gt;execute(array($u)); $t=preg_replace("/s+/", " ", $t); $t=substr($t, 0, 1)==" " ? substr_replace($t, "", 0, 1):$t; $t=substr($t, -1)==" " ? substr_replace($t, "", -1, 1):$t; $t=html_entity_decode($t, ENT_QUOTES); $d=html_entity_decode($d, ENT_QUOTES); echo $u."n"; if($check-&gt;rowCount()==0){ $sql=$dbh-&gt;prepare("INSERT INTO `search` (`title`, `url`, `description`) VALUES (?, ?, ?)"); $sql-&gt;execute(array( $t, $u, $d )); }else{ $sql=$dbh-&gt;prepare("UPDATE `search` SET `description` = ?, `title` = ? WHERE `url`=?"); $sql-&gt;execute(array( $d, $t, $u )); } } } class WSCrawler extends PHPCrawler { function handleDocumentInfo(PHPCrawlerDocumentInfo $p){ $u=$p-&gt;url; $c=$p-&gt;http_status_code; $s=$p-&gt;source; if($c==200 && $s!=""){ $html = str_get_html($s); if(is_object($html)){ $d=""; $do=$html-&gt;find("meta[name=description]", 0); if($do){ $d=$do-&gt;content; } $t=$html-&gt;find("title", 0); if($t){ $t=$t-&gt;innertext; addURL($t, $u, $d); } $html-&gt;clear(); unset($html); } } } } function crawl($u){ $C = new WSCrawler(); $C-&gt;setURL($u); $C-&gt;addContentTypeReceiveRule("#text/html#"); $C-&gt;addURLFilterRule("#(jpg|gif|png|pdf|jpeg|svg|css|js)$# i"); $C-&gt;obeyRobotsTxt(true); $C-&gt;setUserAgentString("DingoBot (http://search.subinsb.com/about/bot.php)"); $C-&gt;setFollowMode(0); $C-&gt;go(); } // Get the last indexed URLs (If there isn't, use default URL's) & start Crawling $last=$dbh-&gt;query("SELECT `url` FROM search"); $count=$last-&gt;rowCount(); if($count &lt; 2){ crawl("http://subinsb.com"); // The Default URL #1 crawl("http://demos.subinsb.com"); // The Default URL #2 }else{ $urls=$last-&gt;fetchAll(); for($i=0;$i&lt;2;$i++){ $index=rand(0, $count-1); crawl($urls[$index]['url']); } } ?&gt;</code></pre> <p>Theย <strong>crawl()</strong> function is the one that initiates the crawling. Whenย <strong>crawl.php</strong> is executed, PHP checks if there are 2 or more rows in theย <strong>search</strong> table. If there is, Using MySQL, PHP gets 2 random URLโ€™s from the table and send them toย <strong>crawl()</strong> for crawling. If not, 2 default URLโ€™s are crawled.</p> <p>To prevent others from directly going to the URL and initiate the crawl, we only continue the crawl if the variableย <strong>$crawlToken</strong> is set and itโ€™s value is &quot;798821&quot;.</p> <p>When each document is loaded by the crawler,ย <strong>handleDocumentInfo()</strong> function is called. This function will check if the status code of the document is &quot;200&quot; (OK) and the contents of the document is not null. If the checks are all Ok, then the title tag from the document and the meta description tag is obtained. If title is null or not found, the record is not inserted in to the table. The description field is not mandatory.</p> <p>The title and description is filtered and the page URL is printed out.</p> <h3 id="bgcrawlphp">bgCrawl.php</h3> <pre class="prettyprint"><code>&lt;? $dir=realpath(dirname(__FILE__)); $GLOBALS['bgFull']=""; $crawlToken=418941; include($dir."/crawl.php"); ?&gt;</code></pre> <p>This file is called byย <strong>runCrawl.php</strong> for background running.</p> <h3 id="runcrawlphp">runCrawl.php</h3> <pre class="prettyprint"><code>&lt;? $dir=realpath(dirname(__FILE__)); $s="$dir/crawlStatus.txt"; $c=file_get_contents($s); if($c==0){ function execInbg($cmd) { if (substr(php_uname(), 0, 7) == "Windows"){ pclose(popen("start /B ". $cmd, "r")); }else{ exec($cmd . " &gt; /dev/null &"); } } execInbg("php -q $dir/bgCrawl.php"); file_put_contents($s, 1); echo "Started Running"; }else{ echo "Currently Running"; } ?&gt;</code></pre> <p>To start the crawling process in background, you should go to this page by using the browser. The background crawling only starts if the contents of theย <strong>crawlStatus.txt</strong> file is &quot;0&quot;. When theย <strong>bgCrawl.php</strong> is executed using the shell command, the contents of theย <strong>crawlStatus.txt</strong>ย is replaced with &quot;1&quot; indicating that the crawling process in the background has started.</p> <p>Every time you update your site, you should visit this page to initiate background crawling. Other wise, crawling wonโ€™t be done and theย <strong>search</strong> tableโ€™s contents wonโ€™t be increased.</p> <p>This concludes the 2nd part. The next part will contain additional features and what more you can do with the search engine. The next part will also contain addingย <strong>Spell Check</strong> to the search engine.</p> Create A Search Engine In PHP, MySQL | Part 1 https://subinsb.com/search-engine-in-php-part-1/ Tue, 08 Apr 2014 07:22:26 +0000 https://subinsb.com/search-engine-in-php-part-1/ <p>When we all search on the web using Google, Yahoo or Bing, we are curious about how it works and how it gets all the information on the web. When us programmers started coding, we all wanted to create a search engine. I too attempted to create a search engine and I ultimately failed (3 years back). But now, I improved my coding skills, improved my knowledge and ideas. So, I decided to create a new search engine with automatic crawling, indexing and stuff.</p> <p>It works great and I made it Open Source. You can see the source code on <a href="https://github.com/subins2000/search" target="_blank">GitHub</a> or we can move together to understand the different code we will write by this series. This is theย **Part 1ย **of &quot;How To Create A Search Engine In PHP&quot;. You can see the finished product or download the finished source code.</p> <div class="padlinks"> <a class="download" href="https://github.com/subins2000/search/archive/master.zip" target="_blank">Download</a><a class="demo" href="http://search.subinsb.com" target="_blank">Demo</a> </div> <h2 id="features">Features</h2> <ul> <li>No JS, Less CSS, Light</li> <li>Simple, Fast &amp; Easy Use</li> <li>Have own Crawler &amp; Obeys robots.txt</li> <li>Only indexes HTML Page (No JS files, CSS files, Images)</li> <li>Not Vulnerable to SQL Injection</li> <li>XSS Attack Not Possible</li> <li>HTML 5 (SVG Images)</li> <li>Uses PDO for Database Queries</li> </ul> <p>Hereโ€™s the summary of the Search Engine weโ€™re going to create :</p> <ul> <li>Crawler Runs In The background</li> <li>Crawler gets the <code>&amp;lt;title&amp;gt;</code> and <code>meta[name=description]</code> from the page and inserts in to the database.</li> <li>When user searches for a query, MySQL searches for query in title, url and description and displays the results.</li> <li>User actually click search engineโ€™s URL when they click on an external link of search results.</li> <li>We display the stats of the search engine (URLs crawled, Last Indexed URLs</li> </ul> <p>In this part of the tutorial, we make the base files and add code to them. Here is the directory tree :</p> <ul> <li>about</li> <li>ย  ย  bot.php</li> <li>ย  ย  index.php</li> <li>ย  ย  stats.php</li> <li>cdn</li> <li>ย  ย  css</li> <li>ย  ย  ย  ย all.css</li> <li>ย  ย  ย  ย index.css</li> <li>ย  ย  ย  ย search.css</li> <li>crawler</li> <li>ย  ย  ย  ย PHPCrawl</li> <li>ย  ย  ย  ย  ย โ€“ A lot of Files Inside This</li> <li>ย  ย  ย  ย bgCrawl.php</li> <li>ย  ย  ย  ย crawl.php</li> <li>ย  ย  ย  ย crawlStatus.txt</li> <li>ย  ย  ย  ย runCrawl.php</li> <li>ย  ย  ย  ย simple_html_dom.php</li> <li>inc</li> <li>ย  ย  ย  ย config.php</li> <li>ย  ย  ย  ย error.php</li> <li>ย  ย  ย  ย functions.php</li> <li>ย  ย  ย  ย track.php</li> <li>.htaccess</li> <li>index.php</li> <li>robots.txt</li> <li>search.php</li> <li>url.php</li> </ul> <p>As you can see, there are a lot of files in the search engine we are going to create.</p> <h2 id="crawler">crawler</h2> <p>We uses two external libraries in our search engine. Download it and place them insideย <strong>crawler</strong> folder.</p> <table class="table"> <tr> <td> PHPCrawl </td> <pre><code>&lt;td&gt; &lt;a href=&quot;http://phpcrawl.cuab.de&quot; target=&quot;_blank&quot;&gt;phpcrawl.cuab.de&lt;/a&gt; &lt;/td&gt; &lt;td&gt; crawler/PHPCrawl &lt;/td&gt; </code></pre> </tr> <tr> <td> SimpleHTMLDom </td> <pre><code>&lt;td&gt; &lt;a href=&quot;http://simplehtmldom.sourceforge.net&quot; target=&quot;_blank&quot;&gt;simplehtmldom.sourceforge.net&lt;/a&gt;โ€Ž &lt;/td&gt; &lt;td&gt; crawler/simple_html_dom.php &lt;/td&gt; </code></pre> </tr> </table> <p>Simple HTML Dom only have one file : <strong>simple_html_dom.php</strong>. Place it directly inย <strong>crawler</strong> folder.</p> <p>There is a bug in the PHPCrawl library which makes PHP errors when there is an invalid <strong>robots.txt</strong> file. Thereโ€™s a way to fix that. Go toย <strong>crawler/PHPCrawl/libs/PHPCrawlerRobotsTxtParser.class.php</strong> file and search for :</p> <pre class="prettyprint"><code>// First, get all "Disallow:"-paths</code></pre> <p>You will see a function named &quot;buildRegExpressions&quot;. In it, replace the code :</p> <pre class="prettyprint"><code>$disallow_pathes[] = trim($match[1]);</code></pre> <p>with the following code :</p> <pre class="prettyprint"><code>if(isset($match[1])){ $disallow_pathes[] = trim($match[1]); }</code></pre> <p>There is also another bug in the same file. Search for :</p> <pre class="prettyprint"><code>$non_follow_path_complpete</code></pre> <p>In the first match, replace the line of code :</p> <pre class="prettyprint"><code>$non_follow_path_complpete = $normalized_base_url.substr($disallow_pathes[$x], 1); // "http://www.foo.com/bla/"</code></pre> <p>with :</p> <pre class="prettyprint"><code>$non_follow_path_complpete = $normalized_base_url."/".substr($disallow_pathes[$x], 1); // "http://www.foo.com/bla/"</code></pre> <p>Thatโ€™s all the bug fixes.</p> <h2 id="cdn">cdn</h2> <p>CDN โ€“ short forย <strong>Content Delivery Network</strong> is the folder where we store ourย <strong>CSS</strong>,ย <strong>JS</strong> files. Since, our search engine don;t have any JS files, we donโ€™t have to create theย <strong>js</strong> folder. But we should create theย <strong>css</strong> folder insideย <strong>cdn</strong>. In theย <strong>css</strong> directory, create 3 files namedย <strong>all.css</strong>,ย <strong>index.css</strong> andย <strong>search.css</strong>.</p> <h3 id="strongallcssstrong"><strong>all.css</strong></h3> <pre class="prettyprint"><code>*{ margin:0px; border:0px; padding:0px; font-family: Ubuntu; } body{ font-size:14px; line-height: 20px; } .header{ position: absolute; top: 0px; left: 0px; right: 0px; background: #EEE; padding: 5px 20px; } .header form{ display: inline-block; } .header .logo{ margin-right:10px; text-decoration: none; font-size:22px; display: inline-block; vertical-align:middle; color:black; } .header .searchForm #query{ width:180px; -webkit-transition:1s; transition:1s; height:30px; font-size:15px; margin-left:10px; } .header .searchForm #query:focus{ width:300px; } .container{ margin: 50px auto 30px auto; display:table; } .footer{ position: fixed; bottom: 0px; left: 0px; right: 0px; background: #EEE; padding: 5px 20px; } .footer a{ margin-right:5px; } /* Default Styles */ a[href]{ text-decoration:none; } a[href]:hover{ text-decoration:underline; } h1,h2,h3,h4{ margin:10px 0px; } input[type="text"]{ padding:3px 5px; outline: none; border: 1px solid #EEE; border-radius: 2px; display: inline-block; vertical-align:middle; } input[type="text"]:hover{ border: 1px solid #DDD; } input[type="text"]:active, input[type="text"]:focus{ border: 1px solid #4585F1; } button, .button{ padding:5px 10px; display: inline-block; vertical-align:middle; background-color: rgb(77, 144, 254); background-image: -webkit-gradient(linear,left top,left bottom,from(rgb(77, 144, 254)),to(rgb(71, 135, 237))); background-image: -webkit-linear-gradient(top,rgb(77, 144, 254),rgb(71, 135, 237)); background-image: -moz-linear-gradient(top,rgb(77, 144, 254),rgb(71, 135, 237)); background-image: -ms-linear-gradient(top,rgb(77, 144, 254),rgb(71, 135, 237)); background-image: -o-linear-gradient(top,rgb(77, 144, 254),rgb(71, 135, 237)); background-image: linear-gradient(top,rgb(77, 144, 254),rgb(71, 135, 237)); cursor: pointer; color:white; border-radius:2px; } button:hover, .button:hover{ box-shadow: inset 0 2px 2px rgba(0,0,0,0.1); } .searchForm .shape-search{ height: 14px; padding:4px 10px; width: 35px; fill:white; } .searchForm button{ padding: 0px; height:30px; }</code></pre> <p>Yeah, we useย <strong>Ubuntu</strong> font because I like it. Hope you like it too. We will add theย <strong>fonts.googleapis.com</strong> stylesheet for proper loading of the font later.</p> <h3 id="indexcss">index.css</h3> <pre class="prettyprint"><code>.container .searchForm{ margin-top:20px; padding:5px; } .container .searchForm #query{ width: 400px; padding:4px 5px; font-size:15px; } .container .searchForm .shape-search{ width: 100px; height:15px; } .container .searchForm div, .container .searchForm p{ margin-top:10px; }</code></pre> <p>This file styles the index page</p> <h3 id="searchcss">search.css</h3> <pre class="prettyprint"><code>.header .searchForm #query{ width:400px !important; } .header{ text-align:center; } .container{ width:500px; } .container .info{ color: gray; } .results{ width: 500px; margin-top:25px; } .result{ margin:20px 0px; } .result .title{ margin-bottom: 0px; font-size: 17px; } .result .url{ font-size: 13px; color: #006621; overflow:hidden; height:20px; } .pages{ width: 500px; text-align: center; margin: 0px auto 10px auto; } .pages .button{ margin: 0px 3px 3px; } .pages .button.current{ background:black; }</code></pre> <p>This style file styles the searh results page (search.php).</p> <p>Everythingโ€™s finished forย <strong>cdn</strong> folder. Letโ€™s move on toย <strong>inc</strong> folder.</p> <h2 id="inc">inc</h2> <p>Contains the includable files. This folder plays a major role in our search engine. The main file isย <strong>functions.php</strong> which is used by all the static pages (which comes from dynamic page).</p> <h3 id="functionsphp">functions.php</h3> <pre class="prettyprint"><code>&lt;? include("config.php"); session_start(); $GLOBALS['q']=isset($_GET['q']) ? htmlspecialchars(urldecode($_GET['q'])):""; $GLOBALS['displayQ']=$GLOBALS['q']; $GLOBALS['q']=strtolower($GLOBALS['q']); $GLOBALS['p']=isset($_GET['p']) && is_numeric($_GET['p']) ? $_GET['p']:1; $GLOBALS['dbh']=$dbh; function htmlFilt($s){ $s=str_replace("&lt;", "&lt;", $s); $s=str_replace("&gt;", "&gt;", $s); return $s; } function head($title="", $IncOtherCss=array()){ $title=$title=="" ? "Web Search" : $title." - Web Search"; /* Display The &lt;title&gt; tag */ echo "&lt;title&gt;$title&lt;/title&gt;"; /* The Stylesheets */ $cssFiles = array_merge( array( "all", "http://fonts.googleapis.com/css?family=Ubuntu" ), $IncOtherCss ); foreach($cssFiles as $css){ $url=preg_match("/http/", $css) ? $css : HOST."/cdn/css/$css.css"; echo "&lt;link href='".$url."' async='async' rel='stylesheet' /&gt;"; } echo "&lt;meta name='description' content="Search the world's information, webpages, problems and more. Find exactly what you're looking for easily without any ads and other distractions"/&gt;"; } function headerElem(){ // header() is already a function in PHP $header = "&lt;div class='header'&gt;&lt;a class='logo' href='".HOST."'&gt;&lt;strong&gt;Web Search&lt;/strong&gt;&lt;/a&gt;&lt;form method='GET' action='".HOST."/search.php' class='searchForm'&gt;&lt;input id='query' type='text' placeholder='Your Query' autocomplete='off' name='q' value="".$GLOBALS['displayQ'].""/&gt;&lt;button&gt;&lt;svg viewBox='0 0 100 100' class='shape-search'&gt;&lt;use xlink:href='#shape-search'&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/button&gt;&lt;/form&gt;&lt;/div&gt;"; echo $header; } function footer(){ include("track.php"); $footer = "&lt;div class='footer'&gt;&lt;a href='".HOST."/about'&gt;About&lt;/a&gt;&lt;a href='".HOST."/about/stats.php'&gt;Stats&lt;/a&gt;&lt;a href='".HOST."/about/bot.php'&gt;Dingo&lt;/a&gt;&lt;div style='float:right;'&gt;&copy; Copyright Subin ".date("Y")."&lt;/div&gt;&lt;/div&gt;"; $footer.=' &lt;svg style="display:none;"&gt; &lt;defs&gt; &lt;path id="shape-search" d="m 85.160239,99.375807 c -0.828634,-0.2952 -6.785463,-5.7653 -13.237403,-12.1558 l -11.730795,-11.6193 -6.6207,2.1766 C 33.39036,84.411907 12.627177,75.515007 3.6984912,56.407007 -5.6131124,36.479667 3.2485677,12.852077 23.649685,3.2119175 29.682607,0.36117746 31.404851,0.01130746 39.459783,5.746345e-5 50.03976,-0.01474254 56.477126,1.9699875 63.781566,7.4987375 77.935087,18.211537 83.541599,36.335507 77.964788,53.348307 l -2.173424,6.6304 11.744957,11.7927 c 9.455968,9.4945 11.857728,12.4888 12.323668,15.3642 1.319521,8.1432 -6.925821,15.008903 -14.69975,12.2402 z m -33.083916,-33.2366 c 5.656943,-2.5459 11.702601,-8.5732 14.216739,-14.1737 8.683318,-19.34281 -5.230473,-40.9032 -26.331076,-40.80178 -26.510022,0.12741 -38.6174499,32.4025 -18.836563,50.21308 2.774148,2.4979 7.069057,5.1647 9.656546,5.9963 5.992636,1.9257 15.497206,1.375 21.294354,-1.2339 z"&gt;&lt;/path&gt; &lt;/defs&gt; &lt;/svg&gt;'; echo $footer; } /* Results */ function getResults(){ $q=$GLOBALS['q']; $p=$GLOBALS['p']; $start=($p-1)*10; if($q!=null){ $starttime = microtime(true); $sql=$GLOBALS['dbh']-&gt;prepare("SELECT `title`, `url`, `description` FROM search WHERE `title` LIKE :q OR `url` LIKE :q OR `description` LIKE :q ORDER By id"); $sql-&gt;bindValue(":q", "%$q%");; $sql-&gt;execute(); $endtime = microtime(true); if($sql-&gt;rowCount()==0 || $start&gt;$sql-&gt;rowCount()){ return 0; }else{ $duration = $endtime - $starttime; $res=array(); $res['count']=$sql-&gt;rowCount(); $res['time']=round($duration, 4); $limitedResults=$GLOBALS['dbh']-&gt;prepare("SELECT `title`, `url`, `description` FROM search WHERE `title` LIKE :q OR `url` LIKE :q OR `description` LIKE :q ORDER BY id LIMIT :start,:limit"); $limitedResults-&gt;bindValue(":q", "%$q%"); $limitedResults-&gt;bindValue(":start", $start, PDO::PARAM_INT); $limitedResults-&gt;bindValue(":limit", 10, PDO::PARAM_INT); $limitedResults-&gt;execute(); while($r=$limitedResults-&gt;fetch()){ $res["results"][]=array($r['title'], $r['url'], $r['description']); } return $res; } } } ?&gt;</code></pre> <p>ย </p> <p><strong>functions.php</strong> makes theย <strong>&lt;head</strong>**&gt;** tag,ย <strong>footer</strong> and <strong>header</strong>. It also fetches the search results, make GLOBAL variables etcโ€ฆ</p> <h3 id="configphp">config.php</h3> <p>The configuration file. Contains information about the database.</p> <pre class="prettyprint"><code>&lt;? /* Configuration */ ini_set("display_errors", "on"); // Do you want to see the errors ? define("HOST", "http://search.subinsb.com"); // No '/' at the end $host = "localhost"; // Hostname $port = "3306"; // MySQL Port; Default : 3306 $user = "username"; // Username Here $pass = "password"; // Password Here $db = "search"; // Database Name $dbh = new PDO('mysql:dbname='.$db.';host='.$host.';port='.$port, $user, $pass); /* End Configuration */ ?&gt;</code></pre> <p>Add the domain of the search engine inside theย <strong>HOST</strong> constant, so that you donโ€™t need to change domains elsewhere on any other pages.</p> <h3 id="errorphp">error.php</h3> <p>The page which is displayed if any errors occur.</p> <pre class="prettyprint"><code>&lt;html&gt; &lt;head&gt;&lt;/head&gt; &lt;body&gt; &lt;h1&gt;404 Not Found&lt;/h1&gt; &lt;p&gt; The request file was not found on this server. &lt;/p&gt; &lt;/body&gt; &lt;/html&gt;</code></pre> <p>The next part will contain the code ofย <strong>index.php</strong> and other files. It will be published shortly.**</p> <p>**</p> MySQL NOW() in JavaScript (UTC & Local) https://subinsb.com/mysql-now-in-js-utc-local/ Fri, 04 Apr 2014 06:56:35 +0000 https://subinsb.com/mysql-now-in-js-utc-local/ <p>If you knowย <strong>MySQL</strong>, you will certainly know theย <strong>NOW()</strong> function that outputs the current date and time with the timezone of the MySQL server. For easy use and compatibility, we useย <strong>UTC</strong> time zone for storing time in database. If you are running a web app that comply with MySQL, then you need the date function as same as theย <strong>NOW()</strong>.</p> <p>So, I will give you a small function that return the same value as MySQLโ€™s NOW() function in both UTC and local time. There are 2 versions of this function, one little big and the other very short (1 line of code). The shorter one is supported by modern browsers and the other is supported by all browsers.</p> <h2 id="longer-function">Longer Function</h2> <h3 id="common-function">Common Function</h3> <p>In both cases (UTC, Local) you need a common function that corrects a single digit value to 2 digit value. Here is the function :</p> <pre class="prettyprint"><code>function twoDigits(d) { if(0 &lt;= d && d &lt; 10) return "0" + d.toString(); if(-10 &lt; d && d &lt; 0) return "-0" + (-1*d).toString(); return d.toString(); }</code></pre> <h3 id="utc">UTC</h3> <p>This function gives the currentย <strong>UTC</strong>ย date time :</p> <pre class="prettyprint"><code>function NOW(){ t=new Date(); return t.getUTCFullYear() + "-" + twoDigits(1 + t.getUTCMonth()) + "-" + twoDigits(t.getUTCDate()) + " " + twoDigits(t.getUTCHours()) + ":" + twoDigits(t.getUTCMinutes()) + ":" + twoDigits(t.getUTCSeconds()); }</code></pre> <p>Note that we use theย <strong>twoDigits</strong> function in the above code.</p> <h3 id="local">Local</h3> <p>Get the current local time of the clientโ€™s browser / system :</p> <pre class="prettyprint"><code>function NOW(){ t=new Date(); return t.getFullYear() + "-" + twoDigits(1 + t.getMonth()) + "-" + twoDigits(t.getDate()) + " " + twoDigits(t.getHours()) + ":" + twoDigits(t.getMinutes()) + ":" + twoDigits(t.getSeconds()); }</code></pre> <p>All we have to do is replace allย <strong>UTC</strong> word from the UTC NOW() code and youโ€™ll get the local date time code.</p> <h2 id="easy-shorter-function">Easy, Shorter Function</h2> <p>Thereโ€™s another easy approach to the NOW() function. Itโ€™s by usingย <strong>.toISOString()</strong>. This supports all modern browsers.</p> <h3 id="utc-1">UTC</h3> <pre class="prettyprint"><code>function NOW(){ return new Date().toISOString().slice(0, 19).replace('T', ' '); }</code></pre> <h3 id="local-1">Local</h3> <pre class="prettyprint"><code>function NOW(){ return new Date(new Date()+" UTC").toISOString().slice(0, 19).replace('T', ' '); }</code></pre> <h2 id="usage">Usage</h2> <p>The usage is same in both cases :</p> <pre class="prettyprint"><code>console.log(NOW())</code></pre> <p>If you used the UTC version of NOW(), then it will print something like :</p> <pre class="prettyprint"><code>2014-04-04 06:50:44</code></pre> <p>In the local case, it would be :</p> <pre class="prettyprint"><code>2014-04-04 12:20:44</code></pre> <p>You can include the date time in a variable too :</p> <pre class="prettyprint"><code>var curDateTime = NOW();</code></pre> <p>Happy coding.</p> In My Name is Linux https://subinsb.com/in-my-name-is-linux/ Wed, 02 Apr 2014 06:26:38 +0000 https://subinsb.com/in-my-name-is-linux/ <p>As you know already, my full name is Subin Siby. Whatโ€™s special about my name is that itโ€™s connected to Linux. As you may have seen, executable files on a Linux system is in the directoryย <strong>/usr/bin</strong>,ย <strong>/usr/sbin</strong> andย <strong>/sbin</strong>. If you look at it closely, you can see thatย <strong>sbin</strong> only misses the characterย <strong>u</strong> from my name. If you add &quot;u&quot; to the name, itโ€™ll becomeย <strong>/usr/subin</strong>.</p> <p>Creepy &amp; Fun, right ? I can assure you one thing. I wasnโ€™t named after the directoryย <strong>/sbin</strong>. It was a totally random decision to make my nameย <strong>Subin</strong> and there are a number of people in Kerala who has the name Subin. So Iโ€™m not alone.</p> <p>Also, the wordย <strong>bin</strong> is coming in my name. Some call itย <strong>Recycle Bin</strong> as in <strong>Windows</strong> and real life. The otherย <strong>bin</strong> word inย <strong>Linux</strong> is the directoryย <strong>/usr/bin</strong>.ย **</p> <p>**</p> <p>Also, there is a command inย <strong>Linux</strong> calledย <strong>su</strong>. It is used forย changing user ID or become superuser. Also,ย <strong>su</strong> comes in the commandย <strong>sudo</strong>.</p> <p>In short words, my name is entirely based onย <strong>Linux</strong> except my last name which is of my dadโ€™s. No wonder why I likeย <strong>Linux</strong> ๐Ÿ™‚</p> <p>From what I have arrived, It creeps me out and what an incredible coincidence.</p> Group Chat In PHP With Usersโ€™ Typing Status https://subinsb.com/php-group-chat-with-user-type-status/ Wed, 02 Apr 2014 06:04:18 +0000 https://subinsb.com/php-group-chat-with-user-type-status/ <p>I wrote a post on creating <a title="Create Group Chat In PHP With MySQL, jQuery And AJAX" href="//subinsb.com/group-chat-in-php-with-ajax-jquery-mysql" target="_blank">Group Chat in PHP</a>. A comment was posted by Ravi asking if it was possible to include userโ€™s typing status. It was a fascinating and a good idea to add userโ€™s typing status. So, I worked on the code and knew it was possible. Iโ€™m going to tell you how to implement the display of usersโ€™ typing status on the <a title="Create Group Chat In PHP With MySQL, jQuery And AJAX" href="//subinsb.com/group-chat-in-php-with-ajax-jquery-mysql" target="_blank">Group Chat I created earlier</a>.</p> <p>This post is an addon of the <a title="Create Group Chat In PHP With MySQL, jQuery And AJAX" href="//subinsb.com/group-chat-in-php-with-ajax-jquery-mysql" target="_blank">Group Chat I mentioned earlier</a>.</p> <div class="padlinks"> <a class="download" href="http://demos.subinsb.com/down.php?id=6276vjhzyuni/s/di7yi98bnqo34mzn7n8x&class=23" target="_blank">Download</a><a class="demo" href="http://demos.subinsb.com/php/chat-typing-status" target="_blank">Demo</a> </div> <h2 id="create-table">Create Table</h2> <p>For storing the usersโ€™ typing status, we should create a table. Here is the SQL code that creates the tableย <strong>typeStatus</strong> :</p> <pre class="prettyprint"><code>-- Table structure for table `typeStatus` CREATE TABLE IF NOT EXISTS `typeStatus` ( `name` varchar(20) NOT NULL, `what` varchar(20) NOT NULL, `inserted` varchar(20) NOT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1;</code></pre> <h2 id="typestatusphp">typeStatus.php</h2> <p>Create a file namedย <strong>typeStatus.php</strong> and add the following code inside it :</p> <pre class="prettyprint"><code>&lt;? include("config.php"); if(isset($_POST['action']) && isset($_SESSION['user'])){ $act=$_POST['action']; if($act=="startedTyping" || $act=="stoppedTyping"){ $sql=$dbh-&gt;prepare("SELECT name FROM typeStatus WHERE `name`=?"); $sql-&gt;execute(array($_SESSION['user'])); if($sql-&gt;rowCount()==0){ $sql2=$dbh-&gt;prepare("INSERT INTO typeStatus (`name`, `what`, `inserted`) VALUES (:name, :what, NOW())"); $sql2-&gt;execute(array( ":name" =&gt; $_SESSION['user'], ":what" =&gt; $act )); }else{ $query=$act=="startedTyping" ? "UPDATE typeStatus SET `what`=:what, `inserted`=NOW() WHERE name=:name":"UPDATE typeStatus SET `what`=:what WHERE name=:name"; $sql2=$dbh-&gt;prepare($query); $sql2-&gt;execute(array( ":name" =&gt; $_SESSION['user'], ":what" =&gt; $act )); } }else{ echo "You can't fool me."; } } ?&gt;</code></pre> <p>We send the AJAX request mentioning the type Status of the user to this file. This file process it and insert the data in to the database. This file only accepts data if theย <strong>$_POST[โ€˜actionโ€™]</strong> is &quot;startedTyping&quot; or &quot;stoppedTyping&quot;.</p> <h2 id="usersphp">users.php</h2> <p>Replace the code inย <strong>users.php</strong> to this :</p> <pre class="prettyprint"><code>&lt;? include("config.php"); echo "&lt;h2&gt;Users&lt;/h2&gt;"; $sql=$dbh-&gt;prepare("SELECT name FROM chatters2"); $sql-&gt;execute(); while($r=$sql-&gt;fetch()){ $name=$r['name']; echo "&lt;div class='user'&gt;$name"; if(isset($_SESSION['user']) && $name!=$_SESSION['user']){ $sql2=$dbh-&gt;prepare("SELECT what FROM typeStatus WHERE name=?"); $sql2-&gt;execute(array($name)); if($sql2-&gt;rowCount()!=0){ $action=str_replace("startedTyping", "Typing...", str_replace("stoppedTyping", "Stopped Typing", $sql2-&gt;fetchColumn())); echo "&lt;div class='status'&gt;$action&lt;/div&gt;"; } } echo "&lt;/div&gt;"; } // Remove Old Type Statuses $sql=$dbh-&gt;query("DELETE FROM typeStatus WHERE `inserted` &lt; DATE_ADD(NOW(), INTERVAL -30 second) AND `what`='stoppedTyping'"); ?&gt;</code></pre> <p>We display the userโ€™s type status in this file along with the user name. The status wonโ€™t be displayed for he current user in the list. If you want that, remove the if clause <strong>$name!=$_SESSION[โ€˜userโ€™]</strong>. Also, the type status of other users will only be displayed if the current user is logged in (registered) for chatting. If you want to remove this feature too, remove the if clauseย <strong>isset($_SESSION[โ€˜userโ€™]) &amp;&amp; $name!=$_SESSION[โ€˜userโ€™]</strong>.</p> <p>We donโ€™t need to flood theย <strong>typeStatus</strong> table with logged out usersโ€™ type status. Hence every time theย <strong>users.php</strong> file is executed, old records inย <strong>typeStatus</strong> table will be removed if the inserted time is less than 30 seconds of the current time.**</p> <p>**</p> <h2 id="chatcss">chat.css</h2> <p>We added the newย <strong>HTML</strong>ย element to the &quot;Users&quot; list. The element is of the class name &quot;status&quot;. So we should style it. Add the following CSS style to the end of the file :</p> <pre class="prettyprint"><code>.chat .users .user .status{ font-size:11px; margin-left:5px; }</code></pre> <p>The status should be fit in to the container. Hence we decreased the font size and to make it look like the status of user we add a margin ofย <strong>15px</strong> to the left. Now, the status element will become like a sub text of the user name.</p> <h2 id="chatjs">chat.js</h2> <p>Thisย <strong>jQuery</strong> file has all the importance. It intelligently check whether the user is typing or not. If he /she โ€˜s typing, then jQuery will send a request toย <strong>typeStatus.php</strong> and if not it will send another request with different data to theย <strong>typeStatus.php</strong> file. Here is the changes you have to make.</p> <p>Add a variable namedย <strong>lastKeyUp</strong> with value as integer beforeย <strong>$(document).ready(function(){</strong> :</p> <pre class="prettyprint"><code>lastKeyUp=0; $(document).ready(function(){</code></pre> <p>In the <strong>$(document).ready(function(){</strong> add the following code to listen theย <strong>keyup</strong> made by the user on the message field :</p> <pre class="prettyprint"><code>$("#msg_form input[type=text]").keyup(function(){ lastKeyUp=0; $.post("typeStatus.php", {action:"startedTyping"}, function(){ lastKeyUp=0; }); });</code></pre> <p>When the user presses a key inside the field, jQuery will make theย <strong>lastKeyUp</strong> variable toย **** and will send a request toย <strong>typeStatus.php</strong>ย with the following JSON Data :</p> <pre class="prettyprint"><code>{action:"startedTyping"}</code></pre> <p><strong>typeStatus.php</strong> will take care of the rest.</p> <p>And finally, we make aย <strong>setInterval</strong> function to increment theย <strong>lastKeyUp</strong> value and post data according to it. Add the code at the end of the file :</p> <pre class="prettyprint"><code>setInterval(function(){ lastKeyUp = ++lastKeyUp % 360 + 1; if(lastKeyUp&gt;5 && $("#msg_form input[type=text]").val()!=""){ $.post("typeStatus.php", {action:"stoppedTyping"}, function(data){ lastKeyUp=0; }); } },1000);</code></pre> <h2 id="what-happens-in-the-background-">What Happens In The Background ?</h2> <p>Each second, theย <strong>lastKeyUp</strong> variable will increase by 1. If the message submit field value is not null and the <strong>lastKeyUp</strong> variable is more than 5, then we can make a conclusion that user is not typing. We send our conclusion toย <strong>typeStatus.php</strong> saying that user is not typing. When the response is received, we make theย <strong>lastKeyUp</strong> variable back toย ****.</p> <p>When aย <strong>keyup</strong> event is fired in the message field, jQuery will send another request saying that the user is typing to theย <strong>typeStatus.php</strong> file.</p> <p>Ifย <strong>typeStatus.php</strong> got theย <strong>action</strong> field with the value &quot;startedTyping&quot;, then PHP will insert a new row with values as below :</p> <pre class="prettyprint"><code>name - User's Name what ย  - $_POST['action'] inserted - NOW() function in MySQL</code></pre> <p>As you know already that jQuery sends a request toย <strong>users.php</strong> file every 5 seconds, usersโ€™ typing status will automatically be displayed in the users table. Here is how the users.php**ย **make the text according to the data received from the database table :</p> <pre class="prettyprint"><code>$sql=$dbh-&gt;prepare("SELECT what FROM typeStatus WHERE name=?"); $sql-&gt;execute(array($name)); if($sql-&gt;rowCount()!=0){ $action=str_replace("startedTyping", "Typing...", str_replace("stoppedTyping", "Stopped Typing", $sql2-&gt;fetchColumn())); echo "&lt;div class='status'&gt;$action&lt;/div&gt;"; }</code></pre> <p><strong>$name</strong> is the name of the online user. It replacesย &quot;startedTyping&quot;**ย **toย &quot;Typingโ€ฆ&quot; andย &quot;stoppedTyping&quot; to &quot;Stopped Typing&quot;.</p> <p>Also, records in theย <strong>typeStatus</strong> table with `what` value as &quot;stoppedTyping&quot; will be removed if the inserted time is less than 30 seconds of the current time to prevent the overflowing of the table data.**</p> <p>**</p> <p>And thatโ€™s how it works ! Hope you liked it and there may be flaws in the post and if you see one, please comment out. If you have suggestions / problems, post in the comments and Iโ€™ll be happy to help.</p> Native JavaScript Equivalents of jQuery https://subinsb.com/jquery-to-javascript/ Mon, 31 Mar 2014 18:11:16 +0000 https://subinsb.com/jquery-to-javascript/ <p>If you want to do some little task on your website, you donโ€™t need <strong>jQuery</strong>. But if you only did work with jQuery, you wonโ€™t know the JavaScript functions that do the same thing. I have ran in to this problem and found the real JavaScript functions in replacement of jQuery functions. Iโ€™m going to share it with you. This post will continue to expand when jQuery adds new functions.</p> <h2 id="selector">Selector</h2> <p>jQuery selects element usingย <strong>Sizzle Selector</strong>, a small library containing in the jQuery source file. In JavaScript you select elements using one of the following doing various type of selections :</p> <pre class="prettyprint"><code>document.getElementById document.getElementsByClassName document.getElementsByName document.getElementsByTagName document.getElementsByTagNameNS</code></pre> <p>jQuery element selecting is like mentioning an element inย <strong>CSS</strong>. There is a native <strong>JavaScript</strong> function that selects elements like CSS selecting of an element. Here is an example of selecting a div element of idย <strong>firstElem</strong>ย that has theย <strong>body</strong>ย parent in both jQuery and JavaScript :**</p> <p>**</p> <pre class="prettyprint"><code>$("body div#firstElem")</code></pre> <pre class="prettyprint"><code>document.querySelector("body div#firstElem")</code></pre> <p>Both selects the same element. JavaScript will return only a single element if you select elements usingย <strong>querySelector()</strong>. You should use <strong>querySelectorAll</strong>,ย <strong>getElementsByClassName</strong> orย <strong>getElementsByTagName</strong> for getting an array of elements.</p> <h2 id="functions">Functions</h2> <p>In the following examples, first is jQuery code and the second is the JavaScript code that does the same task.</p> <h3 id="text">.text()</h3> <pre><code>$(&quot;#elem&quot;).text(); document.getElementById(&quot;elem&quot;).innerText; </code></pre> <h3 id="html">.html()</h3> <pre class="prettyprint"><code>$("#elem").html();</code></pre> <pre class="prettyprint"><code>document.getElementById("elem").innerHTML;</code></pre> <h3 id="each">.each()</h3> <pre class="prettyprint"><code>$("div").each(function(){ console.log($(this).html()); });</code></pre> <pre class="prettyprint"><code>nodes=document.getElementsByTagName("div"); for(i=0;i&lt;nodes.length;i++){ console.log(nodes[i].innerHTML); }</code></pre> <h3 id="find">.find()</h3> <pre class="prettyprint"><code>$("#elem").find("#saves");</code></pre> <pre class="prettyprint"><code>function checkChildren(nodes, elemId){ for(i=0;i&lt;nodes.length;i++){ if(nodes[i].id==elemId){ return nodes[i]; }else{ return checkChildren(nodes[i].children, elemId); } } } nodes=document.getElementById("elem").children; checkChildren(nodes, "saves"); </code></pre> <h3 id="post">.post()</h3> <pre class="prettyprint"><code>$.post("http://subinsb.com/request.php", {"who" : "subin", "what" : "personalBelongings"}, function(data){ ย console.log(data); });</code></pre> <pre class="prettyprint"><code>xhr=new XMLHttpRequest(); xhr.open("POST", "http://subinsb.com/request.php", true); xhr.setRequestHeader("Content-type","application/x-www-form-urlencoded"); xhr.send("who=subin&what=personalBelongings"); xhr.onreadystatechange=function(){ if(xhr.readyState==4 && xhr.status==200){ console.log(xhr.responseText); } }</code></pre> <h3 id="get">.get()</h3> <pre class="prettyprint"><code>$.get("http://subinsb.com/request.php", {"who" : "subin", "what" : "personalBelongings"}, function(data){ console.log(data); });</code></pre> <pre class="prettyprint"><code>xhr=new XMLHttpRequest(); xhr.open("GET", "http://subinsb.com/request.php?who=subin&what=personalBelongings", true); xhr.send(); xhr.onreadystatechange=function(){ if(xhr.readyState==4 && xhr.status==200){ console.log(xhr.responseText); } }</code></pre> <h3 id="load">.load()</h3> <p>$(&quot;#loadTo&quot;).load(&quot;http://subinsb.com&quot;);</p> <pre class="prettyprint"><code>xhr=new XMLHttpRequest(); xhr.open("GET", "http://subinsb.com/request.php?who=subin&what=personalBelongings", true); xhr.send(); xhr.onreadystatechange=function(){ if(xhr.readyState==4 && xhr.status==200){ document.getElementById("loadTo").innerHTML = xhr.responseText; } }</code></pre> <h3 id="hide">.hide()</h3> <pre><code>$(&quot;#elem&quot;).hide(); document.getElementById(&quot;elem&quot;).style.display = &quot;none&quot;; </code></pre> <h3 id="show">.show()</h3> <pre class="prettyprint"><code>$("#elem").show();</code></pre> <pre class="prettyprint"><code>document.getElementById("elem").style.display = "block";</code></pre> <h3 id="toggle">.toggle()</h3> <pre class="prettyprint"><code>$("#elem").toggle();</code></pre> <pre class="prettyprint"><code>document.getElementById("elem").style.display = document.getElementById("elem").style.display=="block" ? "none":"block";</code></pre> <h3 id="remove">.remove()</h3> <pre class="prettyprint"><code>$("#elem").remove();</code></pre> <pre class="prettyprint"><code>document.getElementById("elem").remove();</code></pre> <h3 id="append">.append()</h3> <pre class="prettyprint"><code>$("#elem").append("I'm a good guy.");</code></pre> <pre class="prettyprint"><code>document.getElementById("elem").innerHTML += "I'm a good guy.";</code></pre> <h2 id="conclusion">Conclusion</h2> <p>As you can see, jQuery codes are very small compared to the JavaScript codes. But JavaScript takes less time to execute rather than jQuery. You can use jQuery if youโ€™re web page doesnโ€™t have a lot of codes. If youโ€™re web page has lot of codes in jQuery, then itโ€™s better if you change the codes to native JavaScript to increase page performance. Also, when you need to accomplish a small task, use JavaScript.</p> <p>More to come in the next part of this.</p> New Theme : Light, Simple & Fast https://subinsb.com/subins-blog-v1/ Mon, 31 Mar 2014 06:21:55 +0000 https://subinsb.com/subins-blog-v1/ <p>As you can see, I changed the theme of this blog with a new theme. If you have visited <a href="http://css-tricks.com" target="_blank">css-tricks.com</a>, you can see there are similarities to itโ€™s theme and mine. I really liked Chris Coyerโ€™s theme and I contacted him to lend me the theme. But, no response. So, I decided that I should create my own theme.</p> <p>By WordPress Support forum, I found <a href="http://underscores.me/" target="_blank">_s site</a>. Underscores provide a starter theme for WordPress. It can be downloaded, make changes as we like. I downloaded it and made it in to this awesome theme. Iโ€™m calling this themeย <strong>Subinโ€™s Blog V1</strong>.<figure id="attachment_2675" class="wp-caption aligncenter"></p> <p><a href="//lab.subinsb.com/projects/blog/uploads/2014/03/0112.png"><img class="size-full wp-image-2675" alt="Version 1 of Subin's Blog Theme" src="//lab.subinsb.com/projects/blog/uploads/2014/03/0112.png" width="1367" height="654" /></a><figcaption class="wp-caption-text">Version 1 of Subinโ€™s Blog Theme</figcaption></figure></p> <p>The Navigation menu is mixed with colors and it has a drop down with the same color as that of the parent navigation link.</p> <h1 id="features">Features</h1> <h2 id="responsive">Responsive</h2> <p>The theme was created to be responsive to all screen sizes. I donโ€™t have a smart phone, but when I resize the window itโ€™s adapting to the screen size. Here are some screenshots of the theme in different screen resolutions.<figure id="attachment_2676" class="wp-caption aligncenter"></p> <p><a href="//lab.subinsb.com/projects/blog/uploads/2014/03/0113.png"><img class="size-full wp-image-2676" alt="Mobile Display" src="//lab.subinsb.com/projects/blog/uploads/2014/03/0113.png" width="283" height="487" /></a><figcaption class="wp-caption-text">Mobile Display</figcaption></figure> <figure id="attachment_2677" class="wp-caption aligncenter"><a href="//lab.subinsb.com/projects/blog/uploads/2014/03/0114.png"><img class="size-full wp-image-2677" alt="On a 640x480 resolution" src="//lab.subinsb.com/projects/blog/uploads/2014/03/0114.png" width="640" height="481" /></a><figcaption class="wp-caption-text">On a 640ร—480 resolution</figcaption></figure></p> <p>ย <figure id="attachment_2678" class="wp-caption aligncenter"></p> <p><a href="//lab.subinsb.com/projects/blog/uploads/2014/03/0115.png"><img class="size-full wp-image-2678" alt="On a 1024x768 resolution" src="//lab.subinsb.com/projects/blog/uploads/2014/03/0115.png" width="1026" height="764" /></a><figcaption class="wp-caption-text">On a 1024ร—768 resolution</figcaption></figure></p> <h2 id="light">Light</h2> <p>The theme was created to be light. It has onlyย <strong>500</strong> lines ofย <strong>CSS</strong> code which is served compressed in the blog. The whole theme is of sizeย <strong>85 KB</strong> and most of the files in the theme is not used. So the actual size of theme is less than 85 KB.</p> <p>The theme doesnโ€™t cause any PHP errors as far as I tested. So, the error log is comparitevely small.</p> <h2 id="no-jquery">No jQuery</h2> <p>By default, WordPress loadsย <strong>jQuery</strong> on every pages. But, on this theme I have disabled the loading of jQuery because no component of the theme needs jQuery. Even the navigation drop down feature is made possible byย <strong>CSS</strong>. Widgets that uses jQuery was replaced with native JavaScript and due to this, page loads more fast.</p> <h2 id="fast">Fast</h2> <p>Pages using the theme loads comparitevely fast. According to the test ran using Pingdom, page loadsย <strong>98 % faster than all tested websites</strong>. You can see the full report <a href="http://tools.pingdom.com/fpt/#!/esX1M0/http://subinsb.com" target="_blank">here</a>.</p> <p>The page load time is less because there is no loading ofย <strong>jQuery</strong>,ย <strong>jQuery Migrate</strong> and other silly JavaScript files. Iโ€™m really happy with this theme. But there are some bugs in there somewhere. When I think itโ€™s all perfect, I may post the code on GitHub.</p> <h2 id="cross-browser-support">Cross Browser Support</h2> <p>I have tested the theme on different browsers. Almost all of the browsers give positive result as I expected. Firefox 9.0 didnโ€™t render the site properly probably because it doesnโ€™t supportย <strong>HTML 5</strong>. I havenโ€™t tested this on IE. But, why should I ? Who uses IE anymore ?</p> <h2 id="help">Help</h2> <p>If you found any flaws or problem with the theme, please please report it to me via comments or by sending an email to <a href="mailto:[email protected]">[email protected]</a></p> <p>Version 1 of Subinโ€™s Blog Theme</p> โ€˜return falseโ€™ vs โ€˜e.preventDefault()โ€™ In jQuery https://subinsb.com/jquery-return-false-vs-preventdefault/ Fri, 28 Mar 2014 06:23:08 +0000 https://subinsb.com/jquery-return-false-vs-preventdefault/ <p>I decided to add some improvements to Open and fix some bugs. While I was adding twoย <strong>submit</strong> listeners on a form, it didnโ€™t work. I have tried everything but still the problem came up. So, I removed <strong>return false;</strong> and usedย <strong>e.preventDefault();</strong>. It worked !</p> <p>So, why didnโ€™t theย <strong>submit</strong> listener called on the element ? The problem wasย <strong>return false</strong> will doย **e.stopPropagation()ย **andย <strong>e.preventDefault()</strong>. Ifย <strong>e.stopPropagation()</strong> is ran, then any other submit event handlers of the element wonโ€™t call. Hereโ€™s the 2 submit calls :</p> <pre class="prettyprint"><code>$(".postForm").on("submit", function(){ ย // do something ..... ย return false; }); $(".postForm").on("submit", function(){ // do something other than the first one });</code></pre> <p>When you submit the form, the 1st function will run successfully, but the 2nd one wonโ€™t run, becauseย <strong>return false;</strong> stops the calling of second function. If you rewrite the code by usingย <strong>e.preventDefault()</strong> like this :</p> <pre class="prettyprint"><code>$(".postForm").on("submit", function(e){ ย e.preventDefault(); ย // do something ..... }); $(".postForm").on("submit", function(){ // do something other than the first one });</code></pre> <p>ย </p> <p>It will call both functions without any problem. Now you know when to use <strong>return false;</strong> andย <strong>e.preventDefault();</strong>. A short summary :</p> <pre class="prettyprint"><code>return false; - calls e.preventDefault(); and e.stopPropagation(); e.preventDefault(); - e.preventDefault(); (Prevents the default action)</code></pre> <p>ย </p> <h2 id="external-resources">External Resources</h2> <p>You can see <a href="http://www.mail-archive.com/[email protected]/msg71371.html" target="_blank">the post</a> where jQuery creator John Resig tells about what return false does.</p> <p><a href="http://api.jquery.com/category/events/event-object/" target="_blank">jQuery Event Object</a></p> GOD Is Open Source https://subinsb.com/god-open-source/ Thu, 27 Mar 2014 17:03:36 +0000 https://subinsb.com/god-open-source/ <pre class="prettyprint"><code>This is just my opinion. Say what you think about this using the comments.</code></pre> <p>There are many many religions in the world and we are all part of a religion (or not). But, whatever the religion we are in, we all have a single GOD. A GOD who created atoms to the biggest mammal in Earth. All religions are just a path to GOD. Every religion points to GOD and whatever religion we choose, we all reach a single place. So, if GOD created all the things in universe, then he / she may have created the religions.</p> <pre class="prettyprint"><code>But, if GOD counted everyone as equal, then he won't waste time by creating religions.</code></pre> <p>Human beings created religion, not GOD. We all have to understand this fact.</p> <pre class="prettyprint"><code>If all religions have the same GOD, then we can say the religions are various releases of "path to GOD"</code></pre> <p>GOD created a religion, itโ€™s called <strong>null</strong> which meansย Itโ€™s not defined. GOD made his religion Open Source. Humans got the code and made changes as they like. Thus came religions like Christian, Muslim, Hindu and more and more. Humans still make religions by changing the code more. But, ultimately the code belongs to GOD. So, all religions are same. GOD is an Open Source supporter and software maker. His / Her Official Operating System is the Universe and the various components of the OS are the celestial bodies.</p> <p>If GOD is Open Source, why canโ€™t you be one ? Use Open Source Software, be Open Source and support Open Source. Here is a technological brief of what I mean :</p> <pre class="prettyprint"><code>GOD = A Kernel Religion = Operating Systems using the "GOD" Kernel The "GOD Kernel" is Open Source and anyone can use it. It is licensed under GPL Version 2 or more.</code></pre> Download Zip Files Dynamically in PHP https://subinsb.com/php-dynamic-download-zip-file/ Tue, 18 Mar 2014 17:38:16 +0000 https://subinsb.com/php-dynamic-download-zip-file/ <p>Zip file downloading is used by websites. The most important and popular of them isย <strong>WordPress</strong>. They use Zip files for downloading plugins, themes and even their versions. They do it ofcourse, dynamically. You just provide the location of the file and PHP will download it to the user for you. Actually HTTP headers have the main role in the downloading.</p> <div class="padlinks"> <a class="demo" href="http://demos.subinsb.com/php/download-zip/" target="_blank">Demo</a> </div> <p>We make the headers usingย <strong>header</strong> function in PHP and the browser will take care of the rest. The file path that you provide must be the absolute path. These are the two variables where you provide information about the Zip file :</p> <pre class="prettyprint"><code>$filename = "My Zip File Download.zip"; $filepath = "/var/www/subinsbdotcom/download_cdn/file.zip";</code></pre> <p>The download file name is stored in theย <strong>$filename</strong> variable and the file location is in theย <strong>$filepath</strong> variable.</p> <p>Now weโ€™re going to set the headers for making browser understand that this should be downloaded :</p> <pre class="prettyprint"><code>header("Pragma: public"); header("Expires: 0"); header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header("Cache-Control: public"); header("Content-Description: File Transfer"); header("Content-type: application/octet-stream"); header('Content-Disposition: attachment; filename="'.$filename.'"'); header("Content-Transfer-Encoding: binary"); header("Content-Length: ".filesize($filepath)); ob_end_flush(); @readfile($filepath);</code></pre> <p>When the user visits the page, the download will start. The downloaded file will be of the nameย <strong>My Zip File Download.zip</strong>. You can change the name by changing the value ofย <strong>$filename</strong>.</p> Google Hangouts Is Down https://subinsb.com/google-hangouts-down/ Mon, 17 Mar 2014 17:11:38 +0000 https://subinsb.com/google-hangouts-down/ <p>Again, one of Googleโ€™s service is down. This time itโ€™sย <strong>Google Hangouts</strong> also known before adย <strong>Google Talk</strong>. Google Sheets are down too.</p> <p>The downtime of these services started fromย <strong>17 March 9:45 PM IST</strong>. I noticed the Internal Server Errors when connecting to Google server by Pidgin messenger. I retried again and again, but the problem still poped up. I went to Twitter and found out, I wasnโ€™t the only one that experienced this problem.</p> <p>The Apps Status Dashboard of Google states that itโ€™s a know error with description :</p> <pre class="prettyprint"><code>We're investigating reports of an issue with Google Talk. We will provide more information shortly.</code></pre> <p>Letโ€™s hope it comes back up and doesnโ€™t happen again.</p> <h2 id="update">Update</h2> <p>Google Hangouts, Google Sheets, Google Talk has been restored atย <strong>18 March 12:58 AM IST</strong>.</p> Log In With Username / E-Mail in PHP Login System https://subinsb.com/php-log-in-with-username-email/ Mon, 17 Mar 2014 05:52:57 +0000 https://subinsb.com/php-log-in-with-username-email/ <p>If your login system have both username and email parameter, then you can allow your users to log in with username or email. This is very easy for users, because if they forget their username, then they can log in with their email address. I will tell you an easy to way to set up log in with both username and email. Itโ€™s very easy.</p> <div class="padlinks"> <a class="demo" href="http://demos.subinsb.com/php/username-email-login" target="_blank">Demo</a> </div> <p>A change in yourย <strong>SQL</strong> query can make this possible. Hereโ€™s how to do this.</p> <h2 id="change-your-login-form">Change Your Login Form</h2> <p>Since weโ€™re going to make login with both username and email possible, we have to change the username field name to <strong>Username / E-Mail</strong>.</p> <pre class="prettyprint"><code>&lt;label&gt;Username / E-Mail&lt;/label&gt; &lt;span style="line-height: 1.5em;">&lt;input type="text" name="login" /&gt;&lt;/span></code></pre> <p>We will use the name parameter asย <strong>login</strong> because we accept both email and username.</p> <p>If you are making a new login form, see <a title="Create MySQL Injection free Secure Login System in PHP" href="//subinsb.com/php-secure-login-system" target="_blank">this post on How to create a secure Login System</a>. The users table in the post have username column containing the email of user. Here is a proper user table with username column containing username and email column containing the email of user :</p> <pre class="prettyprint"><code>CREATE TABLE IF NOT EXISTS `users` ( `id` int(11) NOT NULL AUTO_INCREMENT, `username` text NOT NULL, `email` text NOT NULL, `password` text NOT NULL, `psalt` text NOT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;</code></pre> <p>The others are all same except the login form. You should change the name toย <strong>Username / E-Mail</strong> instead of justย <strong>E-Mail</strong>.</p> <h2 id="sql-query-change">SQL query Change</h2> <p>The login system should authorize if the user entered username or email. So we should change the SQL query like this :</p> <pre class="prettyprint"><code>SELECT id,password,psalt FROM users WHERE (username=:login OR email=:login) AND password=:pass</code></pre> <p>In PDO, we execute the above SQL query as :</p> <pre class="prettyprint"><code>$sql = $dbh-&gt;prepare("SELECT id,password,psalt FROM users WHERE (username=:login OR email=:login) AND password=:pass"); $sql-&gt;bindValue(":login", $_POST['login']); $sql-&gt;bindValue(":pass", $_POST['pass']); $sql-&gt;execute();</code></pre> <p>If youโ€™re using <a href="//subinsb.com/php-secure-login-system" target="_blank">this tutorial</a> to create the login system, change the code :</p> <pre class="prettyprint"><code>$sql=$dbh-&gt;prepare("SELECT id,password,psalt FROM users WHERE username=?"); $sql-&gt;execute(array($email)); while($r=$sql-&gt;fetch()){ $p=$r['password']; $p_salt=$r['psalt']; $id=$r['id']; }</code></pre> <p>to this code :</p> <pre class="prettyprint"><code>$sql = $dbh-&gt;prepare("SELECT id,password,psalt FROM users WHERE username=:login OR email=:login"); $sql-&gt;bindValue(":login", $_POST['login']); $sql-&gt;execute(array($email)); while($r=$sql-&gt;fetch()){ $p=$r['password']; $p_salt=$r['psalt']; $id=$r['id']; }</code></pre> <p>This will makeย <strong>MySQL</strong> to check columns that has the email or username value with what user entered.</p> How To Download & Extract Zip Archives in PHP https://subinsb.com/php-download-extract-zip-archives/ Sun, 16 Mar 2014 05:19:13 +0000 https://subinsb.com/php-download-extract-zip-archives/ <p>If you used WordPress before, you know that when you do plugin installation action, WordPress automatically downloads and extract the plugin zip file. If youโ€™re app needs something like this, you will find this post useful.</p> <p><strong>PHP</strong> has theย <strong>Zip Archive Extension</strong>. You can see the <a href="http://www.php.net/manual/en/zip.setup.php" target="_blank">php manual for installing ZipArchive Extension</a>. The usage of ZipArchive extension is very easy.</p> <h2 id="download">Download</h2> <p>For downloading, we will useย <strong>cURL</strong>. First we create a blank zip file, download the zip file from server and put itโ€™s contents to the blank zip file we created.</p> <pre class="prettyprint"><code>$url = "http://example.com/pathtozipfile.zip"; $zipFile = "folder/zipfile.zip"; // Local Zip File Path $zipResource = fopen($zipFile, "w"); // Get The Zip File From Server $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_FAILONERROR, true); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); curl_setopt($ch, CURLOPT_AUTOREFERER, true); curl_setopt($ch, CURLOPT_BINARYTRANSFER,true); curl_setopt($ch, CURLOPT_TIMEOUT, 10); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt($ch, CURLOPT_FILE, $zipResource); $page = curl_exec($ch); if(!$page) { echo "Error :- ".curl_error($ch); } curl_close($ch);</code></pre> <p>cURL will get the Zip archive file from url mentioned in the variableย <strong>$url</strong>. Theย <strong>$zipFile</strong> variable contain the local path of the file were weโ€™re going to save the Zip archive file.</p> <h2 id="extract-unzip">Extract (Unzip)</h2> <p>For extracting as we mentioned before, we will use the PHP Zip Archive Extension.</p> <p>Weโ€™ll make the class variable, open the Zip archive file and extract it :</p> <pre class="prettyprint"><code>/* Open the Zip file */ $zip = new ZipArchive; $extractPath = "path_to_extract"; if($zip-&gt;open($zipFile) != "true"){ echo "Error :- Unable to open the Zip File"; } /* Extract Zip File */ $zip-&gt;extractTo($extractPath); $zip-&gt;close();</code></pre> <p>The extract path should be mentioned in theย <strong>$extractPath</strong> variable. If any of the files exists, it will be overwritten or merged.</p> <p>If any of the above code doesnโ€™t work, check if the directory permission is set toย <strong>Read &amp; Write</strong> and if the problem still exists, please post a comment and I will be delighted to help you.</p> Get Absolute Directory Path of Current File in PHP https://subinsb.com/php-get-script-absolute-directory-path/ Sat, 15 Mar 2014 04:35:36 +0000 https://subinsb.com/php-get-script-absolute-directory-path/ <p>If your code is including other files, you will encounter problems like &quot;The file is not found&quot;. This is because, <strong>PHP</strong> doesnโ€™t know the absolute path of file. So, if you are including files on another file, you should mention the absolute path of file.</p> <p>But, If youโ€™re PHP application is being used by other people, then the absolute path which you mentioned in your system wonโ€™t be the one of the othersโ€™ systems. So, you have to dynamically mention the absolute path that will work on any systems.</p> <h2 id="example-of-problem">Example of Problem</h2> <p>Here is one of the case scenarios where you encounter theย <strong>include</strong> problem.</p> <p>Suppose, theย <strong>index.php</strong> file is including theย <strong>file1.php</strong> which is in theย <strong>inc</strong> directory :</p> <pre class="prettyprint"><code>&lt;? include("inc/file1.php"); ?&gt;</code></pre> <p>Theย <strong>inc</strong> directory also contains other files such asย <strong>file2.php</strong>,ย <strong>file3.php</strong>,ย <strong>file4.php</strong> etcโ€ฆโ€ฆ. If you want to include theย <strong>file2.php</strong> inย <strong>file1.php</strong> like below, it wonโ€™t work :</p> <pre class="prettyprint"><code>&lt;? include("file2.php"); ?&gt;</code></pre> <p>Inย <strong>file1.php</strong>, the root directory is that of <strong>index.php</strong>. Because we are including theย <strong>file1.php</strong> from <strong>index.php</strong> which is outside the directory.**</p> <p>**</p> <p>I think you understand the problem. Luckily, I have a solution that fixes this problem.</p> <h2 id="solution-of-problem">Solution of Problem</h2> <p>Since PHPย <strong>4.0.2</strong>,ย <strong>__FILE__</strong> returns the absolute path of the running script even if itโ€™s an include file. By giving theย <strong>__FILE__</strong> constant to theย <strong>dirname</strong>ย function, you will get the directory of the script. So, code inย <strong>file1.php</strong>ย would become :</p> <pre class="prettyprint"><code>&lt;? include(dirname(__FILE__)."/file2.php"); ?&gt;</code></pre> <p>The versionย <strong>5.3.0</strong> and itโ€™s later versions have a new constant calledย <strong>__DIR__</strong> which is the short way ofย <strong>dirname(__FILE__)</strong>. You can also use this in replacement of what we used earlier. Now code inย <strong>file1.php</strong> will become :</p> <pre class="prettyprint"><code>&lt;? include(__DIR__."/file2.php"); ?&gt;</code></pre> <p>You can see moreย <strong>PHP Magic Constants</strong> in <a href="http://www.php.net/manual/en/language.constants.predefined.php" target="_blank">this manual page</a>.</p> Check If A String Is JSON in PHP https://subinsb.com/php-check-if-string-is-json/ Sat, 08 Mar 2014 07:21:30 +0000 https://subinsb.com/php-check-if-string-is-json/ <p>In my previous post, I gave theย <strong>isHTML</strong> function that returns if a string is HTML or not. In this post, I will give you a simple function of different ways that helps in the detection of validย <strong>JSON</strong> string in <strong>PHP</strong>. The function Iโ€™m giving are fast, easy and doesnโ€™t take up too much CPU memory.</p> <div class="padlinks"> <a class="demo" href="http://demos.subinsb.com/php/isJSON" target="_blank">Demo</a> </div> <h2 id="method-1">Method 1</h2> <p><strong>JSON</strong> (JavaScript Object Notation) can be made in to a PHP object usingย <strong>json_decode</strong>. If the return is not an object, the string we gave is not JSON. This is the principal of Method 1 function.</p> <pre class="prettyprint"><code>function isJSON($string){ return is_string($string) && is_array(json_decode($string, true)) ? true : false; }</code></pre> <h2 id="method-2">Method 2</h2> <p>Requiresย PHP <strong>versions 5.3 or more</strong>.</p> <pre class="prettyprint"><code>function isJSON($string){ return is_string($string) && is_array(json_decode($string, true)) && (json_last_error() == JSON_ERROR_NONE) ? true : false; } </code></pre> <p>Method 2 does 3 checks for calculating if the string given to it isย <strong>JSON</strong>. So, it is the most perfect one, but itโ€™s slower than the other.</p> <h2 id="usage">Usage</h2> <p>If you have used any methods, the usage is the same.</p> <p>Checking when the string given is perfectly valid :</p> <pre class="prettyprint"><code>$string = '{"host" : "demos.subinsb.com"}'; if(isJSON($string)){ ย echo "It's JSON"; }</code></pre> <p>The above code when executed will echoesย <strong>Itโ€™s JSON</strong>.**</p> <p>**</p> <p>Checking when the string given is not valid :</p> <pre class="prettyprint"><code>$string = '{"host : "demos.subinsb.com"}do you think this is valid ?'; if(!isJSON($string)){ ย echo "Not JSON"; }</code></pre> <p>The above code when executed will printย <strong>Not JSON</strong>.</p> Check If A String Is HTML In PHP https://subinsb.com/php-check-if-string-is-html/ Sat, 08 Mar 2014 04:15:58 +0000 https://subinsb.com/php-check-if-string-is-html/ <p><strong>HTML</strong> detection can be hard, because HTML is complicated and there arenโ€™t any good 100% parsers for HTML. RegEx wonโ€™t help you in detection, so you need something else. The trick to identify HTML which Iโ€™m gonna show you is very easy. Itโ€™s fast, short and doesnโ€™t use RegEx. You can simply use an if statement to check if a string is HTML or not.</p> <div class="padlinks"> <a class="demo" href="http://demos.subinsb.com/php/isHTML/" target="_blank">Demo</a> </div> <p>PHPโ€™sย <strong>strip_tags</strong> function when given a string, it returns a string that doesnโ€™t have any HTML / PHP characters (<a href="http://in2.php.net/manual/en/function.strip-tags.php" target="_blank">according to the manual</a>). So, if we give a HTML string to <strong>strip_tags()</strong>, it strips out the HTML code from it and return a normal string.</p> <p>So, if the original value is the same as the return value ofย <strong>strip_tags()</strong>, then that string doesnโ€™t have any HTML code. Here is how you check if a string is HTML :</p> <pre class="prettyprint"><code>function isHTML($string){ if($string != strip_tags($string)){ // is HTML return true; }else{ // not HTML return false; } }</code></pre> <p>Or if you need a simple short function, use this code :</p> <pre class="prettyprint"><code>function isHTML($string){ return $string != strip_tags($string) ? true:false; }</code></pre> <p>Here are some usages of this function :</p> <pre class="prettyprint"><code>$html = "&lt;b&gt;subinsb.com is a programming blog&lt;/b&gt;"; if(isHTML($html)){ ย echo "It's HTML"; }</code></pre> <p>The above code will surely printย <strong>Itโ€™s HTML</strong> since the string we gave was HTML.</p> <pre class="prettyprint"><code>$notHTML = "subinsb.com is online for 3 years"; if(!is_HTML($notHTML)){ ย echo "Not HTML"; }</code></pre> <p>Note the false checking characterย &quot;!&quot; in the above code. Of course, it will printย <strong>Not HTML</strong> since the string we gave didnโ€™t had any HTML code in it.</p> Disable Cache For Web Development In Chrome https://subinsb.com/load-page-without-cached-resources-in-chrome/ Thu, 27 Feb 2014 14:28:50 +0000 https://subinsb.com/load-page-without-cached-resources-in-chrome/ <p>If youโ€™re developing a web page in Chrome and some changes you applied to code doesnโ€™t take effect on the page, you will be angry. You will look and look into the code for errors. But itโ€™s not the problem with your code. Itโ€™s the problem with the browser.</p> <p>The resources loaded on the page are cached. Hence the changes made to the code wonโ€™t be applied. So, you need some way to disable the cache. ย If you look around the Chrome Settings page, you will see an option โ€“ itโ€™sย <strong>Clear Browsing Data</strong>. If you do this, you will clear the entire cache. Even the website which you want the cache (like Facebook, Google +).</p> <p>There isnโ€™t any &quot;temporarily disable cache&quot; option in Chrome Settings. But there is one in the Developer Tools window. I will show you the way of disabling the cache temporarily in different Chrome versions.</p> <h2 id="versions-19--up">Versions 19 &amp; Up</h2> <p>Open the developer tools by using the key combinationย <strong>CTRL + SHIFT + I</strong>. In mac itโ€™sย <strong>COMMAND + OPTION + I</strong>.</p> <p>Click on the settings icon seen at the bottom right corner of the dev tools window.</p> <p>You can see theย <strong>Disable cache</strong> option. Check It. Now when you reload the page, any of the resources it loads wonโ€™t be cached.<figure id="attachment_2593" class="wp-caption aligncenter"></p> <p><a href="//lab.subinsb.com/projects/blog/uploads/2014/02/0108.png"><img class="size-full wp-image-2593" alt="Disable Cache In Chrome" src="//lab.subinsb.com/projects/blog/uploads/2014/02/0108.png" width="706" height="234" /></a><figcaption class="wp-caption-text">General Setting Page Of Chrome Dev Tools</figcaption></figure></p> <p>This temporary disable only works when the Dev Tools is opened.</p> <h2 id="versions-15-8211-18">Versions 15 โ€“ 18</h2> <p>In the versions between 15 &amp; 18, theย <strong>Disable cache</strong> option can be seen belowย <strong>Network</strong> :<figure id="attachment_2594" class="wp-caption aligncenter"></p> <p><a href="//lab.subinsb.com/projects/blog/uploads/2014/02/0109.png"><img class="size-full wp-image-2594" alt="Disable Cache In Chrome" src="//lab.subinsb.com/projects/blog/uploads/2014/02/0109.png" width="609" height="191" /></a><figcaption class="wp-caption-text">Disable Cache In Chrome Versions 15-18</figcaption></figure></p> <p>This temporary disable only works when the Dev Tools is opened.</p> <h2 id="versions-below-15">Versions below 15</h2> <p>There is another way which I donโ€™t know that it will work on all versions under 15. Open Developer Tools and click on theย <strong>Audits</strong> tab.</p> <p>Check theย <strong>Reload Page and Audit on Load</strong> option and click onย <strong>Run</strong>. The page will be reloaded without loading resources from cache memory :<figure id="attachment_2595" class="wp-caption aligncenter"></p> <p><a href="//lab.subinsb.com/projects/blog/uploads/2014/02/0110.png"><img class="size-full wp-image-2595" alt="Clear Cache for Page In Chrome" src="//lab.subinsb.com/projects/blog/uploads/2014/02/0110.png" width="706" height="314" /></a><figcaption class="wp-caption-text">Clear Cache for Page In Chrome using Audit</figcaption></figure></p> <p>The only problem with this is that it will only load uncached content of the domain where dev tools. is opened. In the above case itโ€™sย <strong><a href="http://subinsb.com">http://subinsb.com</a></strong>.</p> <h2 id="other-ways">Other ways</h2> <p>This is an easy way. Open Dev Tools and right click or hold left clicking the reload button. A small window will be opened and you can choose the type of reload you want. Click theย <strong>Hard Reload</strong> option.<figure id="attachment_2598" class="wp-caption aligncenter"></p> <p><a href="//lab.subinsb.com/projects/blog/uploads/2014/02/0111.png"><img class="size-full wp-image-2598" alt="Reload Without Cache In Chrome" src="//lab.subinsb.com/projects/blog/uploads/2014/02/0111.png" width="364" height="110" /></a><figcaption class="wp-caption-text">Reload Without Cache In Chrome easiest way</figcaption></figure></p> <p>You can also use the key combinationย <strong>SHIFT + CTRL + R</strong> to reload page without cache.</p> <p>So, which method worked for you ?</p> 9th Grade Is Over :-( https://subinsb.com/bye-bye-grade-9/ Wed, 26 Feb 2014 12:39:47 +0000 https://subinsb.com/bye-bye-grade-9/ <p>Today marks the end of 9th grade in my school life. Itโ€™s been a wonderful journey with a lot of laughs and seriousness. Got nice grades in the exams and all ends well &amp; happy. Today, my classmates went wild. We celebrated and celebrated until the window was broken. The student who didnโ€™t break the window with consciousness got beat up by the principal. It was painful to watch and hear his screaming.</p> <p>Today was a great day and also a bad day. One of my classmates cried and others tried their best to make the final day of 9th grade fun and happier. Like students, teachers were also in a good mood today. Everyone was happy and we communicated together like friends.</p> <p>Maths teacher asked us to introduce puzzles for solving in class. Recently while I was surfing through StackOverflow, I read <a href="http://math.stackexchange.com/questions/675522/whats-the-intuition-behind-pythagoras-theorem" target="_blank">this StackExchange Maths Question</a> of Pythagorusโ€™ Theorem and it helped me ask it as a puzzle. Nobody got the answer and I had to explain it myself which made me understand more about it :<figure class="wp-caption aligncenter"></p> <p><img alt="Pythagorus' Theorem With Relation Of Squares" src="https://i.stack.imgur.com/POhH1.png" width="400" height="205" /><figcaption class="wp-caption-text">Pythagorusโ€™ Theorem With Relation Of Squares</figcaption></figure> <figure class="wp-caption aligncenter"><img alt="Animation Showing relation between Pythagorus' theorem and Square Area" src="http://i.stack.imgur.com/VqNSK.gif" width="251" height="231" /><figcaption class="wp-caption-text">Animation Showing relation between Pythagorusโ€™ theorem and Square Area</figcaption></figure></p> <p>Tomorrow, Friday and Monday are holidays for studying. But I wouldnโ€™t open my book until Saturday / Sunday. Probably because of the laziness.</p> <p>Now, I only have a year left in my school life โ€“ the 10th grade. Iโ€™m very sad right now. Where did all my years go ? I really hope someone invent a Time Machine, so that I could recover my lost years when I thought school was s***. But, now I understand that school is a real blessing that you wonโ€™t get back in life. So, I have to enjoy my last year as I can.</p> <p>As any 9th graders would think, this year went on too fast. Everything was going on way too fast. I still remember the first time I entered in to the class on June 2013. Now, itโ€™s 2014 and there goes everything.</p> <p>This year was so awesome that I wrote a post about it on my blog unlike the previous years. There were so many memories and I wonโ€™t forget at all. Thank you and this journey was awesome. I hope next year would too become as fun and awesome as this year.</p> <p>Since my exams are coming, I wonโ€™t be able to publish posts like before. Sorryโ€ฆ</p> Disable jQuery Migrate Loading In WordPress Blog https://subinsb.com/remove-jquery-migrate-in-wp-blog/ Sun, 23 Feb 2014 17:09:31 +0000 https://subinsb.com/remove-jquery-migrate-in-wp-blog/ <p>If you run a WordPress blog with all the new stuff (functions) and still WordPress loads the <strong>jQuery Migrate</strong> on your blog, you will be angry (I know hot it feels). The jQuery Migrate fileโ€™s minified version is aboutย <strong>7 KB</strong> and the unminified version is aboutย <strong>17 KB</strong>. Thatโ€™s a file you donโ€™t need if your blogโ€™s jQuery functions arenโ€™t deprecated.</p> <h2 id="what8217s-jquery-migrate-">Whatโ€™s jQuery Migrate ?</h2> <p>jQuery Migrate is a JavaScript file that adds the jQueryย deprecated functions to the page which makes us to use the deprecated functions of jQuery.</p> <h2 id="do-i-need-it-">Do I Need It ?</h2> <p>It depends on the jQuery code youโ€™re using on your blog. If you use the deprecated functions, you need jQuery Migrate. If youโ€™re not and is pretty sure that none of the plugins you installed is using it, you can move on to the next part of post.</p> <h2 id="know-if-blog-has-deprecated-functions">Know If Blog Has Deprecated Functions</h2> <p>The hardest way is to got to jQuery docs, find functions one by one and look for it in your code. This <a href="http://stackoverflow.com/a/14386696/1372424" target="_blank">SO answer</a> has a great info on deprecated functions.</p> <p>Another way is to first remove jQuery migrate and check the browser console for any jQuery errors. If there is an error saying something like this :</p> <pre class="prettyprint"><code>ReferenceError: foo is not defined</code></pre> <p>then there is a depreciated function in your code. You can find it and remove or you can stop this tutorial itself.</p> <h2 id="remove-jquery-migrate">Remove jQuery Migrate</h2> <p>Finally, letโ€™s remove jQuery Migrate. Go to your themesโ€™ย <strong>functions.php</strong> file and add the following code at the end of the file :</p> <pre class="prettyprint"><code>/* No JQ Migrate - http://subinsb.com/remove-jquery-migrate-in-wp-blog */ add_filter( 'wp_default_scripts', 'removeJqueryMigrate' ); function removeJqueryMigrate(&$scripts){ if(!is_admin()){ $scripts-&gt;remove('jquery'); $scripts-&gt;add('jquery', false, array('jquery-core'), '1.10.2'); } }</code></pre> <p>Save the file and close. Now, go to your blog and there wonโ€™t be anyย <strong>jQuery Migrate</strong> file loaded in the page. You just savedย <strong>7 KB</strong>.</p> Posting Code Blocks On WordPress https://subinsb.com/posting-code-blocks-on-wordpress/ Fri, 21 Feb 2014 16:54:44 +0000 https://subinsb.com/posting-code-blocks-on-wordpress/ <p>If youโ€™re a web developer or a programmer and have a programming blog set up in WordPress, you will find it difficult to include codes in the posts. There is no tool in the Visual Editor toolbar menu to automatically wrap a piece of code into a code block.</p> <p>So you have to manually go to theย <strong>Text</strong> version of the post and add the code in <strong>HTML</strong>ย <strong>&lt;pre&gt;</strong> orย <strong>&lt;code&gt;</strong> tag or insideย <strong>&lt;pre&gt;&lt;code&gt;&lt;/code&gt;&lt;/pre&gt;</strong>. As you can see there are different ways to embed codes in your post. So, why not add a tool that satisfies this. Iโ€™m very happily introducing theย <strong>Code Blocks Plugin</strong>, an easy plugin that adds aย <strong>Code Block</strong> tool in the toolbox ofย <strong>Visual</strong> editor andย <strong>Text</strong> editor.</p> <div class="padlinks"> <a class="download" href="http://demos.subinsb.com/WordPress/code-blocks.zip" target="_blank">Download</a> </div> <p>You can also use this plugin to addย <strong>Custom CSS</strong> to Visual Editor of WordPress.</p> <h2 id="configure">Configure</h2> <p>You can access the Configuration Page fromย <strong>Posts</strong> -&gt;ย <strong>Code Blocks</strong>.</p> <p>Under theย <strong>Display</strong> section you can choose where to display the Code Block button.</p> <p>Theย <strong>Content</strong> section can be used to mention the starting code and ending code of the code block :<figure id="attachment_2531" class="wp-caption aligncenter"></p> <p><a href="//lab.subinsb.com/projects/blog/uploads/2014/02/0105.png"><img class="size-medium wp-image-2531" alt="Configure Code - Code Blocks" src="//lab.subinsb.com/projects/blog/uploads/2014/02/0105-300x117.png" /></a><figcaption class="wp-caption-text">Configure Code โ€“ Code Blocks</figcaption></figure></p> <p>If you would like to add <strong>Custom CSS</strong> to the Visual Editor, use the textarea in theย <strong>Custom CSS</strong> section. By default, the plugin add styles to code tag of pre.<figure id="attachment_2532" class="wp-caption aligncenter"></p> <p><a href="//lab.subinsb.com/projects/blog/uploads/2014/02/0106.png"><img class="size-medium wp-image-2532" alt="Custom CSS To WordPress Visual Editor" src="//lab.subinsb.com/projects/blog/uploads/2014/02/0106-300x75.png" width="300" height="75" /></a><figcaption class="wp-caption-text">Custom CSS To WordPress Visual Editor</figcaption></figure></p> <p>If you are making a code inserted as paragraph in your WordPress post and is making that in to a Code Block, then the Paragraph tags will enter into the code block. This might increase the distance between lines of the code. If you donโ€™t want that, tick the <strong>Remove Paragraph</strong> option :<figure id="attachment_2533" class="wp-caption aligncenter"></p> <p><a href="//lab.subinsb.com/projects/blog/uploads/2014/02/0107.png"><img class="size-medium wp-image-2533" alt="Other Settings - Code Blocks" src="//lab.subinsb.com/projects/blog/uploads/2014/02/0107-300x124.png" width="300" height="124" /></a><figcaption class="wp-caption-text">Other Settings โ€“ Code Blocks</figcaption></figure></p> <p>The icon of the tool in Visual Editor is :</p> <p>&lt;//subinsb.com/uploads/2017/10/codeblocks-tool-icon.png&gt;</p> <p>Thatโ€™s all the configuration of Code Blocks. Hope you like this plugin. If you liked it, <a title="Donate" href="//subinsb.com/donate" target="_blank">please donate</a>.</p> <p>If you need help, use the <a title="Code Blocks" href="//subinsb.com/ask/code-blocks" target="_blank">Code Blocks</a> plugin page.</p> Donate https://subinsb.com/donate/ Thu, 20 Feb 2014 18:13:53 +0000 https://subinsb.com/donate/ <p>To keep my site and <a href="https://subinsb.com/projects">projects</a> up and running, there are costs. As a full-time college student, I work on projects in my free time.</p> <p>So, please consider a donation for my future projects and the maintenance of all my sites &amp; <a href="https://subinsb.com/projects">projects</a>.</p> <p>If you would like to mention your website or a message to display on this page, please <a href="https://subinsb.com/contact">send them to me</a> after donation. Every donation will be publicly mentioned here, if you'd like not to, please do contact after.</p> <h2 id="upi">UPI</h2> <p>You can send Indian UPI payments to <code>ssiby@fbl</code> (no transaction fees).</p> <div class="padlinks"> <a class="demo href="upi://pay?pa=ssiby@fbl&pn=Subin%20Siby">Donate to ssiby@fbl</a> </div> <h2 id="paypal">PayPal</h2> <p>You can send PayPal payments to <code>subins2000 [at] gmail [dot] com</code> (PayPal fees applicable) :</p> <div class="padlinks"> <a class="demo" href="https://www.paypal.me/SubinSiby">Donate Via PayPal</a> <!-- <br/><br/> <div class="download"> <form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top"> <input type="hidden" name="cmd" value="_s-xclick"> <input type="hidden" name="hosted_button_id" value="TXLUHEULFHWYN"> <input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif" border="0" name="submit" alt="PayPal โ€“ The safer, easier way to pay online!"> <img alt="" border="0" src="https://www.paypalobjects.com/en_GB/i/scr/pixel.gif" width="1" height="1"> </form> </div> --> </div> <h2 id="liberapay">Liberapay</h2> <p>If you would like to support me with recurring payments, I'm on Liberapay. Liberapay is like Patreon.</p> <div class="padlinks"> <a class="demo" href="https://liberapay.com/subins2000">Liberapay</a> </div> <h2 id="donations">Donations</h2> <p>Thank you very much to all the people who have supported me, this site and projects through donations. ๐Ÿ™‚ โค๏ธโค๏ธ</p> <table> <thead> <tr> <td> <h2><a href="#date"><span id="date">Date</span></a></h2> </td> <td> <h2><a href="#name-btc-address"><span id="name-btc-address">Name / BTC Address</span></a></h2> </td> <td> <h2><a href="#amount"><span id="amount">Amount</span></a></h2> </td> </tr> </thead> <tbody> <tr> <td>2020/08/25</td> <td>Fletcher Amelioration</td> <td>10 USD</td> </tr> <tr> <td>2019/03/07</td> <td>Clyde Summers</td> <td>50 GBP</td> </tr> <tr> <td>2019/03/07</td> <td>Christine Mann</td> <td>10 USD</td> </tr> <tr> <td>2017/02/18</td> <td>Yves Monsel</td> <td>5 EUR</td> </tr> <tr> <td>2017/02/14</td> <td>David Clifford</td> <td>10 USD</td> </tr> <tr> <td>2017/02/9</td> <td>Josรฉ Marรญa Montabes</td> <td>3 USD</td> </tr> <tr> <td>2017/02/01</td> <td>Guidi Egnon</td> <td>20 EUR</td> </tr> <tr> <td>2017/01/05</td> <td>Bruce Robertson</td> <td>25 USD</td> </tr> <tr> <td>2016/12/31</td> <td>Alexander Jankuv</td> <td>5 USD</td> </tr> <tr> <td>2016/09/01</td> <td>Sang Ho</td> <td>5 USD</td> </tr> <tr> <td>2016/07/05</td> <td>Aristide Sere</td> <td>4 USD</td> </tr> <tr> <td>2016/07/02</td> <td><a href="https://www.myetv.tv/" target="_blank">Oscar Cosimo</a></td> <td>10 USD</td> </tr> <tr> <td>2016/06/22</td> <td><a href="http://lisbonbookings.com/" target="_blank">Joshua Anderson</a></td> <td>100 USD</td> </tr> <tr> <td>2016/01/10</td> <td><a href="https://www.myetv.tv/" target="_blank">Oscar Cosimo</a></td> <td>10 USD</td> </tr> <tr> <td>2015/09/19</td> <td><a href="http://hawkeye.net/" target="_blank">Thomas Haberland</a></td> <td>30 USD</td> </tr> <tr> <td>2015/09/12</td> <td>Templaty</td> <td>10 USD</td> </tr> <tr> <td>2015/07/12</td> <td><a href="http://lisbonbookings.com/" target="_blank">Milton Taft</a></td> <td>50 USD</td> </tr> <tr> <td>2015/06/08</td> <td>Piotr Mrzygล‚owski</td> <td>1 USD</td> </tr> <tr> <td>2015/04/20</td> <td>Omega4</td> <td>10 USD</td> </tr> <tr> <td>2015/02/26</td> <td>Brian Brock</td> <td>30 USD</td> </tr> <tr> <td>2014/06/14</td> <td>Brazil365</td> <td>5 USD</td> </tr> <tr> <td>2014/05/20</td> <td>David Moore</td> <td>20 USD</td> </tr> <tr> <td>2014/05/09</td> <td><a href="http://levlaz.blogspot.com/" target="_blank">Lev Lazinskiy</a></td> <td>20 USD</td> </tr></tbody> </table> WhatsApp Acquired By Facebook For $19 Billion https://subinsb.com/whatsapp-acquired-facebook-19-billion/ Thu, 20 Feb 2014 16:24:34 +0000 https://subinsb.com/whatsapp-acquired-facebook-19-billion/ <p>The giant mobile messaging serviceย <strong>WhatsApp</strong> has been acquired byย social network giantย <strong>Facebook</strong> forย <strong>19</strong>ย billion US dollars. This is the biggest acquisition by Facebook in their 10 years. Facebook is making itโ€™s way to enter the mobile communication world.</p> <p><a href="//lab.subinsb.com/projects/blog/uploads/2014/02/0104.png"><img class="aligncenter size-full wp-image-2521" alt="0104" src="//lab.subinsb.com/projects/blog/uploads/2014/02/0104.png" width="210" height="61" /></a></p> <p>The acquisition will make the WhatsApp CEO a billionare. This acquisition will make benefit to both WhatsApp and Facebook. Both companiesโ€™ CEO has been in discussions for 2 years. And the time has come for WhatsApp to sell to Facebook.</p> <p>By this acquisition Facebook is getting more users in which there is a great number of young people. The employees of WhatsApp will have restricted stock units to vest over 4 years following the closing of the deal. WhatsApp C.E.Oย <strong>Jan Koum</strong> will be joining the Facebook board of directors.</p> <p>There has been reports that Google tried to buy WhatsApp (<a href="http://tech.fortune.cnn.com/2014/02/20/google-whatsapp-10-billion" target="_blank">link</a>). This report is not yet verified. But there is a chance of Google trying to buy WhatsApp. Facebook &amp; WhatsApp will totally be benefited by this acquisition.</p> <p>In my opinion, WhatsApp shouldnโ€™t be sold. More people would have joined WhatsApp in a few more years when mobile becomes the most used device in the world. Itโ€™s a real shame that WhatsApp has been sold. On an emerging era of mobile phones, products like WhatsApp have a great chance in the market. If the C.E.O Jan Koum didnโ€™t sell WhatsApp, he would have got more thatย **$**<strong>16</strong> billion byย <strong>2020</strong>.</p> <p>A very bad decision by WhatsApp. Jan Koum should have played the game likeย <strong>Mark Zuckerberg</strong> by not selling the company even ifย <strong>Microsoft</strong>ย comes to buy.</p> <p>PS : I have never used WhatsApp.</p> Configure WordPress To Not Use FTP To Do Stuff https://subinsb.com/wordpress-no-ftp/ Tue, 18 Feb 2014 14:04:23 +0000 https://subinsb.com/wordpress-no-ftp/ <p>By default, if you want to install plugins or upgrade WordPress, you have to provide the <strong>FTP</strong> details. If you are running WordPress on localhost, you wonโ€™t have the FTP credentials. In this case you wonโ€™t be able to install plugins or upgrade WordPress. There is a way to configure WP to donโ€™t use FTP, instead install directly using theย <strong>Read/Write</strong> permission of folder.</p> <p>If WordPress canโ€™t install anything without FTP, it needs another method โ€“ direct install. WP will download the required files in aย <strong>ZIP</strong> archive format, extract it to the plugins directory. But WP canโ€™t just move/copy files to a directory of your WP root with out permissions. So you have to change the permissions of your WP root.</p> <h2 id="set-write-permission">Set Write Permission</h2> <p>WP root directory should have theย <strong>Write</strong> permission. You can set the write permission by applying theย <strong>0777</strong>ย permission to the directory. Onย <strong>Linux</strong> system, you can do this with the following command :</p> <pre class="prettyprint"><code>chmod 0777 /path/to/wordpress-installation</code></pre> <p>As you can see, you have to mention the WP installation directory location. By doing the above command, the WP folderโ€™s permissions would have <strong>Write</strong>.</p> <h2 id="configure-wp-to-not-use-ftp">Configure WP To Not Use FTP</h2> <p>The configuration file of WP isย <strong>wp-config.php</strong>, so any settings we are going to set should be in theย <strong>wp-config.php</strong> file. The &quot;No FTP&quot; setting should also be in this file.</p> <p>Open your WP location. Open theย <strong>wp-config.php</strong> file using a text editor. Add the following code at the end of the file :</p> <pre class="prettyprint"><code>/* No FTP : http://subinsb.com/wordpress-no-ftp */ define('FS_METHOD','direct');</code></pre> <p>Save the file and close the text editor.</p> <p>Now, try installing a plugin or removing a plugin. WordPress wonโ€™t bother you anymore with FTP details form.</p> Make A Blank Template / HTML Page In Blogger https://subinsb.com/make-a-blank-blogger-template/ Sun, 16 Feb 2014 04:54:10 +0000 https://subinsb.com/make-a-blank-blogger-template/ <p>Blogger Templates can be very messed up with lots and lots of code. If you are trying to create a Blogger Template from scratch, the first thing you need is a blank HTML page. Thatโ€™s exactly what we are going to do today.</p> <div class="padlinks"> <a class="demo" href="http://subinsb-blank.blogspot.com/" target="_blank">Demo</a> </div><figure id="attachment_2500" class="wp-caption aligncenter"> <p><a href="//lab.subinsb.com/projects/blog/uploads/2014/02/0103.png"><img class="size-medium wp-image-2500" src="//lab.subinsb.com/projects/blog/uploads/2014/02/0103-300x212.png" alt="Simple Template To Blank Page" width="300" height="212" /></a><figcaption class="wp-caption-text">Blogger Simple Template To Blank Page</figcaption></figure></p> <h2 id="criterias">Criterias</h2> <p>Blogger wonโ€™t allow you to just add the following code as template :</p> <pre class="prettyprint"><code>&lt;html&gt; &lt;head&gt; &lt;title&gt;My Awesome Blank Blog&lt;/title&gt; &lt;/head&gt; &lt;body&gt; &lt;/body&gt; &lt;/html&gt;</code></pre> <p>They will print out errors if you try to save the template. There are certain criteria for making a template for Blogger Blog :</p> <ol> <li>There must beย skin (&lt;b:skin&gt;&lt;/b:skin&gt;) in the template</li> <li>A template must have at least one b:section tag</li> <li>Every section should have a unique id.</li> <li>Correct Syntax</li> </ol> <p>If the above criterias are met, Blogger wonโ€™t produce any errors when saving the template. For creating a blank HTML Template, we will make sure these criterias are met.</p> <h2 id="contents-of-blogger-blank-template">Contents Of Blogger Blank Template</h2> <p>As we said before, Blogger Templates should meet the criterias of Blogger. A Blank Blogger Template should contain the following :</p> <ol> <li>Basic HTML Page Tags (html, head, body) and their closings</li> <li>Only one <strong>&lt;b:skin&gt;&lt;/b:skin&gt;</strong> tag</li> <li>Need At least aย <strong>&lt;b:section&gt;&lt;/b:section&gt;</strong> tag.</li> </ol> <h2 id="create-template">Create Template</h2> <p>Make sure your blog is using Simple Template. If not, apply Simple Template to your blog.</p> <p>Go to yourย **Blogger Blogย **-&gt;ย <strong>Template</strong> and click onย <strong>Edit HTML</strong> button. Remove the contents of Template.</p> <p>We will now add the Basic HTML page to the Template :</p> <pre class="prettyprint"><code>&lt;?xml version="1.0" encoding="UTF-8" ?&gt; &lt;html xmlns='http://www.w3.org/1999/xhtml' xmlns:b='http://www.google.com/2005/gml/b' xmlns:data='http://www.google.com/2005/gml/data' xmlns:expr='http://www.google.com/2005/gml/expr'&gt; &lt;head&gt; &lt;/head&gt; &lt;body&gt; &lt;/body&gt; &lt;/html&gt;</code></pre> <h3 id="head">Head</h3> <p>The contents of theย <strong><head>&lt;/head</strong>**&gt;** tag are the title, skin and other elements. We should add the normal codes that are seen on Blogger Templates first :</p> <pre class="prettyprint"><code>&lt;meta content='IE=EmulateIE7' http-equiv='X-UA-Compatible'/&gt; &lt;b:if cond='data:blog.isMobile'&gt; &lt;meta content='width=device-width,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0' name='viewport'/&gt; &lt;b:else/&gt; &lt;meta content='width=1100' name='viewport'/&gt; &lt;/b:if&gt; &lt;b:include data='blog' name='all-head-content'/&gt;</code></pre> <p>Add the title :</p> <pre class="prettyprint"><code>&lt;title&gt;&lt;data:blog.pageTitle/&gt;&lt;/title&gt;</code></pre> <p>Add the Skin with basic CSS that can be changed using Bloggerโ€™s Template Designer :</p> <pre class="prettyprint"><code>&lt;b:skin&gt; &lt;![CDATA[/* body { font: $(body.font); color: $(body.text.color); background: $(body.background); padding: 0 $(content.shadow.spread) $(content.shadow.spread) $(content.shadow.spread); $(body.background.override) margin: 0; padding: 0; } ]]&gt; &lt;/b:skin&gt;</code></pre> <p>There are more styles that can be inserted inย <strong>&lt;b:skin&gt;</strong>, but only bodyโ€™s is mentioned here. By adding more style rules into it, you will be easily able to update the colors, background etcโ€ฆ from the Template Designer.</p> <p>There are additional <strong>CSS</strong> files that are loaded by Blogger beforeย <strong>&lt;b:skin&gt;</strong>. If you want to disable that, see <a title="Disable Blogger Official CSS From Loading In Template" href="//subinsb.com/disable-blogger-official-css-loading" target="_blank">this post</a>.</p> <h3 id="body">Body</h3> <p>Blogger needs aย **&lt;b:section&gt;ย **element in template. So, we should add it inside body.</p> <pre class="prettyprint"><code>&lt;b:section id='main' showaddelement='yes'/&gt;</code></pre> <p>This section is the main section of the blog where we can add gadgets to it.</p> <h2 id="the-whole-code">The Whole Code</h2> <p>And the whole Template code would be :</p> <pre class="prettyprint"><code>&lt;?xml version="1.0" encoding="UTF-8" ?&gt; &lt;html xmlns='http://www.w3.org/1999/xhtml' xmlns:b='http://www.google.com/2005/gml/b' xmlns:data='http://www.google.com/2005/gml/data' xmlns:expr='http://www.google.com/2005/gml/expr'&gt; &lt;head&gt; &lt;meta content='IE=EmulateIE7' http-equiv='X-UA-Compatible'/&gt; &lt;b:if cond='data:blog.isMobile'&gt; &lt;meta content='width=device-width,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0' name='viewport'/&gt; &lt;b:else/&gt; &lt;meta content='width=1100' name='viewport'/&gt; &lt;/b:if&gt; &lt;b:include data='blog' name='all-head-content'/&gt; &lt;title&gt;&lt;data:blog.pageTitle/&gt;&lt;/title&gt; &lt;b:skin&gt; &lt;![CDATA[/* body { font: $(body.font); color: $(body.text.color); background: $(body.background); padding: 0 $(content.shadow.spread) $(content.shadow.spread) $(content.shadow.spread); $(body.background.override) margin: 0; padding: 0; } ]]&gt; &lt;/b:skin&gt; &lt;/head&gt; &lt;body&gt; &lt;b:section class='main' id='main' showaddelement='yes'/&gt; &lt;!-- Please Keep The Credits --&gt; &lt;center&gt;&lt;a href="//subinsb.com/make-a-blank-blogger-template"&gt;Blank Template By subinsb.com&lt;/a&gt;&lt;/center&gt; &lt;/body&gt; &lt;/html&gt;</code></pre> <h2 id="additional-code-adding">Additional Code adding</h2> <ul> <li>Add additional CSS codes insideย <strong>&lt;b:skin&gt;&lt;/b:skin&gt;</strong></li> <li>Add JavaScript codes beforeย <strong></head></strong> or afterย <strong><head></strong></li> <li>Add HTML codes (widgets, code) inside <strong><body></strong>.</li> <li>You can do all the stuff in this template just like you do it aย <strong>HTML</strong>ย page.</li> </ul> <p>If you want to display the Posts, add the following code insideย <strong>&lt;b:section&gt;&lt;/b:section&gt;</strong> in body :</p> <pre class="prettyprint"><code>&lt;b:widget id='Blog1' locked='true' title='Blog Posts' type='Blog'/&gt;</code></pre> <p>Example :</p> <pre class="prettyprint"><code>&lt;b:section class='main' id='main' showaddelement='yes'&gt; ย  &lt;b:widget id='Blog1' locked='true' title='Blog Posts' type='Blog'/&gt; &lt;/b:section&gt;</code></pre> <p>Save your template and check out your blog. You will now have a plain blank Blog.</p> Disable Blogger Official CSS From Loading In Template https://subinsb.com/disable-blogger-official-css-loading/ Sat, 15 Feb 2014 16:45:20 +0000 https://subinsb.com/disable-blogger-official-css-loading/ <p>Blogger adds theirย <strong>CSS</strong> styles to every templates. These filesโ€™ load time will make your site slow. So for a better user experience, Bloggerย CSS files should be removed. But there isnโ€™t any Settings page for this. Blogger automatically add itโ€™s style sheets. But you can disable the loading with a simple hack.</p> <h2 id="blogger-style-sheets">Blogger Style Sheets</h2> <p>The Blogger CSS files are these :</p> <pre class="prettyprint"><code>https://www.blogger.com/static/v1/widgets/4219271310-widget_css_2_bundle.css https://www.blogger.com/static/v1/widgets/1937454905-widget_css_bundle.css https://www.blogger.com/static/v1/widgets/3160349130-widget_css_2_bundle.css </code></pre> <p>Whenย <strong>Blogger</strong> updates, the above URLโ€™s will also change. Thus page load increases.</p> <h2 id="warning">Warning</h2> <p>The Blogger CSS files contain the styles of Blogger Native Widgets. If you are using a Blogger Made Template and disable the Style Sheet loading, your site will look ugly. Use this hack only if your blog is using a custom template.</p> <h2 id="how-">How ?</h2> <p>The CSS loading &quot;<link>&quot; tags will appear on the source code of your blog, but wonโ€™t be loaded by browsers, because it is wrapped inย <strong>HTML Comment</strong> tag. Browsers ignore the HTML markup inside the comments. So, the Blogger CSS files wonโ€™t be loaded.</p> <h2 id="disable-loading-in-template">Disable Loading In Template</h2> <p>Go to your <strong>Blogger Blog -&gt; Template -&gt; Edit HTML</strong></p> <p>Search for &quot;&lt;b:skin&gt;&quot; in the Template Code using your browser Find Tool (CTRL + F). Move the contents of the &quot;&lt;b:skin&gt;&quot; to &quot;&lt;/b:skin&gt;&quot; element to a file. Now, replace the &quot;&lt;b:skin&gt;&lt;/b:skin&gt;&quot; code with the following :</p> <pre class="prettyprint"><code>&lt;style&gt;&lt;!--/*&lt;b:skin&gt;&lt;![CDATA[*/]]&gt;&lt;/b:skin&gt;</code></pre> <p>After replacing search for the &quot;</head>&quot; element. Before it add the following code :</p> <pre class="prettyprint"><code>&lt;style&gt;&lt;/style&gt;</code></pre> <p>Copy the code that we moved to a file and paste it after &quot;<style>&quot; in the above code.</p> <p>Save the Template.</p> <h2 id="did-it-work-">Did It Work ?</h2> <p>Now, we should check if it worked on your blog. So, go to your blog address, right click on an empty space and choose the &quot;View Page Source&quot; option from the right click context menu Or use the CTRL + U keyboard shortcut.</p> <p>Search for the following code :</p> <pre class="prettyprint"><code>&lt;style&gt;&lt;!---/*</code></pre> <p>If you found the code above and it is highlighted in black/gray color, then you have successfully disabled the Blogger CSS loading.</p> How To Add Disqus Recent Comments Widget https://subinsb.com/add-disqus-recent-comments-widget/ Wed, 12 Feb 2014 14:58:42 +0000 https://subinsb.com/add-disqus-recent-comments-widget/ <p>In the last post, I told the way to implement Disqus Combination widget to your web site which have recent comments, popular threads and commented users, all in one. But, if you only need one of it, why load all 3 of them. So, if you only want the Recent Comments widget, you will find this post useful.</p> <h1 id="screenshotfigure-idattachment_2476-classwp-caption-aligncenter">Screenshot<figure id="attachment_2476" class="wp-caption aligncenter"></h1> <p><a href="//lab.subinsb.com/projects/blog/uploads/2014/02/0101.png"><img class="size-medium wp-image-2476" src="//lab.subinsb.com/projects/blog/uploads/2014/02/0101-300x276.png" alt="Disqus Recent Comments Widget" width="300" height="276" /></a><figcaption class="wp-caption-text">Disqus Recent Comments Widget</figcaption></figure></p> <p>You can also see a demo on JsFiddle.</p> <div class="padlinks"> <a class="demo" href="http://jsfiddle.net/subins2000/6qhN9/" target="_blank" rel="noopener">Demo</a> </div> <h1 id="the-code">The Code</h1> <p>Insert the following code in the place where you want to display the widget :</p> <pre class="prettyprint"><code>&lt;div id="RecentComments" class="dsq-widget"&gt; &lt;h2&gt;Recent Comments&lt;/h2&gt; &lt;script type="text/javascript" src="https://example.disqus.com/recent_comments_widget.js?num_items=5&hide_mods=0&hide_avatars=0&avatar_size=32&excerpt_length=100"&gt;&lt;/script&gt; &lt;/div&gt;</code></pre> <p>You should replace the &quot;example.disqus.com&quot; with your Disqus forum URL ( &quot;shortname.disqus.com&quot; ).</p> <h1 id="configure">Configure</h1> <p>As I said in my previous post, this widget also supports configuration like the &quot;Combination Widget&quot;.</p> <table class="table"> <tr> <td> Name </td> <pre><code>&lt;td&gt; Default Value &lt;/td&gt; &lt;td&gt; Description &lt;/td&gt; </code></pre> </tr> <tr> <td> num_items </td> <pre><code>&lt;td&gt; 5 &lt;/td&gt; &lt;td&gt; The number of items that should be shown (includes all items). &lt;/td&gt; </code></pre> </tr> <tr> <td> hide_mods </td> <pre><code>&lt;td&gt; &lt;/td&gt; &lt;td&gt; Set To &quot;1&quot; to hide Moderators&amp;#8217; comments &lt;/td&gt; </code></pre> </tr> <tr> <td> excerpt_length </td> <pre><code>&lt;td&gt; 100 &lt;/td&gt; &lt;td&gt; The excerpt (short version of comment) length &lt;/td&gt; </code></pre> </tr> <tr> <td> hide_avatars </td> <pre><code>&lt;td&gt; &lt;/td&gt; &lt;td&gt; Set to &quot;1&quot; if you don&amp;#8217;t want to display avatars &lt;/td&gt; </code></pre> </tr> <tr> <td> avatar_size </td> <pre><code>&lt;td&gt; 32 &lt;/td&gt; &lt;td&gt; The Size of the avatar of user. &lt;/td&gt; </code></pre> </tr> </table> <p>You can add this code in Blogger, WordPress and any other Blogging services.</p> <h1 id="blogger">Blogger</h1> <p>Go to your <strong>Blogger Blog -&gt; Layout</strong> and click on the &quot;Add a Gadget&quot; button. Choose &quot;HTML/JavaScript&quot; widget :<figure id="attachment_2477" class="wp-caption aligncenter"></p> <p><a href="//lab.subinsb.com/projects/blog/uploads/2014/02/0102.png"><img class="size-full wp-image-2477" src="//lab.subinsb.com/projects/blog/uploads/2014/02/0102.png" alt="Add HTML/Javascript Widget In Blogger" width="1049" height="244" /></a><figcaption class="wp-caption-text">Add HTML/Javascript Widget In Blogger</figcaption></figure></p> <p>Then, paste the code and click &quot;Save&quot; button.</p> How To Add Disqus Combination Widget With Customization https://subinsb.com/add-custom-disqus-combination-widget/ Tue, 11 Feb 2014 16:47:22 +0000 https://subinsb.com/add-custom-disqus-combination-widget/ <p>Disqus is one of the most used commenting systems in websites. Itโ€™s easy, fast and customizable. Disqus also support real time comments. Like any other commenting systems, Disqus provides various widgets for showcasing comments, discussions and commenters. They also have a widget that combines all these together. It is very easy to install this &quot;combination&quot; widget.<figure id="attachment_2469" class="wp-caption aligncenter"></p> <p><a href="//lab.subinsb.com/projects/blog/uploads/2014/02/0100.png"><img class="size-medium wp-image-2469" alt="Disqus Combination Widget" src="//lab.subinsb.com/projects/blog/uploads/2014/02/0100-145x300.png" width="145" height="300" /></a><figcaption class="wp-caption-text">Disqus Combination Widget</figcaption></figure></p> <p>You can include this code in Bloggerโ€™s HTML Widget or in WordPressโ€™ Text Widget :</p> <pre class="prettyprint"><code>&lt;div id="CombComments" class="dsq-widget"&gt; &lt;script type="text/javascript" src="http://example.disqus.com/combination_widget.js?num_items=5&hide_mods=0&color=grey&default_tab=popular&excerpt_length=100&hide_avatars=0"&gt;&lt;/script&gt; &lt;/div&gt;</code></pre> <p>Replace &quot;example&quot; short name in the above code to your Disqus forum short name.</p> <p>You can configure the widget by setting values on GET parameters :</p> <table class="table"> <tr> <td> Name </td> <pre><code>&lt;td&gt; Default Value &lt;/td&gt; &lt;td&gt; Description &lt;/td&gt; </code></pre> </tr> <tr> <td> num_items </td> <pre><code>&lt;td&gt; 5 &lt;/td&gt; &lt;td&gt; The number of items that should be shown (includes all items). &lt;/td&gt; </code></pre> </tr> <tr> <td> hide_mods </td> <pre><code>&lt;td&gt; &lt;/td&gt; &lt;td&gt; Set To &quot;1&quot; to hide Moderators&amp;#8217; comments &lt;/td&gt; </code></pre> </tr> <tr> <td> color </td> <pre><code>&lt;td&gt; grey &lt;/td&gt; &lt;td&gt; The color theme of widget &lt;/td&gt; </code></pre> </tr> <tr> <td> default_tab </td> <pre><code>&lt;td&gt; popular &lt;/td&gt; &lt;td&gt; The Default Tab Of Widget &lt;/td&gt; </code></pre> </tr> <tr> <td> excerpt_length </td> <pre><code>&lt;td&gt; 100 &lt;/td&gt; &lt;td&gt; The excerpt (short version of comment) length &lt;/td&gt; </code></pre> </tr> <tr> <td> hide_avatars </td> <pre><code>&lt;td&gt; &lt;/td&gt; &lt;td&gt; Set to &quot;1&quot; if you don&amp;#8217;t want to display avatars &lt;/td&gt; </code></pre> </tr> </table> <p>You can add custom styles using CSS. The parent elementโ€™s id is &quot;CombComments&quot; and the class is &quot;dsq-widget&quot;.An Example of adding custom style :</p> <pre class="prettyprint"><code>.dsq-widget a{ color: black; }</code></pre> <p>The above code will make the color of all &quot;a&quot; elements &quot;black&quot;.</p> Create Global Functions In JavaScript https://subinsb.com/global-functions-javascript/ Mon, 10 Feb 2014 02:35:48 +0000 https://subinsb.com/global-functions-javascript/ <p>Normally, a function defined would not be accessible to all places of a page. Say a function is mentioned using &quot;function checkCookie()&quot; on a external file loaded first on a page. This function cannot be called by the JavaScript file loaded last. So you have to make it a ย Global function that can be called from anywhere on a page.</p> <p>The &quot;window&quot; is a Global Object that has a lot of functions.</p> <pre class="prettyprint"><code>&gt;ย typeof window &lt; "object"</code></pre> <p>This &quot;window&quot; object is accessible to all JavaScript code of a page, even if itโ€™s an external file. So, if the &quot;window&quot; object is global, then the functions it contain will also be global. So, if we add a new function to the &quot;window&quot; object, it will be a global function. This is what we are going to do to make a Global function.</p> <p>Here is a normal way that we use to define a function :</p> <pre class="prettyprint"><code>function checkCookie(){ // do whatever you want here }</code></pre> <p>As you already understood, this function wouldnโ€™t be accessible to all JS codes. The error that produce when a function canโ€™t be accessible is :</p> <pre class="prettyprint"><code>ReferenceError: checkCookie is not defined</code></pre> <p>To make the &quot;checkCookie&quot; function global, we are going to add the function to the &quot;window&quot; object :</p> <pre class="prettyprint"><code>window.checkCookie=function(){ // do whatever you want here };</code></pre> <p>Note the semi colon (&quot;;&quot;) at the closing of the function. This semi colon is required when defining a function on a object. As normal you can add parameters to the function.</p> <p>Another Example :</p> <pre class="prettyprint"><code>function makeString(string, position){ // do whatever you want here }</code></pre> <p>can be made global by :</p> <pre class="prettyprint"><code>window.makeString=function(string, position){ // do whatever you want here };</code></pre> <p>Now, you can call the function directly or call it with window :</p> <pre class="prettyprint"><code>checkCookie() window.checkCookie() makeString("subinsb.com", 5) window.makeString("subinsb.com", 5)</code></pre> <p>The output of the different ways to call functions will be the same. You should know that jQuery is also doing this to make &quot;$&quot; &amp; &quot;jQuery&quot; functions global.</p> Position AddThis Recommended Content Section With jQuery https://subinsb.com/position-addthis-recommended-content-section-using-jquery/ Sun, 09 Feb 2014 13:30:52 +0000 https://subinsb.com/position-addthis-recommended-content-section-using-jquery/ <p>AddThis smart layer have a recommended content feature that adds a recommended content box to your page. This box is by default will be placed at the end of the page. A normal user wonโ€™t notice this. To make the recommended content noticeable, you have to move it to someplace else. But, AddThis doesnโ€™t support the positioning of the recommended content.</p> <p>So, the only way to move the recommended content box is to find a hack. I found the hack and Iโ€™m going to share it with you. All your blog or website should need is a jQuery library loaded on the page and the AddThis Smart Layers Recommended Content Feature. The rest will be taken care by the script we are going to add.</p> <p>You can see a demo if you scroll to the bottom of this blog just after the comments section. :<figure id="attachment_2453" class="wp-caption aligncenter"></p> <p><a href="//lab.subinsb.com/projects/blog/uploads/2014/02/0099.png"><img class="size-large wp-image-2453" alt="AddThis Smart Layer Recommended Content Above Footer" src="//lab.subinsb.com/projects/blog/uploads/2014/02/0099-1024x415.png" width="474" height="192" /></a><figcaption class="wp-caption-text">AddThis Smart Layer Recommended Content Above Footer</figcaption></figure></p> <p>Add the following code beforeย <strong></body></strong> orย <strong></head></strong> of your HTML page. Or you can add this to a separate file and load it using <strong><script></strong> tag.</p> <pre class="prettyprint"><code>var __subinsbdotcomAddThist=".at4-recommended-outer-container"; function __subinsbdotcomAddThisintervalTrigger() { return window.setInterval(function(){ if(jQuery(".cloned-at4").length==0 && jQuery(__subinsbdotcomAddThist).length!=0 && jQuery(__subinsbdotcomAddThist).text()!="" && jQuery(window).width() &gt; 1008){ jQuery(__subinsbdotcomAddThist).clone().addClass("cloned-at4").insertBefore("footer").wrap("&lt;div style='z-index:99999999;position:relative;background:#F5F5F5;border-top:1px solid black;'&gt;&lt;/div&gt;"); jQuery(__subinsbdotcomAddThist).not(".cloned-at4").remove(); jQuery(".at4-recommended-recommended").css("cssText","padding:10px 0px;opacity:1 !important;"); jQuery(".at4-visually-hidden").css("cssText","position: relative!important;"); window.clearInterval(__subinsbdotcomAddThis); } },2500); } var __subinsbdotcomAddThis=__subinsbdotcomAddThisintervalTrigger();</code></pre> <p>Mention the place where you want to show it by changing theย <strong>insertBefore(&quot;footer&quot;)</strong> code. By default it will be appended before the <strong><footer></strong>. If you want to place it after the Disqus comment box, replace theย <strong>insertBefore</strong> code with the following :</p> <pre class="prettyprint"><code>insertBefore("#disqus_thread")</code></pre> <p>The variables used in the code are unique, so that it wonโ€™t conflict with any other codes. When the page starts loading a function will start to initiate everyย <strong>2.5</strong> seconds. The function checks if the AddThis Smart Layers Recommended Content is loaded. If itโ€™s loaded, then it will be cloned and moved to the place you mentioned. By default itโ€™s above the <strong><footer></strong>.</p> <p>If you need help in positioning the AddThis Smart Layer etcโ€ฆ post a comment and I will be glad to help you.</p> Move Blog From Blogger To WordPress With Posts Redirection https://subinsb.com/move-blog-from-blogger-to-wordpress/ Sun, 09 Feb 2014 06:09:44 +0000 https://subinsb.com/move-blog-from-blogger-to-wordpress/ <p>If you are fed up with Blogger and wants to move to WordPress, you took a right decision. When migrating, you have to make sure that the posts ย on your Blogger blog should redirect to the post on the new domain. This might get tricky. If it get tricky, you will lose your visitors. You can find the step by step instructions to properly migrate a Blogger Blog To WordPress with a method to redirect old blog posts to your new blog posts.</p> <div class="padlinks"> <a class="download" href="http://demos.subinsb.com/WordPress/blogger-2-wordpress.zip">Download</a><a class="demo" href="http://sag-3.blogspot.com/2013/04/spam-urls-in-blogger-traffic-source.html">Demo</a> </div> <h1 id="import-blogger-posts">Import Blogger Posts</h1> <p>The default Blogger Posts Importer can be buggy. It wonโ€™t work sometimes. So you should look for an alternative.</p> <p>There is a way to import posts from the RSS feed of Blogger blog. We are going forward with this way.ย Go toย <strong>WordPress -&gt; Plugins -&gt; Add</strong>ย <strong>New</strong>,ย search for &quot;FeedWordpress&quot; plugin, install and activate it. Now we should get the feed URL of your blogger blog.</p> <p>Go to your Blogger blogโ€™sย <strong>Settings</strong>ย -&gt;ย <strong>Other</strong> page. Choose &quot;Full&quot; for &quot;Allow Blog Feed&quot;. This will make sure your blog have a feed link. Make sure you removed the &quot;Post Feed Redirect URL&quot;. If there is a redirection, then we canโ€™t do our work. So remove redirection if there is.</p> <p>A blogger blog have a feed URL like this :</p> <pre class="prettyprint"><code>http://yourblog.blogspot.com/feeds/posts/default?max-results=1000&alt=rss</code></pre> <p>We will mention this URL in Feed WordPress plugin. For that go toย <strong>Syndication -&gt; Syndicated Sites</strong> :<figure id="attachment_2419" class="wp-caption aligncenter"></p> <p><a href="//lab.subinsb.com/projects/blog/uploads/2014/02/0092.png"><img class="size-full wp-image-2419" title="Syndication Menu" src="//lab.subinsb.com/projects/blog/uploads/2014/02/0092.png" alt="Syndication Menu" width="175" height="295" /></a><figcaption class="wp-caption-text">Syndication Menu</figcaption></figure></p> <p>Add the blog feed URL we found earlier in to the &quot;New Source&quot; field seen on right side of window and click on &quot;Add&quot; button.</p> <p>When it asks to choose &quot;Atom 1.0&quot; or &quot;RSS 2.0&quot;, choose the &quot;RSS 2.0&quot; option.</p> <p style="text-align: center;"> <a href="//lab.subinsb.com/projects/blog/uploads/2014/02/0093.png"><img class=" wp-image-2420 aligncenter" src="//lab.subinsb.com/projects/blog/uploads/2014/02/0093.png" alt="Choose RSS 2.0" /></a> </p> <p>Then, go toย <strong>Syndication -&gt; Posts &amp; Links</strong>ย page. Choose &quot;The local copy on this website&quot; option under &quot;Links&quot; section. When we are going to import the posts, the settings on this page will affect the posts. So, be careful while changing settings.</p> <p>Under &quot;Custom Post Settings&quot; section add a custom field with key :</p> <pre class="prettyprint"><code>blogger_permalink</code></pre> <p>and value as :</p> <pre class="prettyprint"><code>$(item/link)</code></pre> <p>Also you have to add &quot;blogger_blog&quot; key with any value.</p> <p style="text-align: center;"> <a href="//lab.subinsb.com/projects/blog/uploads/2014/02/0094.png"><img class=" wp-image-2421 aligncenter" src="//lab.subinsb.com/projects/blog/uploads/2014/02/0094.png" alt="Syndication Custom Post Settings" /></a> </p> <p>Save the changes. Now go back to <strong>Syndication -&gt; Syndicated Sites</strong> page. Click on the &quot;Update Now&quot; button aside to your blog feed item. It will take some time to update and create posts. Wait until all posts are imported. Feed WordPress pluginโ€™s purpose is done. You can deactivate or remove the plugin. We donโ€™t need it anymore.</p> <h1 id="redirection">Redirection</h1> <p>Download the &quot;Blogger 2 WordPress&quot; plugin from <a href="http://demos.subinsb.com/WordPress/blogger-2-wordpress.zip">here</a>ย or from the WordPress Plugin Directory, search for &quot;Blogger 2 WordPress&quot;.</p> <p>The plugin is also available in these languages :</p> <p>Spanish &amp; Serbian byย <a href="http://firstsiteguide.com" target="_blank">Ogi Djuraskovic<br /> </a></p> <p>Indonesian byย <a href="http://ChameleonJohn.com">Jordan Silaen</a></p> <p>After activating the plugin, Go to the plugin page from <strong>Plugins -&gt; Blogger 2 WordPress</strong> and follow the instructions of the plugin.</p> <p>You will get aย template code. Itโ€™s better to do a backup of the current template code of your blog in case something goes wrong.</p> <p>Go to the **Templateย **tab of your Blogger blog and chooseย <strong>Edit HTML</strong>.ย Paste the new code got from the plugin in the textarea.<figure id="attachment_2432" class="wp-caption aligncenter"></p> <p><a href="//lab.subinsb.com/projects/blog/uploads/2014/02/0095.png"><img class="wp-image-2432" src="//lab.subinsb.com/projects/blog/uploads/2014/02/0095.png" alt="Get Blogger classic Template Code" width="765" height="482" /></a><figcaption class="wp-caption-text">Donโ€™t mind this image as it is of an older version of the plugin. But the newer version also look something like this.</figcaption></figure></p> <p><a href="//lab.subinsb.com/projects/blog/uploads/2014/02/0122.png"><img class="aligncenter wp-image-2883 size-full" src="//lab.subinsb.com/projects/blog/uploads/2014/02/0122.png" alt="0122" width="1114" height="253" /></a></p> <p>If you want to redirect pages as well, go to the &quot;Blogger 2 WordPress&quot; plugin page and add the pages as JSON data :</p> <p style="text-align: center;"> <a href="//lab.subinsb.com/projects/blog/uploads/2014/02/0097.png"><img class=" wp-image-2434 aligncenter" src="//lab.subinsb.com/projects/blog/uploads/2014/02/0097.png" alt="Add Pages For Redirection" /></a> </p> <p>A JSON data example :</p> <pre class="prettyprint"><code>{ "http://subinsb.com/ask" : "/p/ask.html", "http://subinsb.com/about" : "/p/about.html" }</code></pre> <p>Note that the current WordPress page URL should be mentioned first as key and the old URL mentioned second as value. Separate items using comma. Also itโ€™s better to add just the pathname of the page URL, because there are multiple country domain TLDโ€™s in a Blogger blog (au, in, com).</p> <p>Now when you go to your Blogger Post, it will be redirected to your new WordPress Post URL.</p> Load Data While Scrolling Down With jQuery & PHP https://subinsb.com/load-data-while-scrolling-jquery-php/ Mon, 03 Feb 2014 14:11:16 +0000 https://subinsb.com/load-data-while-scrolling-jquery-php/ <p>If your site have a lot of data to display on a page, it will make the page laggy. With this tutorial, you can limit the data on the main page and load new data when user reach the bottom of the page. This makes it easy to show huge data in a single page. <figure id="attachment_2393" class="wp-caption aligncenter"><a href="//lab.subinsb.com/projects/blog/uploads/2014/02/0090.png"><img class="size-medium wp-image-2393" src="//lab.subinsb.com/projects/blog/uploads/2014/02/0090-300x111.png" alt="Before user reaches the end of page." width="300" height="111" /></a><figcaption class="wp-caption-text">Before user reaches the end of page.</figcaption></figure> ย  <figure id="attachment_2399" class="wp-caption aligncenter"><a href="//lab.subinsb.com/projects/blog/uploads/2014/02/0091.png"><img class=" wp-image-2399 " src="//lab.subinsb.com/projects/blog/uploads/2014/02/0091-300x121.png" alt="After user reaches the end of page." width="300" height="121" /></a><figcaption class="wp-caption-text">After user reaches the end of page.</figcaption></figure></p> <div class="padlinks"> <a class="demo" href="http://open.subinsb.com" target="_blank">Demo</a> </div> <p>jQuery will trigger a POST request when user reaches the end of the page. The return data of the request contains the data older than the last data at the time of the trigger. In Server Side (PHP), weโ€™ll use a SQL query that loads data less than the last data Id.</p> <h2 id="database-table">Database Table</h2> <p>You need a table that contains the data with a unique ID. The unique Id can be accomplished using the Auto Increment option of the field with Primary Key option. Here is a sample which we will use throughout this tutorial :</p> <pre class="prettyprint"><code>CREATE TABLE data( id INT PRIMARY KEY AUTO_INCREMENT, data TEXT );</code></pre> <h2 id="homephp">home.php</h2> <p>The file where the first latest added 10 datas are shown. When user scrolls to the bottom, the next 10 data are shown.</p> <pre class="prettyprint"><code>&lt;html&gt; &lt;head&gt; &lt;script src="http://code.jquery.com/jquery-latest.js"&gt;&lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;? $sql=$dbh-&gt;prepare("SELECT * FROM data ORDER BY id DESC LIMIT 10"); $sql-&gt;execute(); while($r=$sql-&gt;fetch()){ $id=$r['id']; $data=$r['data']; ?&gt; &lt;div id="&lt;?echo $id;?&gt;" class="data"&gt; &lt;?echo $data;?&gt; &lt;/div&gt; &lt;? } ?&gt; &lt;div class='load_more_data'&gt; &lt;div class='normal'&gt;Load More Data&lt;/div&gt; &lt;div class='loader'&gt; &lt;img src='load.gif' height='32' width='32'/&gt; &lt;span&gt;Loading More Data&lt;/span&gt; &lt;/div&gt; &lt;/div&gt; &lt;/body&gt; &lt;/html&gt;</code></pre> <h2 id="jquery">jQuery</h2> <p>The following jQuery code will call the loadData() function when the &quot;Load More Data&quot; button is clicked or when the user reaches the end of the page. The loadData() function will send the request to the load_data.php file and appends the return HTML data after the last data.</p> <pre class="prettyprint"><code>localStorage['dataRequested']=0; function loadData(){ var lastDataId=$(".data:last").attr("id"); var params={}; params["id"]=lastDataId; var t=$(".load_more_data"); t.find(".normal").hide(); t.find(".loader").show(); if(localStorage['dataRequested']==0){ localStorage['dataRequested']=1; $.post("load_data.php", params, function(data){ if(data!=""){ $(".data:last").after(data); } t.find(".normal").show(); t.find(".loader").hide(); localStorage['dataRequested']=0; }); } } $(document).ready(function(){ $(".load_more_data .normal").on("click", function(){ loadData(); }); $(window).scroll(function(){ if($(window).scrollTop() + $(window).height() == $(document).height() && $(".data").length!=0){ loadData(); } }); });</code></pre> <p>You can include the above JS code inside a script tag or include it externally via <script src></p> <h2 id="load_dataphp">load_data.php</h2> <p>This file is where jQuery sents the request to get the data older than the last one.</p> <pre class="prettyprint"><code>&lt;? if(isset($_POST['id'])){ $id=$_POST['id']; $limit=10; // The Data Limit if($id!=""){ $sql=$dbh-&gt;prepare("SELECT * FROM data WHERE id &lt; ? ORDER BY id DESC LIMIT ?"); $sql-&gt;execute(array($id, $limit)); if($sql-&gt;rowCount()!=0){ while($r=$sql-&gt;fetch()){ $id=$r['id']; $data=$r['data'] ?&gt; &lt;div id="&lt;?echo $id;?&gt;" class="data"&gt; &lt;?echo $data;?&gt; &lt;/div&gt; &lt;? } // While End } // If Row Count!=0 End } // If $id!=blank End } // If $_POST['id'] End ?&gt;</code></pre> <h2 id="styling">Styling</h2> <p>Here is some styling to decorate the Load More Data button and data element :</p> <pre class="prettyprint"><code>.data{ border: dashed 1px #48B1D9; padding: 10px; margin: 5px; } .load_more_posts{ background: #FAB359; border-radius: 10px; padding: 7px 25px; margin-top: 5px; } .load_more_posts .normal{ cursor: pointer; vertical-align: middle; } .load_more_posts .loader img{vertical-align: middle;} .load_more_posts .loader span{ vertical-align: middle; margin-left: 10px; }</code></pre> <p>This was a implementation of the code to load new posts in Open. This has not been tested. But I think it works well. If you found any errors, please comment and I will fix it. If you have any problems, please comment. I will be here to help you.</p> Create A Trending Box In PHP With MySQL & HTML https://subinsb.com/trending-box-html-php-mysql/ Sun, 02 Feb 2014 14:08:56 +0000 https://subinsb.com/trending-box-html-php-mysql/ <p>Trending boxes can be seen is social networks. Facebook, Twitter, Google + have it. Why not create one of your own. You can create your own using HTML and add styling by CSS. We will use PHP for updating most searched queries in MySQL database.</p> <div class="padlinks"> <a class="demo" href="http://open.subinsb.com" target="_blank">Demo</a> </div> <p>How the trending box looks like :<figure id="attachment_2387" class="wp-caption aligncenter"></p> <p><a href="//lab.subinsb.com/projects/blog/uploads/2014/02/0089.png"><img class="size-full wp-image-2387" alt="Trending Box" src="//lab.subinsb.com/projects/blog/uploads/2014/02/0089.png" width="186" height="271" /></a><figcaption class="wp-caption-text">Trending Box</figcaption></figure></p> <p>We need a table for storing the search queries. For this we are going to create a table named &quot;trends&quot;.ย Execute this SQL code to create the table</p> <pre class="prettyprint"><code>CREATE TABLE IF NOT EXISTS `trends` ( `title` varchar(50) NOT NULL, `hits` int(11) NOT NULL, PRIMARY KEY (`title`), UNIQUE KEY `title` (`title`), KEY `title_2` (`title`), KEY `hits` (`hits`), FULLTEXT KEY `title_3` (`title`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1;</code></pre> <p>When a user searches for a query in your search page, it should be automatically added to the &quot;trends&quot; table. To automatically add the queries, append the following code at the end or beginning of your search page. Theย <strong>$q</strong> variable should contain the search query.</p> <pre class="prettyprint"><code>&lt;? $q="query";/* The Search Query */ if($q!=''){ $sql=$dbh-&gt;prepare("UPDATE trends SET hits=hits+1 WHERE title=?"); $sql-&gt;execute(array($q)); } /* If There isn't a seacrh query in table, insert it */ if($sql-&gt;rowCount()==0 && $q!=""){ $sql=$dbh-&gt;prepare("INSERT INTO trends(title,hits) VALUES(?,'1')"); $sql-&gt;execute(array($q)); } ?&gt;</code></pre> <p>When a user searches for a query, the script updates the value &quot;hits&quot; to +1 (&quot;hits&quot; + 1). If it wasnโ€™t successfully updated, the query is inserted in to the table with &quot;hist&quot; as &quot;1&quot;.</p> <p>The &quot;hits&quot; field determines the popularity of the query. The query with the most &quot;hits&quot; value is the most trending query.</p> <p>To display the trending box, we get the first 10 popular queries (highest &quot;hits&quot; value) from the table. Then it is displayed in the descending order of the &quot;hits&quot;.</p> <pre class="prettyprint"><code>&lt;div class="trending"&gt; &lt;font size="5" style="color:rgb(0,250,120);"&gt;Trending&lt;/font&gt; &lt;div class="trends"&gt; &lt;? $sql=$db-&gt;query("SELECT * FROM trends ORDER BY hits DESC LIMIT 9"); foreach($sql as $r){ $query=$r['title']; $wdot=strlen($query)&gt;=14 ? "....":""; $sp_t=str_split($query,14); $sp_t=$sp_t[0]; echo '&lt;div style="padding:1px;"&gt;'; echo '&lt;a href="search.php?query='.urlencode($query).'" title="'.$query.'"&gt;'.$sp_t."$wdot&lt;/a&gt;"; echo '&lt;div style="margin-top:5px;"&gt;&lt;/div&gt;'; // Adds A Break like &lt;br/&gt; echo "&lt;/div&gt;"; } ?&gt; &lt;/div&gt; &lt;/div&gt;</code></pre> <p>If you want to delete the old non popular queries from table, add the following code where as you like :</p> <pre class="prettyprint"><code>&lt;? $db-&gt;query("DELETE FROM trend WHERE hits=(SELECT MIN(hits) FROM (SELECT * FROM trend HAVING COUNT(hits)&gt;150) x);"); ?&gt; </code></pre> <p>Yes, the &quot;x&quot; should be in the query or you would get the derived table error (#1248).</p> <p>Add this CSS code to design the trending box :</p> <pre class="prettyprint"><code>&lt;style&gt; .trending{ background: black; border-radius: 10px; padding:15px; } .trending .trends{ color:#fff; padding-left:10px; margin-top:10px; } &lt;/style&gt;</code></pre> <p>The finished product will look something like this :<figure id="attachment_2387" class="wp-caption aligncenter"></p> <p><a href="//lab.subinsb.com/projects/blog/uploads/2014/02/0089.png"><img class="size-full wp-image-2387" alt="Trending Box" src="//lab.subinsb.com/projects/blog/uploads/2014/02/0089.png" width="186" height="271" /></a><figcaption class="wp-caption-text">Trending Box</figcaption></figure></p> Add Invite Facebook Friends Feature In A Website https://subinsb.com/add-invite-facebook-friends-in-website/ Sat, 01 Feb 2014 07:22:55 +0000 https://subinsb.com/add-invite-facebook-friends-in-website/ <p>Please read this before continuing :</p> <blockquote> <p>Looks like Facebook is making restrictions into this. Note that, this tutorial is not officially supported by Facebook. You can say this is a trick or a hack.</p> <p>So, no guarantee whether this will work now or in the future. This worked before, but it has been noted that Facebook is restricting this &quot;hack&quot;.</p> </blockquote> <p>There is an Invite feature for Facebook apps. Inviting feature helps your siteโ€™s users to invite their friends to your site. This increases the traffic and will make your site popular. All you should need is a Facebook App to implement this on your site.</p> <div class="padlinks"> <a class="demo" href="http://open.subinsb.com/invite" target="_blank">Demo</a> </div> <h2 id="facebook-app">Facebook App</h2> <p>Create a Facebook App. Instructions can be found <a href="//subinsb.com/2012/02/tutorial-how-to-create-a-facebook-app" target="_blank">here</a>. Go to the &quot;Settings&quot; page of your app :</p> <p>Click on &quot;Add Platform&quot; button. Choose &quot;App on Facebook&quot; and &quot;Website&quot; after adding the &quot;App on Facebook&quot; platform :</p> <p><a href="//lab.subinsb.com/projects/blog/uploads/2014/02/0085.png"><img class="aligncenter size-medium wp-image-2377" src="//lab.subinsb.com/projects/blog/uploads/2014/02/0085-300x183.png" alt="0085" width="300" height="183" /></a></p> <p>Here are the settings for &quot;Website&quot; platform :</p> <p><a href="//lab.subinsb.com/projects/blog/uploads/2014/02/0086.png"><img class="aligncenter size-medium wp-image-2378" src="//lab.subinsb.com/projects/blog/uploads/2014/02/0086-300x105.png" alt="0086" width="300" height="105" /></a></p> <p>Add your website URL is &quot;Site URL&quot; and the mobile site URL if it have any.</p> <p>Settings for &quot;App on Facebook&quot; platform :</p> <p><a href="//lab.subinsb.com/projects/blog/uploads/2014/02/0087.png"><img class="aligncenter size-medium wp-image-2380" src="//lab.subinsb.com/projects/blog/uploads/2014/02/0087-300x138.png" alt="0087" width="300" height="138" /></a></p> <p>Add theย <strong>facebook_app.html</strong> page to your siteโ€™s &quot;Canvas URL&quot; and &quot;Secure Canvas URL&quot; with theย &quot;?fb&quot; parameter, because Facebook wonโ€™t allow you to add a page to URL without &quot;?&quot; character.</p> <h1 id="website-integration">Website Integration</h1> <h2 id="invite-page">Invite Page</h2> <p>Create an invite page (invite.html). Add the following code insideย &quot;<body></body>&quot; :</p> <pre class="prettyprint"><code>&lt;div id="facebook_invite"&gt;&lt;/div&gt;</code></pre> <p>Load the Facebook JS SDK inside #facebook_invite :</p> <pre class="prettyprint"><code>&lt;script src="http://connect.facebook.net/en_US/all.js"&gt;&lt;/script&gt;</code></pre> <p>Add the Invite Link with &quot;FBInvite()&quot; callback on click :</p> <pre class="prettyprint"><code>&lt;a href="#" onclick="FBInvite()"&gt;Invite Facebook Friends&lt;/a&gt;</code></pre> <p>Start the FB function :</p> <pre class="prettyprint"><code>&lt;script&gt; FB.init({ appId:'app_id', cookie:true, status:true, xfbml:true }); &lt;/script&gt;</code></pre> <p>Replace &quot;app_id&quot; with the Applicationโ€™s ID.</p> <p>FBInvite() makes the call to Facebook for app request :</p> <pre class="prettyprint"><code>&lt;script&gt; function FBInvite(){ FB.ui({ method: 'apprequests', message: 'Invite your Facebook Friends' },function(response) { if (response) { alert('Successfully Invited'); } else { alert('Failed To Invite'); } }); } &lt;/script&gt;</code></pre> <p>Change the &quot;message&quot; parameter as you want. When user clicks the link, &quot;FBInvite()&quot; is called and the &quot;Invite Friends&quot; dialog appears :</p> <img class="aligncenter size-medium wp-image-2381" src="//lab.subinsb.com/projects/blog/uploads/2014/02/0088-300x287.png" alt="0088" width="300" height="287" /> <p>The &quot;Done&quot; button should be clicked after clicking of &quot;Invite&quot; buttons near the friendsโ€™ names.</p> <h2 id="facebook-canvas">Facebook Canvas</h2> <p>We really donโ€™t need a canvas, because we are inviting them to our site, not to our Facebook app. So we should make a redirection page as canvas. We mentioned the canvas URL asย <strong>facebook_app.html</strong> when we created our app. So create the &quot;facebook_app.html&quot; on your siteโ€™s main directory and add the following contents :</p> <pre class="prettyprint"><code>&lt;html&gt; &lt;head&gt;&lt;/head&gt; &lt;body&gt; You are being redirected. If not &lt;a href="http://yoursite.com/" target="_top"&gt;click here&lt;/a&gt;. &lt;script&gt;window.top.location.href = "http://yoursite.com/";&lt;/script&gt; &lt;/body&gt; &lt;/html&gt;</code></pre> <p>Replace &quot;yoursite.com&quot; with your siteโ€™s URL. When the user goes to your Facebook App, the canvas is loaded with the &quot;facebook_app.html&quot; of your site which will redirect to your main site.</p> <p>Sometimes Facebook will ask for Secure Canvas URL. In this case upload theย HTML file to Services that provides HTML hosting and has a SSL certificate. Google Drive offers this feature.</p> <p>Hope you liked it. If you have any problems feel free to comment. I will help you.</p> Move Cursor To End Of Input Or Textarea In jQuery https://subinsb.com/move-cursor-to-end-input-textarea-jquery/ Fri, 31 Jan 2014 16:03:21 +0000 https://subinsb.com/move-cursor-to-end-input-textarea-jquery/ <p>The function that moves the cursor of an input element to the end in jQuery isย <strong>.focus()</strong>. But sometimes, this wonโ€™t work even if you replace it withย <strong>[0].click()</strong>. Itโ€™ll maybe work on input fields properly, but wonโ€™t properly at all in text areas. Mostly it wonโ€™t work, if you are calling theย <strong>.focus()</strong> function inside an event listener function.</p> <p>To solve this you can use 2 other methods if the first one donโ€™t work. Itโ€™s pretty simple and I donโ€™t know why it works. I found this solution on a Stack Overflow question and the one who answered doesnโ€™t know why it works. Here is a list of the events that happens when an element is clicked :</p> <ol> <li>mousedown</li> <li>focus</li> <li>mouseup</li> <li>click</li> </ol> <p>If you are calling mousedown on an element, you wonโ€™t be able to focus that element in itโ€™s callback. So use mouseup or click for listening events to focus an element.</p> <p>Letโ€™s get back on the topic. As I said before, there are 3 solutions. If 1 didnโ€™t work move on the Plan B (2) or Plan C (3).</p> <h2 id="solution-1">Solution 1</h2> <p>Focus before appending the value :</p> <pre class="prettyprint"><code>$("textarea").focus().val("How Did This Happen ?");</code></pre> <h2 id="solution-2">Solution 2</h2> <p>Add value first, then focus and add value again (original solution by <a href="http://stackoverflow.com/a/1056406/1372424" target="_blank">Stack Overflow user</a>) :</p> <pre class="prettyprint"><code>$("textarea").val("Two Values").focus().val("Two Values");</code></pre> <h2 id="solution-3">Solution 3</h2> <p>Focus, clear value, then revert to original value :</p> <pre class="prettyprint"><code>$("textarea").focus().val("").val("Original Value");</code></pre> <p>If you have any other methods to do this confusing task, please share it.</p> Blogโ€™s 3rd Anniversary https://subinsb.com/blog-3rd-aniversary/ Thu, 30 Jan 2014 15:43:26 +0000 https://subinsb.com/blog-3rd-aniversary/ <p>Today, January 30 marks the 3rd anniversary of this blog. Thanks to everyone who have supported me and this blog. With out your help, I couldnโ€™t have run this blog for 3 years. Here are the 5 popular posts of the last 3 years :</p> <p><a href="//subinsb.com/2012/07/how-to-add-a-header-image-to-blogger-dynamic-views" target="_blank">HOW TO ADD A HEADER IMAGE TO BLOGGER DYNAMIC VIEWS</a></p> <p><a href="//subinsb.com/2012/09/how-to-repairrestorereinstall-grub-2-using-a-ubuntu-live-cd" target="_blank">HOW TO REPAIR/RESTORE/REINSTALL GRUB 2 USING A UBUNTU LIVE CD</a></p> <p><a href="//subinsb.com/2012/02/how-to-add-a-fixed-header-to-blogger-blog" target="_blank">HOW TO ADD A FIXED HEADER TO BLOGGER BLOG</a></p> <p><a href="//subinsb.com/2012/04/how-to-create-a-localhost-web-site-in-ubuntu-using-apache-web-server" target="_blank">HOW TO CREATE A LOCALHOST WEB SITE IN LINUX USING APACHE WEB SERVER</a></p> <p><a href="//subinsb.com/2013/10/how-to-create-a-simple-web-crawler-in-php" target="_blank">HOW TO CREATE A SIMPLE WEB CRAWLER IN PHP</a></p> <p>Other Popular Posts</p> <p><a href="//subinsb.com/2013/05/create-facebook-like-system-with-jquery-mysql-pdo-in-php" target="_blank">CREATE FACEBOOK LIKE SYSTEM WITH JQUERY, MYSQL, PDO IN PHP</a></p> <p><a href="//subinsb.com/2013/10/how-to-use-filezillasftp-to-update-site-in-openshift" target="_blank">HOW TO USE FILEZILLA/SFTP TO UPDATE SITE IN OPENSHIFT</a></p> <p><a href="//subinsb.com/2013/08/create-mysql-injection-free-secure-login-system-in-php" target="_blank">CREATE MYSQL INJECTION FREE SECURE LOGIN SYSTEM IN PHP</a></p> <p><a href="//subinsb.com/2013/04/how-to-check-if-the-mouse-is-over-an-element-in-jquery" target="_blank">HOW TO CHECK IF THE MOUSE IS OVER AN ELEMENT IN JQUERY ?</a></p> <p><a href="//subinsb.com/2012/08/insert-xml-file-contents-to-mysql-database-table-using-php" target="_blank">INSERT XML FILE CONTENTS TO MYSQL DATABASE TABLE USING PHP</a></p> <p><a href="//subinsb.com/2013/04/spam-urls-in-blogger-traffic-source-stats-what-should-i-do" target="_blank">SPAM URLโ€™S IN BLOGGER TRAFFIC SOURCE STATS : WHAT SHOULD I DO ?</a></p> <p><a href="//subinsb.com/2013/10/how-to-create-a-simple-username-availability-checker-using-jquery-and-php" target="_blank">HOW TO CREATE A SIMPLE USERNAME AVAILABILITY CHECKER USING JQUERY AND PHP</a></p> <p><a href="//subinsb.com/2013/10/how-to-add-a-simple-birthday-field-in-a-form-using-jquery" target="_blank">HOW TO ADD A SIMPLE BIRTHDAY FIELD IN A FORM USING JQUERY</a></p> <p><a href="//subinsb.com/2012/08/refresh-a-div-container-in-equal-intervals-of-time" target="_blank">REFRESH A DIV CONTAINER IN EQUAL INTERVALS OF TIME</a></p> <p>Thank you every one for your support, comments, likes and shares.</p> Send E-Mails Via SMTP Server In PHP โ€“ GMail & Outlook https://subinsb.com/send-mails-via-smtp-server-gmail-outlook-php/ Tue, 28 Jan 2014 16:51:53 +0000 https://subinsb.com/send-mails-via-smtp-server-gmail-outlook-php/ <p>Email Service providers have POP and SMTP servers for incoming and outgoing E-Mails. SMTP is for Outgoing (Sending) emails and POP is for Incoming (Receiving) emails. If you have an account in email services, it means that you can send or receive emails using these servers. This service is free, fast and secure. You can change the &quot;From&quot; address and the &quot;From&quot; name if you send emails using SMTP server. In this post I will tell you how to send emails usingย <strong>SMTP</strong> servers ofย <strong>GMail</strong> &amp;ย <strong>Outlook</strong>ย in <strong>PHP</strong>.</p> <div class="padlinks"> <a class="download" href="http://demos.subinsb.com/down.php?id=n7t4ppks7xyn/s/f77onz2xf8ruzonhqc9y&class=18" target="_blank">Download</a><a class="demo" href="http://open.subinsb.com/invite" target="_blank">Demo</a> </div> <h1 id="phpmailer">PHPMailer</h1> <p>We are going to use <a href="https://github.com/PHPMailer/PHPMailer" target="_blank">PHPMailer</a> class for sending emails. Itโ€™s an easy usable PHP library for sending emails. This class is included in the Download File.</p> <h1 id="configuration">Configuration</h1> <p>This configuration contains account information, Recipient address with name and the message details :</p> <pre class="prettyprint"><code>$account="[email protected]"; $password="accountpassword"; $to="[email protected]"; $from="[email protected]"; $from_name="Vishal G.V"; $msg="&lt;strong&gt;This is a bold text.&lt;/strong&gt;"; // HTML message $subject="HTML message";</code></pre> <h1 id="gmail">GMail</h1> <p>Include PHPMailer class first :</p> <pre class="prettyprint"><code>include("phpmailer/class.phpmailer.php");</code></pre> <p>Create the Class object and append the settings of the SMTP server :</p> <pre class="prettyprint"><code>$mail = new PHPMailer(); $mail-&gt;IsSMTP(); $mail-&gt;CharSet = 'UTF-8'; $mail-&gt;Host = "smtp.gmail.com"; $mail-&gt;SMTPAuth= true; $mail-&gt;Port = 465; // Or 587 $mail-&gt;Username= $account; $mail-&gt;Password= $password; $mail-&gt;SMTPSecure = 'ssl'; $mail-&gt;From = $from; $mail-&gt;FromName= $from_name; $mail-&gt;isHTML(true); $mail-&gt;Subject = $subject; $mail-&gt;Body = $msg; $mail-&gt;addAddress($to);</code></pre> <p>Then, check if the mail sends without error. If there is an error, it will print out the error :</p> <pre class="prettyprint"><code>if(!$mail-&gt;send()){ echo "Mailer Error: " . $mail-&gt;ErrorInfo; }else{ echo "E-Mail has been sent"; }</code></pre> <p>This concludes the GMail part.</p> <h1 id="outlook">Outlook</h1> <p>Include PHPMailer class first :</p> <pre class="prettyprint"><code>include("phpmailer/class.phpmailer.php");</code></pre> <p>Create the Class object and append the settings of the SMTP server :</p> <pre class="prettyprint"><code>$mail = new PHPMailer(); $mail-&gt;IsSMTP(); $mail-&gt;CharSet = 'UTF-8'; $mail-&gt;Host = "smtp.live.com"; $mail-&gt;SMTPAuth= true; $mail-&gt;Port = 587; $mail-&gt;Username= $account; $mail-&gt;Password= $password; $mail-&gt;SMTPSecure = 'tls'; $mail-&gt;From = $from; $mail-&gt;FromName= $from_name; $mail-&gt;isHTML(true); $mail-&gt;Subject = $subject; $mail-&gt;Body = $msg; $mail-&gt;addAddress($to);</code></pre> <p>Then, check if the mail sends without any errors. If there is an error, it will print out the error :</p> <pre class="prettyprint"><code>if(!$mail-&gt;send()){ echo "Mailer Error: " . $mail-&gt;ErrorInfo; }else{ echo "E-Mail has been sent"; }</code></pre> <p>If there was an error printed out and you need help, please comment.</p> Set Up Free Outlook E-Mail Accounts on a Custom Domain https://subinsb.com/outlook-free-e-mail-accounts-on-custom-domains/ Fri, 24 Jan 2014 17:12:07 +0000 https://subinsb.com/outlook-free-e-mail-accounts-on-custom-domains/ <p>A custom email account on your own domain is useful for various purposes. By getting an own domain email name makes you not to disclose your personal mail and use the work email for disclosing. Email account on a custom domain is costly these days. Google Apps increased the price of their plan, which makes it impossible for custom email addresses.</p> <p>But, Microsoft Outlook is giving it away for free ! They will host the Email address for you free of cost. Only you have to do is, create a account on Microsoft Live. You will find the step by step instructions for setting up a custom email address on your domain.</p> <p>I will prove it to you by disclosing the email address set up on this domain : <strong><a href="mailto:[email protected]">[email protected]</a></strong>. To get a E-Mail address like mine you should have a Microsoft Account. If you donโ€™t have one yet, <a href="https://signup.live.com/" target="_blank">signup for it</a>.</p> <h2 id="add-domain">Add Domain</h2> <p>Go to the <a href="https://domains.live.com/Signup/SignupDomain.aspx" target="_blank">Signup Domain Page</a>. The page will be like below :</p> <p><a href="//lab.subinsb.com/projects/blog/uploads/2014/01/0074.png"><img class="aligncenter size-medium wp-image-2288" alt="0074" src="//lab.subinsb.com/projects/blog/uploads/2014/01/0074-300x157.png" width="300" height="157" /></a></p> <p>Type in the domain name and choose &quot;Set up Outlook.com for my domain&quot; option. Once filled, click Continue button.</p> <p>You will be asked for assigning a domain administrator :</p> <p><a href="//lab.subinsb.com/projects/blog/uploads/2014/01/0079.png"><img class="aligncenter size-medium wp-image-2289" alt="0079" src="//lab.subinsb.com/projects/blog/uploads/2014/01/0079-300x93.png" width="300" height="93" /></a></p> <p>Choose the 1st option since you already signed up for a Microsoft account. When you click &quot;Continue&quot;, the Login page will be shown. Log in with your Microsoft account. You will be redirected back to the domains page :</p> <p><a href="//lab.subinsb.com/projects/blog/uploads/2014/01/0075.png"><img class="aligncenter size-medium wp-image-2291" alt="0075" src="//lab.subinsb.com/projects/blog/uploads/2014/01/0075-300x221.png" width="300" height="221" /></a></p> <p>Make sure the details are correct. Then type in the captcha and click on &quot;I Accept&quot; button. If the captcha was correct, you will be redirected to your domain page.</p> <h2 id="verify-domain">Verify Domain</h2> <p><a href="//lab.subinsb.com/projects/blog/uploads/2014/01/0076.png"><img class="aligncenter size-medium wp-image-2292" alt="0076" src="//lab.subinsb.com/projects/blog/uploads/2014/01/0076-300x228.png" width="300" height="228" /></a></p> <p>The domain page will ask you to add aย <strong>MX</strong> record to your site. You should only add the firstย <strong>MX</strong> record shown. Itโ€™s not necessary to add all the other records. Remember to make the record priority at the highest number than otherย <strong>MX</strong> records.</p> <p>Once you added theย <strong>MX</strong> record, click onย &quot;Refresh&quot; button. If verified, the page will reload. To check if it has been verified successfully, go to the D<a href="https://domains.live.com/manage/default.aspx" target="_blank">omain Dashboard</a>. If there is a green circle besides your domain, then itโ€™s verified :</p> <p><a href="//lab.subinsb.com/projects/blog/uploads/2014/01/0077.png"><img class="aligncenter size-medium wp-image-2293" alt="0077" src="//lab.subinsb.com/projects/blog/uploads/2014/01/0077-300x62.png" width="300" height="62" /></a></p> <h1 id="add-account">Add Account</h1> <p>Click on your domain where you want to add an E-Mail account. Click the &quot;Add&quot; button on the page where you are now. A Form will pop on your screen. Fill it according to your needs :</p> <p><a href="//lab.subinsb.com/projects/blog/uploads/2014/01/0078.png"><img class="aligncenter size-medium wp-image-2294" alt="0078" src="//lab.subinsb.com/projects/blog/uploads/2014/01/0078-300x215.png" width="300" height="215" /></a></p> <p>The &quot;Account Name&quot; is the username of the E-Mail address which is situated before theย <strong>@</strong> character. If the Form is filled like in the above image, the E-Mail address will be :</p> <pre class="prettyprint"><code>[email protected]</code></pre> <p>Choose a Password. Note that the form you submit is going to be like creating another account on Microsoft. So be careful while filling the fields. Once you submit the form, a new account will be created. You now have an own E-Mail address on your domain. The E-Mail address will be :</p> <pre class="prettyprint"><code>[email protected]</code></pre> <p>An example when I typedย <strong>mail</strong>ย inย &quot;Account Name&quot; for the domainย <strong>subinsb.com</strong> :</p> <pre class="prettyprint"><code>[email protected]</code></pre> <p>So, there you go, you own E-Mail address. If you want to access your new accountโ€™s E-Mails, Log Out from the current user and login with the E-Mail address of your domain and with the password you typed in when you filled the form. If you checked the &quot;Password Change On First Login&quot; while submitting the form, then you will be asked to change your password. Once that is done, you will be able to access your account.</p> <h2 id="mail-software-configuration">Mail Software Configuration</h2> <p>If you want to add the account to your Mail Software like &quot;<strong>Evolution</strong>&quot;, here is the server details of incoming E-Mails and Outgoing E-Mails.**</p> <p>**</p> <h2 id="incoming-e-mail">Incoming E-Mail</h2> <pre class="prettyprint"><code>Server Type : POP Server :ย pop3.live.com Use Authentication : Yes Use Secure Connection : SSL</code></pre> <h2 id="outgoing-e-mail">Outgoing E-Mail</h2> <pre class="prettyprint"><code>Server Type : SMTP Server :ย smtp.live.com Use Authentication : Yes Use Secure Connection : SSL</code></pre> <p>If you have any problems, or have a suggestion please comment it.</p> Add Pagination To MySQL Database Result In PHP https://subinsb.com/pagination-to-mysql-database-result-in-php/ Thu, 23 Jan 2014 18:14:07 +0000 https://subinsb.com/pagination-to-mysql-database-result-in-php/ <p>Pagination makes the results tidy and simple. When there are many results, pagination helps sorting them out and adding each results to specific pages. In <strong>PHP</strong>, itโ€™s real simple. You can use this tutorial to add a pagination to your database results in PHP.</p> <div class="padlinks"> <a class="demo" href="http://open.subinsb.com/find">Demo</a> </div> <p>We will be using PDO for database connection and queries. The Database table named &quot;users&quot; is like this :</p> <table class="table"> <tr> <td> id </td> <pre><code>&lt;td&gt; First_Name &lt;/td&gt; &lt;td&gt; Last_Name &lt;/td&gt; </code></pre> </tr> <tr> <td> 1 </td> <pre><code>&lt;td&gt; Subin &lt;/td&gt; &lt;td&gt; Siby &lt;/td&gt; </code></pre> </tr> <tr> <td> 2 </td> <pre><code>&lt;td&gt; Peter &lt;/td&gt; &lt;td&gt; Charles &lt;/td&gt; </code></pre> </tr> <tr> <td> 3 </td> <pre><code>&lt;td&gt; Thomas &lt;/td&gt; &lt;td&gt; Chacko &lt;/td&gt; </code></pre> </tr> </table> <p>It contains more and more data. Itโ€™s just a sample. Letโ€™s move on.</p> <h2 id="variables">Variables</h2> <p>We will set the result limit in a page using theย <strong>$limit</strong> variable :</p> <pre class="prettyprint"><code>$limit = 10;</code></pre> <p>Theย <strong>$p</strong> variable have the page number got from $_GET :</p> <pre class="prettyprint"><code>$p=$_GET['p']=="" ? 1:$_GET['p'];</code></pre> <p>Note that the above variable will have the valueย <strong>1</strong> even if the $_GET[โ€˜pโ€™] is empty or not defined.</p> <p>Theย <strong>$start</strong> variable calculates the starting number weโ€™re going to add in theย <strong>SQL</strong> queries <strong>LIMIT</strong> clause :</p> <pre class="prettyprint"><code>$start=($p-1)*$limit;</code></pre> <p>The page number is subtracted byย <strong>1</strong> and is multiplied by theย <strong>$limit</strong> number which will return the start number used in theย <strong>LIMIT caluse</strong>.</p> <h2 id="get-data">Get Data</h2> <p>We will first get the data from database into theย <strong>$data</strong> variable :</p> <pre class="prettyprint"><code>$sql=$dbh-&gt;prepare("SELECT * FROM users ORDER BY id LIMIT :start, :limit"); $sql-&gt;bindValue(':limit', $limit, PDO::PARAM_INT); $sql-&gt;bindValue(':start', $start, PDO::PARAM_INT); $sql-&gt;execute(); $data=$sql-&gt;fetch(); </code></pre> <p>You can output the data you got from SQL query as you like :</p> <pre class="prettyprint"><code>if($sql-&gt;rowCount()!=0){ while($r=$data){ echo $r['First_Name']." ".$r['Last_Name']; } }else{ echo "No Users Found"; } </code></pre> <p>We add the row checking, because if the page number mentioned is not correct SQL query will return nothing.</p> <h2 id="pagination">Pagination</h2> <p>We will display the pages now and CSS styling to it. The following PHP code will get the actual Total row numbers as <strong>$count</strong> variableย :</p> <pre class="prettyprint"><code>$count=$db-&gt;prepare("SELECT COUNT(id) FROM users ORDER BY id"); $count-&gt;execute(); $count=$count-&gt;fetchColumn();</code></pre> <p>Now, we will generate the pages list in a horizontal scrollable element :</p> <pre class="prettyprint"><code>$countP=(ceil($count/$limit)) + 1; $tW=($countP*50) + $countP; echo"&lt;center style='overflow-x:auto;margin-top:10px;padding-bottom:10px;'&gt;"; echo"&lt;div style='width:".$tW."px'&gt;"; for($i=1;$i&lt;$countP;$i++){ $isC=$i==$_GET['p'] ? "b-green":""; echo "&lt;a href='?p=$i'&gt;&lt;button class='pgbutton $isC'&gt;$i&lt;/button&gt;&lt;/a&gt;"; } echo"&lt;/div&gt;"; echo"&lt;/center&gt;";</code></pre> <p>The styling of the page buttons is :</p> <pre class="prettyprint"><code>&lt;style&gt; .pgbutton{ width:45px; margin:0px 5px; } &lt;/style&gt; </code></pre> <p>If you want to display the no of results, you can use :</p> <pre class="prettyprint"><code>echo"$count Results Found.";</code></pre> <p>You can make changes to the code as you like. When you change the SQL queries, be sure that you have changed the SQL queries of both occurences, one withย <strong>LIMIT clause</strong> and one without.</p> Blog Changes For My 14th Birthday https://subinsb.com/changes-to-blog-for-14th-birthday/ Mon, 20 Jan 2014 02:21:25 +0000 https://subinsb.com/changes-to-blog-for-14th-birthday/ <p>My birthday is here. So long to the age 13. I will turn 14 in 3 hours from the published time of this post. My blog has been changed as like my age. This blog will turnย <strong>3 years</strong> onย <strong>January 30</strong>. A lot of changes happened to this blog since the launch. I still have the memory of the moment when I created this blog with my brother and the help of my neighbor Simraj. I will always be thankful to Simraj bro for giving his time to help me create this blog. Letโ€™s get to the point. I have made some huge changes to this blog (At Server).</p> <h1 id="removed-haproxy">Removed HAproxy</h1> <p>You might be wondering why I removed haproxy, the leading load balancer software. The haproxy I installed is from Openshift. They use their haproxy for other purposes like connecting my app to other nodes which makes the site very slow and causes 503 downtimes most of the time. So I removed Haproxy.</p> <h1 id="moved-domain">Moved Domain</h1> <p>The original domain (blog-subins.rhcloud.com) is moved to main-subins.rhcloud.com. I did this because Openshift doesnโ€™t allow you to remove the web load balancer (haproxy) from an app after itโ€™s created. Since I have to remove haproxy, I had to clone my app with out haproxy. This changed the domain.</p> <h1 id="updated-description">Updated Description</h1> <p>Since Iโ€™m 14 years old now, I had to change the description. There are many sites where I added 13 years mentions. I have to find all those sites and update it something else apart from the 14 year old mention. Because In 2015, I have to change it again.</p> Make Better WordPress Minify Work On OpenShift https://subinsb.com/make-bwp-work-on-openshift-wordpress-blog/ Sat, 18 Jan 2014 06:54:26 +0000 https://subinsb.com/make-bwp-work-on-openshift-wordpress-blog/ <p>If you run aย <strong>WordPress</strong> blog onย <strong>OpenShift</strong>, you might not be able to run the Minify plugins. These plugins wonโ€™t work if your OpenShift app is directly installed from the WordPress catridge they provide. This happens because the plugins, themes and other directories of wp-content are linked directories which means theyโ€™re fake. The folders are just shortcuts of the original folder situated inย <strong>app-root/data</strong>. This makes the minify plugin hard to find the source of the file. Hence it wonโ€™t work.</p> <p>This happened to my blog and I looked in to the source files of plugin and found a solution. You can solve this problem with onlyย **5 linesย **of code !</p> <h1 id="editing-bwp-minifyminindexphp">Editing bwp-minify/min/index.php</h1> <p>The changes we are going to make to fix the problem are on theย <strong>bwp-minify/min/index.php</strong> file of the plugin. You can useย <strong>SFTP</strong> to edit the file or you can use theย <strong>Plugin Editor</strong> of WordPress.</p> <h2 id="sftp">SFTP</h2> <p>See the <a href="//subinsb.com/2013/10/how-to-use-filezillasftp-to-update-site-in-openshift">tutorial</a>ย to know how to use File Transfer Protocol (FTP) to access the source code of you app running on OpenShift.</p> <p>Connect to your siteโ€™s **FTPย **server and go to the following location :</p> <pre class="prettyprint"><code>/var/lib/openshift/your-app-id/app-root/runtime/repo/php/wp-content/plugins/bwp-minify/min</code></pre> <p>Open the fileย <strong>index.php</strong> from the directory using your text editor.</p> <h2 id="wordpress-plugin-editor">WordPress Plugin Editor</h2> <p>Go toย <strong>wp-admin/plugin-editor.php</strong> page. Choose <strong>Betterย Wordpress Minify</strong> from &quot;plugin to edit&quot; field. Then choose</p> <pre class="prettyprint"><code>bwp-minify/min/index.php</code></pre> <p>from the files section shown on right side of window.</p> <h1 id="solution">Solution</h1> <p>Search the file for the following line :</p> <pre class="prettyprint"><code>$min_serveOptions['minifierOptions']['text/css']['symlinks']</code></pre> <p>Add the following code just above the line you just searched :</p> <pre class="prettyprint"><code>if(preg_match("/wp-content/",$_GET['f'])){ ย $_SERVER['DOCUMENT_ROOT'] = "/var/lib/openshift/app-id/app-root"; ย $_GET['f']=str_replace("wp-content/","data/",$_GET['f']); ย $_GET['f']=str_replace("wp-includes/","runtime/repo/php/wp-includes/",$_GET['f']); }</code></pre> <p>Make sure that you have replaced the <strong>app-id</strong> with your applicationโ€™s id. You can get your app id from the Web URL of your app on Openshift Console. An example URL :</p> <pre class="prettyprint"><code>https://openshift.redhat.com/app/console/application/527de613e0b8cdef8d000212-blog</code></pre> <p>From the above URL, the id of the app isย <strong>527de613e0b8cdef8d000212</strong>ย found just after the &quot;<strong>application/&quot;</strong> and end at the &quot;-&quot; sign.</p> <p>And the whole code of that area would be :</p> <pre class="prettyprint"><code>if(preg_match("/wp-content/",$_GET['f'])){ ย $_SERVER['DOCUMENT_ROOT'] = "/var/lib/openshift/app-id/app-root"; ย $_GET['f']=str_replace("wp-content/","data/",$_GET['f']); ย $_GET['f']=str_replace("wp-includes/","runtime/repo/php/wp-includes/",$_GET['f']); } $min_serveOptions['minifierOptions']['text/css']['symlinks'] = $min_symlinks;</code></pre> <p>Save the file. Now, Enable the plugin if itโ€™s deactivated. Open your blog and you will see the magic. If there are any problems, then please comment it on the comments section below. I will be here to help you out.</p> Making Text To Speech In PHP With Google Translate https://subinsb.com/text-to-speech-in-php-with-google-translate/ Thu, 16 Jan 2014 16:30:14 +0000 https://subinsb.com/text-to-speech-in-php-with-google-translate/ <p>Google provides text to speech feature on their translator product which is an awesome feature. If you are creating a web app of your own and need a human speaking voice for your app, you will get lost. Google have a URL for creating these audio files when given a text. I will tell you how to implement this text to speech feature on your <strong>PHP</strong> site without directly compromising the Google URL.</p> <div class="padlinks"> <a class="download" href="http://demos.subinsb.com/down.php?id=404x12bqlmmu/s/y15htxpnn21icg2f9hxz&class=17">Download</a><a class="demo" href="http://demos.subinsb.com/php/speech">Demo</a> </div> <p>For our task, we will only create a file namedย <strong>get_sound.php</strong> which sends a <strong>GET</strong>ย request to Google viaย <strong>cURL</strong> and returns the audio file. We will play this audio file using the audio element inย <strong>HTML5</strong> or you can use SWF players. The audio returned will be of theย <strong>mpeg</strong> format.</p> <h1 id="get_soundphp">get_sound.php</h1> <p>This file sends request to Google and returns the audio file. This file needs theย <strong>text</strong> parameter to return the sound file. The audio file type isย <strong>mpeg</strong>.</p> <pre class="prettyprint"><code>&lt;? if(isset($_GET['text'])){ ย $txt=htmlspecialchars($_GET['text']); ย $txt=rawurlencode($txt); ย if($txt!=""ย ||ย strlen($txt)ย &lt;ย 100){ ย ย header("Content-type:ย audio/mpeg"); ย ย $url="http://translate.google.com/translate_tts?ie=UTF-8&q=$txt&tl=en"; ย ย $chย =ย curl_init(); ย ย curl_setopt($ch,ย CURLOPT_URL,ย $url); ย ย curl_setopt($ch,ย CURLOPT_RETURNTRANSFER,ย true); ย ย curl_setopt($ch,ย CURLOPT_TIMEOUT,ย 30); ย ย $audioย =ย curl_exec($ch); ย ย echoย $audio; ย }else{ ย ย echoย "Noย valueย orย Stringย exceedsย 100ย characters."; ย } } ?&gt;</code></pre> <p>As you can see, the URL of the Google text to speech is :</p> <pre class="prettyprint"><code>http://translate.google.com/translate_tts?ie=UTF-8&q=$txt&tl=en</code></pre> <p>where <strong>$txt</strong> is a string.</p> <p>This is applicable only to english. So, pronunciation will be different for other languages. In this case, replace the &quot;en&quot; in the url to the short forms of the language needed to make speech.</p> <p>You can see shortย forms in <a href="https://github.com/subins2000/francium-translator/blob/master/class.translator.php" target="_blank">this file</a>ย from line 52.</p> <h1 id="update-8211-14-dec-2015">UPDATE โ€“ 14 Dec 2015</h1> <p>This doesnโ€™t work anymore as Google enhanced the URL making us unable to use it. Now, a 403 status is returned when requests are made to the URL.</p> <p>So, sorry guys and gals it dosenโ€™t work anymore</p> Create Group Chat In PHP With MySQL, jQuery And AJAX https://subinsb.com/group-chat-in-php-with-ajax-jquery-mysql/ Wed, 15 Jan 2014 17:34:29 +0000 https://subinsb.com/group-chat-in-php-with-ajax-jquery-mysql/ <p>Chatting is one of the most implemented feature on websites. Group chat makes users to share their feelings and other news easily to their friends easily. AJAX makes this chatting more beautiful, elegant, simple and comfortable. Group chats may be vulnerable to <strong>SQL injections</strong> and <strong>XSS attacks</strong>. But in this post where weโ€™re going to make a group chat thatย <strong>doesnโ€™t have these vulnerabilities</strong> which makes it more awesome. You can see a demo, or you can download the files directly.</p> <div class="padlinks"> <a class="download" href="http://demos.subinsb.com/down.php?id=b4i8alv3xd7k/s/6wle8d7632fcj0w2j80x&class=16" target="_blank">Download</a><a class="demo" href="http://demos.subinsb.com/php/chat" target="_blank">Demo</a> </div> <h2 id="things-to-note">Things To Note</h2> <p>Make sure the Time Zone on MySQL server is the same as on PHP server. If the time zone is different, the userโ€™s online presence canโ€™t be understood.</p> <p>We limit the name of the user toย <strong>20 characters</strong>, because we donโ€™t want a long name that overflows the &quot;online users&quot; display element. There is no error message displayed when a user submits a name of more than 20 chars. If the user submits the name of 20 chars, the first 20 chars will only be inserted in to the table. Other chars after 20 chars will be removed by MySQL.</p> <p>If you needย <strong>Usersโ€™ Typing Status</strong> display with the chat, see <a title="Group Chat In PHP With Users' Typing Status" href="//subinsb.com/php-group-chat-with-user-type-status" target="_blank">this tutorial</a> after completing this tutorial.</p> <h2 id="tablessql">tables.sql</h2> <p>The SQL code that creates the two tables needed for the group chat is contained in theย <strong>tables.sql</strong> file :</p> <pre class="prettyprint"><code>-- Set MySQL timezone to UTC SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO"; SET GLOBAL time_zone = "+00:00"; -- Table structure for table `chatters` CREATE TABLE IF NOT EXISTS `chatters` ( `name` varchar(20) NOT NULL, `seen` varchar(20) NOT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1; -- Table structure for table `messages` CREATE TABLE IF NOT EXISTS `messages` ( `name` varchar(20) NOT NULL, `msg` text NOT NULL, `posted` varchar(20) NOT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1;</code></pre> <p>When you execute the aboveย <strong>SQL</strong> code, you will have two tables, oneย <strong>chatters</strong> and the otherย <strong>messages</strong>. Inย <strong>chatters</strong> table, we add the logged in usersโ€™ details where as the other one, we will add the messages sent by the users.</p> <h2 id="configphp">config.php</h2> <p>The database configuration is stored in this file. You should change the credentials according to your database :</p> <pre class="prettyprint"><code>&lt;? // ini_set("display_errors","on"); if(!isset($dbh)){ session_start(); date_default_timezone_set("UTC"); $musername = "username"; $mpassword = "password"; $hostname = "hostname"; $dbname = "dbname"; $dbh=new PDO('mysql:dbname='.$dbname.';host='.$hostname.";port=3306",$musername, $mpassword); /*Change The Credentials to connect to database.*/ include("user_online.php"); } ?&gt; </code></pre> <p>The session is started when this file loads. There is a file namedย <strong>user_online.php</strong> included in the file. This file deletes the offline users and updates the time stamp of the currently logged in user. This time stamp determines the online, offline status. I explained more about it in theย <strong>user_online.php</strong> heading in this post.</p> <h2 id="indexphp">index.php</h2> <p>The main character of our chat is this file.ย <strong>index.php</strong>ย joins everything together.</p> <pre class="prettyprint"><code>&lt;?include("config.php");include("login.php");?&gt; &lt;!DOCTYPEย html&gt; &lt;html&gt; ย &lt;head&gt; ย ย &lt;scriptย src="//code.jquery.com/jquery-1.11.1.min.js"&gt;&lt;/script&gt; ย ย &lt;scriptย src="chat.js"&gt;&lt;/script&gt; ย ย &lt;linkย href="chat.css"ย rel="stylesheet"/&gt; ย ย &lt;title&gt;PHPย Groupย Chatย Withย jQueryย &ย AJAX&lt;/title&gt; ย &lt;/head&gt; ย &lt;body&gt; ย ย &lt;divย id="content"ย style="margin-top:10px;height:100%;"&gt; ย ย ย &lt;center&gt;&lt;h1&gt;Groupย Chatย Inย PHP&lt;/h1&gt;&lt;/center&gt; ย ย ย &lt;divย class="chat"&gt; ย ย ย ย &lt;divย class="users"&gt; ย ย ย ย ย &lt;?include("users.php");?&gt; ย ย ย ย &lt;/div&gt; ย ย ย ย &lt;divย class="chatbox"&gt; ย ย ย ย ย &lt;? ย ย ย ย ย if(isset($_SESSION['user'])){ ย ย ย ย ย ย include("chatbox.php"); ย ย ย ย ย }else{ ย ย ย ย ย ย $display_case=true; ย ย ย ย ย ย include("login.php"); ย ย ย ย ย } ย ย ย ย ย ?&gt; ย ย ย ย &lt;/div&gt; ย ย ย &lt;/div&gt; ย ย &lt;/div&gt; ย &lt;/body&gt; &lt;/html&gt; </code></pre> <p>When a user is not logged in, this file will load theย <strong>login.php</strong> file which have the login box and others. If the user is logged in, then it will directly display the <strong>chatbox.php</strong> which contains the chatbox. Users who are currently online are shown usingย <strong>users.php</strong> file.</p> <h2 id="loginphp">login.php</h2> <p>The login box and the login authentication, filtering, checking are added in this file. This file is included twice in theย <strong>index.php</strong> file, one for checking and other for displaying login box.</p> <pre class="prettyprint"><code>&lt;? if(isset($_POST['name']) && !isset($display_case)){ $name=htmlspecialchars($_POST['name']); if($name!=""){ $sql=$dbh-&gt;prepare("SELECT name FROM chatters WHERE name=?"); $sql-&gt;execute(array($name)); if($sql-&gt;rowCount()!=0){ $ermsg="&lt;h2 class='error'&gt;Name Taken. &lt;a href='index.php'&gt;Try another Name.&lt;/a&gt;&lt;/h2&gt;"; }else{ $sql=$dbh-&gt;prepare("INSERT INTO chatters (name,seen) VALUES (?,NOW())"); $sql-&gt;execute(array($name)); $_SESSION['user']=$name; } }else{ $ermsg="&lt;h2 class='error'&gt;&lt;a href='index.php'&gt;Please Enter A Name.&lt;/a&gt;&lt;/h2&gt;"; } }elseif(isset($display_case)){ if(!isset($ermsg)){ ?&gt; &lt;h2&gt;Name Needed For Chatting&lt;/h2&gt; You must provide a name for chatting. This name will be visible to other users.&lt;br/&gt;&lt;br/&gt; &lt;form action="index.php" method="POST"&gt; &lt;div&gt;Your Name : &lt;input name="name" placeholder="A Name Please"/&gt;&lt;/div&gt; &lt;button&gt;Submit & Start Chatting&lt;/button&gt; &lt;/form&gt; &lt;? }else{ echo $ermsg; } } ?&gt;</code></pre> <p>If the user has submitted the login form, then this file will do the following :</p> <ul> <li>Filter Name (Remove HTML entities)</li> <li>Check If there is another user with the name</li> </ul> <p>If everything is OK, then the file changes theย <strong>user</strong> value of session to the name submitted.ย <strong>index.php</strong> andย <strong>chatbox.php</strong> takes care of the rest.</p> <h2 id="chatboxphp">chatbox.php</h2> <p>This file donโ€™t have that much content. This file contains the log out link, chat messages container and chat form :</p> <pre class="prettyprint"><code>&lt;? include("config.php"); if(isset($_SESSION['user'])){ ?&gt; ย &lt;h2&gt;Roomย Forย ALL&lt;/h2&gt; ย &lt;aย style="right:ย 20px;top:ย 20px;position:ย absolute;cursor:ย pointer;"ย href="logout.php"&gt;Logย Out&lt;/a&gt; ย &lt;divย class='msgs'&gt; ย ย &lt;?include("msgs.php");?&gt; ย &lt;/div&gt; ย &lt;formย id="msg_form"&gt; ย  &lt;inputย name="msg"ย size="30"ย type="text"/&gt; ย  &lt;button&gt;Send&lt;/button&gt; &lt;/form&gt; &lt;? } ?&gt;</code></pre> <p>The messages are displayed fromย <strong>msgs.php</strong> and the form is also displayed.</p> <h2 id="msgsphp">msgs.php</h2> <p>Displays the messages sent by the other users and himself/herself. A request is made to this file every 5 seconds to check new messages. When the user logs out from another page of the browser window,ย <strong>msgs.php</strong> will make the current page reload to make sure everything is alright.</p> <pre class="prettyprint"><code>&lt;? include("config.php"); $sql=$dbh-&gt;prepare("SELECTย *ย FROMย messages"); $sql-&gt;execute(); while($r=$sql-&gt;fetch()){ ย echoย "&lt;divย class='msg'ย title='{$r['posted']}'&gt;&lt;spanย class='name'&gt;{$r['name']}&lt;/span&gt;ย :ย &lt;spanย class='msgc'&gt;{$r['msg']}&lt;/span&gt;&lt;/div&gt;"; } if(!isset($_SESSION['user'])ย &&ย strtolower($_SERVER['HTTP_X_REQUESTED_WITH'])=='xmlhttprequest'){ ย echoย "&lt;script&gt;window.location.reload()&lt;/script&gt;"; } ?&gt;</code></pre> <h2 id="sendphp">send.php</h2> <p>When the user submits a message, the message is sent toย <strong>send.php</strong>. This file handles the message, filters it and insert into database.</p> <pre class="prettyprint"><code>&lt;? include("config.php"); if(!isset($_SESSION['user'])ย &&ย strtolower($_SERVER['HTTP_X_REQUESTED_WITH'])=='xmlhttprequest'){ ย die("&lt;script&gt;window.location.reload()&lt;/script&gt;"); } if(isset($_SESSION['user'])ย &&ย isset($_POST['msg'])){ ย $msg=htmlspecialchars($_POST['msg']); ย if($msg!=""){ ย ย $sql=$dbh-&gt;prepare("INSERTย INTOย messagesย (name,msg,posted)ย VALUESย (?,?,NOW())"); ย ย $sql-&gt;execute(array($_SESSION['user'],$msg)); ย } } ?&gt;</code></pre> <h2 id="usersphp">users.php</h2> <p>Currently online users are displayed using this file. This file is also requested in every 5 seconds byย <strong>jQuery</strong>.</p> <pre class="prettyprint"><code>&lt;? include("config.php"); echoย "&lt;h2&gt;Users&lt;/h2&gt;"; $sql=$dbh-&gt;prepare("SELECTย nameย FROMย chatters"); $sql-&gt;execute(); while($r=$sql-&gt;fetch()){ ย echoย "&lt;divย class='user'&gt;{$r['name']}&lt;/div&gt;"; } ?&gt;</code></pre> <h2 id="user_onlinephp">user_online.php</h2> <p>Whenever theย <strong>config.php</strong>ย file is called, this file is also called. This file loops through the online users on tableย <strong>chatters</strong> and check if their time stamp is lesser that 25 seconds the current time. If it is lesser, then that user is dropped (deleted) from the table. It also updates the time stamp of the currently logged in user if there is one making it impossible for the other script to delete the current user. It is necessary to have the same time zone onย **MySQLย **server and theย <strong>PHP</strong> server. If the currently logged in user is accidentally deleted in case of misunderstanding, the script will automatically add the user to the tableย <strong>chatters</strong>. What an important file !</p> <pre class="prettyprint"><code>&lt;? if(isset($_SESSION['user'])){ ย $sqlm=$dbh-&gt;prepare("SELECTย nameย FROMย chattersย WHEREย name=?"); ย $sqlm-&gt;execute(array($_SESSION['user'])); ย if($sqlm-&gt;rowCount()!=0){ ย ย $sql=$dbh-&gt;prepare("UPDATEย chattersย SETย seen=NOW()ย WHEREย name=?"); ย ย $sql-&gt;execute(array($_SESSION['user'])); ย }else{ ย ย $sql=$dbh-&gt;prepare("INSERTย INTOย chattersย (name,seen)ย VALUESย (?,NOW())"); ย ย $sql-&gt;execute(array($_SESSION['user'])); ย } } /* Make sure the timezone on Database server and PHP server is same */ $sql=$dbh-&gt;prepare("SELECTย *ย FROMย chatters"); $sql-&gt;execute(); while($r=$sql-&gt;fetch()){ ย $curtime=strtotime(date("Y-m-dย H:i:s",strtotime('-25ย seconds',ย time()))); ย if(strtotime($r['seen'])ย &lt;ย $curtime){ ย ย $kql=$dbh-&gt;prepare("DELETEย FROMย chattersย WHEREย name=?"); ย ย $kql-&gt;execute(array($r['name'])); ย } } ?&gt;</code></pre> <h2 id="logoutphp">logout.php</h2> <p>If the user can log in,.there should be a log out option. Here is the file that will destroy the session and redirects to the main page or as you call it &quot;logout&quot; :</p> <pre class="prettyprint"><code>&lt;? session_start(); include("config.php"); $sql=$dbh-&gt;prepare("DELETEย FROMย chattersย WHEREย name=?"); $sql-&gt;execute(array($_SESSION['user'])); session_destroy(); header("Location:ย index.php"); ?&gt;</code></pre> <h1 id="client-side">Client Side</h1> <p>Itโ€™s time to move to the client side, where we will design our chatbox withย <strong>CSS</strong> and add theย <strong>jQuery</strong> code to make it easy.</p> <h2 id="chatcss">chat.css</h2> <p>The chatbox, online users and other styling is in here :</p> <pre class="prettyprint"><code>.chat .users, .chat .chatbox{ display:inline-block; vertical-align:top; height:350px; padding:0px 15px; position:relative; } .chat .users{ background:#CCC; color:white; width:98px; overflow-y:auto; } .chat .chatbox{ background:#fff; color:black; margin-left:4px; width:330px; } .chat .chatbox .msgs{ border-top:1px solid black; border-bottom:1px solid black; overflow-y:auto; height:260px; } .chat .chatbox #msg_form{ padding-top:1.5px; } .chat .error{color:red;} .chat .success{color:green;} .chat .msgs .msg, .chat .users .user{border-bottom:1px solid black;padding:4px 0px;white-space:pre-line;word-break:break-word;}</code></pre> <p>The elements we added are all wrapped in theย <strong>.chat</strong> container, so the <strong>chat.css</strong>ย wonโ€™t mess up any other styles of your site.</p> <h2 id="chatjs">chat.js</h2> <p>Theย <strong>jQuery</strong> code is the content of this file. Note that you should add a **script[src]ย **that links to theย <strong>jQuery</strong> library source.</p> <pre class="prettyprint"><code>functionย scTop(){ ย $(".msgs").animate({scrollTop:$(".msgs")[0].scrollHeight}); } functionย load_new_stuff(){ ย localStorage['lpid']=$(".msgsย .msg:last").attr("title"); ย $(".msgs").load("msgs.php",function(){ ย ย if(localStorage['lpid']!=$(".msgsย .msg:last").attr("title")){ ย ย ย scTop(); ย ย } ย }); ย $(".users").load("users.php"); } $(document).ready(function(){ ย scTop(); ย $("#msg_form").on("submit",function(){ ย ย t=$(this); ย ย val=$(this).find("input[type=text]").val(); ย ย if(val!=""){ ย ย ย t.after("&lt;spanย id='send_status'&gt;Sending.....&lt;/span&gt;"); ย ย ย $.post("send.php",{msg:val},function(){ ย ย ย ย load_new_stuff(); ย ย ย ย $("#send_status").remove(); ย ย ย ย t[0].reset(); ย ย ย }); ย ย } ย ย returnย false; ย }); }); setInterval(function(){ ย load_new_stuff(); },5000);</code></pre> <p>I think thatโ€™s all the files. I made it to these much files to make the tutorial easy. Hope you like it. Be open source, share this with your developer friends. Iโ€™m sure they would love to see this. If you have any problems / suggestions, please say it out in the comments, I would love to hear it from you and I will reply if there isnโ€™t any stupid school projects.</p> Simplest Way To Detect A Mobile Device In PHP https://subinsb.com/how-to-detect-a-mobile-device-in-php/ Tue, 14 Jan 2014 06:12:25 +0000 https://subinsb.com/how-to-detect-a-mobile-device-in-php/ <p>Mobile users are increasing. Most of the site visitors of a website is using mobiles to browse. So you need to redirect users who uses mobile to a mobile page of your site. In Javascript it is easy, because you can check the width and height of the window. But on server side, it can become difficult. You will findย <strong>is_mobile()</strong> function in this post which detects if the client is in mobile or not.</p> <p>This function checks the user agent parameter inย <strong>$_SERVER</strong> variable to determine if the user is using mobile or not. Here is the function :</p> <pre class="prettyprint"><code>function is_mobile(){ global $_SERVER; $useragent=$_SERVER['HTTP_USER_AGENT']; return preg_match('/(android|bbd+|meego).+mobile|avantgo|bada/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)/|plucker|pocket|psp|series(4|6)0|symbian|treo|up.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i',$useragent)||preg_match('/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw-(n|u)|c55/|capi|ccwa|cdm-|cell|chtm|cldc|cmd-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc-s|devi|dica|dmob|do(c|p)o|ds(12|-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(-|_)|g1 u|g560|gene|gf-5|g-mo|go(.w|od)|gr(ad|un)|haie|hcit|hd-(m|p|t)|hei-|hi(pt|ta)|hp( i|ip)|hs-c|ht(c(-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i-(20|go|ma)|i230|iac( |-|/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |/)|klon|kpt |kwc-|kyo(c|k)|le(no|xi)|lg( g|/(k|l|u)|50|54|-[a-w])|libw|lynx|m1-w|m3ga|m50/|ma(te|ui|xo)|mc(01|21|ca)|m-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|-([1-8]|c))|phil|pire|pl(ay|uc)|pn-2|po(ck|rt|se)|prox|psio|pt-g|qa-a|qc(07|12|21|32|60|-[2-7]|i-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55/|sa(ge|ma|mm|ms|ny|va)|sc(01|h-|oo|p-)|sdk/|se(c(-|0|1)|47|mc|nd|ri)|sgh-|shar|sie(-|m)|sk-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h-|v-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl-|tdg-|tel(i|m)|tim-|t-mo|to(pl|sh)|ts(70|m-|m3|m5)|tx-9|up(.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas-|your|zeto|zte-/i',substr($useragent,0,4)); } </code></pre> <p>Here is an example usage of this function :</p> <pre class="prettyprint"><code>&lt;? if( is_mobile() ){ // It's mobile }else{ //It's not mobile } ?&gt;</code></pre> <p>Thatโ€™s it for today.</p> Open Blog https://subinsb.com/open-blog/ Sat, 11 Jan 2014 15:01:51 +0000 https://subinsb.com/open-blog/ <p>Open, the open source social network have a new blog now. This blog can be accessed at <a href="http://open.subinsb.com/blog" target="_blank"><a href="http://open.subinsb.com/blog">http://open.subinsb.com/blog</a></a>. This new blog will contain the documentation of Open, news about Open and other info about Open. Developers are required to read the functions before making changes to the source code. Developers can also ask questions on the <a href="http://open.subinsb.com/blog/developer" target="_blank">developer</a> page of Open Blog. Happy coding !</p> Parsing sMention Form Data On Server In PHP https://subinsb.com/parsing-smention-form-data-in-php/ Thu, 09 Jan 2014 17:24:30 +0000 https://subinsb.com/parsing-smention-form-data-in-php/ <p>In my previous post, I introduced theย <strong>sMention</strong> <strong>jQuery</strong> plugin โ€“ a plugin that adds theย <strong>@mentions</strong>ย to a input element. But I havenโ€™t told in the post how to handle the data on the server side after the form has been submitted. This handling replaces theย <strong>@mentions</strong> to the userโ€™s name inย <strong>a[href]</strong> tag. Itโ€™s made possible usingย <strong>smention</strong> function bind as the callback function ofย <strong>preg_replace_callback</strong>. This smention function can be seen on the fileย <a href="https://github.com/subins2000/open/blob/master/comps/config.php" target="_blank"><strong>comps/config.php</strong></a> in the <a href="https://github.com/subins2000/open" target="_blank">Open Repository</a>.</p> <div class="padlinks"> <a class="download" href="https://github.com/subins2000/smention/archive/master.zip" target="_blank">Download</a><a class="demo" href="http://demos.subinsb.com/jquery/smention" target="_blank">Demo</a> </div> <p>The formโ€™s data is searched for theย <strong>@</strong> character. The callback function is smention. The following line will set the callback :</p> <blockquote> <p>$data=preg_replace_callback(&quot;/@(.*?)(s|z)/&quot;, function($match) use ($data){return smention($match,data);},$data);</p> </blockquote> <p>where $data is the input data. An Example input data :</p> <blockquote> <p>@1 Google is the best search engine ever.</p> </blockquote> <p>The above data when parsed usingย <strong>smention</strong> function will return the data as (in my case [Open]) :</p> <blockquote> <p>&lt;a href=&quot;http://open.subinsb.com/1โ€ณ&gt;Subin Siby</a> Google is the best search engine ever.</p> </blockquote> <p>Hereโ€™s the code I used onย **Openย **(<a href="http://open.subinsb.com" target="_blank"><a href="http://open.subinsb.com">http://open.subinsb.com</a></a>) :</p> <blockquote> <p>functionย smention($s,$t){</p> </blockquote> <blockquote> <p>ย $userid=$t[1];</p> </blockquote> <blockquote> <p>ย $nxs=strpos($s,&quot;@$userid&quot;);</p> </blockquote> <blockquote> <p>ย $nxs=strlen(&quot;@$userid&quot;)+$nxs;</p> </blockquote> <blockquote> <p>ย $nxs=substr($s,$nxs,1);</p> </blockquote> <blockquote> <p>ย global$db;</p> </blockquote> <blockquote> <p>ย $sql=$db-&gt;prepare(&quot;SELECTย nameย FROMย usersย WHEREย id=?&quot;);</p> </blockquote> <blockquote> <p>ย $sql-&gt;execute(array($userid));</p> </blockquote> <blockquote> <p>ย if($sql-&gt;rowCount()==0){</p> </blockquote> <blockquote> <p>ย ย return&quot;@$userid&quot;.$nxs;</p> </blockquote> <blockquote> <p>ย }else{</p> </blockquote> <blockquote> <p>ย ย while($r=$sql-&gt;fetch()){</p> </blockquote> <blockquote> <p>ย ย ย $name=$r[โ€˜nameโ€™];</p> </blockquote> <blockquote> <p>ย ย }</p> </blockquote> <blockquote> <p>ย ย $html=&quot;&lt;aย href=โ€™//open.com/$useridโ€™&gt;@$name</a>&quot;.$nxs;</p> </blockquote> <blockquote> <p>ย ย return$html;</p> </blockquote> <blockquote> <p>ย }</p> </blockquote> <blockquote> <p>}</p> </blockquote> <blockquote> <p>$data=$_POST[โ€˜dataโ€™];</p> </blockquote> <blockquote> <p>$data=preg_replace_callback(&quot;/@(.*?)(s|z|[^0-9])/&quot;,ย function($t)ย useย ($s){returnย smention($s,$t);},$s);</p> </blockquote> <p>You can see the whole smention function at <a href="https://github.com/subins2000/open/blob/master/comps/config.php" target="_blank"><a href="https://github.com/subins2000/open/blob/master/comps/config.php">https://github.com/subins2000/open/blob/master/comps/config.php</a></a></p> Fix WordPress Database Error "MySQL server has gone away.." https://subinsb.com/fix-wordpress-error-mysql-server-has-gone-away/ Thu, 09 Jan 2014 15:00:31 +0000 https://subinsb.com/fix-wordpress-error-mysql-server-has-gone-away/ <p>If you run a WordPress blog and see the error &quot;MySQL server has gone away for queryโ€ฆ..&quot; on your error logs a lot, you are certainly in trouble. When this happens, your blog will be down. It happened to this blog and I started searching for a solution. Finally I got a solution and it works. Itโ€™s a simple solution. All you have to do is add 2 lines after a specific code. Letโ€™s get right on it.</p> <p>This trick will work for all WordPress versions. Open yourย Wordpress directory. The directory will contain the folders :</p> <ol> <li>wp-admin</li> <li>wp-content</li> <li>wp-includes</li> </ol> <p>Openย <strong>wp-includes</strong>. Search for theย **wp-db.phpย **file. If you found the file, open it using a text editor. Using the text editorโ€™s search tool, search for :</p> <blockquote> <p>$this-&gt;ready = true;</p> </blockquote> <p>Here is a screenshot of the found string inย <strong>gEdit</strong> text editor :</p> <p style="text-align: center;"> <a href="//lab.subinsb.com/projects/blog/uploads/2014/01/0073.png"><img class="aligncenter size-medium wp-image-2214" src="//lab.subinsb.com/projects/blog/uploads/2014/01/0073-300x135.png" alt="0073" width="300" height="135" /></a> </p> <p>Once you found the line, add the following lines just after the found line :</p> <blockquote> <p>//WP Query Gone Away Error Fix</p> </blockquote> <blockquote> <p>$this-&gt;query(&quot;set session wait_timeout=600&quot;);</p> </blockquote> <p>Save the file. Now, when you check the error log of your site, you wonโ€™t see the error anymore which means that the site wonโ€™t go down as before.</p> <p>This is just a temporary fix. You canโ€™t be 100% sure that the error wonโ€™t come anymore. By doing this &quot;fix&quot;, MySQL will wait for some time to finish a query. Here are some tips to fix this error permanently :</p> <ol> <li>Try Disabling / Removing Very High Memory Needed Plugins</li> <li>Disable plugins one by one and find the plugins that cause this error</li> <li>Use plugins that you only need. More plugins means more C.P.U memory and MySQL server will be overloaded</li> <li>Use LightWeight Themes that only uses less memory (ย <a href="http://www.wpthm.com/wordpress/lightweight" target="_blank"><a href="http://www.wpthm.com/wordpress/lightweight">http://www.wpthm.com/wordpress/lightweight</a></a> )</li> </ol> Add @mentions To Input Fields โ€“ jQuery sMention Plugin https://subinsb.com/jquery-smention-plugin/ Wed, 08 Jan 2014 17:54:30 +0000 https://subinsb.com/jquery-smention-plugin/ <p>Mentioning persons usingย **@ย **is pretty common on social web sites. Facebook, Google+ and even StackOverflow have theย **@mentionย **feature. They developed it on their own and doesnโ€™t share the code with others. If you are developing a social site, then itโ€™s better to have thisย mention feature. I wanted this, but theย <strong>jQuery</strong> plugins I found was too big.</p> <p>The first plugin I found wasย <strong>20 KB</strong> ! This made me create a plugin of my own to accomplish my need. Hence I createdย <strong>sMention</strong>ย โ€“ a plugin that implements theย @mention feature on elements. I created it in a day, so there might be errors and it isnโ€™t perfect. I made aย <a href="https://github.com/subins2000/smention" target="_blank"><strong>GitHu</strong><strong>b</strong> repository</a> forย sMention. You can contribute toย sMention by suggestions, feedback and reporting bugs.</p> <h2 id="current-version--02">Current Version : 0.2</h2> <h2 id="size--40-kb">Size : 4.0 KB</h2> <h2 id="last-update--25--01--2014-ddmmyyyy">Last Update : 25 / 01 / 2014 (DD/MM/YYYY)</h2> <div class="padlinks"> <a class="download" href="http://demos.subinsb.com/down.php?id=gjys13rzolod/s/4bap9bxwi5d2d8e5au5z&class=15" target="_blank">Download</a>ย <a class="demo" href="http://demos.subinsb.com/jquery/smention" target="_blank">Demo</a> </div> <p>In this post Iโ€™m going to give you the details and usage of this plugin.</p> <h2 id="usage">Usage</h2> <p>Add the following two lines of code in theย <strong>head</strong> section of yourย <strong>HTML</strong> :</p> <pre class="prettyprint"><code>&lt;script src="smention.js"&gt;&lt;/script&gt; &lt;link href="smention.css" rel="stylesheet"/&gt;</code></pre> <p>Theย <strong>smention.js</strong> andย **smention.cssย **can be found in the Download package or in theย <strong>GitHub</strong> repository (<a href="https://github.com/subins2000/smention">https://github.com/subins2000/smention</a>).</p> <p>A simple example is :</p> <pre class="prettyprint"><code>$("#textarea").smention("get_users.php");</code></pre> <p>Theย <strong>smention</strong> function also accepts other parameters :</p> <h2 id="parameters">Parameters</h2> <ul> <li>URL ย  ย  โ€“ The URL to send the request</li> <li>Options โ€“ A <strong>JSON</strong> array containing the options</li> </ul> <p>Currently the options that supports are :</p> <ul> <li>avatar : false ( If set to true, avatars will be shown aside to the name )</li> <li>extraParams : {} ( If a JSON array is given, it will be sent as GET parameters within the request to the URL )</li> <li>position : &quot;above&quot; ( If set to &quot;below&quot;, the list will be shown below the input field )</li> <li>after : null ( If a string is given, it will be added within the selection of user. eg : @1 text_added )</li> <li>cache : true ( If set to false, requests will not be cached )</li> </ul> <h2 id="response-data">Response Data</h2> <p>The response data which the plugin will parse should be inย <strong>JSON</strong> format. An example is given :</p> <pre class="prettyprint"><code>{ "0" : { "id":"1", "name":"Subin", "avatar":"http://open.subinsb.com/data/1/img/avatar" }, "1" : { "id":"2", "name":"Simrin", "avatar":"" } }</code></pre> <p>By default the avatar winโ€™t be shown unless you set the &quot;avatar&quot; parameter to &quot;true&quot;.</p> <p>Theย <strong>id</strong> key holds the unique id of the user. This can be a integer or a username according to your system.</p> <h2 id="customize">Customize</h2> <p>You can change the trigger character fromย <strong>@</strong>ย toย <strong>#</strong> or any other characters. You only need to replace the keycode. In theย <strong>smention.js</strong> file, replace allย <strong>50</strong> character toย <strong>51</strong> if you need to trigger onย <strong>#</strong> character. Here are some of the keycodes for special characters :</p> <pre class="prettyprint"><code>keyCode - Key - Description 51 - 3 - used for &lt;strong>#&lt;/strong> 52 - 4 - used for &lt;strong>$&lt;/strong> 54 - 6 - used for &lt;strong>^&lt;/strong>ย </code></pre> <p>You can find more key codes from <a href="http://www.cambiaresearch.com/articles/15/javascript-char-codes-key-codes" target="_blank">here</a>.</p> <h2 id="examples">Examples</h2> <p>Adding on the #textarea element (textarea) with avatars :</p> <pre class="prettyprint"><code>$("#textarea").smention("get_users.php",{ ย avatar : true });</code></pre> <p>Adding on the #input element (input[type=text]) with extraParams :</p> <pre class="prettyprint"><code>$("#input").smention("get_users.php",{ ย extraParams : {"akey" : "avalue"} });</code></pre> <p>Adding a white space after the user selection :</p> <pre class="prettyprint"><code>$("#input").smention("get_users.php",{ after : " " });</code></pre> <p>The above code will add a white space after the string of the user selection. Example :</p> <pre class="prettyprint"><code>@subinย </code></pre> <p>If the position parameter in options is set to &quot;below&quot;, the suggestion box will be below the input :</p> <p><a href="//lab.subinsb.com/projects/blog/uploads/2014/01/0080.png"><img class="aligncenter size-medium wp-image-2315" alt="0080" src="//lab.subinsb.com/projects/blog/uploads/2014/01/0080-300x122.png" width="300" height="122" /></a></p> <p>instead of above the input :</p> <p><a href="//lab.subinsb.com/projects/blog/uploads/2014/01/0081.png"><img class="aligncenter size-medium wp-image-2316" alt="0081" src="//lab.subinsb.com/projects/blog/uploads/2014/01/0081-300x123.png" width="300" height="123" /></a></p> <p>This plugin is used in <a href="http://open.subinsb.com" target="_blank">Open</a>. You can see this plugin in action @ Open. Please contribute to this plugin. We can make this plugin more awesome. I will keep improving this project if I get time.</p> Check If a Number is Odd Or Even In PHP & JavaScript https://subinsb.com/check-if-number-is-odd-or-even-in-php-javascript/ Mon, 06 Jan 2014 14:42:52 +0000 https://subinsb.com/check-if-number-is-odd-or-even-in-php-javascript/ <p>Odd numbers and even numbers are used inย programming languages. To check if a number is even or odd needs brilliant code. In this post, you will be introduced toย <strong>checkNum()</strong> function in bothย <strong>PHP</strong> andย <strong>JavaScript</strong>. This functions will return <strong>even</strong>ย for even numbers andย <strong>odd</strong> for odd numbers.</p> <h1 id="parameters">Parameters</h1> <p>$num โ€“ An integer (PHP)</p> <p>num ย  โ€“ An integer (JS)</p> <h1 id="returns">Returns</h1> <p>&quot;odd&quot; for odd number, &quot;even&quot; for even number.</p> <h1 id="function">Function</h1> <h2 id="javascript">JavaScript</h2> <blockquote> <p>functionย checkNum(num){</p> </blockquote> <blockquote> <p>ย if(numย %ย 2){</p> </blockquote> <blockquote> <p>ย ย returnย &quot;even&quot;;</p> </blockquote> <blockquote> <p>ย }else{</p> </blockquote> <blockquote> <p>ย ย returnย &quot;odd&quot;;</p> </blockquote> <blockquote> <p>ย }</p> </blockquote> <blockquote> <p>}</p> </blockquote> <h2 id="php">PHP</h2> <blockquote> <p>functionย checkNum($num){</p> </blockquote> <blockquote> <p>ย if($numย %ย 2){</p> </blockquote> <blockquote> <p>ย ย returnย &quot;even&quot;;</p> </blockquote> <blockquote> <p>ย }else{</p> </blockquote> <blockquote> <p>ย ย returnย &quot;odd&quot;;</p> </blockquote> <blockquote> <p>ย }</p> </blockquote> <blockquote> <p>}</p> </blockquote> E-Mail Verification Script In PHP Using Mailgun API https://subinsb.com/e-mail-verification-script-in-php-using-mailgun-api/ Fri, 03 Jan 2014 15:47:12 +0000 https://subinsb.com/e-mail-verification-script-in-php-using-mailgun-api/ <p>As years goes, so does the increase inย <strong>SPAM</strong> on the web. Most users sign up on services with a fake E-Mail. They might even use otherโ€™s E-Mail for signing up. This is a big problem, because when you send an email to the signed up user, it goes to the wrong guy. So, you should verify userโ€™s email before signing them up. You might think that it would costย <strong>database</strong> memory. Donโ€™t worry, because my script wonโ€™t require storage of verification codes on database.</p> <div class="padlinks"> <a class="demo" href="http://open.subinsb.com/register">DEMO</a> </div> <h1 id="dependencies">Dependencies</h1> <ol> <li>Mailgun API key</li> <li>send_mail() function which you will get from <a title="Send Free E-Mails Using Mailgun API in PHP" href="//subinsb.com/2013/12/send-free-emails-using-mailgun-api-in-php" target="_blank">here</a>.</li> <li>rantext() function which you will get from <a title="Generating Random Text in PHP" href="//subinsb.com/2013/08/generating-random-text-in-php" target="_blank">here</a>.</li> <li>encrypter() function which you will get from <a title="Encryption & Decryption Using Mcrypt In PHP" href="//subinsb.com/2013/12/secure-encryption-decryption-using-mcrypt-php" target="_blank">here</a>.</li> <li>decrypter() function which you will get from <a title="Encryption & Decryption Using Mcrypt In PHP" href="//subinsb.com/2013/12/secure-encryption-decryption-using-mcrypt-php" target="_blank">here</a>.</li> <li>session_start() function which should be added on the starting of every page we are going to create</li> </ol> <p>We have three pages :</p> <ol> <li>register.php</li> <li>verify.php</li> <li>config.php</li> </ol> <h1 id="configphp">config.php</h1> <p>This file contains the configuration variables includingย <strong>database</strong> connection and theย **checkVerification() **function whichย check whether the user has verified his/her email.ย Example :</p> <blockquote> <? </blockquote> <blockquote> <p>$db=&quot;database&quot;;</p> </blockquote> <blockquote> <p>$host=&quot;127.0.0.1โ€ณ;</p> </blockquote> <blockquote> <p>$usr=&quot;Username&quot;;</p> </blockquote> <blockquote> <p>$pass=&quot;Password&quot;;</p> </blockquote> <blockquote> <p>$dbh=newย PDO(&quot;mysql:dbname=$db;host=$host&quot;,ย $usr,ย $pass);</p> </blockquote> <blockquote> <p>/*ย E-Mailย Verificationย Configurationย โ€“ย START*/</p> </blockquote> <blockquote> <p>$secure_code=&quot;&quot;;/*ย Aย Securityย Code.ย Shouldย onlyย containย numeralsย andย alphabeticย charactersย */</p> </blockquote> <blockquote> <p>/*ย E-Mailย Verificationย Configurationย โ€“ย END*/</p> </blockquote> <blockquote> <p>functionย checkVerification(){</p> </blockquote> <blockquote> <p>ย globalย $_SESSION;</p> </blockquote> <blockquote> <p>ย globalย $_POST;</p> </blockquote> <blockquote> <p>ย $code=$_POST[โ€˜codeโ€™]==&quot;&quot;ย ?ย $_SESSION[โ€˜codeโ€™]ย :ย &quot;subinsb.com&quot;;</p> </blockquote> <blockquote> <p>ย if($_SESSION[&quot;token&quot;]==decrypter($code)){</p> </blockquote> <blockquote> <p>ย ย returnย true;</p> </blockquote> <blockquote> <p>ย }else{</p> </blockquote> <blockquote> <p>ย ย returnย false;</p> </blockquote> <blockquote> <p>ย }</p> </blockquote> <blockquote> <p>}</p> </blockquote> <blockquote> <p>?&gt;</p> </blockquote> <h1 id="registerphp">register.php</h1> <p>This file contains the sign up form. If the email isnโ€™t verified, the page will redirect to <strong>verify.php</strong> which showsย verify form. If emailโ€™s verified, then the page will show other fields like name, age, location etcโ€ฆ. (this is represented as <em><em>/</em> Other form fields</em>* <em>/ in the code</em>*ย **).</p> <p>The following code is the whole script which displays the form for every action.</p> <blockquote> <? </blockquote> <blockquote> <p>include(&quot;config.php&quot;);</p> </blockquote> <blockquote> <p>if(checkVerification()==false){</p> </blockquote> <blockquote> <p>header(&quot;Location: /verify.php&quot;);</p> </blockquote> <blockquote> <p>}else{</p> </blockquote> <blockquote> <p>/* Other Form Fields. Add Other Form Fields Here. Example : */</p> </blockquote> <blockquote> <p>?&gt;</p> </blockquote> <blockquote> <form action="register.php" method="POST"> </blockquote> <blockquote> <p>Name :</p> </blockquote> <blockquote> <p><input type="text" name="name"/><br/></p> </blockquote> <blockquote> <input type="submit" value="Submit" name="submit"/> </blockquote> <blockquote> </form> </blockquote> <blockquote> <? </blockquote> <blockquote> <p>}</p> </blockquote> <blockquote> <p>if(isset($_POST[โ€˜submitโ€™])){</p> </blockquote> <blockquote> <p>// Process Form Submission and finally destroy the session</p> </blockquote> <blockquote> <p>session_destroy();</p> </blockquote> <blockquote> <p>}</p> </blockquote> <blockquote> <p>?&gt;</p> </blockquote> <h1 id="verifyphp">verify.php</h1> <p>This file processes the verification stuff. If the user has verified the email then this page will redirect toย <strong>register.php</strong> :</p> <blockquote> <? </blockquote> <blockquote> <p>include(&quot;config.php&quot;);</p> </blockquote> <blockquote> <p>if(isset($_POST[โ€˜verifyโ€™])ย &amp;&amp;ย isset($_POST[โ€˜codeโ€™])){</p> </blockquote> <blockquote> <p>ย $code=$_POST[โ€˜codeโ€™];</p> </blockquote> <blockquote> <p>ย if($code==&quot;&quot;){</p> </blockquote> <blockquote> <p>ย ย die(&quot;<h2>Noย Codeย Entered.</h2><div>Pleaseย Enterย Aย Code</div>&quot;);</p> </blockquote> <blockquote> <p>ย }</p> </blockquote> <blockquote> <p>ย if(checkVerification()==false){</p> </blockquote> <blockquote> <p>ย ย die(&quot;<h2>Wrongย Verificationย Code.</h2>&quot;);</p> </blockquote> <blockquote> <p>ย }</p> </blockquote> <blockquote> <p>ย $_SESSION[โ€˜codeโ€™]=$_POST[โ€˜codeโ€™];</p> </blockquote> <blockquote> <p>}</p> </blockquote> <blockquote> <p>if(isset($_POST[โ€˜verifyโ€™])ย &amp;&amp;ย isset($_POST[โ€˜mailโ€™])){</p> </blockquote> <blockquote> <p>ย /*ย Checkย valuesย andย sendย verificationย codeย toย emailย */</p> </blockquote> <blockquote> <p>ย $email=$_POST[โ€˜mailโ€™];</p> </blockquote> <blockquote> <p>ย $password=&quot;&quot;;/*ย Aย keyย thatย isย */</p> </blockquote> <blockquote> <p>ย if(!preg_match(โ€˜/^[a-zA-Z0-9]+[a-zA-Z0-9_.-]+[a-zA-Z0-9_-]+@[a-zA-Z0-9]+[a-zA-Z0-9.-]+[a-zA-Z0-9]+.[a-z]{2,4}$/โ€™,$email)){</p> </blockquote> <blockquote> <p>ย ย die(&quot;<h2>E-Mailย Isย Notย Valid</h2>&quot;);</p> </blockquote> <blockquote> <p>ย }</p> </blockquote> <blockquote> <p>ย /*ย Youย canย addย theย checkingย ifย theย emailย existย onย databaseย inย thisย sectionย */</p> </blockquote> <blockquote> <p>ย $highcode=encrypter($_POST[โ€˜mailโ€™].$secure_code);</p> </blockquote> <blockquote> <p>ย $_SESSION[&quot;token&quot;]=$highcode;</p> </blockquote> <blockquote> <p>ย send_mail($email,&quot;Verifyย Yourย E-Mail&quot;,&quot;Youย requestedย forย registeringย onย &quot;.$_SERVER[โ€˜HTTP_HOSTโ€™].&quot;.ย Forย signingย up,ย youย needย toย verifyย yourย E-Mailย address.ย Pasteย theย codeย belowย inย theย inputย fieldย ofย theย pageย whereย youย requestedย forย signingย up.<blockquote>&quot;.$highcode.&quot;</blockquote>&quot;);</p> </blockquote> <blockquote> <p>?&gt;</p> </blockquote> <blockquote> <div>An&nbsp;E-Mail&nbsp;containing&nbsp;a&nbsp;code&nbsp;have&nbsp;been&nbsp;sent&nbsp;to&nbsp;the&nbsp;E-Mail&nbsp;address&nbsp;you&nbsp;gave&nbsp;us.&nbsp;Check&nbsp;Your&nbsp;Inbox&nbsp;for&nbsp;that&nbsp;mail.&nbsp;The&nbsp;mail&nbsp;might&nbsp;have&nbsp;went&nbsp;to&nbsp;the&nbsp;SPAM&nbsp;folder.&nbsp;Hence&nbsp;you&nbsp;have&nbsp;to&nbsp;check&nbsp;that&nbsp;folder&nbsp;too.</div><br/> </blockquote> <blockquote> <p>&lt;formย action=&quot;verify.php&quot;ย method=&quot;POST&quot;&gt;</p> </blockquote> <blockquote> <p>ย Pasteย Theย Codeย youย receivedย viaย E-Mailย below<br/></p> </blockquote> <blockquote> <p>ย &lt;inputย name=&quot;code&quot;ย style=&quot;width:290px;&quot;ย autocomplete=&quot;off&quot;ย placeholder=&quot;Pasteย Theย Codeย Here&quot;ย type=&quot;text&quot;/&gt;<br/></p> </blockquote> <blockquote> <p>ย &lt;inputย name=&quot;verify&quot;ย type=&quot;submit&quot;ย value=&quot;Completeย Verification&quot;/&gt;<br/></p> </blockquote> <blockquote> </form> </blockquote> <blockquote> <? </blockquote> <blockquote> <p>}elseif(checkVerification()==false){</p> </blockquote> <blockquote> <p>?&gt;</p> </blockquote> <blockquote> <p>&lt;formย action=&quot;verify.php&quot;ย method=&quot;POST&quot;&gt;</p> </blockquote> <blockquote> <p>ย Typeย Inย Yourย E-Mailย Toย Continueย Signupย Process.<br/></p> </blockquote> <blockquote> <p>ย &lt;inputย name=&quot;mail&quot;ย style=&quot;width:290px;&quot;ย placeholder=&quot;Donโ€™tย Youย Haveย Anย E-Mailย ?&quot;ย type=&quot;text&quot;/&gt;<br/></p> </blockquote> <blockquote> <p>ย &lt;inputย name=&quot;verify&quot;ย type=&quot;submit&quot;ย value=&quot;Verifyย E-Mail&quot;/&gt;<br/></p> </blockquote> <blockquote> <p>ย Youย canย onlyย signย upย ifย youย verifyย yourย email.</p> </blockquote> <blockquote> </form> </blockquote> <blockquote> <? </blockquote> <blockquote> <p>}elseif(checkVerification()==true){</p> </blockquote> <blockquote> <p>ย header(&quot;Location:ย /register.php&quot;);</p> </blockquote> <blockquote> <p>}</p> </blockquote> <blockquote> <p>?&gt;</p> </blockquote> <p>This post is very long and itโ€™s possible that I made errors on some places. So if you find any errors, or had errors when you run this script, please report it via comments. I will be glad to help you.</p> Create A Contact Form In PHP With Mailgun https://subinsb.com/mail-contact-form-in-php-with-mailgun/ Sun, 29 Dec 2013 08:04:38 +0000 https://subinsb.com/mail-contact-form-in-php-with-mailgun/ <p>Contact forms make it easy for the visitors of your site to contact you. Contact forms are available in variousย <strong>CM systems</strong>, but if you are creating your own site, you have to create the contact form yourself. The messages thus sent by the users have to be stored in databases and you have to constantly check the database for new messages. To overcome this problem, itโ€™s better to directly send the messages to your inbox.</p> <p>In my <a title="Send Free E-Mails Using Mailgun API in PHP" href="//subinsb.com/send-free-emails-using-mailgun-api-in-php#comment-2546148234" target="_blank">previous post</a>, I gave the functionย <strong>send_mail</strong> which can be used to send free mails using theย <strong>Mailgun</strong> <strong>API</strong>.</p> <div class="padlinks"> <a class="demo" href="http://demos.subinsb.com/contact-form-mailgun" target="_blank">DEMO</a> <a class="download" href="http://demos.subinsb.com/down.php?id=j2vocxn1by3x&class=14" target="_blank">DOWNLOAD</a> </div> <p>We can use that function in our contact form to send the messages given by the user directly to you. If you havenโ€™t seen theย <strong>send_mail()</strong> function yet, see <a title="Send Free E-Mails Using Mailgun API in PHP" href="//subinsb.com/2013/12/send-free-emails-using-mailgun-api-in-php" target="_blank">this post</a>. We will create a contact form which sends the messages directly to the site admin usingย <strong>Mailgun API</strong> andย <strong>PHP</strong>. We should create our form first.</p> <pre class="prettyprint"><code>&lt;formย action="contact.php"ย method="POST"&gt; Name&lt;br/&gt; &lt;inputย type="text"ย name="name"ย placeholder="Yourย Name"ย size="40"/&gt;&lt;br/&gt; Message&lt;br/&gt; &lt;textareaย name="message"ย cols="40"ย rows="10"&gt;&lt;/textarea&gt;&lt;br/&gt; &lt;inputย type="submit"ย value="Sendย Message"ย name="submit"/&gt; &lt;/form&gt;</code></pre> <h1 id="contactphp">contact.php</h1> <p>This is the page where the form data will be sent to. This file checks if all the fields are filled or not and if all are filled, it will send the email :</p> <pre class="prettyprint"><code>&lt;?php if(isset($_POST['submit'])){ $name = $_POST['name']; $msg = $_POST['message']; if($name != ""ย &&ย $msg != ""){ $ip_address = $_SERVER['REMOTE_ADDR']; send_mail("[email protected]","Newย Message","Theย IPย ($ip_address)ย hasย sentย youย aย messageย :ย &lt;blockquote&gt;$msg&lt;/blockquote&gt;"); echoย "&lt;h2ย style='color:green;'&gt;Yourย Messageย Hasย Beenย Sent&lt;/h2&gt;"; }else{ echoย "&lt;h2ย style='color:red;'&gt;Pleaseย Fillย Upย allย theย Fields&lt;/h2&gt;"; } } ?&gt;</code></pre> <p>The email sent will have theย <strong>IP address</strong> of the user and the message of the user.</p> Encryption & Decryption Using Mcrypt In PHP https://subinsb.com/secure-encryption-decryption-using-mcrypt-php/ Wed, 25 Dec 2013 17:39:41 +0000 https://subinsb.com/secure-encryption-decryption-using-mcrypt-php/ <p><strong>Mcrypt</strong> is a replacement ofย <strong>Unix</strong>โ€˜s popular commandย <strong>crypt</strong>. It is a file encryption tool.ย <strong>Mcrypt</strong> uses modern algorithms for encrypting. Hence it is considered as secure and safe. To encrypt a string,ย <strong>Mcrypt</strong> requires a key to encrypt and decrypt. This key have a critical role in encryption and decryption. In this post Iโ€™ll be giving out two functions that will encrypt and decrypt based on a key.</p> <h1 id="the-key">The Key</h1> <p>We should use the same key for both encryption and decryption. Note that the key length should not exceed <strong>25</strong> characters.</p> <p>For this post, we are going to take</p> <pre class="prettyprint"><code>a_key_in_2014</code></pre> <p>as the key. The variableย <strong>$key</strong> contains the key in the functions used for encryption and decryption.</p> <h1 id="encryption">Encryption</h1> <p>This small function will encrypt any string :</p> <pre class="prettyprint"><code>functionย encrypt($value){ ย if($value == ''){ returnย false; }else{ ย  $keyย  =ย "a_key_in_2014"; ย  $iv_sizeย =ย mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256,ย MCRYPT_MODE_ECB); ย $iv ย =ย mcrypt_create_iv($iv_size,ย MCRYPT_RAND); ย $cryptedย =ย mcrypt_encrypt(MCRYPT_RIJNDAEL_256,ย $key,ย $value,ย MCRYPT_MODE_ECB,ย $iv); ย returnย urlencode(trim(base64_encode($crypted))); } }</code></pre> <h2 id="usage">Usage</h2> <p>You can encrypt a string just like this :</p> <pre class="prettyprint"><code>&lt;? echo encrypt("subinsb.com"); ?&gt;</code></pre> <p>The above will print out the encrypted string :</p> <pre class="prettyprint"><code>Rl3PeBCve4vjjwu1SgzFvvj%2BG3Prl2TDN2AmXrWKSqw%3D</code></pre> <p>As you can see, itโ€™s hard to figure out the original string from above.</p> <h1 id="decryption">Decryption</h1> <p>This small function will decrypt strings that are encoded with the same key :</p> <pre class="prettyprint"><code>function decrypt($value){ $key = "a_key_in_2014"; $value = urldecode($value); if($value == "" || base64_encode(base64_decode($value)) != $value){ return $value; }else{ $crypttext = base64_decode($value); $iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB); $iv = mcrypt_create_iv($iv_size, MCRYPT_RAND); $decrypted = mcrypt_decrypt(MCRYPT_RIJNDAEL_256, $key, $crypttext, MCRYPT_MODE_ECB, $iv); return trim($decrypted); } }</code></pre> <h2 id="usage-1">Usage</h2> <p>The decryption is also easy :</p> <pre class="prettyprint"><code>echo decrypt("Rl3PeBCve4vjjwu1SgzFvvj%2BG3Prl2TDN2AmXrWKSqw%3D");</code></pre> <p>And the above code will output &quot;subinsb.com&quot; which was the original string.</p> <p>You can use this functions wherever you want. This trickย is used inย <strong><a href="http://open.subinsb.com" target="_blank">Open</a></strong>ย for encrypting and decrypting.</p> Send Free E-Mails Using Mailgun API in PHP https://subinsb.com/send-free-emails-using-mailgun-api-in-php/ Wed, 25 Dec 2013 08:25:47 +0000 https://subinsb.com/send-free-emails-using-mailgun-api-in-php/ <p>E-Mails increases your siteโ€™s traffic. E-Mails are used in websites that require E-Mail verification to Reset Passwords. There is already aย <strong>mail</strong> function inย <strong>PHP</strong>, but the E-Mails that are sent viaย <strong>PHP</strong>โ€˜sย <strong>mail</strong> function goes toย <strong>SPAM</strong> folder in most of the mail services. So, developers use <strong>API</strong> services to send E-Mails that gets received on userโ€™sย <strong>Inbox</strong>. Most of theย <strong>API</strong>โ€˜s need money to use. If you are a starting developer, you need aย <strong>Free</strong> service. In fact there is a free service provided byย <strong>Mailgun</strong>.ย <strong>10,000</strong>ย E-Mails are free in every month. Isnโ€™t that a good offer ? You can sign up free without entering any credit card details. <img class="aligncenter" alt="" src="https://s3.amazonaws.com/tres-cms/mailgun_logo.png" /><span style="line-height: 1.5em;">They have their own class for sending E-Mailโ€™s inย </span><strong style="line-height: 1.5em;">PHP</strong><span style="line-height: 1.5em;">, but in this post I will be introducing you to a simpleย </span><strong style="line-height: 1.5em;">PHP</strong> <span style="line-height: 1.5em;">function (send_mail) that will sendย </span><strong style="line-height: 1.5em;">E-Mail</strong><span style="line-height: 1.5em;">โ€˜s throughย </span><strong style="line-height: 1.5em;">Mailgun</strong><span style="line-height: 1.5em;">โ€˜s API service vai </span><strong style="line-height: 1.5em;">cURL</strong><span style="line-height: 1.5em;">. I will also tell you the step by step instructions from signing up to sending mails.</span> Like any other services, you have to sign up to use the features ofย <strong>Mailgun</strong>. You can sign up @ย <a href="https://mailgun.com/signup" target="_blank"><a href="https://mailgun.com/signup">https://mailgun.com/signup</a></a>. Fill up the required fields and click &quot;Create Account&quot; button. Now you need to get theย <strong>API Key</strong>. Login to your new account.ย Note that you need to add your domain and verify your domain. If you donโ€™t verify your domain, you will be limited to send onlyย <strong>300</strong> mails per day. So you need to verify your domain. Go to the pageย <a href="https://mailgun.com/cp/my_account">https://mailgun.com/cp/my_account</a>. On the left side, you can see theย <strong>API</strong>ย key :<figure id="attachment_2165" class="wp-caption aligncenter"></p> <p><a href="//lab.subinsb.com/projects/blog/uploads/2013/12/0072.png"><img class="size-medium wp-image-2165" alt="The API key is not real" src="//lab.subinsb.com/projects/blog/uploads/2013/12/0072-300x92.png" width="300" height="92" /></a><figcaption class="wp-caption-text">The API key is not real</figcaption></figure></p> <p>You will need this <strong>API</strong> key for future use in this tutorial. Letโ€™s move on to theย <strong>send_mail</strong> function :</p> <pre class="prettyprint"><code>&lt;? functionย send_mail($email,$subject,$msg)ย { $api_key="";/*ย Apiย Keyย gotย fromย https://mailgun.com/cp/my_accountย */ $domainย ="";/*ย Domainย Nameย youย givenย toย Mailgunย */ $chย =ย curl_init(); curl_setopt($ch,ย CURLOPT_HTTPAUTH,ย CURLAUTH_BASIC); curl_setopt($ch,ย CURLOPT_USERPWD,ย 'api:'.$api_key); curl_setopt($ch,ย CURLOPT_RETURNTRANSFER,ย 1); curl_setopt($ch,ย CURLOPT_CUSTOMREQUEST,ย 'POST'); curl_setopt($ch,ย CURLOPT_URL,ย 'https://api.mailgun.net/v2/'.$domain.'/messages'); curl_setopt($ch,ย CURLOPT_POSTFIELDS,ย array( 'from'ย =&gt;ย 'Openย &lt;[email protected]&gt;', 'to'ย =&gt;ย $email, 'subject'ย =&gt;ย $subject, 'html'ย =&gt;ย $msg )); $resultย =ย curl_exec($ch); curl_close($ch); returnย $result; } ?&gt;</code></pre> <p>Donโ€™t forget to fill the following fields : ย  $api_key โ€“ API key got fromย <a href="https://mailgun.com/cp/my_account">https://mailgun.com/cp/my_account</a> $domain โ€“ The domain name you gave in Mailgun (<a href="https://mailgun.com/cp/my_account">https://mailgun.com/cp/my_account</a>). ย  You can now send E-Mails usingย <strong>send_mail()</strong> function with the values as below :</p> <pre class="prettyprint"><code>$email ย  - E-Mail address $subject - Subject of E-Mail $msg ย  ย  - Body of E-Mail ย </code></pre> <p>ย </p> <p>An example of sending email toย <strong><a href="mailto:[email protected]">[email protected]</a></strong> with subjectย <strong>Hello Kerala</strong> and body asย <strong>Kerala is a nice place</strong> :</p> <pre class="prettyprint"><code>&lt;? send_mail("[email protected]", "Hello Kerala", "Kerala is a nice place."); ?&gt;</code></pre> <p>If you encountered with any problems or have a feedback, please say it on the comments. I love to hear from you andย <strong>Merry Christmas</strong>.</p> Check If jQuery is Loaded Using typeof Operator in JavaScript https://subinsb.com/check-if-jquery-is-loaded-using-javascript/ Wed, 25 Dec 2013 05:45:25 +0000 https://subinsb.com/check-if-jquery-is-loaded-using-javascript/ <p><strong>jQuery</strong> is the most used and popular library ofย <strong>JavaScript</strong>. Ifย <strong>jQuery</strong>ย isnโ€™t loaded, aย <strong>jQuery</strong>ย coded site will not function properly. Such sites will reload automatically or give an error whenย <strong>jQuery</strong> isnโ€™t loaded. But, how do they check ifย <strong>jQuery</strong> is loaded ? You will find a simple solution to accomplish this task in this post. Since,ย <strong>jQuery</strong>ย wonโ€™t be loaded, we canโ€™t check ifย <strong>jQuery</strong> is loaded usingย <strong>jQuery</strong>. But we can use <strong>JavaScript</strong> which will always be available in browsers.</p> <p>Inย <strong>JavaScript</strong>, there is an operator calledย <strong>typeof</strong>, which will return the type of a variable. We are going to pass theย <strong>jQuery</strong> global function which isย <strong>$</strong> toย <strong>typeof</strong>, if it returns the string &quot;function&quot;, thenย <strong>jQuery</strong> is loaded. Here is a simple example :</p> <blockquote> <p>if(typeof($)==&quot;function&quot;){</p> <p>// jQuery is loaded</p> <p>}else{</p> <p>// jQuery isnโ€™t loaded</p> <p>}</p> </blockquote> <p>The above code isnโ€™t perfect, because there are other libraries which has the global functionย <strong>$</strong>. So, we have to check ifย <strong>jQuery</strong> is a function too :</p> <blockquote> <p>if(typeof($)==&quot;function&quot; &amp;&amp; typeof(jQuery)==&quot;function&quot;){</p> <p>// jQuery is loaded</p> <p>}else{</p> <p>// jQuery isnโ€™t loaded</p> <p>}</p> </blockquote> <p>The above code is perfect if your site donโ€™t have a custom function namedย <strong>jQuery</strong>.</p> Use uTorrent Without Installing (Portable uTorrent) https://subinsb.com/use-utorrent-without-installing-portable-utorrent/ Tue, 24 Dec 2013 14:53:07 +0000 https://subinsb.com/use-utorrent-without-installing-portable-utorrent/ <p>Torrents are the most common thing computer users hear of. There are torrent downloading, torrent sharing and many others. Torrent has become a business in theย <strong>WWW</strong>. Due to the increase in demand of torrents, there should be torrent clients that downloads the files of a torrent. The most popular of them isย <strong>uTorrent</strong> โ€“ Aย <strong>Windows</strong> package. <strong>uTorrent</strong> is widely used by computer enthusiasts.ย <strong>uTorrent</strong> is widely used because of itโ€™s lightness, simple usage and limitless options. But, you have to installย <strong>uTorrent</strong>to use itโ€™s features. What if, your friend needs a download from torrent and he doesnโ€™t have a torrent client. He donโ€™t know how to install a torrent client. In this case, the only way is to use aย <strong>Portable Torrent Client</strong>. Sinceย <strong>uTorrent</strong> is light weight and easy to use, itโ€™s the best torrent client to give to anyone.</p> <p>In this post I will tell you how to make aย <strong>uTorrent</strong> software package portable.</p> <p>First of all downloadย <strong>uTorrent</strong> fromย <a href="http://www.utorrent.com/">www.utorrent.com</a>.</p> <p><a href="//lab.subinsb.com/projects/blog/uploads/2013/12/0070.png"><img class="aligncenter size-medium wp-image-2148" alt="0070" src="//lab.subinsb.com/projects/blog/uploads/2013/12/0070-300x153.png" width="300" height="153" /></a></p> <p>The downloaded fileโ€™s name isย <strong>utorrent.exe</strong>. Move the file to an empty location (folder).</p> <p>Create a file namedย <strong>settings.dat</strong> on the location whereย **utorrent.exeย **is located.</p> <p>Openย <strong>utorrent.exe</strong>.</p> <p>Some files and folders will be created in the directory whereย <strong>utorrent.exe</strong> is located.</p> <p><a href="//lab.subinsb.com/projects/blog/uploads/2013/12/0071.png"><img class="aligncenter size-full wp-image-2149" alt="0071" src="//lab.subinsb.com/projects/blog/uploads/2013/12/0071.png" width="166" height="205" /></a></p> <p>The folder where all of these files withย <strong>utorrent.exe</strong> is theย <strong>Portable uTorrent</strong>. You can give this folder to your friends and others and they can useย <strong>uTorrent</strong> without installing.</p> Implementing Login With Google + In PHP https://subinsb.com/implement-login-with-google-in-php/ Tue, 24 Dec 2013 06:37:45 +0000 https://subinsb.com/implement-login-with-google-in-php/ <p>In the last post, I introduced you to aย <strong>PHP OAuth Class</strong>ย namedย <strong>OAuth API</strong>. In this post Iโ€™m going to tell you how to implementย <strong>Login With Google +</strong> feature inย <strong>PHP</strong> using the class I introduced. Itโ€™s very simple. I will tell the ways of implementing step by step. This tutorial includes placing a **Login with Googleย +ย **button on web site to authorization and finishes when we get user details. You should readย <a title="Implementing OAuth System Using OAuth API Library In PHP" href="//subinsb.com/2013/12/oauth-api-library-php" target="_blank">this post</a>ย beforeย starting this tutorial.</p> <div class="padlinks"> <a class="demo" href="http://open.subinsb.com" target="_blank">DEMO</a> </div> <h1 id="appearance">Appearance</h1> <div> First of all, we will design ourย <strong>Login With Google + button</strong>. Then we will move on to the server side. We are going to design the button usingย <strong>HTML</strong>,ย <strong>CSS</strong> and a small icon. </div> <p>Place the belowย <strong>HTML</strong> code on the place where you want to show the button :</p> <blockquote> <p><a href="login\_with\_google.php" id="login\_with\_google">Login With Google +</a></p> </blockquote> <p>You should need aย <strong>Google +</strong> small logo for making the button attractive. I have included the image below :</p> <p><a href="//lab.subinsb.com/projects/blog/uploads/2013/12/g+_icon.png"><img class="aligncenter size-full wp-image-2143" alt="g+_icon" src="//lab.subinsb.com/projects/blog/uploads/2013/12/g+_icon.png" width="28" height="28" /></a></p> <p>Here is theย <strong>CSS</strong> code that will decorate the button. I have provided the imageย <strong>URL</strong> asย <strong><a href="https://lab.subinsb.com/projects/blog/uploads/2013/12/g+_icon.png">https://lab.subinsb.com/projects/blog/uploads/2013/12/g+_icon.png</a></strong></p> <blockquote> <p>#login_with_google{</p> <p>display: inline-block;</p> <p>height: 43px;</p> <p>margin: 0px;</p> <p>padding: 0px 20px 0px 52px;</p> <p>font-family: โ€˜Ubuntuโ€™, sans-serif;</p> <p>font-size: 18px;</p> <p>font-weight: 400;</p> <p>color: #fff;</p> <p>line-height: 41px;</p> <p>background:rgb(231, 38, 54) url(<a href="//lab.subinsb.com/projects/blog/uploads/2013/12/g+_icon.png">https://lab.subinsb.com/projects/blog/uploads/2013/12/g+_icon.png</a>) no-repeat 14px 8px scroll;</p> <p>-webkit-border-radius: 4px;</p> <p>-moz-border-radius: 4px;</p> <p>border-radius: 4px;</p> <p>text-decoration: none;</p> <p>cursor:pointer;</p> <p>}</p> </blockquote> <p>The finished button will look something like below :</p> <p><a href="//lab.subinsb.com/projects/blog/uploads/2013/12/0069.png"><img class="aligncenter size-full wp-image-2144" alt="Login With Google + button" src="//lab.subinsb.com/projects/blog/uploads/2013/12/0069.png" width="238" height="52" /></a></p> <h1 id="server-side">Server Side</h1> <h2 id="login_with_googlephp">login_with_google.php</h2> <p>This is the file that handles the authorization. You need the <strong>oauth_client.php</strong> which we mentioned in the <a title="Implementing OAuth System Using OAuth API Library In PHP" href="//subinsb.com/2013/12/oauth-api-library-php" target="_blank">previous post</a>. You need aย **client idย **andย <strong>client secret</strong> which you get when you create an app @ย <a href="http://code.google.com/apis/console" target="_blank"><a href="http://code.google.com/apis/console">http://code.google.com/apis/console</a></a>. You have to mention the redirect URL in the app settings of <strong>Google Console</strong>.</p> <p>Here is the complete code :</p> <blockquote> <?php </blockquote> <blockquote> <p>require(โ€˜http.phpโ€™);</p> </blockquote> <blockquote> <p>require(โ€˜oauth_client.phpโ€™);</p> </blockquote> <blockquote> <p>$clientย =ย newย oauth_client_class;</p> </blockquote> <blockquote> <p>$client-&gt;serverย =ย โ€˜Googleโ€™;</p> </blockquote> <blockquote> <p>$client-&gt;debugย =ย false;</p> </blockquote> <blockquote> <p>$client-&gt;debug_httpย =ย true;</p> </blockquote> <blockquote> <p>$client-&gt;redirect_uriย =ย โ€˜http://โ€™.$_SERVER[โ€˜HTTP_HOSTโ€™].dirname(strtok($_SERVER[โ€˜REQUEST_URIโ€™],โ€™?โ€™)).โ€™/login_with_google.phpโ€™;</p> </blockquote> <blockquote> <p>$client-&gt;client_idย =ย &quot;;/*Clientย ID*/</p> </blockquote> <blockquote> <p>$client-&gt;client_secretย =ย &quot;;/*Clientย Secret*/</p> </blockquote> <blockquote> <p>$client-&gt;scopeย =ย โ€˜https://www.googleapis.com/auth/userinfo.emailย https://www.googleapis.com/auth/userinfo.profileย https://www.googleapis.com/auth/plus.meโ€™;</p> </blockquote> <blockquote> <p>$application_lineย =ย \__LINE__;</p> </blockquote> <blockquote> <p>if(strlen($client-&gt;client_id)ย ==ย 0ย ||ย strlen($client-&gt;client_secret)ย ==ย 0){</p> </blockquote> <blockquote> <p>ย die(โ€˜Pleaseย goย toย Googleย APIsย consoleย pageย โ€˜.</p> </blockquote> <blockquote> <p>ย ย โ€˜http://code.google.com/apis/consoleย inย theย APIย accessย tab,ย โ€˜.</p> </blockquote> <blockquote> <p>ย ย โ€˜createย aย newย clientย ID,ย andย inย theย lineย โ€˜.$application_line.</p> </blockquote> <blockquote> <p>ย ย โ€˜ย setย theย client_idย toย Clientย IDย andย client_secretย withย Clientย Secret.ย โ€˜.</p> </blockquote> <blockquote> <p>ย ย โ€˜Theย callbackย URLย mustย beย โ€˜.$client-&gt;redirect_uri.โ€™ย butย makeย sureย โ€˜.</p> </blockquote> <blockquote> <p>ย ย โ€˜theย domainย isย validย andย canย beย resolvedย byย aย publicย DNS.โ€™);</p> </blockquote> <blockquote> <p>}</p> </blockquote> <blockquote> <p>if(($successย =ย $client-&gt;Initialize())){</p> </blockquote> <blockquote> <p>ย if(($successย =ย $client-&gt;Process())){</p> </blockquote> <blockquote> <p>ย ย if(strlen($client-&gt;authorization_error)){</p> </blockquote> <blockquote> <p>ย ย ย $client-&gt;errorย =ย $client-&gt;authorization_error;</p> </blockquote> <blockquote> <p>ย ย ย $successย =ย false;</p> </blockquote> <blockquote> <p>ย ย }elseif(strlen($client-&gt;access_token)){</p> </blockquote> <blockquote> <p>ย ย ย $successย =ย $client-&gt;CallAPI(โ€˜https://www.googleapis.com/oauth2/v1/userinfoโ€™,ย โ€˜GETโ€™,ย array(),ย array(โ€˜FailOnAccessErrorโ€™=&gt;true),ย $user);</p> </blockquote> <blockquote> <p>ย ย ย if($success){</p> </blockquote> <blockquote> <p>ย ย ย ย $email=$user-&gt;email;</p> </blockquote> <blockquote> <p>ย ย ย ย $name=$user-&gt;name;</p> </blockquote> <blockquote> <p>ย ย ย ย $gender=$user-&gt;gender;</p> </blockquote> <blockquote> <p>ย ย ย ย $birthday=date(โ€˜d/m/Yโ€™,ย strtotime($user-&gt;birthday));</p> </blockquote> <blockquote> <p>ย ย ย ย $image=$user-&gt;picture;</p> </blockquote> <blockquote> <p>ย ย ย }</p> </blockquote> <blockquote> <p>ย ย }</p> </blockquote> <blockquote> <p>ย }</p> </blockquote> <blockquote> <p>ย $successย =ย $client-&gt;Finalize($success);</p> </blockquote> <blockquote> <p>}</p> </blockquote> <blockquote> <p>if($client-&gt;exit){</p> </blockquote> <blockquote> <p>ย die(&quot;Somethingย Happened&quot;,&quot;&lt;aย href='&quot;.$client-&gt;redirect_uri.&quot;โ€˜&gt;Tryย Again</a>&quot;);</p> </blockquote> <blockquote> <p>}</p> </blockquote> <blockquote> <p>if(!$success){</p> </blockquote> <blockquote> <p>?&gt;</p> </blockquote> <blockquote> <p>ย <!DOCTYPE&nbsp;HTML&nbsp;PUBLIC&nbsp;"-//W3C//DTD&nbsp;HTML&nbsp;4.01&nbsp;Transitional//EN"></p> </blockquote> <blockquote> <p>ย <html></p> </blockquote> <blockquote> <p>ย ย <head></p> </blockquote> <blockquote> <p>ย ย ย <title>Error</title></p> </blockquote> <blockquote> <p>ย ย </head></p> </blockquote> <blockquote> <p>ย ย <body></p> </blockquote> <blockquote> <p>ย ย ย <h1>OAuthย clientย error</h1></p> </blockquote> <blockquote> <p>ย ย ย <pre>Error:ย <?php&nbsp;echo&nbsp;HtmlSpecialChars($client->error);&nbsp;?></pre></p> </blockquote> <blockquote> <p>ย ย </body></p> </blockquote> <blockquote> <p>ย </html></p> </blockquote> <blockquote> <?}?> </blockquote> <p>Donโ€™t forget to replaceย <strong>client_id</strong> &amp;ย <strong>client_secret</strong> values.</p> <h1 id="how-it-works">How It Works</h1> <ol> <li>When a user clicksย <strong>Login With Google +</strong> button, the user will be redirected to theย <strong>login_with_google.php</strong>ย page.</li> <li>Theย <strong>PHP</strong> file will redirect the user toย <strong>Google</strong>โ€˜s authorization page with all the app details needed byย <strong>Google</strong>.</li> <li>When the user authorizes the app, he/she will be redirected back toย <strong>login_with_google.php</strong> page with a **GETย **parameter namedย <strong>code</strong>.</li> <li><strong>OAuth API</strong> library will request anย <strong>access token</strong> toย <strong>Google</strong> with the givenย <strong>code</strong>.</li> <li>When it receives theย <strong>access token</strong>, It sends a request toย <strong><a href="https://www.googleapis.com/oauth2/v1/userinfo">https://www.googleapis.com/oauth2/v1/userinfo</a></strong>ย with theย <strong>access_token</strong> and theย <strong>URL</strong> will return the details of the user.</li> </ol> <h1 id="variables">Variables</h1> <blockquote> <p>$email โ€“ The E-Mail of the user</p> <p>$name โ€“ The Name of the user</p> <p>$gender โ€“ The Gender of the user</p> <p>$birthday โ€“ The Birthday of the user</p> <p>$image โ€“ The Image URL of the user</p> </blockquote> <p>Isnโ€™t this tutorial simple ?</p> <p>If you encountered any problems or have a suggestion, please say it on the comments. I will be happy to respond.</p> Image Handling On Client Side With Base64 In PHP https://subinsb.com/image-handling-on-client-using-base64-in-php/ Sun, 22 Dec 2013 18:17:23 +0000 https://subinsb.com/image-handling-on-client-using-base64-in-php/ <p>Every website needs images. It make the site attractive and beautiful. But sometimes, images wonโ€™t get loaded. The latestย **Browsersย **have a feature that generates image on aย <strong>base64</strong> string. Most of the browser have it. In this post Iโ€™m going to describe the way to useย <strong>base64</strong> in displaying images on a website.</p> <h1 id="what8217s-base64-">Whatโ€™s base64 ?</h1> <p><strong>Base64</strong> is a encrypting method which is available in many languages. It can be used for encrypting and decrypting. It is not like otherย <strong>hash</strong> functions (MD5, SHA 256, SHA 512). Unlike other <strong>hash</strong> methods, aย <strong>base64</strong>ย encrypted string can be directly decrypted. But otherย <strong>hash</strong> functions can only be used for checking a value.</p> <h1 id="syntax">Syntax</h1> <p>A string can be encrypted usingย <strong>base64</strong> byย <strong>base64_encode</strong> function inย <strong>PHP</strong>. An Example :</p> <blockquote> <p>$string=&quot;subinsb.com&quot;;</p> <p>$encrypted=base64_encode($string);</p> <p>echo $encrypted; // Printsย c3ViaW5zYi5jb20=</p> </blockquote> <p>An Encrypted string can be decrypted by usingย <strong>base64_decode</strong> function inย <strong>PHP</strong>. An Example :</p> <blockquote> <p>$encrypted=&quot;c3ViaW5zYi5jb20=&quot;;</p> <p>$decrypted=base64_decode($encrypted);</p> <p>echo $decrypted; // Prints subinsb.com</p> </blockquote> <h1 id="image-handling">Image Handling</h1> <p>Images can also be encrypted and decrypted usingย <strong>base64</strong>. You might know that images are made by characters. These characters are rendered as images. By encoding these image characters byย <strong>base64</strong>, we will get a simpler, readable character containing string. When we decode this simpler string, we will get back that image. This is the principle we are going to use.</p> <h1 id="how-to-encrypt-an-image-">How to Encrypt an Image ?</h1> <p>For this, we will first get the contents of the image file, then we will encrypt it :</p> <blockquote> <p>$image=file_get_contents(&quot;/path/to/image.png&quot;);</p> <p>$encrypted=base64_encode($image);</p> </blockquote> <p>Theย <strong>$encrypted</strong> variable contains the encrypted image.</p> <h1 id="how-to-decrypt-an-encoded-image-string">How to Decrypt an Encoded Image String?</h1> <p>Get the **base64ย **encoded string of an image. Then decrypt it normally :</p> <blockquote> <p>$encrypted=&quot;&quot;;// A base64 encoded image string</p> <p>$decrypted=base64_decode($encrypted);</p> </blockquote> <p>Then we will set theย <strong>header</strong> content type to make the image renderable by the browser.</p> <blockquote> <p>header(&quot;Content-type: image/png&quot;);</p> </blockquote> <p>Or you can enter the decrypted string to a file and make that file an image :</p> <blockquote> <p>file_put_contents(&quot;/path/to/a/new/image.png&quot;,$decrypted);</p> </blockquote> <h1 id="client-side-handling">Client Side Handling</h1> <p>We will render the image on the client side by passing theย <strong>base64</strong> encoded string to aย <strong>URL</strong>. The URL is :</p> <blockquote> <p>data:image/png;base64,<em><strong>encrypted_string_here</strong></em></p> </blockquote> <p>A simple Example would be :</p> <blockquote> <? $image=file\_get\_contents("/path/to/image.png"); $encrypted=base64_encode($image); ?> <blockquote> </blockquote> <img src="data:image/png;base64,<?echo$encrypted;?>"/> </blockquote> <p>You can wrap it all in to a simple function :</p> <blockquote> <p>functionย baseImage($f){</p> </blockquote> <blockquote> <p>$image=file_get_contents($f);</p> </blockquote> <blockquote> <p>$encrypted=base64_encode($image);</p> </blockquote> <blockquote> <p>$url=&quot;data:image/png;base64,&quot;.$encrypted;</p> </blockquote> <blockquote> <p>echo$url;</p> </blockquote> <blockquote> <p>}</p> </blockquote> <p>The usage of the function is :</p> <blockquote> <p>&lt;img src=&quot;<?baseImage("/path/to/image.png");?>&quot;/&gt;</p> </blockquote> <p>Thatโ€™s all for today.</p> Replace Broken Images With Default Image Using JavaScript OR jQuery OR HTML https://subinsb.com/replace-broken-images-with-default-image-using-javascript-jquery-html/ Sun, 22 Dec 2013 08:22:59 +0000 https://subinsb.com/replace-broken-images-with-default-image-using-javascript-jquery-html/ <p>Images are common in web pages now a days. These images make the web page attractive and beautiful. But sometimes due to problems, some images wonโ€™t load completely. When the image doesnโ€™t load completely, that image is said to be a <strong>broken image</strong>. When the image is broken, theย <strong>Browser</strong> will replace that broken image with an ugly image or replace the broken image with a blank space. I have included a broken image below. Differentย <strong>Browsers</strong> will render the broken image in different ways.</p> <p><a href="http://open.subinsb.com/a-broken-image"><img class="aligncenter" alt="" src="http://open.subinsb.com/a-broken-image" /></a> The replaced image by browsers look ugly and the page loses itโ€™s beauty.</p> <h1 id="what-causes-a-broken-image-">What Causes a Broken Image ?</h1> <ol> <li>Slow Internet Connection makes the image broken</li> <li>Image Does not exist (404)</li> <li>Image URL redirects to a non Image URL</li> <li>User stops the loading of the page.</li> </ol> <h1 id="fix--1">Fix # 1</h1> <p>Usingย <strong>JavaScript</strong>,we can easily replace the image with a default image. Inย <strong>Fix #</strong>ย <strong>1</strong>, we will add <strong>onerror</strong>ย attribute tothe image element :</p> <blockquote> <img src="//subinsb.com/to-an-image" onerror="this.src=&#8217;http://subinsb.com/path-to-default-image&#8217;;"/> </blockquote> <p>If you have a lot of images and need to apply anย <strong>onerror</strong> attribute on each of them, itโ€™s very difficult. If you want something like that, seeย <strong>Fix # 2</strong>.</p> <h1 id="fix--2">Fix # 2</h1> <p>The following code will add anย <strong>onerror</strong>ย function on all images of a web page. Itโ€™s pureย <strong>JavaScript</strong>.</p> <blockquote> <p>(function(){</p> </blockquote> <blockquote> <p>for(i=0;i&lt;nodes.length;i++){</p> </blockquote> <blockquote> <p>nodes[i].onerror=nodes[i].src=โ€™http://subinsb.com/path-to-default-imageโ€™;</p> </blockquote> <blockquote> <p>}</p> </blockquote> <blockquote> <p>})();</p> </blockquote> <p>If you really need to do the task inย <strong>jQuery</strong>, seeย <strong>Fix # 3</strong>.</p> <h1 id="fix--3">Fix # 3</h1> <p>The followingย <strong>jQuery</strong> code will do the same function asย <strong>Fix # 2</strong>.</p> <blockquote> <p>$(document).ready(function(){</p> </blockquote> <blockquote> <p>$(&quot;img&quot;).each(function(){</p> </blockquote> <blockquote> <p>$(this).attr(&quot;onerror&quot;,&quot;this.src=โ€™http://subinsb.com/path-to-default-image'&quot;);</p> </blockquote> <blockquote> <p>});</p> </blockquote> <blockquote> <p>});</p> </blockquote> <p>In all of the fixes above, the path of the default image is :</p> <blockquote> <p><a href="http://subinsb.com/path-to-default-image">http://subinsb.com/path-to-default-image</a></p> </blockquote> Implementing Login With Facebook In PHP https://subinsb.com/implement-login-with-facebook-in-php/ Sat, 21 Dec 2013 07:04:15 +0000 https://subinsb.com/implement-login-with-facebook-in-php/ <p>In the last post, I introduced you to aย <strong>PHP OAuth Class</strong>ย namedย <strong>OAuth API</strong>. In this post Iโ€™m going to tell you how to implementย <strong>Login With Facebook</strong> feature inย <strong>PHP</strong> using the class I introduced. Itโ€™s very simple. I will tell the ways of implementing step by step. This tutorial includes placing a Login with Facebook button on web site to authorization and finishes when we get user details. You should read the <a title="Implementing OAuth System Using OAuth API Library In PHP" href="//subinsb.com/2013/12/oauth-api-library-php" target="_blank">previous post</a> before starting this tutorial.</p> <div class="padlinks"> <a class="demo" href="http://open.subinsb.com" target="_blank">DEMO</a> </div> <h1 id="appearance">Appearance</h1> <div> First of all, we will design ourย <strong>Login With Facebook button</strong>. Then we will move on to the server side. We are going to design the button usingย <strong>HTML</strong>,ย <strong>CSS</strong> and a small icon. </div> <p>Place the belowย <strong>HTML</strong> code on the place where you want to show the button :</p> <blockquote> <p><a href="login\_with\_facebook.php" id="login\_with\_facebook">Login With Facebook</a></p> </blockquote> <p>You should need aย <strong>Facebook</strong> small logo for making the button attractive. I have included the image below :</p> <p style="text-align: center;"> <a href="//lab.subinsb.com/projects/blog/uploads/2013/12/fb_icon.png"><img class="size-full wp-image-2118 aligncenter" style="background-color: black;" alt="fb_icon" src="//lab.subinsb.com/projects/blog/uploads/2013/12/fb_icon.png" width="28" height="28" /></a> </p> <p>Here is theย <strong>CSS</strong> code that will decorate the button. I have provided the imageย <strong>URL</strong> asย <strong><a href="https://lab.subinsb.com/projects/blog/uploads/2013/12/fb_icon.png">https://lab.subinsb.com/projects/blog/uploads/2013/12/fb_icon.png</a></strong></p> <blockquote> <p>#login_with_facebook{</p> </blockquote> <blockquote> <p>display: inline-block;</p> </blockquote> <blockquote> <p>height: 43px;</p> </blockquote> <blockquote> <p>margin: 0px;</p> </blockquote> <blockquote> <p>padding: 0px 20px 0px 52px;</p> </blockquote> <blockquote> <p>font-family: โ€˜Ubuntuโ€™, sans-serif;</p> </blockquote> <blockquote> <p>font-size: 18px;</p> </blockquote> <blockquote> <p>font-weight: 400;</p> </blockquote> <blockquote> <p>color: #fff;</p> </blockquote> <blockquote> <p>line-height: 41px;</p> </blockquote> <blockquote> <p>background: #3b579d url(<strong><a href="https://lab.subinsb.com/projects/blog/uploads/2013/12/fb_icon.png">https://lab.subinsb.com/projects/blog/uploads/2013/12/fb_icon.png</a></strong>) no-repeat 14px 8px scroll;</p> </blockquote> <blockquote> <p>-webkit-border-radius: 4px;</p> </blockquote> <blockquote> <p>-moz-border-radius: 4px;</p> </blockquote> <blockquote> <p>border-radius: 4px;</p> </blockquote> <blockquote> <p>text-decoration: none;</p> </blockquote> <blockquote> <p>cursor:pointer;</p> </blockquote> <blockquote> <p>}</p> </blockquote> <p>The finished button will look something like below :</p> <p><a href="//lab.subinsb.com/projects/blog/uploads/2013/12/0068.png"><img class="aligncenter size-full wp-image-2119" alt="The finished button" src="//lab.subinsb.com/projects/blog/uploads/2013/12/0068.png" width="245" height="46" /></a></p> <h1 id="server-side">Server Side</h1> <h2 id="login_with_facebookphp">login_with_facebook.php</h2> <p>This is the file that handles the authorization. You need the <strong>oauth_client.php</strong> which we mentioned in the <a title="Implementing OAuth System Using OAuth API Library In PHP" href="//subinsb.com/2013/12/oauth-api-library-php" target="_blank">previous post</a>. You need aย **client idย **andย <strong>client secret</strong> which you get when you create an app @ย <a href="https://developers.facebook.com/apps" target="_blank"><a href="https://developers.facebook.com/apps">https://developers.facebook.com/apps</a></a>ย (Tutorial <a href="//subinsb.com/2012/02/tutorial-how-to-create-a-facebook-app" target="_blank">here</a>).</p> <p>Here is the complete code :</p> <blockquote> <?php </blockquote> <blockquote> <p>require(โ€˜http.phpโ€™);</p> </blockquote> <blockquote> <p>require(โ€˜oauth_client.phpโ€™);</p> </blockquote> <blockquote> <p>$clientย =ย newย oauth_client_class;</p> </blockquote> <blockquote> <p>$client-&gt;serverย =ย โ€˜Facebookโ€™;</p> </blockquote> <blockquote> <p>$client-&gt;debugย =ย false;</p> </blockquote> <blockquote> <p>$client-&gt;debug_httpย =ย true;</p> </blockquote> <blockquote> <p>$client-&gt;redirect_uriย =ย โ€˜http://โ€™.$_SERVER[โ€˜HTTP_HOSTโ€™].dirname(strtok($_SERVER[โ€˜REQUEST_URIโ€™],โ€™?โ€™)).โ€™/login_with_facebook.phpโ€™;</p> </blockquote> <blockquote> <p>$client-&gt;client_idย =ย &quot;;/*Clientย ID*/</p> </blockquote> <blockquote> <p>$client-&gt;client_secretย =ย &quot;;/*Clientย Secret*/</p> </blockquote> <blockquote> <p>$client-&gt;scopeย =ย โ€™email,user_about_me,user_birthdayโ€™;</p> </blockquote> <blockquote> <p>$application_lineย =ย \__LINE__;</p> </blockquote> <blockquote> <p>if(strlen($client-&gt;client_id)ย ==ย 0ย ||ย strlen($client-&gt;client_secret)ย ==ย 0){</p> </blockquote> <blockquote> <p>ย die(โ€˜Pleaseย goย toย Facebookย Appsย pageย https://developers.facebook.com/appsย ,ย โ€˜.</p> </blockquote> <blockquote> <p>ย ย โ€˜createย anย application,ย andย inย theย lineย โ€˜.$application_line.</p> </blockquote> <blockquote> <p>ย ย โ€˜ย setย theย client_idย toย Appย ID/APIย Keyย andย client_secretย withย Appย Secretโ€™);</p> </blockquote> <blockquote> <p>}</p> </blockquote> <blockquote> <p>if(($successย =ย $client-&gt;Initialize())){</p> </blockquote> <blockquote> <p>ย if(($successย =ย $client-&gt;Process())){</p> </blockquote> <blockquote> <p>ย ย if(strlen($client-&gt;authorization_error)){</p> </blockquote> <blockquote> <p>ย ย ย $client-&gt;errorย =ย $client-&gt;authorization_error;</p> </blockquote> <blockquote> <p>ย ย ย $successย =ย false;</p> </blockquote> <blockquote> <p>ย ย }elseif(strlen($client-&gt;access_token)){</p> </blockquote> <blockquote> <p>ย ย ย $successย =ย $client-&gt;CallAPI(โ€˜https://graph.facebook.com/meโ€™,ย โ€˜GETโ€™,ย array(),ย array(โ€˜FailOnAccessErrorโ€™=&gt;true),ย $user);</p> </blockquote> <blockquote> <p>ย ย ย if($success){</p> </blockquote> <blockquote> <p>ย ย ย ย $email=$user-&gt;email;</p> </blockquote> <blockquote> <p>ย ย ย ย $name=$user-&gt;name;</p> </blockquote> <blockquote> <p>ย ย ย ย $gender=$user-&gt;gender;</p> </blockquote> <blockquote> <p>ย ย ย ย $birthday=date(โ€˜d/m/Yโ€™,ย strtotime($user-&gt;birthday));</p> </blockquote> <blockquote> <p>ย ย ย ย $image=get_headers(&quot;https://graph.facebook.com/me/picture?width=200&amp;height=200&amp;access_token=&quot;.$client-&gt;access_token,1);</p> </blockquote> <blockquote> <p>ย ย ย ย $image=$i[โ€˜Locationโ€™];</p> </blockquote> <blockquote> <p>ย ย ย }</p> </blockquote> <blockquote> <p>ย ย }</p> </blockquote> <blockquote> <p>ย }</p> </blockquote> <blockquote> <p>ย $successย =ย $client-&gt;Finalize($success);</p> </blockquote> <blockquote> <p>}</p> </blockquote> <blockquote> <p>if($client-&gt;exit){</p> </blockquote> <blockquote> <p>ย die(&quot;Somethingย Happened&quot;,&quot;&lt;aย href='&quot;.$client-&gt;redirect_uri.&quot;โ€˜&gt;Tryย Again</a>&quot;);</p> </blockquote> <blockquote> <p>}</p> </blockquote> <blockquote> <p>if(!$success){</p> </blockquote> <blockquote> <p>?&gt;</p> </blockquote> <blockquote> <p>ย <!DOCTYPEย HTMLย PUBLICย "-//W3C//DTDย HTMLย 4.01ย Transitional//EN"></p> </blockquote> <blockquote> <p>ย <html></p> </blockquote> <blockquote> <p>ย ย <head></p> </blockquote> <blockquote> <p>ย ย ย <title>Error</title></p> </blockquote> <blockquote> <p>ย ย </head></p> </blockquote> <blockquote> <p>ย ย <body></p> </blockquote> <blockquote> <p>ย ย ย <h1>OAuthย clientย error</h1></p> </blockquote> <blockquote> <p>ย ย ย <pre>Error:ย <?phpย echoย HtmlSpecialChars($client->error);ย ?></pre></p> </blockquote> <blockquote> <p>ย ย </body></p> </blockquote> <blockquote> <p>ย </html></p> </blockquote> <blockquote> <?}?> </blockquote> <p>Donโ€™t forget to replaceย <strong>client_id</strong> &amp;ย <strong>client_secret</strong> values.</p> <h1 id="how-it-works">How It Works</h1> <ol> <li>When a user clicksย <strong>Login With Facebook</strong> button, the user will be redirected to theย <strong>login_with_facebook.php</strong>ย page.</li> <li>Theย <strong>PHP</strong> file will redirect the user toย <strong>Facebook</strong>โ€˜s authorization page with all the app details needed byย <strong>Facebook</strong>.</li> <li>When the user authorizes the app, he/she will be redirected back toย <strong>login_with_facebook.php</strong> page with a **GETย **parameter namedย <strong>code</strong>.</li> <li><strong>OAuth API</strong> library will request anย <strong>access token</strong> toย <strong>Facebook</strong> with the givenย <strong>code</strong>.</li> <li>When it receives theย <strong>access token</strong>, It sends a request toย <strong><a href="https://graph.facebook.com/me">https://graph.facebook.com/me</a></strong> with theย <strong>access_token</strong> and theย <strong>URL</strong> will return the details of the user.</li> <li>It also sends a request toย **<a href="https://graph.facebook.com/me/picture">https://graph.facebook.com/me/picture</a>ย **with the access token and the image size needed (<strong>200 x 200</strong>).</li> </ol> <h1 id="variables">Variables</h1> <blockquote> <p>$email โ€“ The E-Mail of the user</p> </blockquote> <blockquote> <p>$name โ€“ The Name of the user</p> </blockquote> <blockquote> <p>$gender โ€“ The Gender of the user</p> </blockquote> <blockquote> <p>$birthday โ€“ The Birthday of the user</p> </blockquote> <blockquote> <p>$image โ€“ The Image URL of the user</p> </blockquote> <p>Isnโ€™t this tutorial simple ?</p> <p>If you encountered any problems or have a suggestion, please say it on the comments. I will be happy to respond.</p> About https://subinsb.com/about/ Sat, 21 Dec 2013 05:33:08 +0000 https://subinsb.com/about/ <div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-php" data-lang="php"><span style="display:flex;"><span>$cur_year <span style="color:#f92672">=</span> <span style="color:#a6e22e">date</span>(<span style="color:#e6db74">&#34;Y&#34;</span>); <span style="color:#75715e">// PHP. This returns the current year. </span></span></span><span style="display:flex;"><span><span style="color:#75715e"></span>$age <span style="color:#f92672">=</span> $cur_year <span style="color:#f92672">-</span> <span style="color:#ae81ff">2000</span>; <span style="color:#75715e">// Forget the month and the date </span></span></span></code></pre></div><h2 id="hi--im-subin">Hi ! I'm Subin</h2> <p>Hi all,</p> <p>I am Subin Siby,ย a self-taught programmer who loves to make &amp; tinker with things. I was born in the year <strong>2000</strong> (And that's how I got the username). I am currently $ageย years old and lives in Kerala, India. <strong>Malayalam (เดฎเดฒเดฏเดพเดณเด‚)</strong> is my native language. I learnt English from school and by watching a LOT of tv shows and movies.</p> <p>I started programming inย <strong>2011</strong> when I was <strong>11</strong> years old. I love FOSS because of the collaborative nature and the freedom to hack the software to our needs. I support Free Software, Open Knowledge &amp; Sharing.</p> <p>I'm a very curious person. I try to learn new things and love doing interesting stuff, like the one time (2018) where I tracked rainfall for a week and <a href="https://codepen.io/subins2000/pen/WgvNgM">made a chart</a> with ChartJS.</p> <p>I love reading history, going through many Wikipedia pages, reddit and all things internet :D</p> <h3 id="profiles">Profiles</h3> <p>You can find me on sites with the username <code>subins2000</code> or <code>SubinSiby</code>.</p> <ul> <li><a href="https://github.com/subins2000">GitHub</a> <br>Has most of my FOSS projects. Plus contributions</li> <li><a href="https://gitlab.com/subins2000">GitLab</a> <br>Has my relatively new FOSS projects. Plus contributions</li> <li><a href="https://meta.wikimedia.org/wiki/User:Subins2000">Wikipedia</a> <br>I contribute to Wikipedia and its sister-projects</li> <li><a href="https://www.openstreetmap.org/user/subins2000/">OpenStreetMap</a> <br>I sometimes map, upload traces to OSM</li> <li><a href="https://t.me/SubinSiby">Telegram</a> <br>I share interesting things I find on the web &amp; sometimes my original content in this Telegram channel</li> <li><a href="https://aana.site/@subins2000">Mastodon : @[email protected]</a> <br>Toots in <a href="https://subinsb.com/tags/malayalam">เดฎเดฒเดฏเดพเดณเด‚</a> or English or both :P</li> <li><a href="https://twitter.com/SubinSiby">Twitter</a> <br>My Mastodon &amp; Twitter is bridged.</li> <li><a href="https://www.linkedin.com/in/subinsiby/">LinkedIn</a> <br>I don't use it much</li> <li><a href="https://www.instagram.com/subins2000">Instagram</a> <br>Is a reminder of the places I've travelled. I post interesting stuff as stories too.</li> </ul> <p>If you're a curious person like me, you'll like my stories on Instagram, my toots and things in my Telegram channel.</p> <h3 id="contact">Contact</h3> <p>See <a href="https://subinsb.com/contact">/contact</a>.</p> <h2 id="projects">Projects</h2> <p>I've made a lot of free &amp; open source software which you can find in this blog and in my <a href="https://github.com/subins2000">GitHub</a> and <a href="https://gitlab.com/subins2000">GitLab</a> profiles.</p> <p>See <a href="https://subinsb.com/projects">/projects</a>.</p> <h3 id="legacy">Legacy</h3> <p>I've made more projects that I don't maintain anymore. You can find them on my GitHub or GitLab.</p> <ul> <li><a href="https://subinsb.com/lobby/">Lobby</a> : A framework/platform for running web apps in localhost</li> <li><a href="https://subinsb.com/tags/open/">Open</a> : An Open Source social network in PHP</li> </ul> <h2 id="about-this-blog">About this blog</h2> <ul> <li>When I encounter a problem during programming or while making something and find a solution, I post it in this blog.</li> <li>When I participate in tech events, I share about the experience here</li> <li>When I feel like writing something, I share it here</li> <li>Some stories <a href="https://subinsb.com/myre">like this one</a></li> </ul> <p>I started this blog when I was <strong>11</strong> years old. This blog shows how I've grown as a person. I cringe myself seeing my old blog posts ๐Ÿ˜ฌ, but I don't delete em. It's history and nostalgic ๐Ÿ˜๐ŸŒŸ.</p> <p>A lot of people were kind enough to <a href="https://subinsb.com/donate">donate money</a> to support my projects. You see, as a middle class kid growing up in a rural part of India, these donations, feedback and appreciation were a huge boost for me growing up. Besides, seeing the donations, my parents were quite surprised and that helped in their support towards me.</p> <h3 id="subscribe">Subscribe</h3> <p>There used to be email subscriptions before. But it's too hard to manage. Instead better follow my Telegram channel or Mastodon or Twitter.</p> <h2 id="stats">Stats</h2> <p>Google Analytics was used at first for pageviews count. Then, StatCounter was used. Then again, it was switched back to GA.</p> <p>Since 2019 July, I've been using a <a href="https://github.com/defuse/phpcount">custom hit counter</a>. The pageviews from this is shown in the header of posts. The count was reset to zero at the beginning of 2020, so that a better analysis is obtained. This custom hit counter doesn't track users.</p> <p>Since the stats measurement tool was changed between years, it was hard to make an overall total. But I <a href="https://gist.github.com/subins2000/7b81088787cda65efb8694b8a2406fa2">did it</a> with some effort.</p> <p>Stats till <code>2020-01-01</code> :</p> <ul> <li>Users: <code>2,400,000</code>+</li> <li>Pageviews: <code>4,266,068</code>+</li> </ul> <p>I wonder how many people around the world I've made an influence on, even in a small way. Feels good :)</p> <p>I encourage everyone to start a blog, write stuff. When you face a problem, fixes it, and there's no docs on it anywhere, blog about it. It might help someone else, maybe even after 10, 20 years :)</p> <p>Your writings may influence others, perhaps someone who came across your blog while wandering through the internet. Hey, I still remember some things I read in random blogs I came across when roaming around the world wide web and that have influenced me, yes ;)</p> <h2 id="blogs-history">Blog's History</h2> <h3 id="2011---2013">2011 - 2013</h3> <p>This blog was first created as &quot;Science And Games&quot; (SAG) in Blogger.com. My neighbour and good friend Simrajettan (Simraj KS) introduced me to blogging. He was a physics school teacher at the time. He has a <a href="http://simmash.blogspot.com">blog named &quot;scintillla&quot;</a> from which I drew inspiration.</p> <p>Someone had already took <code>sag.blogspot.com</code>, so I registered with <a href="http://sag-3.blogspot.com">sag-3.blogspot.com</a>. I took the number 3 because it was me, my brother Simrin Siby and Simraj KS who were at the time I thought would contribute to the blog.</p> <p>The initial posts were about some tutorials, Wikipedia copy-paste articles and stuff. Some of these posts were deleted later. You can see the <a href="https://gitlab.com/subins2000/subinsb.com/tree/075097114ab1d3d66b13659de1343b77cad2d995/content/posts">entire post list here</a>.</p> <p><a href="https://web.archive.org/web/20120101000000*/http://sag-3.blogspot.in">Archive.org snapshots of the site sag-3.blogspot.in</a></p> <h3 id="2013">2013</h3> <p>In September 2013, after constant begging to my parents, appa (dad) finally gave me his debit card to buy a domain. Online transactions weren't common at the time and appa was suspicious of me using it. Thanks to GoDaddy's $0.99 domain offer, it was cheap to buy it.</p> <blockquote> <p>$0.99 != 70 Indian Rupees</p> </blockquote> <p>I chose <code>subinsb.com</code>. It stands as an abbreviation of <code>SUBIN'S Blog</code>. It can also stand for <code>SUBIN SiBy</code> :P</p> <p>I mapped my blogspot domain to the new one and old post links were all automatically redirected. The blog used <code>www.subinsb.com</code>.</p> <p><a href="https://web.archive.org/web/20130101000000*/http://subinsb.com">Archive.org snapshots of the site subinsb.com</a></p> <h3 id="2013---2017">2013 - 2017</h3> <p>In November of 2013, the blog was moved from <strong>Blogger to WordPress</strong>. The hosting was provided for free by RedHat's OpenShift platform which had a special free tier.</p> <p>The redirection of old links of Blogger to WordPress was done possible with a <a href="//subinsb.com/move-blog-from-blogger-to-wordpress/">small WordPress plugin I made</a>.</p> <p>I made a <a href="https://github.com/subins2000/brenton-wordpress">custom theme called Brenton</a> for the blog.</p> <p>Meanwhile, the site <a href="http://demos.subinsb.com">demos.subinsb.com</a> was started to showcase examples of tutorials in the blog. The entire transition process is also mentioned there.</p> <p>One huge influence of my blog and work were <a href="http://9lessons.info">Srinivas Tamada's 9lessons.info</a>.</p> <p><a href="https://web.archive.org/web/20130101000000*/http://demos.subinsb.com">Archive.org snapshots of the site demos.subinsb.com</a></p> <h3 id="2017---now">2017 - now</h3> <p>RedHat discontinued OpenShift platform in favor of OpenShift 3 which had no free tier plans. So now I was troubled with another &quot;movement&quot;.</p> <p>Looking for a free alternative and low maintenance, I found <a href="https://gohugo.io/">Hugo</a>. I made a <a href="//github.com/subins2000/brenton-hugo">custom theme called Brenton</a> which was a near reimplemtation of the old WordPress theme.</p> <p>The blog is hosted for <a href="https://gitlab.com/subins2000/subinsb.com">free thanks to GitLab โค๏ธ</a>.</p> <h2 id="stories">Stories</h2> <p>These stories will be completed later</p> <h3 id="the-internet">The Internet</h3> <p>Appa (dad) was the one who introduced me to internet. It was in the year 2008 on a GPRS enabled phone. The goal was to download games. How expensive internet and small games were back then !</p> <p>The Samsung flip-phone we had supported Java games. To download new ones, there's a store called GameJAR or something. GPRS internet was billed on bandwidth usage from prepaid balance (100KB was 1Rs IIRC). When me &amp; my brother get bored of games, we would reluctantly ask Appa to get us new ones โ˜บ๏ธ. Since the whole procedure was expensive, we only get to do it once or twice an year. We had to patiently wait for Appa to do it for us. Ahh, the power he had over us then ๐Ÿ˜‚</p> <p>We bought a computer in 2010. In 2011, we got a <code>156Kbps</code> Tata Docomo mobile internet connection (USB). I used this internet till 2016. It was using this poor connection that I learnt programming,</p> <h3 id="how-i-chose-the-username-subins2000">How I chose the username subins2000</h3> <h3 id="how-i-started-programming">How I started programming</h3> <h3 id="linux">Linux</h3> <p>The first GNU/Linux distro I got to interact with was Fedora around 2007/2008-ish. It was my uncle's computer and when we visit during vacation time, we'd play games on it. Fedora was the way how our uncle prevented us from using the Windows OS in it, so that we don't mess things up. I remember playing <a href="https://wiki.gnome.org/Apps/Nibbles">Nibbles</a> very often.</p> <p>I got seriously introduced to GNU/Linux from school where the Information Technology textbooks were all in GNU/Linux software. Kerala schools have a custom Ubuntu based distro, called <a href="https://kite.kerala.gov.in">IT@School Linux</a>. The shift from Windows XP to Ubuntu happened in textbooks when I entered 5th grade (2009).</p> <p>When we were able to buy a computer (2010), we made sure that the IT@School distro came with the computer. I explored Ubuntu further, because I liked tinkering with it, the terminal, installation, software and all. At one point, I formatted the entire system which my dad absolutely didn't like :P</p> <p>I still have that IT@School Ubuntu 10.04 CD with me. Should frame it and put up on the wall someday !</p> <p>Kerala, that has a population of 30 million still continues to use &amp; promote FOSS in school. I often see kids making cool stuff with tools they get. Kids in school these days get to play with Raspberyy Pi &amp; Arduino, wish I was in school now !</p> <h2 id="copyright-notice">Copyright Notice</h2> <p><a rel="license" href="http://creativecommons.org/licenses/by/4.0/"><img alt="Creative Commons License" style="border-width:0" src="https://i.creativecommons.org/l/by/4.0/88x31.png" /></a><br />All content of this site is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by/4.0/">Creative Commons Attribution 4.0 International License</a>.</p> Implementing OAuth System Using OAuth API Library In PHP https://subinsb.com/oauth-api-library-php/ Fri, 20 Dec 2013 15:07:52 +0000 https://subinsb.com/oauth-api-library-php/ <p><strong>OAuth Login System</strong> is one of the needed system in a website. There are many online services that have their ownย <strong>OAuth</strong> system. <strong>Popular Services</strong> have their own <strong>PHP OAuth</strong>ย library and documentation.</p> <p>But, weโ€™re gonna use a simpler and a commonย <strong>Library</strong> for all of those services. This common <strong>library</strong>ย (OAuth API) is created byย <strong>PHPClasses.org</strong> founderย <strong>Manuel Lemos</strong>.</p> <p>His library can be used to authorize manyย <strong>API</strong>โ€˜s includingย <strong>Facebook</strong>,ย <strong>Twitter</strong>,ย <strong>Google</strong>. Everything is made easy byย Manuel. He is a hard working programmer. Thatโ€™s why he has theย <strong># 1</strong> rank onย <strong>PHP Classes</strong>.</p> <h1 id="demo">Demo</h1> <p><a href="http://open.subinsb.com/oauth/login_with_facebook" target="_blank">Login With Facebook</a></p> <p><a href="http://open.subinsb.com/oauth/login_with_google" target="_blank">Login With Google</a></p> <h1 id="download">Download</h1> <p>Only some files are needed from the library to accomplish our tasks. You can see the all theย <strong>Library</strong> files @ย <strong><a href="http://www.phpclasses.org/package/7700-PHP-Authorize-and-access-APIs-using-OAuth.html" target="_blank">PHPClasses</a></strong>. <strong>OAuth API</strong> also need theย <strong>HTTP Protocol Client</strong>ย class.ย Here are the files you need to download for <strong>OAuth API</strong> :</p> <ol> <li><a href="http://www.phpclasses.org/browse/file/42008.html" target="_blank">oauth_client.php</a></li> <li><a href="http://www.phpclasses.org/browse/file/5.html" target="_blank">http.php</a></li> </ol> <h1 id="features">Features</h1> <ol> <li>Implement the <strong>OAuth</strong> protocol to retrieve a token from a server to authorize the access to an API on behalf of the current user.</li> <li>Store authorization details (access token, refresh token etc..) according to users in a table using <strong>SQL</strong>.</li> <li>Offline Access to <strong>API</strong>โ€˜s</li> <li>Perform calls to a Web services API using a token previously obtained using this class or a token provided some other way by the Web services provider.</li> </ol> <h1 id="some-of-the-oauth-api8217s">Some Of The OAuth APIโ€™s</h1> <ol> <li>Facebook</li> <li>Google</li> <li>Twitter</li> <li>LinkedIn</li> <li>Instagram</li> <li>Ubuntu</li> <li>Microsoft Live</li> <li>Tumblr</li> <li>Yahoo</li> </ol> <p>and many moreโ€ฆ..</p> <h1 id="including">Including</h1> <p>You only have to includeย <strong>oauth_client.php</strong>.ย **http.phpย **will be included byย <strong>oauth_client.php</strong> :</p> <pre class="prettyprint"><code>&lt;?php require("oauth_client.php"); ?&gt;</code></pre> <h2 id="examples">Examples</h2> <p>As I mentioned in the demo part before, this has been implemented in <a href="https://open.subinsb.com">Open</a>. You can see the source code of them :</p> <p><a href="https://github.com/subins2000/open/blob/master/source/oauth/login_with_facebook.php">login_with_facebook.php</a></p> <p><a href="https://github.com/subins2000/open/blob/master/source/oauth/login_with_google.php">login_with_google.php</a></p> <p>I will be publishing posts about implementing variousย <strong>API</strong>โ€˜s using this library in the future.</p> Open : An Open Source Social Network Is Released https://subinsb.com/open-an-open-source-social-network-is-released/ Wed, 04 Dec 2013 17:40:33 +0000 https://subinsb.com/open-an-open-source-social-network-is-released/ <p>Iโ€™m excited to announce thatย <strong>Open</strong>, theย <strong>Open Source Social Network</strong> initiated by me is released. Actually it has been released onย <strong>December 1</strong>st, but was undergoing many bug fixes and was making it smooth on theย <strong>WWW</strong>. You can accessย <strong>Open</strong> @ย **<a href="http://open.subinsb.com">http://open.subinsb.com</a>.ย **If you would like to contribute to this project, there are a few ways :</p> <ol> <li>Report Bugs, Issues &amp; Suggestions (<a href="https://github.com/subins2000/open/issues">https://github.com/subins2000/open/issues</a>)</li> <li>Fix errors on Source Code (<a href="https://github.com/subins2000/open">https://github.com/subins2000/open</a>)</li> <li>Try Out Open (<strong><a href="http://open.subinsb.com">http://open.subinsb.com</a></strong>)</li> <li>Share the link (<strong><a href="http://open.subinsb.com">http://open.subinsb.com</a></strong>) with your friends and others.</li> </ol> <p>As it is anย <strong>Open Source Project</strong>, there are no ads. Each contributer of this project is a developer of this project. <strong>Itโ€™s your contribution that makesย Open Powerful</strong>. Letโ€™s create the <strong>world more connective and more Open</strong>. Here is the logo ofย <strong>Open</strong>. If you have a better logo, please submit it.</p> <p><a href="//lab.subinsb.com/projects/blog/uploads/2013/11/logo1.png"><img class="size-full wp-image-2062 aligncenter" alt="Open Logo" src="//lab.subinsb.com/projects/blog/uploads/2013/11/logo1.png" width="185" height="69" /></a></p> <p>Your feedback is my everything. What do you think about this project ? Please suggest out anything you have in your mind even if it is harsh.</p> How To Open/Show A Select Element Using jQuery https://subinsb.com/how-to-open-a-select-element-using-jquery/ Sat, 30 Nov 2013 06:22:01 +0000 https://subinsb.com/how-to-open-a-select-element-using-jquery/ <p>The defaultย <strong>select</strong> elements looks ugly and if you want to create beautiful sites, its better to not useย <strong>select</strong> element. But what if you really want to useย <strong>select</strong> element ? The only way to accomplish this is to create a dynamicย <strong>select</strong> box which functions just like theย <strong>HTML select</strong> element. In this post Iโ€™m going to show you the way to create a fakeย <strong>select</strong> box that will open when clicked and when the user selects an option, theย <strong>select</strong> box will automatically close.</p> <p>Here is ourย <strong>HTML</strong> code :</p> <pre class="prettyprint"><code>&lt;button id="clickme"&gt;Click Me To Open Select Box&lt;/button&gt; &lt;select id="choose" name="choose" style=display:none;""&gt; &lt;option value="burger"&gt;Burger&lt;/option&gt; &lt;option value="fries"&gt;French Fries&lt;/option&gt; &lt;option value="banana"&gt;Banana&lt;/option&gt; &lt;/select&gt;</code></pre> <p>This is theย <strong>jQuery</strong> code that will open theย <strong>#choose</strong> select box when clicked onย <strong>#clickme</strong> and will close if the user chooses an option :</p> <pre class="prettyprint"><code>$("#clickme").on("click",function(){ var se=$("#choose"); se.show(); se[0].size=2; }); $("#choose").on("click",function(){ var se=$(this); se.hide(); });</code></pre> <p>This trick is used onย <strong>Open</strong> in the post form**ย **: <a href="http://open.subinsb.com" target="_blank"><a href="http://open.subinsb.com">http://open.subinsb.com</a></a></p> How To Add Back jQuery .live() & .die() Function https://subinsb.com/how-to-add-back-jquery-live-die-function/ Sun, 24 Nov 2013 12:31:47 +0000 https://subinsb.com/how-to-add-back-jquery-live-die-function/ <p>As you may know,ย <strong>jQuery</strong>ย removedย <strong>.live()</strong> function and instead they told to use <strong>.on()</strong> function. But I didnโ€™t like this becauseย <strong>.on()</strong>ย needs up more parameters thanย <strong>.live()</strong> and toย handle aย <strong>click</strong> function you have to add an event to theย <strong>document</strong>, instead of the element. A normalย <strong>live</strong> <strong>click event</strong>ย codeย is like this</p> <pre class="prettyprint"><code>$("#element").live("click",function(){ dosomething(); });</code></pre> <p>When usingย <strong>.on()</strong> to do the same task, the code will be like this :</p> <pre class="prettyprint"><code>$(document).on("click","#element",function(){ dosomething(); });</code></pre> <p>Notice the big difference. Usingย <strong>.on()</strong> event have a lot more code thanย <strong>.live()</strong> and itโ€™s not easy to use. Itโ€™s not comfortable. The motto ofย <strong>jQuery</strong>ย isย <strong>Write Less, Do More</strong>. In the case ofย <strong>.on()</strong>ย the motto doesnโ€™t apply. So we needย <strong>.live()</strong> back.ย <strong>jQuery</strong> wonโ€™t bring it back. Hence we should take things on our own.</p> <p>In this post Iโ€™m going to tell youย <strong>How To Bring Back .live() function</strong>. Itโ€™s pretty simple. All you have to do is add some lines at a place of yourย <strong>jQuery</strong> file.</p> <p>Open yourย <strong>jQuery</strong>ย source file andย search for :</p> <pre class="prettyprint"><code>unbind:</code></pre> <p>You will get a code something like this :</p> <pre class="prettyprint"><code>unbind: function( types, fn ) { return this.off( types, null, fn ); },</code></pre> <p>If itโ€™s aย <strong>jQuery</strong> minified version, you will get something like this :</p> <pre class="prettyprint"><code>unbind:function(a,b){return this.off(a,null,b)},</code></pre> <p>Now add the following code just after the comma (<strong>,</strong>) of **unbindย **:</p> <pre class="prettyprint"><code>live:function(types,data,fn){jQuery(document).on(types,this.selector,data,fn);return this;},die:function(types,data,fn){jQuery(document).off(types,this.selector);return this;},</code></pre> <p>And the whole code will be :</p> <pre class="prettyprint"><code>unbind:function(a,b){return this.off(a,null,b)},live:function(types,data,fn){jQuery(document).on(types,this.selector,data,fn);return this;},die:function(types,data,fn){jQuery(document).off(types,this.selector);return this;},</code></pre> <p>And on the unminified version :</p> <pre class="prettyprint"><code>unbind: function( types, fn ) { return this.off( types, null, fn ); },live:function(types,data,fn){jQuery(document).on(types,this.selector,data,fn);return this;},die:function(types,data,fn){jQuery(document).off(types,this.selector);return this;},</code></pre> <p>Now, try usingย <strong>.live()</strong>ย &amp; <strong>.die()</strong>ย functions and it will work ! If you have any problems /suggestions /feedback, donโ€™t hesitate to say it in the comments.</p> Executing JavaScript Code In AJAX Response https://subinsb.com/how-to-execute-javascript-in-ajax-response/ Sat, 23 Nov 2013 15:21:46 +0000 https://subinsb.com/how-to-execute-javascript-in-ajax-response/ <p>This is the first post I am creating related to theย Open project. This trick is used for posting posts and making that post appear at the first of the post feed. This tutorial will guide you on how to executeย JavaScriptย code which is in the response ofย <strong>AJAX</strong> call. We are going to useย **jQuery **for bothย AJAXย handling.</p> <p>This is theย <strong>AJAX</strong> response :</p> <pre class="prettyprint"><code>&lt;script&gt;alert("Hello Subin");&lt;/script&gt;</code></pre> <p>With a plain <strong>AJAX</strong> response, the code wonโ€™t execute. Even If you append theย <strong>HTML</strong> code inย <strong>AJAX</strong> response to theย <strong>DOM</strong>, it wonโ€™t execute. To make it execute, you should useย <strong>eval</strong> function. Some sayย <strong>eval is evil</strong>, but there is no other way for this purpose.</p> <p>You should need a div wrapper that will store theย <strong>AJAX</strong> responses :</p> <pre class="prettyprint"><code>&lt;div id="ajax_responses" style="display:none;"&gt;&lt;/div&gt;</code></pre> <p>The following code will execute an <strong>AJAX</strong> callย and handle theย <strong>AJAX</strong> response in a way to make the code in the <strong>AJAX</strong> responseย execute.</p> <pre class="prettyprint"><code>&lt;script&gt; $.post("ajaxResponse.php",{data : "some data"}, function(response){ ย  $("#ajax_responses").html(response); ย  $("#ajax_responses").find("script").each(function(){ ย  ย eval($(this).text()); ย  }); }); &lt;/script&gt;</code></pre> <h2 id="what-happens-">What Happens ?</h2> <p>When the request is made, the server will return theย <strong>JavaScript</strong> code insideย <strong>script</strong> tag.ย <strong>jQuery</strong> will append theย <strong>HTML</strong> response inย <strong>#ajax_responses</strong>ย element. Thenย <strong>jQuery</strong> will loop through theย <strong>script</strong> elements in theย <strong>#ajax_responses</strong>ย element. Then the contents of theย <strong>script</strong> tag is passed throughย <strong>eval</strong> function and the code will execute.</p> Open : An Open Source Social Network https://subinsb.com/open-source-social-network/ Thu, 21 Nov 2013 15:31:10 +0000 https://subinsb.com/open-source-social-network/ <p>I decided to create a new social network. I already created 3 social networks, 2 is under project and one another was online. Among the 2 under going projects isย <strong>Open</strong> which I decided to make itย <strong>Open Source</strong>. Hence the name,ย <strong>Open</strong>. It is currently available for subscribing @ <a href="http://open.subinsb.com">http://open.subinsb.com</a> which will soon be completely online. I didnโ€™t had the time to work on it because of theย **Bundlesย **of school projects (GOD! I hate School). The code will be available on <a href="https://github.com/subins2000/open">GitHub</a>ย soon.ย ****</p> <p>ย </p> <p>Here is the current logo ofย <strong>Open</strong> :</p> <p><a href="//lab.subinsb.com/projects/blog/uploads/2013/11/logo1.png"><img class="size-full wp-image-2062 aligncenter" alt="logo" src="//lab.subinsb.com/projects/blog/uploads/2013/11/logo1.png" width="185" height="69" /></a></p> <p>ย </p> <p>The logo was created usingย <strong>GIMP</strong>. The font of the logo is <strong>ubuntu</strong>. Itโ€™s a very simple logo which only has 2 layers. The color of the text isย <strong>#009CFF</strong>.</p> <p>You can subscribe toย **Openย **@ย <a href="http://open.subinsb.com">http://open.subinsb.com</a>ย . If you subscribe you will be notified whenย <strong>Open</strong> becomes online. The subscribers of <strong>Subinโ€™s Blog</strong> will be automatically notified ofย <strong>Open</strong>.</p> <p>As I go through developingย <strong>Open</strong> so will the new posts. I will tell you the technics, codes used and the features on the upcoming posts. I need your feedback on this <strong>Open Source Project</strong>ย movement. Tell your ideas, suggestions, feedback via comments. I will reply to them If I can.</p> How To Remove Smart Quotes From Posts In WordPress https://subinsb.com/how-to-remove-smart-quotes-from-posts-in-wordpress/ Mon, 18 Nov 2013 16:04:45 +0000 https://subinsb.com/how-to-remove-smart-quotes-from-posts-in-wordpress/ <p>If yourย <strong>WordPress</strong> blog containsย <strong>code</strong> snippets,ย <strong>WordPress</strong> will make the quotes in the codes look fancy. The quotes will become something likeย **โ€˜ย **andย <strong>โ€™</strong>. If you canโ€™t see it well, here it is :</p> <h2 id="heading">**โ€˜ย **โ€™</h2> <p>When a reader of your blog copies your code, the special characters (quotes) will be copied with the code instead of the real code quotes. When this happens the code wonโ€™t work. This happened to me yesterday. I immediately tried to find a solution and I found the perfect solution. Iโ€™m going to share that perfect solution. There is a plugin namedย <strong>Unfancy</strong>ย <strong>Quotes</strong> onย <strong>WordPress</strong>, but it didnโ€™t do the job. Hereโ€™s what I did to removeย <strong>Fancy</strong>ย <strong>Quotes</strong>.</p> <p>Go to yourย <strong>Theme</strong>ย <strong>Editor</strong> which is available @ย **Appearanceย **-&gt; <strong>Editor</strong>.</p> <p>On the right side which contains the name of the files of your theme, chooseย <strong>Theme Functions (functions.php)</strong>.</p> <p>Add the following code to theย <strong>functions.php</strong> file :</p> <blockquote> <p>remove_filter(โ€˜the_contentโ€™, โ€˜wptexturizeโ€™);</p> <p>remove_filter(โ€˜comment_textโ€™, โ€˜wptexturizeโ€™);</p> <p>remove_filter (โ€˜single_post_titleโ€™, โ€˜wptexturizeโ€™);</p> <p>remove_filter (โ€˜the_titleโ€™, โ€˜wptexturizeโ€™);</p> <p>remove_filter (โ€˜wp_titleโ€™, โ€˜wptexturizeโ€™);</p> </blockquote> <p>And save the file by clickingย <strong>Update File</strong> below theย <strong>Editor</strong> textarea. Now, when you go to your blog posts you wonโ€™t see anyย <strong>Fancy Quotes</strong>.</p> Contact https://subinsb.com/contact/ Mon, 18 Nov 2013 15:40:23 +0000 https://subinsb.com/contact/ <p>You can contact me via email. This is my preferred method for communication.</p> <p><a href="https://www.base64decode.org/">Decode this Base64</a> string to get my email addresses :</p> <pre class="prettyprint"><code>bWFpbFthdF1zdWJpbnNiW2RvdF1jb20=</code></pre> <p>Spammers these days are so complicated that itโ€™s hard for someone to show their email address publicly. Hope there arenโ€™t any spammer email address crawler script that decodes Base64.</p> Ask https://subinsb.com/ask/ Sat, 09 Nov 2013 15:51:16 +0000 https://subinsb.com/ask/ <p>If you have any questions / problems / suggestions you can ask / request it in the comments below</p> <p>If you want to request a tutorial, you can request it too via the comments.</p> <p>If you want to discuss about a topic or need help, please use this page. I will be glad to help you.</p> <p>I will reply to your comments if Iโ€™m not in the following conditions :</p> <ol> <li>Have a school project</li> <li>Have got fever or other diseases</li> <li>Have a function to attend</li> <li>Internet Connection Expired</li> <li>Internet Not Working</li> <li>Dead</li> </ol> <p>Please donโ€™t paste codes on the comments. If you want to paste codes you can useย <a href="http://pastebin.com" target="_blank"><strong>pastebin</strong></a>. If you want to directly contact me, send an email to ย mail[@]subinsb.com</p> <p>If you want to embed codes in the comment, use <strong>&lt;blockquote&gt;</strong> tag. Example :</p> <pre class="prettyprint"><code>&lt;blockquote&gt;&lt;? echo "Hello World"; ?&gt;&lt;/blockquote&gt;</code></pre> <p>You can also use &quot;code&quot; &amp; &quot;pre&quot; tags for embedding codes. You can bold using &quot;<b></b>&quot; &amp; can add a link using <code>&lt;a href=&quot;&gt;&lt;/a&gt;</code>.</p> <p>And if you think, itโ€™s vulnerable to XSS attack, think again.</p> Uploading Images Using Imgur API in PHP https://subinsb.com/uploading-images-using-imgur-api-in-php/ Fri, 08 Nov 2013 16:17:00 +0000 https://subinsb.com/uploading-images-using-imgur-api-in-php/ <div dir="ltr" style="text-align: left;"> <span style="font-family: inherit;">This tutorial was a request from <a href="http://disqus.com/anandubajith/">Anandu</a>.</span><br /> <span style="font-family: inherit;"><b>Imgur</b>ย provides developers to upload images anonymously using their app. For this you only need to <b>signup</b>ย for <b>Imgur</b>ย and get anย <b>Application Client ID</b>. In this post I&#8217;m going to tell you the step by step process of uploading images using <b>Imgur API</b>ย in <b>PHP</b>. This is pretty easy. You only have to send a <b>POST</b>ย request to a file on their site.</span></p> <div class="padlinks"> <span style="font-family: inherit;"><a class="download" href="http://demos.subinsb.com/down.php?id=r8zy7w2bdzegmo5&class=13">Download</a> <a class="demo" href="http://demos.subinsb.com/imgur-api-image-upload">Demo</a></span> </div> <div id="toc_container" class="no_bullets"> <p class="toc_title"> Contents </p> <pre><code>&lt;ul class=&quot;toc_list&quot;&gt; &lt;li&gt; &lt;a href=&quot;#sign-up&quot;&gt;&lt;span class=&quot;toc_number toc_depth_1&quot;&gt;1&lt;/span&gt; Sign Up&lt;/a&gt; &lt;/li&gt; &lt;li&gt; &lt;a href=&quot;#create-application-get-client-id&quot;&gt;&lt;span class=&quot;toc_number toc_depth_1&quot;&gt;2&lt;/span&gt; Create Application &amp; Get Client ID&lt;/a&gt; &lt;/li&gt; &lt;li&gt; &lt;a href=&quot;#html&quot;&gt;&lt;span class=&quot;toc_number toc_depth_1&quot;&gt;3&lt;/span&gt; HTML&lt;/a&gt; &lt;/li&gt; &lt;li&gt; &lt;a href=&quot;#uploadphp&quot;&gt;&lt;span class=&quot;toc_number toc_depth_1&quot;&gt;4&lt;/span&gt; upload.php&lt;/a&gt; &lt;/li&gt; &lt;li&gt; &lt;a href=&quot;#fixes&quot;&gt;&lt;span class=&quot;toc_number toc_depth_1&quot;&gt;5&lt;/span&gt; Fixes&lt;/a&gt; &lt;/li&gt; &lt;/ul&gt; </code></pre> </div> <h2 style="text-align: left;"> <span id="sign-up">Sign Up</span> </h2> <p> <span style="font-family: inherit;">Go to <a href="https://imgur.com/register">this page</a>ย to sign up. It supports Social signup with <b>Google</b>, <b>Facebook</b>, <b>Twitter</b>ย & <b>Yahoo! </b>or you can sign up via the form.</span> </p> <h2 style="text-align: left;"> <span id="create-application-get-client-id">Create Application & Get Client ID</span> </h2> <p> <span style="font-family: inherit;">You need to create an app to get the <b>Client ID</b>. For creating an application go to <a href="https://api.imgur.com/oauth2/addclient">this page</a>.</span><br /> <span style="font-family: inherit;">Selectย <span style="background-color: white; white-space: pre-wrap;"><b>Anonymous usage without user authorization</b> option as <b>Authorization Type</b>.</span></span> </p> <div class="separator" style="clear: both; text-align: center;"> <a style="margin-left: 1em; margin-right: 1em;" href="https://2.bp.blogspot.com/-dgydVjb63bA/Unu6-42TaFI/AAAAAAAADSs/Cs60K83uWhU/s1600/0066.png"><img src="https://2.bp.blogspot.com/-dgydVjb63bA/Unu6-42TaFI/AAAAAAAADSs/Cs60K83uWhU/s1600/0066.png" alt="" border="0" /></a> </div> <p> <span style="font-family: inherit;"><span style="background-color: white; white-space: pre-wrap;">Fill up all the other fields including <b>CAPTCHA</b>. Then click <b>submit</b> button.</span></span><br /> <span style="font-family: inherit;"><span style="background-color: white; white-space: pre-wrap;">You will now get a <b>client ID</b> and a <b>client Secret</b> key. We will only need a <b>client ID</b>.</span></span> </p> <div class="separator" style="clear: both; text-align: center;"> <a style="margin-left: 1em; margin-right: 1em;" href="//1.bp.blogspot.com/-VcTfGBwRRVM/Unu7eZ9KRSI/AAAAAAAADS0/G51gyDi2pl8/s1600/0067.png"><img src="//1.bp.blogspot.com/-VcTfGBwRRVM/Unu7eZ9KRSI/AAAAAAAADS0/G51gyDi2pl8/s1600/0067.png" alt="" border="0" /></a> </div> <h2 style="text-align: left;"> <span id="html"><span style="font-family: inherit;"><span style="background-color: white; white-space: pre-wrap;">HTML</span></span></span> </h2> <pre class="prettyprint"><code>&lt;form action="upload.php" enctype="multipart/form-data" method="POST"&gt; Choose Image : &lt;input name="img" size="35" type="file"/&gt;&lt;br/&gt; &lt;input type="submit" name="submit" value="Upload"/&gt; &lt;/form&gt;</code></pre> <p> The above form is just like any other normal file upload form. </p> <h2 style="text-align: left;"> <span id="uploadphp"><span style="background-color: white; white-space: pre-wrap;">upload.php</span></span> </h2> <pre class="prettyprint"><code>&lt;? $img=$_FILES['img']; if(isset($_POST['submit'])){ย  ย if($img['name']==''){ ย  ย  echo "&lt;h2&gt;An Image Please.&lt;/h2&gt;"; ย }else{ ย  $filename = $img['tmp_name']; ย  $client_id="88fd52d307ecceb"; ย  $handle = fopen($filename, "r"); ย  $data = fread($handle, filesize($filename)); ย  $pvars ย  = array('image' =&gt; base64_encode($data)); ย  $timeout = 30; ย  $curl = curl_init(); ย  curl_setopt($curl, CURLOPT_URL, 'https://api.imgur.com/3/image.json'); ย  curl_setopt($curl, CURLOPT_TIMEOUT, $timeout); ย  curl_setopt($curl, CURLOPT_HTTPHEADER, array('Authorization: Client-ID ' . $client_id)); ย  curl_setopt($curl, CURLOPT_POST, 1); ย  curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); ย  curl_setopt($curl, CURLOPT_POSTFIELDS, $pvars); ย  $out = curl_exec($curl); ย  curl_close ($curl); ย  $pms = json_decode($out,true); ย  $url=$pms['data']['link']; ย  if($url!=""){ ย  ย echo "&lt;h2&gt;Uploaded Without Any Problem&lt;/h2&gt;"; ย  ย echo "&lt;img src='$url'/&gt;"; ย  }else{ ย  ย echo "&lt;h2&gt;There's a Problem&lt;/h2&gt;"; ย  ย echo $pms['data']['error']; ย  ย  }ย  ย } } ?&gt;</code></pre> <h2> <a href="#fixes"><span id="fixes">Fixes</span></a> </h2> <p> Sometimes, the code won&#8217;t work or other problems will arise. In this case, check the following : </p> <ul> <li> Is PHP JSON extension installed ? </li> <li> Is PHP cURL extension installed ? </li> </ul> <p> If the above didn&#8217;t fix your problem, add this code just after setting theย <strong>$curl</strong> variable in the code : </p> <p> <span style="color: #3f4549;"></span> </p> <pre class="prettyprint"><code>curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);</code></pre> <p> <span style="color: #3f4549;"></span> </p> <p> By doing this, we are disabling theย <strong>SSL Certificate</strong> verification which is not good, so I recommend you do <a href="http://stackoverflow.com/a/6325154/1372424" target="_blank">this</a>. </p> <p> <span style="white-space: pre-wrap;">Replace the content of </span><span style="background-color: white; white-space: pre-wrap;"><b>$client_id</b> variable with the <b>Client ID</b> value you got.ย </span><span style="white-space: pre-wrap; line-height: 1.5em;">You can get the </span><b style="white-space: pre-wrap; line-height: 1.5em;">URL</b><span style="white-space: pre-wrap; line-height: 1.5em;"> of the image uploaded from </span><b style="white-space: pre-wrap; line-height: 1.5em;">$url</b><span style="white-space: pre-wrap; line-height: 1.5em;"> variable.</span><br /> <span style="background-color: white; white-space: pre-wrap;">If you have any problems / suggestions / feedback contact me through the comments.</span> </p> </div> Google + Profile URL Shortening Now Available To The Public https://subinsb.com/google-profile-url-shortening-now-available-to-the-public/ Sun, 03 Nov 2013 13:59:00 +0000 https://subinsb.com/google-profile-url-shortening-now-available-to-the-public/ <div dir="ltr" style="text-align: left;" trbidi="on"> The wait is over. Now you can short your <b>Google&nbsp;</b><b>+</b>&nbsp;long profile <b>URL</b>&nbsp;to something like <b>http://www.google.com/+SubinSiby</b>. Yes, you can get a short <b>URL</b>&nbsp;on <b>google.com</b>. <b>Google</b>&nbsp;made this public <b>3 </b>or <b>4&nbsp;</b>days ago. I got a <b>mail</b>&nbsp;saying that your <b>profile</b>&nbsp;is now eligible to short. In this post I&#8217;m going to tell the step by step procedure to short the long <b>URL</b>. If you got the <b>mail</b>&nbsp;already you can skip <b>Step 1</b>.</p> <h2 style="text-align: left;"> <b>Step 1</b> </h2> <p> Go to your <b>Google+ </b><a href="http://plus.google.com/u/o/me" >profile page</a>. Wait till the page is completely loaded. If you get the bar (shown below) at the top of your <b>profile</b>&nbsp;page, then you are eligible to short your <b>URL</b>. </p> <div class="separator" style="clear: both; text-align: center;"> <a href="//1.bp.blogspot.com/-GyG763qmu9Q/UnZSs5j0bWI/AAAAAAAADQM/9FkhP8S8VVw/s1600/0061.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="//1.bp.blogspot.com/-GyG763qmu9Q/UnZSs5j0bWI/AAAAAAAADQM/9FkhP8S8VVw/s1600/0061.png" /></a> </div> <div class="separator" style="clear: both; text-align: center;"> </div> <h2 style="text-align: left;"> Step 2 </h2> <p> Click on <b>Get URL</b>&nbsp;button on the bar. You will get a window like below : </p> <div class="separator" style="clear: both; text-align: center;"> <a href="https://2.bp.blogspot.com/-ackSzSsf3-c/UnZSwacitFI/AAAAAAAADQg/mt2X3DTgzfs/s1600/0062.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://2.bp.blogspot.com/-ackSzSsf3-c/UnZSwacitFI/AAAAAAAADQg/mt2X3DTgzfs/s1600/0062.png" /></a> </div> <p> Tick the <b>I agree to the Terms of Service</b>&nbsp;check box and click on <b>Change URL</b>. </p> <h2 style="text-align: left;"> Step 3 </h2> <p> <b>Google</b>&nbsp;will ask for confirmation. Note that you can&#8217;t change this short <b>URL</b>&nbsp;to something else in the future once done. </p> <div class="separator" style="clear: both; text-align: center;"> <a href="//4.bp.blogspot.com/-YgWRY8SEHxs/UnZSwyEbLTI/AAAAAAAADQo/14RTxRZty2M/s1600/0063.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="//4.bp.blogspot.com/-YgWRY8SEHxs/UnZSwyEbLTI/AAAAAAAADQo/14RTxRZty2M/s1600/0063.png" /></a> </div> <div class="separator" style="clear: both; text-align: center;"> </div> <p> To confirm click on <b>Confirm choice</b>&nbsp;button. Once clicked a loading screen will be shown : </p> <div class="separator" style="clear: both; text-align: center;"> <a href="https://2.bp.blogspot.com/-1V8Uz5RJ1I4/UnZSwRKWo7I/AAAAAAAADQc/1W0AXkIP8ic/s1600/0064.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://2.bp.blogspot.com/-1V8Uz5RJ1I4/UnZSwRKWo7I/AAAAAAAADQc/1W0AXkIP8ic/s1600/0064.png" /></a> </div> <p> Everything&#8217;s now finished. You will get a success box if there are no errors : </p> <div class="separator" style="clear: both; text-align: center;"> <a href="//4.bp.blogspot.com/-b-yLN2zWt5Y/UnZSyDP4vaI/AAAAAAAADQw/Cv7IJ5k49WA/s1600/0065.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="//4.bp.blogspot.com/-b-yLN2zWt5Y/UnZSyDP4vaI/AAAAAAAADQw/Cv7IJ5k49WA/s1600/0065.png" /></a> </div> <p> Congratulations, you now have a short <b>URL</b>. Try it out. Here&#8217;s my short <b>URL</b>&nbsp;: <a href="http://www.google.com/+SubinSiby">http://www.google.com/+SubinSiby</a></div> How To Create A Simple Web Crawler in PHP https://subinsb.com/how-to-create-a-simple-web-crawler-in-php/ Sun, 20 Oct 2013 07:08:00 +0000 https://subinsb.com/how-to-create-a-simple-web-crawler-in-php/ <p>A <strong>Web Crawler</strong>ย is a program that crawls through the sites in the Webย and indexes those <strong>URL</strong>โ€˜s. <strong>Search Engines</strong>ย uses a crawlerย to index URLโ€™s on the Web. Google uses a crawler written in <strong>Python</strong>. There are other search engines that uses different types of crawlers.</p> <p>In this post Iโ€™m going to tell you how to create a simple Web Crawlerย in <strong>PHP</strong>.</p> <p>The codes shown here was created by me. It took me 2 daysย to create a simpleย crawler. Then How much time would it take to create a perfect crawlerย ? Creatingย aย Crawlerย is a very hard task. Itโ€™s like creating a Robot. Letโ€™s start building a crawler.</p> <div class="padlinks"> <a class="download" href="http://demos.subinsb.com/down.php?id=r8zy7w2bdzegmo5&class=12">Download</a> <a class="demo" href="http://demos.subinsb.com/php-web-crawler">Demo</a> </div> <p>For parsing the web page of a URL, we are going to use <strong>Simple HTML Dom</strong>ย class which can be downloaded at <strong><a href="http://sourceforge.net/project/showfiles.php?group_id=218559">Sourceforge</a></strong>. Include the file &quot;simple_html_dom.php&quot;ย and mention the variables we are going to use :</p> <pre class="prettyprint"><code>include "simple_html_dom.php"; $crawled_urls = array(); $found_urls = array();</code></pre> <p>Then, Add the functions we are going to use. The following function will convert <strong>relative</strong>ย <strong>URL</strong>โ€˜s to <strong>absolute URL</strong>โ€˜s :</p> <pre class="prettyprint"><code>functionย rel2abs($rel, ย  $base) { ifย (parse_url($rel, ย PHP_URL_SCHEME)ย  != ย '') { returnย  $rel; } ifย ($rel[0] == '#'ย  || ย  $rel[0] == '?') { returnย  $base . $rel; } extract(parse_url($base)); $pathย  = ย preg_replace('#/[^/]*$#', ย '', ย  $path); ifย ($rel[0]ย  == ย '/') { $pathย  = ย ''; } $absย  = ย "$host$path/$rel"; $reย  = ย array('#(/.?/)#', ย '#/(?!..)[^/]+/../#'); for ($n = 1; ย  $n & gt; 0; $abs = preg_replace($re, '/', ย  $abs, -1, $n)) {} $abs = str_replace('../', '', $abs); returnย  $scheme . '://' . $abs; }</code></pre> <p>The following function will change the <strong>URL</strong>โ€˜s found when crawling to real <strong>URL</strong>โ€˜s :</p> <pre class="prettyprint"><code>functionย perfect_url($u, $b) { $bp = parse_url($b); if (($bp['path'] != '/'ย  & amp; & amp; ย  $bp['path'] != '')ย  || ย  $bp['path'] == '') { if ($bp['scheme'] == '') { $scheme = 'http'; } else { $scheme = $bp['scheme']; } $b = $scheme . '://' . $bp['host'] . '/'; } if (substr($u, 0, 2) == '//') { $u = 'http:' . $u; } if (substr($u, 0, 4) != 'http') { $u = rel2abs($u, $b); } returnย  $u; }</code></pre> <p>This code is the <strong>core</strong>ย of the crawlerย :</p> <pre class="prettyprint"><code>functionย crawl_site($u) { globalย  $crawled_urls, ย  $found_urls; $uen = urlencode($u); if ((array_key_exists($uen, $crawled_urls) == 0ย  || ย  $crawled_urls[$uen]ย  & lt; ย date('YmdHis', strtotime('-25ย seconds', ย time())))) { $htmlย  = ย file_get_html($u); $crawled_urls[$uen] = date('YmdHis'); foreach ($html- & gt; find('a')ย asย  $li) { $url = perfect_url($li- & gt; href, $u); $enurl = urlencode($url); if ($url != ''ย  & amp; & amp; ย substr($url, 0, 4) != 'mail'ย  & amp; & amp; ย substr($url, 0, 4) != 'java'ย  & amp; & amp; ย array_key_exists($enurl, $found_urls) == 0) { $found_urls[$enurl] = 1; echoย  $url . PHP_EOL; } } } }</code></pre> <p>Finally, we will call the <strong>crawl_site</strong>ย function to <strong>crawl</strong>ย a <strong>URL</strong>. Iโ€™m going to use <strong><a href="http://subinsb.com">http://subinsb.com</a></strong>ย for <strong>crawling</strong>.</p> <pre class="prettyprint"><code>crawl_site("http://subinsb.com");</code></pre> <p>When you run the PHPย crawlerย now, you will get all the URLโ€™s in the page. You can again crawlย those founded URLโ€™s to find more URLโ€™s, but you would need a fastย Server and a High Speedย Internet Connection.</p> <p>A Super Computerย and an Internet Connection of 10 GB/Secondย would be perfect for that. If you think that your computerย is fast and can crawlย many URLโ€™s, then change the following line in the code :</p> <pre class="prettyprint"><code>echoย  $url . PHP_EOL; </code></pre> <p>to :</p> <pre class="prettyprint"><code>crawl_site($url);</code></pre> <p>Note :- The code isnโ€™t perfect, there may be errors when crawling some URLโ€™s. I donโ€™t recommendย you to crawlย the URLโ€™s found again unless you have a Super Computer and aย High Speed Internet Connection. Feel free to make the crawlerย better, awesomeย and fastย @ <a href="https://github.com/subins2000/phpwebcrawler">GitHub</a>.</p> <p>If you have any problems / suggestions / feedback, echo it in the comments. Your Feedback is my happiness.</p> How To Check If Internet Connection Exists In jQuery & Javascript https://subinsb.com/how-to-check-if-internet-connection-exists-in-jquery-javascript/ Fri, 18 Oct 2013 13:58:00 +0000 https://subinsb.com/how-to-check-if-internet-connection-exists-in-jquery-javascript/ <div dir="ltr" style="text-align: left;"> If you are running an app on the web that requires <b>Internet Connection</b>ย all the time, sometimes the <b>internet connection</b> will fail on the client side and your app won&#8217;t properly work. The best example is the New Tabย <b>Chrome Apps</b>ย that will display the <b>URL</b>ย icons <b>grayscale</b>ย when offline and will make the icons back to color when online. To check whether the client&#8217;s <b>internet connection</b>ย is online, we use <b>jQuery</b>. You can also use <b>Javascript</b>ย to check. I will tell you how to do the checking in both <b>jQuery</b>ย and <b>Javascript</b>.<br /> The checking is simple. We will send a request to one of the site&#8217;s image. If the request was successful,<b>ย </b>theย <b>Internet Connection</b>ย is active and if it&#8217;s not successful, there isn&#8217;t any active <b>Internet Connection</b>. It&#8217;s as simple as that. The following modal will make you understand the concept easily :</p> <div class="separator" style="clear: both; text-align: center;"> <a style="margin-left: 1em; margin-right: 1em;" href="//1.bp.blogspot.com/-LtDtdVE1roA/UmAavs_T_iI/AAAAAAAADNY/g0L-HAPlkTY/s1600/0060.png"><img alt="" src="//1.bp.blogspot.com/-LtDtdVE1roA/UmAavs_T_iI/AAAAAAAADNY/g0L-HAPlkTY/s1600/0060.png" border="0" /></a> </div> <div class="padlinks"> <a class="download" href="http://demos.subinsb.com/down.php?id=rqzu9k13h8hdm9d&class=11">Download</a> <a class="demo" href="http://demos.subinsb.com/check-internet-connection-js-jquery">Demo</a> </div> <p> I have wrapped the checking into a function namedย <b>checkNetConnection</b>. </p> <h2 style="text-align: left;"> <span style="font-size: large;">Javascript</span> </h2> <pre class="prettyprint"><code>function checkNetConnection(){ var xhr = new XMLHttpRequest(); var file = "http://yoursite.com/somefile.png"; var r = Math.round(Math.random() * 10000); xhr.open('HEAD', file + "?subins=" + r, false); try { xhr.send(); if (xhr.status &gt;= 200 && xhr.status &lt; 304) { return true; } else { return false; } } catch (e) { return false; } }</code></pre> <h2 style="text-align: left;"> <span style="font-size: large;">jQuery</span> </h2> <pre class="prettyprint"><code>function checkNetConnection(){ ย jQuery.ajaxSetup({async:false}); ย re=""; ย r=Math.round(Math.random() * 10000); ย $.get("http://yoursite.com/somefile.png",{subins:r},function(d){ ย  re=true; ย }).error(function(){ ย  re=false; ย }); ย return re; }</code></pre> <p> In Both Codes above you have to change the <b>URL</b> </p> <blockquote class="tr_bq"> <p> http://yoursite.com/somefile.png </p> </blockquote> <p> to a small <b>Image</b>ย file location of your site. If you want a small size image (<b>137</b>ย bytes) go to <b><a href="https://demos.subinsb.com/cdn/dot.png">https://demos.subinsb.com/cdn/dot.png</a>.</b><br /> If you have any suggestions / problems report it to me via comments. I am here 10/7. </p> </div> How To Add A Simple Birthday Field In A Form Using jQuery https://subinsb.com/datepicker-birthday-field-in-form/ Mon, 14 Oct 2013 14:55:00 +0000 https://subinsb.com/datepicker-birthday-field-in-form/ <div dir="ltr" style="text-align: left;"> There are certain laws on the <b>Web</b>. One of them is the <b>COPPA </b>lawย which clarifies the minimum age of a user to signup for a site. The minimum age is <b>13</b>. If any site allows users under <b>13</b>ย to signup, it is considered <b>illegal</b>. So it&#8217;s necessary to add a <b>birthday</b>ย field in site&#8217;sย <b>Sign-Up</b>ย form. So I&#8217;m going to tell you how to add a <b>simple, stylish</b>ย <b>birthday</b>ย field to your <b>Sign-Up</b>ย form.</p> <div class="padlinks"> <a class="download" href="http://demos.subinsb.com/down.php?id=4i3stvjau05bh0o&class=10">Download</a> <a class="demo" href="http://demos.subinsb.com/birthday-form-jquery">Demo</a> </div> <p> Extractย <b>datepicker.js</b> andย <b>datepicker.css </b>from the archive downloadable from above link. Create <b>index.php</b>ย (Containing Form) &ย <b>birthchecker.js</b>. </p> <h3 style="text-align: left;"> <b><span style="font-size: large;">index.php</span></b> </h3> <blockquote class="tr_bq"> <p> <!DOCTYPE html><br /> <html><br /> <head><br /> <link href="datepicker.css" rel="stylesheet"/><br /> <script src="http://code.jquery.com/jquery-latest.min.js"></script><br /> <script src="datepicker.js"></script><br /> <script src="birthchecker.js"></script><br /> <title>jQuery Birthday Form Field & Checker</title><br /> </head><br /> <body><br /> <div id="content" style="margin-top:10px;height:100%;"><br /> <center><h1>jQuery Birthday Form Field & Checker</h1></center><br /> <form method="POST" action="submit.php"><br /> <table class="table"><tbody><br /> <tr><br /> <td>Birthday :</td><br /> <td><input id="birth" name="birth" value="2000-01-20&#8243;/><div id="ermsg">Users under 13 are not allowed.</div></td><br /> <td>YY-MM-DD</td><br /> </tr><br /> <tr><br /> <td></td><br /> <td><input type="submit"/></td><br /> </tr><br /> </tbody></table><br /> </form><br /> </div><br /> <style><br /> input{<br /> border:none;<br /> padding:8px;<br /> }<br /> #ermsg{<br /> display:none;<br /> color:red;<br /> }<br /> </style><br /> <!&#8211; http://www.subinsb.com/2013/10/add-simple-birthday-field-in-form-jquery-and-validate-in-php.html &#8211;><br /> </body><br /> </html> </p> </blockquote> <h3 style="text-align: left;"> <b><span style="font-size: large;">birthchecker.js</span></b> </h3> <blockquote class="tr_bq"> <p> $(document).ready(function(){<br /> v=$(&#8216;#birth&#8217;);<br /> function above13(v){<br /> cur=new Date();<br /> cls=new Date(v.val());<br /> age = new Date(cur &#8211; cls).getFullYear() &#8211; 1970;<br /> console.log(age);<br /> if(age<13){<br /> v.css("background","red");<br /> $("#ermsg").show();<br /> }else{<br /> v.css("background","white");<br /> $("#ermsg").hide();<br /> }<br /> }<br /> v.DatePicker({<br /> format:&#8217;Y-m-d&#8217;,<br /> date: v.val(),<br /> current: v.val(),<br /> starts: 1,<br /> position: &#8216;r&#8217;,<br /> onBeforeShow:function(){<br /> v.DatePickerSetDate(v.val(), true);<br /> },<br /> onChange:function(formated, dates){<br /> v.val(formated);<br /> v.DatePickerHide();<br /> above13(v);<br /> }<br /> });<br /> v.on("keyup",function(){<br /> above13(v);<br /> });<br /> }); </p> </blockquote> <h3 style="text-align: left;"> <b><span style="font-size: large;">submit.php</span></b> </h3> <blockquote class="tr_bq"> <p> <?<br /> function age($birthday){<br /> list($day,$month,$year) = explode("/",$birthday);<br /> $year_diff ย = date("Y") &#8211; $year;<br /> $month_diff = date("m") &#8211; $month;<br /> $day_diff ย  = date("d") &#8211; $day;<br /> if ($day_diff < 0 && $month_diff==0){$year_diff&#8211;;}<br /> if ($day_diff < 0 && $month_diff < 0){$year_diff&#8211;;}<br /> return $year_diff;<br /> /* http://www.subinsb.com/2013/05/the-best-age-calculation-code-in-php.html */<br /> }<br /> $birth=$_POST[&#8216;birth&#8217;];<br /> if(isset($_POST) && $birth!="){<br /> $birth=explode("-",$birth);<br /> $nbir=$birth[2]."/".$birth[1]."/".$birth[0];<br /> $age=age($nbir);<br /> echo "Your Age is $age.<br/><a href=&#8217;index.php&#8217;>Click Here To Go To Demo Form</a>";<br /> }<br /> ?> </p> </blockquote> <p> That&#8217;s all. If you have any problems / suggestions / feedback, comment it. I am here 10/7. </p> </div> How To Create A Simple Password Strength Checker In jQuery https://subinsb.com/how-to-create-a-simple-password-strength-checker-using-jquery/ Sun, 13 Oct 2013 16:55:00 +0000 https://subinsb.com/how-to-create-a-simple-password-strength-checker-using-jquery/ <div dir="ltr" style="text-align: left;"> <p> A lot of new hacking methods are coming day by day. So it&#8217;s the programmers duty to make their user&#8217;s <b>password</b>ย secure. Here is a simple <b>Password Strength</b>ย Checker created using <b>jQuery</b>. The code contain a function got from <b>WordPress </b>(I modified it)ย which is the core component of the checker. This checker will check the following on the password : </p> <ol style="text-align: left;"> <li> Have minimum value of <b>4</b>ย characters. </li> <li> Whether the username matches with password </li> <li> Whether the password contain small <b>a-z</b>ย characters and capital <b>A-Z</b>ย characters. </li> <li> Whether the password has numeric characters and special characters. </li> </ol> <p> If all of the above criteria is matched, the checker will give a <b>Strong Password</b>ย message. </p> <div class="padlinks"> <a class="download" href="http://demos.subinsb.com/down.php?id=5b6cxortxy85zbc&class=9">Download</a> <a class="demo" href="http://demos.subinsb.com/jquery-password-strength-checker">Demo</a> </div> <p> Create two files : <b>index.html</b>ย and <b>passchecker.js</b><br /> We will also include the <b>jQuery</b>ย library on the <b>HTML</b>ย file. </p> <h2 style="text-align: left;"> index.html </h2> <pre class="prettyprint"><code>&lt;!DOCTYPE html&gt; &lt;html&gt; ย &lt;head&gt; ย  &lt;script src="http://code.jquery.com/jquery-latest.min.js"&gt;&lt;/script&gt; ย  &lt;script src="passchecker.js"&gt;&lt;/script&gt; ย  &lt;title&gt;Simple jQuery Password Strength Checker&lt;/title&gt; ย &lt;/head&gt; ย &lt;body&gt; ย  &lt;div id="content" style="margin-top:10px;height:100%;"&gt; ย  ย &lt;center&gt;&lt;h1&gt;Simple jQuery Password Strength Checker&lt;/h1&gt;&lt;/center&gt; ย  ย &lt;table&gt;&lt;tbody&gt; ย  ย  &lt;tr&gt; ย  ย  ย &lt;td&gt; ย  ย  ย  Username : ย  ย  ย &lt;/td&gt; ย  ย  ย &lt;td&gt; ย  ย  ย  &lt;input type="text" size="35" id="user" placeholder="Username"/&gt; ย  ย  ย &lt;/td&gt; ย  ย  &lt;/tr&gt; ย  ย  &lt;tr&gt; ย  ย  ย &lt;td&gt; ย  ย  ย  Password : ย  ย  ย &lt;/td&gt; ย  ย  ย &lt;td&gt; ย  ย  ย  &lt;input type="password" size="35" id="pass" placeholder="Type A Password"/&gt; ย  ย  ย &lt;/td&gt; ย  ย  &lt;/tr&gt; ย  ย  &lt;tr&gt; ย  ย  ย &lt;td&gt;&lt;/td&gt; ย  ย  ย &lt;td&gt; ย  ย  ย  &lt;div id="ppbar" title="Strength"&gt;&lt;div id="pbar"&gt;&lt;/div&gt;&lt;/div&gt; ย  ย  ย  &lt;div id="ppbartxt"&gt;&lt;/div&gt; ย  ย  ย &lt;/td&gt; ย  ย  &lt;tr&gt; ย  ย  ย &lt;td&gt; ย  ย  ย  Retype Password : ย  ย  ย &lt;/td&gt; ย  ย  ย &lt;td&gt; ย  ย  ย  &lt;input type="password" size="35" id="pass2" placeholder="ReType Password"/&gt; ย  ย  ย &lt;/td&gt; ย  ย  &lt;/tr&gt; ย  ย &lt;/tbody&gt;&lt;/table&gt; ย  &lt;/div&gt; ย  &lt;style&gt; ย  input{ ย  ย border:none; ย  ย padding:8px; ย  } ย  #ppbar{ ย  ย background:#CCC; ย  ย width:300px; ย  ย height:15px; ย  ย margin:5px; ย  } ย  #pbar{ ย  ย margin:0px; ย  ย width:0px; ย  ย background:lightgreen; ย  ย height: 100%; ย  } ย  #ppbartxt{ ย  ย text-align:right; ย  ย margin:2px; ย  } ย  &lt;/style&gt; &lt;!-- http://www.subinsb.com/2013/10/create-simple-password-strength-checker-using-jquery.html --&gt; ย &lt;/body&gt; &lt;/html&gt;</code></pre> <h2 style="text-align: left;"> passchecker.js </h2> <pre class="prettyprint"><code>function passwordStrength(f,i,d){var k=1,h=2,b=3,a=4,c=5,g=0,j,e;if((f!=d)&&d.length&gt;0){return c}if(f.length==0){return 0;}if(f.length&lt;4){return k}if(f.toLowerCase()==i.toLowerCase()){return h}if(f.match(/[0-9]/)){g+=10}if(f.match(/[a-z]/)){g+=26}if(f.match(/[A-Z]/)){g+=26}if(f.match(/[^a-zA-Z0-9]/)){g+=31}j=Math.log(Math.pow(g,f.length));e=j/Math.LN2;if(e&lt;40){return h}if(e&lt;56){return b}return a}; function widthofpr(p){ if(p==0){return "0%";} if(p==1){return "25%";} if(p==2){return "50%";} if(p==3){return "75%";} if(p==4){return "100%";} } function textofpr(p){ if(p==0){return "Type A Password";} if(p==1){return "Short Password";} if(p==2){return "Bad Password";} if(p==3){return "Good Password";} if(p==4){return "Strong Password";} if(p==5){return "Password Mismatch";} } $(document).ready(function(){ user=$("#user"); pass=$("#pass"); pass2=$("#pass2"); pbar=$("#pbar"); pbart=$("#ppbartxt"); function onKeyUp(){ pbar.css('width',widthofpr(passwordStrength(pass.val(),user.val(),pass2.val()))); pbart.text(textofpr(passwordStrength(pass.val(),user.val(),pass2.val()))); } pass.bind('keyup',function(){ onKeyUp(); }); pass2.bind('keyup',function(){ onKeyUp(); }); });</code></pre> <p> When a keypress event is fired on any one of the password fields, <b>jQuery</b>ย will check the password strength and print according to the strength. Easy as compiling <b>Python</b>.<br /> If you have any problems / suggestions / feedback, contact me via comments. I am here 10/7. </p> </div> Create Simple Username Availability Checker Using jQuery & PHP https://subinsb.com/create-simple-username-availability-checker-jquery-php/ Sun, 13 Oct 2013 07:07:00 +0000 https://subinsb.com/create-simple-username-availability-checker-jquery-php/ <div dir="ltr" style="text-align: left;"> <p> Many sites have signup pages. Every programmers try to make the signup pages attractive by adding stylish inputย CSSย codes and others. Why not add a stylishย username availability checker ? It&#8217;s very easy to add and will work on <b>jQuery</b>ย versions <b>1.2</b>ย and up. I&#8217;m also going to tell you how to check if username is available in the server side. Of course it&#8217;s <b>PHP</b>. The checking is <b>SQL</b>ย <b>Injection</b>ย free too. For Executingย SQLย queries we will use <b>PHP PDO</b>. </p> <div class="padlinks"> <a class="download" href="http://demos.subinsb.com/down.php?id=yxns9kk4ubhkosb&class=8">Download</a> <a class="demo" href="http://demos.subinsb.com/jquery-username-availability-check">Demo</a> </div> <p> First of all create two files<b>ย </b>&#8211; <b>index.php</b>ย (<b>signup page</b>),ย <b>check.php </b>& <b>checker.js</b><br /> It&#8217;s not necessary to set the name of signup page to <b>index.php</b>. Any name will work. </p> <h2 style="text-align: left;"> index.php </h2> <pre class="prettyprint"><code>&lt;html&gt; ย &lt;head&gt; ย  &lt;script src="http://code.jquery.com/jquery-latest.min.js"&gt;&lt;/script&gt; ย  &lt;script src="checker.js"&gt;&lt;/script&gt; ย &lt;/head&gt; ย &lt;body&gt; ย  &lt;input type="text" size="35" id="user" value="" placeholder="Type Your Desired Username"/&gt; ย  &lt;input type="button" id="check" style="cursor:pointer;" value="Check Availablity"/&gt;&lt;br/&gt; ย  &lt;div style="margin:5px 15px;" id="msg"&gt;http://mysite.com/&lt;b id="prev"&gt;subinsiby&lt;/b&gt;&lt;/div&gt; ย &lt;/body&gt; &lt;/html&gt;</code></pre> <h2 style="text-align: left;"> checker.js &#8211; Request To Check Username </h2> <pre class="prettyprint"><code>$(document).ready(function(){ ย v=$("#user"); ย $("#check").on('click',function(){ ย  v.attr("disabled","true"); ย  v.css({background:"url(../cdn/load.gif) no-repeat",backgroundSize: "2em",backgroundPosition: "center right"}); ย  $.post('check.php',{user:v.val().toLowerCase()},function(d){ ย  ย v.css("background","white"); ย  ย v.removeAttr("disabled"); ย  ย if(d=='available'){ ย  ย  $("#msg").html("&lt;span style='color:green;'&gt;The username &lt;b&gt;"+v.val().toLowerCase()+"&lt;/b&gt; is available&lt;/span&gt;"); ย  ย }else{ ย  ย  $("#msg").html("&lt;span style='color:red;'&gt;The username &lt;b&gt;"+v.val().toLowerCase()+"&lt;/b&gt; is not available&lt;/span&gt;"); ย  ย } ย  }); ย }); ย v.bind('keyup',function(){ ย  $("#prev").text(v.val().toLowerCase()); ย }); });</code></pre> <h2 style="text-align: left;"> check.php &#8211; Checks Username </h2> <pre class="prettyprint"><code>&lt;? include("config.php"); $user=strtolower($_POST['user']); if(isset($_POST) && $user!=''){ ย $sql=$dbh-&gt;prepare("SELECT username FROM users WHERE username=?"); ย $sql-&gt;execute(array($user)); ย if($sql-&gt;rowCount()==0){ ย  echo "available"; ย }else{ ย  echo "not-available"; ย } } ?&gt;</code></pre> <p> and of course <b>config.phpย </b> </p> <pre class="prettyprint"><code>&lt;? $host = "localhost"; // Database Hostname $port = "3306"; / /MySQL Port : Default : 3306 $user = "username"; // Databse Username Here $pass = "password"; // Databse Password Here $db ย  = "database_name"; // Database Name $dbh ย = new PDO('mysql:dbname='.$db.';host='.$host.';port='.$port,$user,$pass); ?&gt;</code></pre> <p> When the user clicks the <b>Check Availability</b>ย button, jQueryย will send a <b>POST</b>ย request to <b>check.php</b>ย with <b>user</b>ย parameter containing the usernameย value the client entered. check.phpย will check it&#8217;s database with the username given by <b>AJAX</b>ย call. If it matches a user response will be not-availableย and if it doesn&#8217;t match a user, then the response will be available.<br /> jQueryย will make changes to the page according to the <b>AJAX</b>ย response ie jQueryย will take care of the rest. If you have any suggestions / feedback/ problems , say it in the comments. </p> </div> How To Create A HTML, CSS, JS Code Editor Using jQuery https://subinsb.com/how-to-create-a-html-css-js-code-editor-using-jquery/ Sat, 12 Oct 2013 07:56:00 +0000 https://subinsb.com/how-to-create-a-html-css-js-code-editor-using-jquery/ <p>There are a lot of <strong>HTML</strong>ย editing services in the <strong>Web</strong>. Some of the popular services are <strong>JsFiddle</strong>ย andย <strong>JsBin</strong>. These sites offer saving function to your account too. If you want to create a site like <strong>JSFiddle</strong>, then you are at the right place. Iโ€™m going to tell you how to create a basic <strong>HTML</strong>ย editing software using <strong>jQuery</strong>.</p> <p>The editor weโ€™re going to create also has a live preview service which means that the user donโ€™t have to submit the code form every time. The preview is automatically updated using <strong>jQuery</strong>โ€˜s <strong>keyup</strong>ย trigger except for **JS **code update, because <strong>Javascript</strong>ย canโ€™t be added every time when user types something because there will be <strong>syntax</strong>ย errors.</p> <div class="padlinks"> <a class="download" href="http://demos.subinsb.com/down.php?id=txjxy7h69mhznsz&class=7">Download</a> <a class="demo" href="http://demos.subinsb.com/html-css-js-editor">Demo</a> </div> <p>First, we create the text editor layout which have a table containingย <strong>HTML</strong>ย codes, <strong>CSS</strong>ย codes, <strong>JS</strong>ย codes andย <strong>textareas</strong>. Here is the full <strong>HTML</strong>ย code of layout (Weโ€™re also adding the jQuery library) :</p> <pre class="prettyprint"><code>&lt;script src="http://code.jquery.com/jquery-latest.min.js"&gt;&lt;/script&gt; &lt;script src="htmleditor.js"&gt;&lt;/script&gt; &lt;table&gt; ย &lt;tbody&gt; ย  &lt;tr&gt; ย  ย &lt;td&gt; ย  ย  &lt;h2&gt;HTML&lt;/h2&gt; ย  ย  &lt;textarea class="codes" id="html" placeholder="Your HTML Code HERE"&gt;&lt;/textarea&gt; ย  ย &lt;/td&gt; ย  ย &lt;td&gt; ย  ย  &lt;h2&gt;CSS&lt;/h2&gt; ย  ย  &lt;textarea class="codes" id="css" placeholder="Your CSS Code HERE"&gt;&lt;/textarea&gt; ย  ย &lt;/td&gt; ย  &lt;/tr&gt; ย  &lt;tr&gt; ย  ย &lt;td&gt; ย  ย  &lt;h2&gt;JS&lt;/h2&gt; ย  ย  &lt;textarea class="codes" id="js" placeholder="Your JavaScript Code HERE"&gt;&lt;/textarea&gt; ย  ย &lt;/td&gt; ย  ย &lt;td&gt; ย  ย  &lt;h2&gt;Preview&lt;/h2&gt; ย  ย  &lt;iframe id="preview" src="javascript:;"&gt;&lt;/iframe&gt; ย  ย &lt;/td&gt; ย  &lt;/tr&gt; ย  &lt;tr&gt; ย  ย &lt;td&gt; ย  ย  &lt;div style="text-align:right;"&gt;&lt;input id="upjs" type="button" value="Update And Run JS"/&gt;&lt;/div&gt; ย  ย &lt;/td&gt; ย  &lt;/tr&gt; ย &lt;/tbody&gt; &lt;/table&gt; &lt;style&gt; .codes,#preview{ ย width: 320px; ย height: 135px; ย border:2px dashed white; ย background:white; ย color:black; ย overflow:auto; } &lt;/style&gt;</code></pre> <h2 style="text-align: left;"> <b><span style="font-family: inherit; font-size: large;">htmleditor.js</span></b> </h2> <pre class="prettyprint"><code>$(document).ready(function(){ var p=$("#preview").contents().find("body"); p.css("margin","2px"); p.html('&lt;span id="subinsbdotcomhtmlpr"&gt;&lt;/span&gt;&lt;style id="subinsbdotcomcsspr"&gt;&lt;/style&gt;'); $("#html").on('keyup',function(){ p.find("#subinsbdotcomhtmlpr").html($(this).val()); }); $("#css").on('keyup',function(){ p.find("#subinsbdotcomcsspr").html($(this).val()); }); $("#js").on('change',function(){ p.find("#subinsbdotcomjspr").remove(); p.append('&lt;script id="subinsbdotcomjspr"&gt;'+$(this).val()+'&lt;/script&gt;'); }); $("#upjs").on('click',function(){ p.find("#subinsbdotcomjspr").remove(); p.append('&lt;script id="subinsbdotcomjspr"&gt;'+$("#js").val()+'&lt;/script&gt;'); }); });</code></pre> <p>The <strong>jQuery</strong>ย code is too less. The <strong>jQuery</strong>ย code is only binding some <strong>keyup</strong>ย functions and appending <strong>HTML</strong>ย code to the <strong>preview</strong>ย <strong>iframe</strong>. If you have any problems / feedback / suggestions write it on the comments. Iโ€™m here 10/7.</p> How To Use FileZilla/SFTP To Update Site in OpenShift https://subinsb.com/how-to-use-filezillasftp-to-update-site-in-openshift/ Wed, 09 Oct 2013 14:35:00 +0000 https://subinsb.com/how-to-use-filezillasftp-to-update-site-in-openshift/ <p>In the <a title="Goodbye AppFog, Hello OpenShift" href="//subinsb.com/goodbye-appfog-hello-openshift" target="_blank">recent post</a>, I mentioned about <strong>OpenShift</strong>, a <strong>PaaS</strong>ย Service that offers <strong>Free</strong>ย <strong>Hosting</strong>. You can update your application using GIT. OpenShiftย also provides <strong>SSH</strong>ing into your application. You may have heard of <strong>FTP</strong>ย protocol which allows you to transfer files through web. Most hosting companies use <strong>FTP</strong>ย protocol to update client apps. OpenShiftย unlike <strong>AppFog</strong>ย have <strong>FTP</strong>ย support, but in a different manner.</p> <p>It hasย SFTPย support ie <strong>SSH File Transfer Protocol</strong>. SFTPย is a FTPย like protocol that allows to transfer files via <strong>SSH</strong>ย sessions. Most FTPย clients support <strong>SFTP</strong>. FTP client <strong>FileZilla</strong>ย supports SFTP which means that you can use FileZillaย for updating site hosted on OpenShift.ย You can download FileZillaย from <a href="https://filezilla-project.org/">here</a>ย available for Linux, Mac &amp; Windows.</p> <p>You should mention theย <strong>ssh-key</strong>ย you gave toย OpenShiftย in FileZilla too.</p> <p>For that Got to **Edit Menu **-&gt; <strong>Settings</strong>ย and choose the tab SFTPย :</p> <div class="separator" style="clear: both; text-align: center;"> <a style="margin-left: 1em; margin-right: 1em;" href="//3.bp.blogspot.com/-B5FTshkmrNM/UlVbEkMj-6I/AAAAAAAADFY/cYXjZ7ABCgA/s1600/0056.png"><img alt="" src="//3.bp.blogspot.com/-B5FTshkmrNM/UlVbEkMj-6I/AAAAAAAADFY/cYXjZ7ABCgA/s1600/0056.png" border="0" /></a> </div> <p>Click on <strong>Add keyfile</strong>ย and choose the file containing the <strong>ssh-key</strong>. Normally on a **Linux **system it will beย <strong>/home/user/.ssh/id_rsa</strong>. When you select the <strong>SSH</strong>ย key file, <strong>FileZilla</strong>ย will ask for to save the key file in a format <strong>FileZilla</strong>ย understands. Choose <strong>Yes</strong>ย and save it in <strong>/home/user/.ssh</strong>ย with the nameย <strong>filezilla</strong>.</p> <div class="separator" style="clear: both; text-align: center;"> <a style="margin-left: 1em; margin-right: 1em;" href="//3.bp.blogspot.com/-KWB9pk_5uzA/UlVdbIYXhzI/AAAAAAAADFk/3OIKT2iYeB0/s1600/0057.png"><img alt="" src="//3.bp.blogspot.com/-KWB9pk_5uzA/UlVdbIYXhzI/AAAAAAAADFk/3OIKT2iYeB0/s1600/0057.png" border="0" /></a> </div> <p>Now, go to your <strong>OpenShift</strong>ย account and get the username of the <strong>SSH</strong>ย account.</p> <div class="separator" style="clear: both; text-align: center;"> <a style="margin-left: 1em; margin-right: 1em;" href="//3.bp.blogspot.com/-ZxtATowtMJY/UlVnUFRNgJI/AAAAAAAADIM/of3ghPGQyoo/s1600/0058.png"><img alt="" src="//3.bp.blogspot.com/-ZxtATowtMJY/UlVnUFRNgJI/AAAAAAAADIM/of3ghPGQyoo/s1600/0058.png" border="0" /></a> </div> <p>Hereโ€™s how to get the username :</p> <pre class="prettyprint"><code>ssh://[email protected]/~/git/demos.git/</code></pre> <p>The username of the above <strong>SSH</strong>ย command is **198734c26793ca219000106d **and the host is <strong>demos.subinsb.com</strong>.</p> <p>Now, type in the credentials you got from the <strong>SSH</strong>ย command into <strong>FileZilla</strong>.</p> <p>Example :</p> <pre class="prettyprint"><code>Host ย  ย  : sftp://&lt;b>demos.subins.com&lt;/b> Username : 198734c26793ca219000106d</code></pre> <p>Leave the <strong>Password</strong>ย field blank, because we already have an <strong>ssh-key</strong>ย that will authorize us.</p> <p>You will now have complete access to your appโ€™s hosted directory.</p> <p>If you want to update the <strong>source code</strong>ย paste/add/remove youโ€™re source code in the **app-root/repo/php **or whatever the language is.</p> <p>Screenshot :</p> <div class="separator" style="clear: both; text-align: center;"> <a style="margin-left: 1em; margin-right: 1em;" href="//4.bp.blogspot.com/-KjN79ZQLADI/UlVo1AknemI/AAAAAAAADIY/VIPCAsefrUU/s1600/0059.png"><img alt="" src="//4.bp.blogspot.com/-KjN79ZQLADI/UlVo1AknemI/AAAAAAAADIY/VIPCAsefrUU/s1600/0059.png" border="0" /></a> </div> <p>Note that if you do a <strong>git push</strong> to the application, the changes made by SFTP will be replaced. So, be careful while doing a git commit to application if you have made changes to code by SFTP.</p> <p>If you have any problems / suggestions / feedback type it out in the comments.</p> How To Change The Browser URL Without Refreshing Page โ€“ HTML5 https://subinsb.com/how-to-change-the-browser-url-without-refreshing-page-html5/ Tue, 08 Oct 2013 16:03:00 +0000 https://subinsb.com/how-to-change-the-browser-url-without-refreshing-page-html5/ <div dir="ltr" style="text-align: left;" trbidi="on"> This post was suggested by&nbsp;<a href="http://disqus.com/sumitkumarpradhan/" >Sumit Kumar Pradhan</a>. I recently saw many questions like this on <b>Stack Overflow</b>. Let me start explaining, there is already a function in <b>JavaScript</b>&nbsp;to do this special task. The function is <b>window.history.replaceState</b>. It&#8217;s a simple function that needs <b>3 </b>values.<br />This is actually a <b>HTML5</b>&nbsp;function that came out on <b>July 2012</b>&nbsp;(I think). All the latest <b>browsers</b>&nbsp;support the new function except <b>IE 9</b>.</p> <div class="padlinks"> <a class="download" href="http://demos.subinsb.com/down.php?id=ofo66cuias9wgrj&class=6" >Download</a> <a class="demo" href="http://demos.subinsb.com/change-url-without-reloading" >Demo</a> </div> <p> Here is a small example of the usage of <b>window.history.replaceState </b>: </p> <blockquote class="tr_bq"> <p> window.history.replaceState({},&#8217;subinsb.com&#8217;,&#8217;/html5&#8242;); </p> </blockquote> <p> If someone clicks a special&nbsp;<b>URL</b>&nbsp;on your site, you could also change the <b>browser</b>&nbsp;<b>URL</b> with the <b>URL</b>&nbsp;clicked by the user. Here is a small example : </p> <blockquote class="tr_bq"> <p> $(".link").on(&#8216;click&#8217;,function(){<br />&nbsp;window.history.replaceState({},&#8217;subinsb.com&#8217;,&#8217;/&#8217;+$(this).attr("href"));<br />&nbsp;return false;<br />}); </p> </blockquote> <p> The <b>return false;</b>&nbsp;is used at the end of the above code to prevent the redirection of <b>browser</b> to the&nbsp;<b>URL</b>. <b>window.history.pushState</b>&nbsp;is similar to <b>window.history.replaceState</b>&nbsp;function.<br />If you want to see a demo, you can stop by <a href="http://demos.subinsb.com/change-url-without-reloading" >here</a>.</div> Goodbye AppFog, Hello OpenShift https://subinsb.com/goodbye-appfog-hello-openshift/ Sun, 06 Oct 2013 17:27:00 +0000 https://subinsb.com/goodbye-appfog-hello-openshift/ <div dir="ltr" style="text-align: left;" trbidi="on"> <b>AppFog </b>and <b>Heroku</b>&nbsp;were one of the most popular <b>PaaS</b>&nbsp;services. But due to the limitations of service many moved out. At first when <b>AppFog</b>&nbsp;came, there were a lot of cool awesome features more than <b>Heroku</b>. For the <b>Free</b>&nbsp;plan <b>AppFog</b>&nbsp;had <b>SSL</b>, <b>Custom Domain </b>and other features. But by the end of <b>February</b>&nbsp;<b>2013</b>, <b>AppFog</b>&nbsp;removed <b>Custom Domain </b>from free plan. Many customers (including me) got sad, angry and were trying to find another <b>PaaS</b>&nbsp;service. And Here it is, the <b>next Awesome</b>&nbsp;<b>PaaS</b>&nbsp;service &#8211; <b><span style="font-size: large;"><a href="https://www.openshift.com/" >OpenShift</a></span></b>. Here is the best part : <b><a href="https://www.openshift.com/" >OpenShift</a></b>&nbsp;is created by the <b>Open-Source</b>&nbsp;legend <b>Red Hat</b>. How awesome is that ? <b>OpenShift</b>&nbsp;is easy to use, fast and reliable. I used it for like <b>5</b>&nbsp;<b>hours</b>&nbsp;now and I already liked it. I have moved the <a href="http://demos.subinsb.com/" ><b>Demo </b>site</a>&nbsp;from <b>3owl</b>&nbsp;to <b>OpenShift</b>.</p> <div class="separator" style="clear: both; text-align: center;"> <a href="https://openshift.redhat.com/app/assets/openshift-logo-horizontal-99a90035cbd613be7b6293335eb05563.svg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://openshift.redhat.com/app/assets/openshift-logo-horizontal-99a90035cbd613be7b6293335eb05563.svg" style="background-color: black; background-position: initial initial; background-repeat: initial initial;" /></a> </div> <div> </p> <pre><code>&lt;div&gt; You will be amazed by the speed of the &lt;b&gt;PaaS&lt;/b&gt;, From what I experienced &lt;b&gt;OpenShift&lt;/b&gt;&amp;nbsp;is faster than &lt;b&gt;AppFog&lt;/b&gt;.&amp;nbsp;&lt;b&gt;OpenShift&lt;/b&gt;&amp;nbsp;is just like &lt;b&gt;AppFog&lt;/b&gt;, &lt;b&gt;OpenShift&lt;/b&gt;&amp;nbsp;have a large list of supported languages and services. Here are some of them :&lt;/p&gt; &lt;ol style=&quot;text-align: left;&quot;&gt; &lt;li&gt; Java &lt;/li&gt; &lt;li&gt; PHP &lt;/li&gt; &lt;li&gt; Ruby &lt;/li&gt; &lt;li&gt; Node.js &lt;/li&gt; &lt;li&gt; Python &lt;/li&gt; &lt;li&gt; Perl &lt;/li&gt; &lt;li&gt; MySQL &lt;/li&gt; &lt;li&gt; MongoDB &lt;/li&gt; &lt;li&gt; PostgreSQL &lt;/li&gt; &lt;li&gt; Jenkins &lt;/li&gt; &lt;/ol&gt; &lt;p&gt; See More &lt;a href=&quot;https://www.openshift.com/developers/technologies&quot; &gt;Here&lt;/a&gt;. Why wait ? Use &lt;b&gt;&lt;a href=&quot;https://www.openshift.com/&quot; &gt;OpenShift&lt;/a&gt; &lt;/b&gt;Now.&amp;nbsp;I totally recommend you to use &lt;b&gt;&lt;a href=&quot;https://www.openshift.com/&quot; &gt;OpenShift&lt;/a&gt;&lt;/b&gt;.&lt;br /&gt;As long as &lt;b&gt;OpenShift&lt;/b&gt;&amp;nbsp;don&amp;#8217;t remove &lt;b&gt;Custom Domains&lt;/b&gt;, I&amp;#8217;m gonna stick with &lt;b&gt;OpenShift&lt;/b&gt;.&lt;/div&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> E4KS : The Great Work Done By Rajeev Joseph https://subinsb.com/e4ks-the-great-work-done-by-rajeev-joseph/ Sun, 06 Oct 2013 05:10:00 +0000 https://subinsb.com/e4ks-the-great-work-done-by-rajeev-joseph/ <div dir="ltr" style="text-align: left;" trbidi="on"> There are millions of <b>bloggers</b>&nbsp;and <b>blogs</b>&nbsp;in the <b>World Wide Web </b>(WWW).&nbsp;<b>90 %</b>&nbsp;of those blogs are useful. There are a lot of people who would visit those blogs. Since there are a lot of viewers, most of the <b>blog</b>&nbsp;owners would set up <b>ads</b>&nbsp;on their blog to get maximum revenue. Most of the <b>Bloggers</b>&nbsp;(including me) only set up <b>blogs</b>&nbsp;just to get <b>revenue</b>&nbsp;from it. I&#8217;m gonna introduce you to a man that has helped a lot of students (including me) of <b>Kerala</b>. His name is <b>Rajeev Joseph</b>. Check out his <b>Google&nbsp;</b><b>+ </b>profile <a href="https://plus.google.com/104655132380874995884" >here</a>. And his blog is <b><a href="http://www.english4keralasyllabus.com/" >English4KeralaSyllabus</a>&nbsp;:</b></p> <div class="separator" style="clear: both; text-align: center;"> <a href="//1.bp.blogspot.com/-wXvTkO38-CA/UlDtRgfkSnI/AAAAAAAADFI/FzOPLkQuC3g/s1600/0055.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="//1.bp.blogspot.com/-wXvTkO38-CA/UlDtRgfkSnI/AAAAAAAADFI/FzOPLkQuC3g/s1600/0055.png" /></a> </div> <p> As you can see it&#8217;s a typical blog with a lot of posts and pages. But what you won&#8217;t see are <b>ads</b>&nbsp;!<br />Yes, He didn&#8217;t put up ads on his blog. With Page Views like that, he could have made thousands of <b>Dollars</b>. In the field of education in <b>Kerala</b>, this man has helped a lot of students (including me). That&#8217;s one of the reasons why the blog got a lot of Page Views.<br />He could have made thousands of <b>Dollars</b>&nbsp;by monetizing with ads, but he didn&#8217;t. He don&#8217;t even ask for donations. This blog is the best example for "<span style="background-color: white; color: #444444; font-family: arial, sans-serif; font-size: x-small; line-height: 16px;">giving&nbsp;</span><em style="background-color: white; color: #444444; font-family: arial, sans-serif; font-size: small; font-style: normal; font-weight: bold; line-height: 16px;">without expecting&nbsp;</em><span style="background-color: white; color: #444444; font-family: arial, sans-serif; font-size: x-small; line-height: 16px;">anything in return</span>" also known as <b>generosity</b>.<br />Another Example of <b>generosity </b>is <b>Wikipedia</b>. Actually <b>E4KS </b>(<b><a href="http://www.english4keralasyllabus.com/" >English4KeralaSyllabus</a></b>) is like <b>Wikipedia</b>.<br />Thank You <b>Rajeev</b>&nbsp;sir for making the <b>blog</b>&nbsp;ad-free and keep continuing the good work.</div> Create a Simple Browser Using PyGTK, GLADE And MozEmbed https://subinsb.com/create-a-simple-browser-using-pygtk-glade-and-mozembed/ Wed, 02 Oct 2013 06:47:00 +0000 https://subinsb.com/create-a-simple-browser-using-pygtk-glade-and-mozembed/ <div dir="ltr" style="text-align: left;" trbidi="on"> Let&#8217;s start creating softwares using&nbsp;<b>Python GTK </b>(<b>PyGTK</b>). <b>Python</b>&nbsp;is the easiest programming language ever and If you are coming from other <b>Programming Languages </b>such as <b>PHP</b>, Here is something that you should understand :</p> <div> <ol style="text-align: left;"> <li> <b>Python</b>&nbsp;doesn&#8217;t have <b>semi-colons</b>&nbsp;for closing a code. </li> <li> <b>function</b>&nbsp;in <b>PHP</b>&nbsp;is <b>def</b>&nbsp;in <b>Python.</b> </li> <li> Spaces from the starting of a line decides the <b>wrapper</b>&nbsp;of the code. </li> <li> <b>{</b>&nbsp;in <b>PHP</b>&nbsp;is <b>:</b>&nbsp;in <b>Python.</b> </li> <li> There is no closing <b>}</b>&nbsp;in <b>Python</b>. </li> <li> Since there is no closing attribute ("<b>;</b>"), <b>2</b>&nbsp;or more code can&#8217;t be placed in a single line. </li> <li> <b>Python </b>doesn&#8217;t need variables starting with <b>$</b>. </li> </ol> </div> <div> The <b>Browser</b>&nbsp;we are going to create is built using <b>GTK 2</b>. The latest version of <b>GTK</b>&nbsp;is <b>GTK 3</b>. </div> <div> We are going to use <b>GLADE</b>&nbsp;for designing the interface. If you don&#8217;t have <b>GLADE</b>&nbsp;installed, install it using the following command :</p> <pre><code>&lt;blockquote class=&quot;tr_bq&quot;&gt; &lt;p&gt; sudo apt-get install glade &lt;/p&gt; &lt;/blockquote&gt; &lt;p&gt; Let&amp;#8217;s begin. First of all create a folder named &lt;b&gt;browser&lt;/b&gt;&amp;nbsp;on your &lt;b&gt;home&lt;/b&gt; folder.&lt;br /&gt;Create a new project in&amp;nbsp;&lt;b&gt;GLADE&lt;/b&gt;&amp;nbsp;with the &lt;b&gt;Project File Format&lt;/b&gt;&amp;nbsp;as &lt;b&gt;GtkBuilder &lt;/b&gt;: &lt;/p&gt; &lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt; &lt;a href=&quot;//1.bp.blogspot.com/-j7Z4wUCuAk0/Ukuq_mGcKLI/AAAAAAAADEA/ckE8w8y6yJ4/s1600/0051.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;//1.bp.blogspot.com/-j7Z4wUCuAk0/Ukuq_mGcKLI/AAAAAAAADEA/ckE8w8y6yJ4/s1600/0051.png&quot; /&gt;&lt;/a&gt; &lt;/div&gt; &lt;p&gt; Save the project as &lt;b&gt;window.glade&lt;/b&gt;&amp;nbsp;in &lt;b&gt;browser&lt;/b&gt;&amp;nbsp;folder we created in &lt;b&gt;home &lt;/b&gt;folder.&lt;br /&gt;Create a Window by clicking on &lt;b&gt;Window&lt;/b&gt;&amp;nbsp;button in &lt;b&gt;Toplevels&lt;/b&gt;&amp;nbsp;section on the toolbox. Choose &lt;b&gt;Signals&lt;/b&gt;&amp;nbsp;and add &lt;b&gt;remove&lt;/b&gt;&amp;nbsp;signal of &lt;b&gt;GtkContainer&lt;/b&gt;&amp;nbsp;to&amp;nbsp;&lt;b&gt;on_MainWindow_close_event&lt;/b&gt;&amp;nbsp;: &lt;/p&gt; &lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt; &lt;a href=&quot;//3.bp.blogspot.com/-QmJa9RgpBS8/Uku5E1QiqoI/AAAAAAAADEo/ZHgCP6TWBSk/s1600/0053.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;//3.bp.blogspot.com/-QmJa9RgpBS8/Uku5E1QiqoI/AAAAAAAADEo/ZHgCP6TWBSk/s1600/0053.png&quot; /&gt;&lt;/a&gt; &lt;/div&gt; &lt;p&gt; Choose &lt;b&gt;Vertical Box&lt;/b&gt;&amp;nbsp;from the &lt;b&gt;Containers&lt;/b&gt;&amp;nbsp;and click on the blank space of the &lt;b&gt;window1&lt;/b&gt;. The &lt;b&gt;Number Of Items&lt;/b&gt;&amp;nbsp;should be &lt;b&gt;2&lt;/b&gt;. The &lt;b&gt;window1&lt;/b&gt;&amp;nbsp;would be divided into &lt;b&gt;2&amp;nbsp;&lt;/b&gt;now. &lt;/p&gt; &lt;p&gt; Choose &lt;b&gt;Tool Bar&lt;/b&gt;&amp;nbsp;from the &lt;b&gt;Containers&lt;/b&gt;&amp;nbsp;and click on the &lt;b&gt;1&lt;/b&gt;st division of&amp;nbsp;&lt;b&gt;window1&lt;/b&gt;.&lt;br /&gt;Right click on &lt;b&gt;toolbar1&lt;/b&gt;&amp;nbsp;and choose &lt;b&gt;Edit&lt;/b&gt;&amp;nbsp;option. Toggle to &lt;b&gt;Hierarchy&lt;/b&gt;&amp;nbsp;tab and add the following Buttons : &lt;/p&gt; &lt;blockquote class=&quot;tr_bq&quot;&gt; &lt;table class=&quot;table&quot;&gt; &lt;tr&gt; &lt;td&gt; Name &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/td&gt; &lt;td&gt; : &lt;/td&gt; &lt;td&gt; &lt;b&gt;new&lt;/b&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; Label &lt;/td&gt; &lt;td&gt; : &lt;/td&gt; &lt;td&gt; &lt;b&gt;New&lt;/b&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; Icon Name &lt;/td&gt; &lt;td&gt; : &lt;/td&gt; &lt;td&gt; &lt;b&gt;list-add&lt;/b&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;/blockquote&gt; &lt;blockquote class=&quot;tr_bq&quot;&gt; &lt;table class=&quot;table&quot;&gt; &lt;tr&gt; &lt;td&gt; Name &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/td&gt; &lt;td&gt; : &lt;/td&gt; &lt;td&gt; &lt;b&gt;stop&lt;/b&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; Label &lt;/td&gt; &lt;td&gt; : &lt;/td&gt; &lt;td&gt; &lt;b&gt;Stop&lt;/b&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; Icon Name &lt;/td&gt; &lt;td&gt; : &lt;/td&gt; &lt;td&gt; &lt;b&gt;view-refresh&lt;/b&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;/blockquote&gt; &lt;blockquote class=&quot;tr_bq&quot;&gt; &lt;table class=&quot;table&quot;&gt; &lt;tr&gt; &lt;td&gt; Name &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/td&gt; &lt;td&gt; : &lt;/td&gt; &lt;td&gt; &lt;b&gt;reload&lt;/b&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; Label &lt;/td&gt; &lt;td&gt; : &lt;/td&gt; &lt;td&gt; &lt;b&gt;Reload&lt;/b&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; Icon Name &lt;/td&gt; &lt;td&gt; : &lt;/td&gt; &lt;td&gt; &lt;b&gt;edit-delete&lt;/b&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;/blockquote&gt; &lt;blockquote class=&quot;tr_bq&quot;&gt; &lt;table class=&quot;table&quot;&gt; &lt;tr&gt; &lt;td&gt; Name &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/td&gt; &lt;td&gt; : &lt;/td&gt; &lt;td&gt; &lt;b&gt;urlcont&lt;/b&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; Type &lt;/td&gt; &lt;td&gt; : &lt;/td&gt; &lt;td&gt; &lt;b&gt;Custom&lt;/b&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; Expand &lt;/td&gt; &lt;td&gt; : &lt;/td&gt; &lt;td&gt; &lt;b&gt;Yes&lt;/b&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;/blockquote&gt; &lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt; Choose &lt;b&gt;Text Entry&lt;/b&gt;&amp;nbsp;from &lt;b&gt;Control and Display&lt;/b&gt;&amp;nbsp;and click on empty space of &lt;b&gt;urlcont&lt;/b&gt;&amp;nbsp;of &lt;b&gt;toolbar1&lt;/b&gt;. &lt;/div&gt; &lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt; The Current Window Will Look Like This: &lt;/div&gt; &lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt; &lt;/div&gt; &lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt; &lt;a href=&quot;https://2.bp.blogspot.com/-vfrjGagDsKQ/Uku2QgFWXCI/AAAAAAAADEc/h8--HTDsvGo/s1600/0052.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://2.bp.blogspot.com/-vfrjGagDsKQ/Uku2QgFWXCI/AAAAAAAADEc/h8--HTDsvGo/s1600/0052.png&quot; /&gt;&lt;/a&gt; &lt;/div&gt; &lt;p&gt; The Interfacing is over, Now we should create the &lt;b&gt;Python&lt;/b&gt;&amp;nbsp;file. Create a file named &lt;b&gt;browser.py&lt;/b&gt;&amp;nbsp;in the directory containing &lt;b&gt;window.glade&lt;/b&gt;. Add The Following contents on &lt;b&gt;browser.py&lt;/b&gt;&amp;nbsp;: &lt;/p&gt; &lt;blockquote class=&quot;tr_bq&quot;&gt; &lt;p&gt; #!/usr/bin/python&lt;br /&gt;import pygtk&lt;br /&gt;pygtk.require(&quot;2.0&quot;)&lt;br /&gt;import gtk&lt;br /&gt;import gtk.glade&lt;br /&gt;import gtkmozembed&lt;br /&gt;class SubinsWindow:&lt;br /&gt;&amp;nbsp;def __init__(self):&lt;br /&gt;&amp;nbsp; self.gladefile = &quot;window.glade&quot;&lt;br /&gt;&amp;nbsp; self.glade = gtk.Builder()&lt;br /&gt;&amp;nbsp; self.glade.add_from_file(self.gladefile)&lt;br /&gt;&amp;nbsp; self.glade.connect_signals(self)&lt;br /&gt;&amp;nbsp; self.win=self.glade.get_object(&quot;window1&quot;)&lt;br /&gt;&amp;nbsp; self.win.show_all()&lt;br /&gt;&amp;nbsp; self.win.maximize()&lt;br /&gt;&amp;nbsp; self.win.set_title(&quot;Subin&amp;#8217;s Blog Browser &amp;#8211; http://www.subinsb.com&quot;)&lt;br /&gt;&amp;nbsp; self.mw = gtkmozembed.MozEmbed()&lt;br /&gt;&amp;nbsp; self.glade.get_object(&quot;vbox1&quot;).add(self.mw)&lt;br /&gt;&amp;nbsp; self.mw.set_size_request(800,600)&lt;br /&gt;&amp;nbsp; self.mw.load_url(&quot;http://www.subinsb.com&quot;)&lt;br /&gt;&amp;nbsp; self.mw.show()&lt;br /&gt;&amp;nbsp; self.glade.get_object(&quot;entry1&quot;).set_text(&quot;http://www.subinsb.com&quot;)&lt;br /&gt;&amp;nbsp; self.glade.get_object(&quot;entry1&quot;).connect(&quot;activate&quot;,self.on_entry1_activate)&lt;br /&gt;&amp;nbsp; self.glade.get_object(&quot;reload&quot;).connect(&quot;clicked&quot;,self.on_entry1_activate)&lt;br /&gt;&amp;nbsp; self.glade.get_object(&quot;stop&quot;).connect(&quot;clicked&quot;,self.on_stop_click)&lt;br /&gt;&amp;nbsp; self.glade.get_object(&quot;new&quot;).connect(&quot;clicked&quot;,self.on_new_click) &lt;/p&gt; &lt;p&gt; &amp;nbsp;def on_entry1_activate(self,widget):&lt;br /&gt;&amp;nbsp; v=self.glade.get_object(&quot;entry1&quot;).get_text()&lt;br /&gt;&amp;nbsp; self.mw.load_url(v)&lt;br /&gt;&amp;nbsp; self.win.set_title(&quot;Subin&amp;#8217;s Blog Browser &amp;#8211; &quot;+v) &lt;/p&gt; &lt;p&gt; &amp;nbsp;def on_reload_click(self,widget):&lt;br /&gt;&amp;nbsp; self.mw.reload() &lt;/p&gt; &lt;p&gt; &amp;nbsp;def on_new_click(self,widget):&lt;br /&gt;&amp;nbsp; self.glade.get_object(&quot;entry1&quot;).set_text(&quot;http://www.subinsb.com&quot;)&lt;br /&gt;&amp;nbsp; self.mw.load_url(&quot;http://www.subinsb.com&quot;) &lt;/p&gt; &lt;p&gt; &amp;nbsp;def on_stop_click(self,widget):&lt;br /&gt;&amp;nbsp; v=self.mw.get_location()&lt;br /&gt;&amp;nbsp; self.mw.stop_load()&lt;br /&gt;&amp;nbsp; self.win.set_title(&quot;Subin&amp;#8217;s Blog Browser &amp;#8211; &quot;+v+&quot; &amp;#8211; Stopped&quot;) &lt;/p&gt; &lt;p&gt; &amp;nbsp;def on_MainWindow_close_event(self, widget, event=1):&lt;br /&gt;&amp;nbsp; gtk.main_quit() &lt;/p&gt; &lt;p&gt; if __name__ == &quot;__main__&quot;:&lt;br /&gt;&amp;nbsp;a = SubinsWindow()&lt;br /&gt;&amp;nbsp;gtk.main() &lt;/p&gt; &lt;/blockquote&gt; &lt;p&gt; That&amp;#8217;s It ! Run &lt;b&gt;browser.py &lt;/b&gt;using &lt;b&gt;python browser.py&lt;/b&gt;&amp;nbsp;and see your own &lt;b&gt;Browser&lt;/b&gt;&amp;nbsp;in action : &lt;/p&gt; &lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt; &lt;a href=&quot;//3.bp.blogspot.com/-6vF3PBfr2yY/UkvAypPzcaI/AAAAAAAADE4/JJuFGWvCqXc/s1600/0054.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;//3.bp.blogspot.com/-6vF3PBfr2yY/UkvAypPzcaI/AAAAAAAADE4/JJuFGWvCqXc/s1600/0054.png&quot; /&gt;&lt;/a&gt; &lt;/div&gt; &lt;p&gt; If you have any problems/doubts/suggestions/feedback print it out in the comments. Thank You. Hope You Like it. &lt;/p&gt; </code></pre> </div> </div> How To Change Your Country By Using Proxy in Ubuntu ? https://subinsb.com/how-to-change-your-country-by-using-proxy-in-ubuntu/ Mon, 30 Sep 2013 17:15:00 +0000 https://subinsb.com/how-to-change-your-country-by-using-proxy-in-ubuntu/ <div dir="ltr" style="text-align: left;" trbidi="on"> There are certain restrictions on some sites such as <b>Country Restriction</b>. Mostly there are sites just for <b>US</b>&nbsp;citizens. For Example The most <b>99</b>&nbsp;cent domain offers from <b>GoDaddy</b>&nbsp;is only available to <b>US</b>&nbsp;citizens. They check the country by <b>IP</b>&nbsp;Address. I&#8217;m going to tell you how to Change your Country by changing the <b>IP</b>&nbsp;address using a&nbsp;<b>PROXY</b>. This is explained to work on <b>Ubuntu</b>, you can also use this method in <b>Windows</b>&nbsp;& Others but in a different way.<br />OK. First Of All Open Terminal (<b>CTRL&nbsp;+ ALT&nbsp;+ T</b>) and do the following command :</p> <blockquote class="tr_bq"> <p> gnome-network-properties </p> </blockquote> <p> You will get a Window Like Below : </p> <div class="separator" style="clear: both; text-align: center;"> <a href="//4.bp.blogspot.com/-Nyh1YH6PLk8/UkmtvMXmdeI/AAAAAAAADDQ/5uZ60C9iSko/s1600/0048.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="//4.bp.blogspot.com/-Nyh1YH6PLk8/UkmtvMXmdeI/AAAAAAAADDQ/5uZ60C9iSko/s1600/0048.png" /></a> </div> <p> Now, What you have to do is go to a Free Proxy Site like&nbsp;<a href="http://free-proxy-list.net/">free-proxy-list.net</a>&nbsp;and get a <b>Proxy IP </b>and <b>Port</b>. You can choose the <b>Proxy</b>&nbsp;based on countries or anything else.<br />Click On <b>Manual proxy configuration</b>&#8216;s radio button and choose <b>Use the same</b>&nbsp;proxy for all protocols. Then type in the <b>Proxy IP</b>&nbsp;address and port. Example : </p> <div class="separator" style="clear: both; text-align: center;"> <a href="//3.bp.blogspot.com/-G_nZkJNBmOM/Ukmv0uoJymI/AAAAAAAADDc/9IbHZSoUU3A/s1600/0049.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="//3.bp.blogspot.com/-G_nZkJNBmOM/Ukmv0uoJymI/AAAAAAAADDc/9IbHZSoUU3A/s1600/0049.png" /></a> </div> <p> Then Click on <b>Close</b>&nbsp;button. You will be asked for using the proxy completely on your system which means that the applications you install via <b>syanptic</b>&nbsp;or <b>software-center</b>&nbsp;use the <b>Proxy</b>&nbsp;mentioned. If you just want to trick a site, then ignore the dialog box. Here is an example of my <b>IP</b>&nbsp;details&nbsp;when my <b>Proxy</b>&nbsp;was changed : </p> <div class="separator" style="clear: both; text-align: center;"> <a href="//4.bp.blogspot.com/-3HbpUGhfaqM/UkmxW0UI_dI/AAAAAAAADDo/R0ImYhVN61Y/s1600/0050.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="//4.bp.blogspot.com/-3HbpUGhfaqM/UkmxW0UI_dI/AAAAAAAADDo/R0ImYhVN61Y/s1600/0050.png" /></a> </div> <p> If you have any doubts/suggestions/problems/feedback say it out in the comments, I will help you.</div> Submitting Blogger Blog Sitemap To Google & Other Search Engines https://subinsb.com/submitting-blogger-blog-sitemap-to-google-other-search-engines/ Sun, 29 Sep 2013 06:35:00 +0000 https://subinsb.com/submitting-blogger-blog-sitemap-to-google-other-search-engines/ <div dir="ltr" style="text-align: left;" trbidi="on"> <span style="font-family: inherit;"><b>Sitemap </b>is a&nbsp;<b>XML</b>&nbsp;file that contains all the links of your site/blog. <b>Sitemap</b>&nbsp;can be manually created or automatically created using some online tools. These <b>Sitemap</b>&nbsp;can be submitted to search engine via the tools they provide or by mentioning the <b>sitemap</b> in <b>robots.txt</b>. In <b>Blogger</b>&nbsp;blogs the sitemap is located in different places.</span><br /><span style="font-family: inherit;">In <b>Blogger</b>&nbsp;<b>Blogs</b>&nbsp;with the <b>.blogspot.com</b>&nbsp;sub domain, the sitemap is in a simple location ie :</span></p> <blockquote class="tr_bq"> <p> <span style="font-family: inherit;">http://YOURBLOG.blogspot.com/sitemap.xml</span> </p> </blockquote> <p> <span style="font-family: inherit;">But on other blogs ie blogs on custom&nbsp;<b>domains</b>&nbsp;doesn&#8217;t have a sitemap like the above <b>URL</b>. Instead you should use the following <b>URL</b>&nbsp;:</span> </p> <blockquote class="tr_bq"> <p> <span style="font-family: inherit;">http://YOURBLOG.com<span style="white-space: pre-wrap;">/atom.xml?redirect=false&start-index=1&max-results=1000</span></span> </p> </blockquote> <p> <span style="white-space: pre-wrap;"><span style="font-family: inherit;">Now, Let&#8217;s mention the sitemap on <b>robots.txt</b>. For That Go To <b>Blogger </b>-><b> YOUR BLOG</b> -><b> Settings </b>-><b> Search Preferences</b>.</span></span><br /><span style="font-family: inherit;"><span style="white-space: pre-wrap;">Click on <b>Edit</b> button near </span><span style="color: #222222;"><b>Custom robots.txt </b>and add the following in the textbox:</span></span> </p> <blockquote class="tr_bq"> <p> <span style="color: #222222;">User-agent: *</span><br /><span style="color: #222222;">Disallow: /search?q=*</span><br /><span style="color: #222222;">Disallow: /*?updated-max=*</span><br /><span style="color: #222222;">Allow: /</span><br /><span style="color: #222222;">Sitemap: <span style="background-color: yellow;">http://www.subinsb.com/atom.xml?redirect=false&start-index=1&max-results=1000</span></span> </p> </blockquote> <p> <span style="color: #222222;">Replace The yellow background <b>URL</b> with your blog&#8217;s sitemap <b>URL </b>and click on <b>Save Changes</b>&nbsp;button :</span> </p> <div class="separator" style="clear: both; text-align: center;"> <a href="//1.bp.blogspot.com/-D5ZGGJBQlBs/UkfHg6HBIYI/AAAAAAAADCQ/uRNuoLccAPw/s1600/0047.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="//1.bp.blogspot.com/-D5ZGGJBQlBs/UkfHg6HBIYI/AAAAAAAADCQ/uRNuoLccAPw/s1600/0047.png" /></a> </div> <p> <span style="color: #222222;">When the search engines crawl your site, they will get the <b>sitemap</b> <b>URL</b> from <b>robots.txt </b>and they will index all the <b>URL</b>&#8216;s in the sitemap.</span><br /><span style="color: #222222;">If you have any suggestions/problems/feedback say it out in the comments, I will help you.</span></div> Create Your Own URL Shortening Service Using PHP & jQuery https://subinsb.com/create-your-own-url-shortening-service-using-php-jquery/ Fri, 27 Sep 2013 16:30:00 +0000 https://subinsb.com/create-your-own-url-shortening-service-using-php-jquery/ <div dir="ltr" style="text-align: left;" trbidi="on"> I made a <b>URL</b>&nbsp;shortening service a year back using <b>PHP</b>&nbsp;& <b>jQuery</b>. It was pretty simple. You should know the concept of <b>URL</b>&nbsp;Shortening. The concept is simple. When a user sends a request to short a <b>URL</b>, <b>PHP</b>&nbsp;will check if the <b>URL</b>&nbsp;is valid. If it&#8217;s valid then <b>PHP</b>&nbsp;will make a string of <b>5</b>&nbsp;or <b>6</b>&nbsp;characters. A folder is created with the name of this string and an <b>index.php</b>&nbsp;file with <b>header</b>&nbsp;<b>function</b>&nbsp;code is created in this folder. This will make the folder redirect to the <b>URL</b>&nbsp;the user requested. Since it&#8217;s a folder no extensions will be seen ! So You can make up some pretty good <b>URL</b>&#8216;s.</p> <div class="padlinks"> <a class="download" href="http://demos.subinsb.com/down.php?id=az03vqeafry3e8o&class=4" >Download</a> <a class="demo" href="http://demos.subinsb.com/url-shortener/" >Demo</a> </div> <p> Here is the form for <b>URL</b>&nbsp;<b>Shortening</b>&nbsp;: </p> <blockquote class="tr_bq"> <p> <form id="subinsbshorter"><br />&nbsp; <center><br />&nbsp; &nbsp;<input type="text" id="url" name="url" autocomplete="off" placeholder="Your URL here&#8230;"/><br/><br />&nbsp; &nbsp;<input type="submit" value="Short URL !"/><br/><br />&nbsp; &nbsp;Type in a <b>URL</b> and click on <b>Short URL !</b> to start shorting.<br />&nbsp; </center><br />&nbsp; <div id="loader" style="display:none;"><br />&nbsp; &nbsp;<center><img src="../cdn/load.gif" /></center><br />&nbsp; </div><br />&nbsp; <div id="successDiv" style="display:none;"><br />&nbsp; &nbsp;<h2 style="color:green;">Shorting Successful</h2><br />&nbsp; &nbsp;Here is Your Shorted URL : <a href=""></a><br />&nbsp; </div><br />&nbsp; <div id="errorDiv" style="display:none;"><br />&nbsp; &nbsp;<h2 style="color:red;">Invalid URL</h2><br />&nbsp; </div><br />&nbsp;</form><br />&nbsp;<style><br />&nbsp; #url{font-family: &#8216;Droid Sans&#8217;, Arial;font-size: 15px;font-weight: normal;border-width: 0px;padding: 5px;color: #999999;width: 405px;outline-style: none; outline-width: 0px;<br />&nbsp;</style> </p> </blockquote> <p> We also added a <b>loader</b>&nbsp;div, <b>success</b>&nbsp;div and an <b>error</b>&nbsp;div in the <b><form></b>&nbsp;tag. The <b>jQuery</b>&nbsp;code plays a vital role in this process because we are not adding any <b>action</b>&nbsp;attributes in the form, so if <b>jQuery</b>&nbsp;fail to load then the conversion won&#8217;t work. Here is the <b>jQuery </b>code : </p> <blockquote class="tr_bq"> <p> <script><br />$(document).ready(function(){<br />&nbsp;function isValidUrl(aUrl){var urlregex=new RegExp("^(http://|https://|ftp://){1}([0-9A-Za-z]+.)");return urlregex.test(aUrl);}<br />&nbsp;function ser(u){$("#errorDiv,#successDiv,#loader").hide();$("#errorDiv h2").text(u);$("#errorDiv").show();}<br />&nbsp;function slo(){$("#errorDiv,#successDiv,#loader").hide();$("#loader").show();}<br />&nbsp;function sss(v,s){$("#errorDiv,#successDiv,#loader").hide();$("#successDiv").show();$("#successDiv a").attr("href",v);$("#successDiv a").html("<blockquote>"+v+"</blockquote>");}<br />&nbsp;$("#subinsbshorter").on(&#8216;submit&#8217;,function(){<br />&nbsp; v=$(this).find("#url").val();<br />&nbsp; slo();<br />&nbsp; if(isValidUrl(v)){<br />&nbsp; &nbsp;$.post(&#8216;add.php&#8217;,$(this).serialize(),function(d){<br />&nbsp; &nbsp;d=JSON.parse(d);<br />&nbsp; &nbsp;if(d.stat==&#8217;1&#8242;){<br />&nbsp; &nbsp; sss(d.url,d.name);<br />&nbsp; &nbsp;}else{<br />&nbsp; &nbsp; ser("Failed To Short");<br />&nbsp; &nbsp;}<br />&nbsp; &nbsp;}).error(function(){ser("Failed To Short");});<br />&nbsp; }else{<br />&nbsp; &nbsp;ser("Invalid URL");<br />&nbsp; }<br />&nbsp; return false;<br />&nbsp;});<br />});<br /></script> </p> </blockquote> <p> Insert the above code anywhere you like. The <b>jQuery</b>&nbsp;will check if the <b>URL</b>&nbsp;is valid and will&nbsp;send a <b>POST</b>&nbsp;request to <b>add.php</b>&nbsp;when user submits the form. If the <b>URL</b>&nbsp;is not valid, then <b>jQuery</b>&nbsp;will show the <b>error </b>div.&nbsp;Here is the <b>add.php</b>&nbsp;file : </p> <blockquote class="tr_bq"> <p> <?<br />header(&#8216;Content-Type: text/html&#8217;);<br />function rantext($length){$chars="abcdefghijklmnopqrstuvwxyzsubinsblogABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789&#8243;;$size=strlen($chars);for($i=0;$i<$length;$i++){$str.=$chars[rand(0,$size-1)];}return $str;}<br />$dir="/urls/";/*Directory to store URL&#8217;s. If main folder use "/" */<br />$url=$_POST[&#8216;url&#8217;];<br />if(!preg_match("/^(http://|https://|ftp://){1}([0-9A-Za-z]+.)/",$url)){<br />&nbsp;die(&#8216;{"stat":"0&#8243;}&#8217;);<br />}<br />$name = rantext(5);<br />if (file_exists($name)){<br />&nbsp;$name = rantext(6);<br />}else{<br />&nbsp;mkdir(&#8216;.&#8217;.$dir.$name);<br />&nbsp;$subinsbshort = fopen(&#8216;.&#8217;.$dir.$name.&#8217;/index.php&#8217;, &#8216;x&#8217;) or die(&#8216;{"stat":"0&#8243;}&#8217;);<br />}<br />if(fwrite($subinsbshort,'<?header("Location:&#8217;.$url.'");?>&#8217;)){<br />&nbsp;echo &#8216;{"stat":"1&#8243;,"url":"//demos.subinsb.com/url-shortener&#8217;.$dir.$name.'","name":"&#8216;.$name.'"}&#8217;;<br />}else{<br />&nbsp;die(&#8216;{"stat":"0&#8243;}&#8217;);<br />}<br />fclose($subinsbshort);<br />?> </p> </blockquote> <p> We also added the <b>Random String Function</b>&nbsp;to the <b>add.php</b>&nbsp;available from <a href="http://www.subinsb.com/2013/08/generating-random-text-in-php.html" >here</a>. The <b>Function</b>&nbsp;will generate a string of <b>5</b>&nbsp;characters. If the string created is already used, then the <b>script</b>&nbsp;will generate another string of <b>6</b>&nbsp;characters. Then the <b>add.php</b>&nbsp;will create a folder with the name of random string. The <b>add.php</b>&nbsp;returns a <b>JSON</b>&nbsp;data to <b>jQuery</b>. <b>jQuery </b>will process the data and if everything is <b>OK</b>, then <b>jQuery</b>&nbsp;will show a success message with the new shorted <b>URL</b>.<br />If you have any suggestions/problems/feedback say it out in the comments, I will help you.<br />And <b>Happy Birthday Google</b>.</div> Uploading An Image Using AJAX In jQuery With PHP https://subinsb.com/uploading-an-image-using-ajax-in-jquery-with-php/ Wed, 25 Sep 2013 17:25:00 +0000 https://subinsb.com/uploading-an-image-using-ajax-in-jquery-with-php/ <div dir="ltr" style="text-align: left;"> As you know <b>AJAX</b>ย is the method of sending data without refreshing the page. Now I&#8217;m going to tell you how to upload images using AJAXย in <b>jQuery</b>. For This You need to Download the <b>jquery.form</b>ย plugin from <b><a href="http://malsup.com/jquery/form/#download">here</a></b>. The Minimum requirement for this plugin is jQueryย version <b>1.5</b>ย or later.</p> <div class="padlinks"> <a class="download" href="http://demos.subinsb.com/down.php?id=x2gngcvpjdurrlz&class=3">Download</a> <a class="demo" href="http://demos.subinsb.com/ajax-image-upload-jquery">Demo</a> </div> <p> A Sample of uploading image using <b>AJAX</b>ย in <b>jQuery</b>ย is shown below : </p> <div class="separator" style="clear: both; text-align: center;"> <a style="margin-left: 1em; margin-right: 1em;" href="//1.bp.blogspot.com/-2zQRbtHjad4/UkMbiwcJEdI/AAAAAAAADCA/mbn3sNJZ5DE/s1600/0046.png"><img alt="" src="//1.bp.blogspot.com/-2zQRbtHjad4/UkMbiwcJEdI/AAAAAAAADCA/mbn3sNJZ5DE/s1600/0046.png" border="0" /></a> </div> <div> <div class="separator" style="clear: both; text-align: center;"> </div> <pre><code>&lt;div&gt; Now Let&amp;#8217;s start on the code. Here is the &lt;b&gt;HTML&lt;/b&gt;ย page : &lt;/div&gt; &lt;div&gt; &lt;pre class=&quot;prettyprint&quot;&gt;&lt;code&gt;&amp;lt;!DOCTYPE html&amp;gt; </code></pre> <p>&lt;html&gt; &lt;head&gt; &lt;script src=&quot;//code.jquery.com/jquery-latest.min.js&quot;&gt;&lt;/script&gt; &lt;script src=&quot;http://malsup.github.io/jquery.form.js&quot;&gt;&lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;form action=&quot;upload.php&quot; method=&quot;POST&quot; id=&quot;uploadform&quot;&gt; ย  &lt;input type=&quot;file&quot; name=&quot;file&quot;/&gt; ย  &lt;input type=&quot;submit&quot; value=&quot;Upload&quot;/&gt;&lt;br/&gt;&lt;br/&gt; ย  Message : ย  &lt;div id=&quot;onsuccessmsg&quot; style=&quot;border:5px solid #CCC;padding:15px;&quot;&gt;&lt;/div&gt; &lt;/form&gt; &lt;/body&gt; &lt;/html&gt;</code></pre> </div></p> </div> </div> <div> We don&#8217;t have to mention the <b>enctype</b>ย or <b>encoding</b>ย attribute on the form because the <b>jQuery.form</b>ย will take care of it. </div> <div> Add the following <b>JavaScript</b>ย code just before <b></body></b>ย : </div> <pre class="prettyprint"><code>&lt;script&gt; $(document).ready(function(){ ย function onsuccess(response,status){ ย  $("#onsuccessmsg").html("Status :&lt;b&gt;"+status+'&lt;/b&gt;&lt;br&gt;&lt;br&gt;Response Data :&lt;div id="msg" style="border:5px solid #CCC;padding:15px;"&gt;'+response+'&lt;/div&gt;'); ย } ย $("#uploadform").on('submit',function(){ ย  var options={ ย  ย url ย  ย  : $(this).attr("action"), ย  ย success : onsuccess ย  }; ย  $(this).ajaxSubmit(options); ย return false; ย }); }); &lt;/script&gt;</code></pre> <div> Here is the upload form&#8217;s details : </div> <pre class="prettyprint"><code>ID ย  ย  ย  ย : uploadform Action ย  ย : &lt;b>upload.php &lt;/b>Method ย  : &lt;b>POST&lt;/b></code></pre> <div> This is the <b>upload.php</b>ย file to which we send the form data : </div> <div> <pre class="prettyprint"><code>&lt;? function getExtension($str) {$i=strrpos($str,".");if(!$i){return"";}$l=strlen($str)-$i;$ext=substr($str,$i+1,$l);return $ext;} $formats = array("jpg", "png", "gif", "bmp", "jpeg", "PNG", "JPG", "JPEG", "GIF", "BMP"); if(isset($_POST) and $_SERVER['REQUEST_METHOD'] == "POST"){ ย $name = $_FILES['file']['name']; ย $size = $_FILES['file']['size']; ย $tmp ย = $_FILES['file']['tmp_name']; ย if(strlen($name)){ ย  $ext = getExtension($name); ย  if(in_array($ext,$formats)){ ย  ย if($size&lt;(1024*1024)){ ย  ย  $imgn = time().".".$ext; ย  ย  if(move_uploaded_file($tmp, "./uploads/".$imgn)){ ย  ย  ย echo "File Name : ".$_FILES['file']['name']; ย  ย  ย echo "&lt;br/&gt;File Temporary Location : ".$_FILES['file']['tmp_name']; ย  ย  ย echo "&lt;br/&gt;File Size : ".$_FILES['file']['size']; ย  ย  ย echo "&lt;br/&gt;File Type : ".$_FILES['file']['type']; ย  ย  ย echo "&lt;br/&gt;Image : &lt;img style='margin-left:10px;' src='uploads/".$imgn."'&gt;"; ย  ย  }else{ ย  ย  ย echo "Uploading Failed."; ย  ย  } ย  ย }else{ ย  ย  echo "Image File Size Max 1 MB"; ย  ย } ย  }else{ ย  ย echo "Invalid Image file format."; ย  } ย }else{ ย  echo "Please select an image."; ย  exit; ย } } ?&gt;</code></pre> </div> <div> The above code only accepts a file if it met some conditions such as : </div> <div> <ol style="text-align: left;"> <li> A File Should Be Uploaded </li> <li> Should be an Image Extension </li> <li> File Size Must Not Exceed 1 MB </li> </ol> </div> <div> If you have any suggestions/problems/feedback say it out in the comments, I will help you. </div> How To Use Hard Disk As RAM In Ubuntu Linux https://subinsb.com/how-to-use-hard-disk-as-ram-in-ubuntu-linux/ Sun, 22 Sep 2013 15:32:00 +0000 https://subinsb.com/how-to-use-hard-disk-as-ram-in-ubuntu-linux/ <div dir="ltr" style="text-align: left;"> I heard that it is possible to use a portion of hard disk as <b>RAM</b>ย in <b>Windows</b>. I wondered if this trick is available for <b>Ubuntu</b>, so I googled about it and couldn&#8217;t find anything related to it. But I found out an <b>AskUbuntu</b>ย answer of using <b>USB</b>ย sticks as <b>RAM</b>. I did the same trick on <b>Hard Disk</b>ย and it works !!<br /> This trick can be accomplished with the use of some small commands in <b>Terminal</b>. The <b>RAM</b>ย memory increase can&#8217;t be noted in the <b>System</b>ย <b>Monitor</b>ย application.So, Let&#8217;s begin.<br /> Create a file of <b>512</b>ย <b>MB</b>ย (The <b>512</b>ย indicates the <b>RAM</b>ย memory to be added):</p> <pre class="prettyprint"><code>dd if=/dev/zero of=~/subinsblog bs=4096 count=&lt;span style="background-color: yellow;">131072&lt;/span></code></pre> <p> The <span style="background-color: yellow;">yellow background text</span> above shows the count of the file we are going to create. This <b>count</b> and <b>bs</b>ย determines the file size. This is how I got the <b>count</b>ย : </p> <pre class="prettyprint"><code>&lt;span style="background-color: yellow;">512&lt;/span> * 1024^2 / 4096 = 131072</code></pre> <p> Theย <span style="background-color: yellow;">yellow background text</span>ย above shows the file size we need to create in <b>Mega Bytes (MB)</b>. If you need to create <b>SWAP</b>ย space with more than <b>512 MB</b>ย change theย <span style="background-color: yellow;">yellow background text</span>ย above to the <b>MB</b>ย you want and get the result of the calculation. The result is the <b>count</b>.<br /> Example of <b>1 GB</b>ย : </p> <pre class="prettyprint"><code>1024ย * 1024^2 / 4096 =ย &lt;span style="background-color: yellow;">262144&lt;/span></code></pre> <p> and the command will become : </p> <pre class="prettyprint"><code>dd if=/dev/zero of=~/subinsblog bs=4096 count=&lt;span style="background-color: yellow;">262144&lt;/span></code></pre> <p> The command will create a file named <b>subinsblog</b>ย on your home directory. </p> <p> Now let&#8217;s create the <b>SWAP</b>ย space on the file and enable the <b>SWAP </b>: </p> <pre class="prettyprint"><code>sudo mkswap ~/subinsblog -f && sudo swapon -p 1000 ~/subinsblog</code></pre> <p> You&#8217;re <b>RAM</b>ย <b>Memory</b>ย is now increased. To check whether if it is increased, do the following command : </p> <pre class="prettyprint"><code>free -m</code></pre> <p> You will get a result like below : </p> <div class="separator" style="clear: both; text-align: center;"> <a style="margin-left: 1em; margin-right: 1em;" href="https://2.bp.blogspot.com/-Ij3bqBN2EzA/Uj8MXR8WzfI/AAAAAAAADBM/gcsMgzYcf6A/s1600/0045.png"><img alt="" src="https://2.bp.blogspot.com/-Ij3bqBN2EzA/Uj8MXR8WzfI/AAAAAAAADBM/gcsMgzYcf6A/s1600/0045.png" border="0" /></a> </div> <p> The picture says it all. Good Luck ! ๐Ÿ™‚<br /> If you have any <b>problems/suggestions/feedback</b> just print it out in the comment box below. </p> </div> GoDaddy WorldWide 99 cents for new or transfer domain of .COM https://subinsb.com/godaddy-worldwide-99-cents-for-new-or-transfer-domain-of-com/ Sun, 22 Sep 2013 05:10:00 +0000 https://subinsb.com/godaddy-worldwide-99-cents-for-new-or-transfer-domain-of-com/ <div dir="ltr" style="text-align: left;" trbidi="on"> Here is the ultimate coupon code you were waiting for : <b>99</b>&nbsp;Cents for <b>.COM</b>&nbsp;buying or transferring domain worldwide. This offer <b>is applicable to every country</b>. Here are the conditions for this coupon :</p> <blockquote class="tr_bq"> <p> Plus ICANN fee of $0.18 per domain name per year. $0.99 price for the first year for one new or transfer .COM purchases only; not valid for renewals. Additional years or .COMs may be purchased for $9.99* per year. Discounts cannot be used in conjunction with any other offer or promotion. After the initial year, discounted domains will renew at the then-current renewal list price. Customers may not use gift cards, Store credit, PayPalยฎ or AliPay to redeem this offer. Your discount will be applied in your shopping cart. Go Daddy reserves the right to deny use of this offer and/or cancel domains purchased using this offer if the offer is abused or used fraudulently, as determined by Go Daddy in its sole discretion. </p> </blockquote> <p> Please Like/Share this post to your friends (Sharing Is Caring!). The expire date of this coupon code is unknown so use the coupon code fast.<br />Here is the coupon code : </p> <blockquote class="tr_bq"> <p> <span style="font-size: large;">99lUv</span> </p> </blockquote> <p> <b>Proof</b> : I bought <b><a href="http://www.subinsb.com/">www.subinsb.com</a></b>&nbsp;by using this coupon code for just <b>Rs 75</b>.<br />Good Luck ! ๐Ÿ™‚</div> Loading A Window Created Using GLADE in Python https://subinsb.com/loading-a-window-created-using-glade-in-python/ Mon, 16 Sep 2013 05:20:00 +0000 https://subinsb.com/loading-a-window-created-using-glade-in-python/ <div dir="ltr" style="text-align: left;" trbidi="on"> If you have created a window using <b>Glade</b>&nbsp;and want to display this window on your <b>Python</b>&nbsp;program containing the event handlers of the <b>Window</b>, then you should follow this tutorial.<br />This small code will load the <b>Glade</b>&nbsp;file and displays the window.<br />Note : The <b>Glade</b>&nbsp;Project file format should be <b>GtkBuilder</b>.<br />Now, let&#8217;s get down to the code. Create a&nbsp;<b>Python </b>file named <b>window.py</b>&nbsp;in the folder containing the glade file and put in the following contents :</p> <blockquote class="tr_bq"> <p> #!/usr/bin/python<br />import pygtk<br />pygtk.require("2.0")<br />import gtk<br />import gtk.glade<br />class SubinsWindow:<br />&nbsp;def __init__(self):<br />&nbsp; self.gladefile = "<span style="background-color: yellow;">window.glade</span>"<br />&nbsp; self.glade = gtk.Builder()<br />&nbsp; self.glade.add_from_file(self.gladefile)<br />&nbsp; self.glade.connect_signals(self)<br />&nbsp; self.win=self.glade.get_object("<span style="background-color: yellow;">window1</span>") # Window Name in GLADE<br />&nbsp; self.win.show_all() </p> <pre><code>&lt;p&gt; if __name__ == &quot;__main__&quot;:&lt;br /&gt;&amp;nbsp;a = SubinsWindow()&lt;br /&gt;&amp;nbsp;gtk.main() &lt;/p&gt; </code></pre> </blockquote> <p> The first <span style="background-color: yellow;">yellow backgrounded text</span>&nbsp;has the name of the <b>GLADE</b>&nbsp;file.<br />The second&nbsp;<span style="background-color: yellow;">yellow backgrounded text</span>&nbsp;has the name of the&nbsp;<b>GLADE </b>Window. Normally It would be <b>window1</b>.<br />Execute the <b>Python </b>program by opening a terminal with the folder and execute the following command: </p> <blockquote class="tr_bq"> <p> python window.py </p> </blockquote> <div class="separator" style="clear: both; text-align: center;"> <a href="https://2.bp.blogspot.com/-GWeSNOSCe0o/UjaUsps12uI/AAAAAAAADA0/UqT5IzS_9A0/s1600/0044.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="185" src="https://2.bp.blogspot.com/-GWeSNOSCe0o/UjaUsps12uI/AAAAAAAADA0/UqT5IzS_9A0/s400/0044.png" width="400" /></a> </div> <p> Here is a sample window created using <b>GLADE</b>&nbsp;and executed in <b>Python </b>: </p> <div class="separator" style="clear: both; text-align: center;"> <a href="//4.bp.blogspot.com/-eTA7M5PSLi0/UjaT5nPllhI/AAAAAAAADAs/LQ_2KjD1l3s/s1600/0043.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="//4.bp.blogspot.com/-eTA7M5PSLi0/UjaT5nPllhI/AAAAAAAADAs/LQ_2KjD1l3s/s1600/0043.png" /></a> </div> <p> So, Now you know how to import a <b>GLADE</b>&nbsp;file in <b>Python</b>&nbsp;and display the window.<br />If you have any problems/suggestions/feedback just say it out in the comment box below.</div> GoDaddy .COM domain for just 0.99$ Worldwide https://subinsb.com/godaddy-com-domain-for-just-0-99-worldwide/ Sun, 15 Sep 2013 06:31:00 +0000 https://subinsb.com/godaddy-com-domain-for-just-0-99-worldwide/ <div dir="ltr" style="text-align: left;" trbidi="on"> Want to buy a <b>.COM</b>&nbsp;domain for just <b>0.99</b>&nbsp;<b>US</b> Dollars ?<br />This coupon is valid for everyone in the world.<br />Here is a table of price of <b>.COM</b>&nbsp;domain using this coupon :</p> <p> Indian Rupee &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;: <b>65</b><br />Australian Dollar &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;:&nbsp;<b>1.07</b><br />British Pound Sterling &nbsp;: <b>0.62</b><br />Chinese Yuan &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; : <b>6.06</b><br />Kuwaiti Dinar &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; : <b>0.28</b><br /><b><br /></b>Just type in the following coupon in <b>GoDaddy</b>&nbsp;and you&#8217;re good to go. </p> <blockquote class="tr_bq"> <p> SMB99F </p> </blockquote> <p> Good Luck. </p> </div> Add Floating Like Box to Blogger Blog https://subinsb.com/add-floating-like-box-to-blogger-blog/ Sat, 14 Sep 2013 06:29:00 +0000 https://subinsb.com/add-floating-like-box-to-blogger-blog/ <div dir="ltr" style="text-align: left;" trbidi="on"> Every Success Blog was popularized with the social integration such as Like Box, Share Box, Commenting and others. The social sharing widget will help other users to reach your blog. So, In this tutorial I&#8217;m going to tell you how to add a <b>Floating</b>&nbsp;<b>Like Box</b>. I made the like box floating, because wherever the user goes the like box will also go with him. Hence the user will notice the like box all the time and he will click sometime during his visit. The liking action will be posted to his <b>Facebook</b>&nbsp;Wall or <b>Google&nbsp;</b><b>+</b>&nbsp;page or his&nbsp;<b>Twitter </b>and his friends who sees this post will also visit. That friends too like your post if it is good and thus your post will pass along a lot of people.</p> <p> In this <b>Floating Box</b>, there are <b>5</b>&nbsp;like plugins. They are : </p> <ol style="text-align: left;"> <li> Facebook Like </li> <li> Twitter Tweet </li> <li> Google Plus&nbsp;+1 </li> <li> Pinterest Pinning </li> <li> Stumbleupon Submission </li> </ol> <p> Let&#8217;s begin. First of all go to <b>Blogger </b>-> <b>YOUR BLOG</b>&nbsp;-><b>&nbsp;Layout</b>.<br />Add a new <b>HTML/JavaScript</b>&nbsp;widget. </p> <div class="separator" style="clear: both; text-align: center;"> <a href="//3.bp.blogspot.com/-_gbP2lRSQAU/TzEvXRJvIxI/AAAAAAAABCE/5BGNp6f4yeE/s1600/fb7.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="//3.bp.blogspot.com/-_gbP2lRSQAU/TzEvXRJvIxI/AAAAAAAABCE/5BGNp6f4yeE/s1600/fb7.png" /></a> </div> <p> Leave the title value of the widget blank.<br />Then add the following contents : </p> <blockquote class="tr_bq"> <p> <div id="subinsblogshare" title="Like and Share this to your friends"><br />&nbsp;<script><br />&nbsp;/*Floating Share Box [http://sag-3.blogspot.com/2013/09/floating-share-box-to-blogger-blog.html] Copyright Subin Siby 2013*/<br />&nbsp;/*Facebook*/<br />&nbsp;ifr=document.createElement("iframe");<br />&nbsp;ifr.style.height="62px";<br />&nbsp;ifr.style.width="56px";<br />&nbsp;ifr.style.border="none";<br />&nbsp;ifr.src="https://www.facebook.com/plugins/like.php?layout=box_count&width=56&colorscheme=light&show_faces=false&send=true&href="+window.location;<br />&nbsp;document.getElementById(&#8216;subinsblogshare&#8217;).appendChild(ifr);<br />&nbsp;/*Twitter*/<br />&nbsp;ifr=document.createElement("iframe");<br />&nbsp;ifr.style.height="62px";<br />&nbsp;ifr.style.width="56px";<br />&nbsp;ifr.style.border="none";<br />&nbsp;ifr.src="https://platform.twitter.com/widgets/tweet_button.1375828408.html#_=1377268257182&count=vertical&id=twitter-widget-2&lang=en&size=m&url="+window.location;<br />&nbsp;document.getElementById(&#8216;subinsblogshare&#8217;).appendChild(ifr);<br />&nbsp;/*Google +*/<br />&nbsp;ifr=document.createElement("div");<br />&nbsp;ifr.style.height="80px";<br />&nbsp;ifr.style.marginTop="10px";<br />&nbsp;subinsblogp=document.createElement("div");<br />&nbsp;subinsblogp.setAttribute("class","g-plusone");<br />&nbsp;subinsblogp.setAttribute("data-size","tall");<br />&nbsp;ifr.appendChild(subinsblogp);<br />&nbsp;(function() {var po = document.createElement("script"); po.type = "text/javascript"; po.async = true;po.src = "https://apis.google.com/js/plusone.js";var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(po, s);})();<br />&nbsp;document.getElementById(&#8216;subinsblogshare&#8217;).appendChild(ifr);<br />&nbsp;/*Pinterest*/<br />&nbsp;ifr=document.createElement("a");<br />&nbsp;subinsblogp=document.createElement("img");<br />&nbsp;subinsblogp.src="//assets.pinterest.com/images/pidgets/pin_it_button.png";<br />&nbsp;ifr.appendChild(subinsblogp);<br />&nbsp;img="http://goo.gl/3i1AG";/*Change this url to your desired image.*/<br />&nbsp;ds="Check out this Blog Post. You Will love it.";/*Change this to your desired description.*/<br />&nbsp;ds=ds.replace(" ","%20");<br />&nbsp;ifr.href="//www.pinterest.com/pin/create/button/?url="+window.location+"&media="+img+"&description="+ds;<br />&nbsp;ifr.setAttribute("data-pin-do","buttonPin");<br />&nbsp;ifr.setAttribute("data-pin-config","above");<br />&nbsp;document.getElementById(&#8216;subinsblogshare&#8217;).appendChild(ifr);<br />&nbsp;(function(d){<br />&nbsp; var f = d.getElementsByTagName(&#8216;SCRIPT&#8217;)[0], p = d.createElement(&#8216;SCRIPT&#8217;);<br />&nbsp; p.type = &#8216;text/javascript&#8217;;<br />&nbsp; p.async = true;<br />&nbsp; p.src = &#8216;//assets.pinterest.com/js/pinit.js&#8217;;<br />&nbsp; f.parentNode.insertBefore(p, f);<br />&nbsp;}(document));<br />&nbsp;/*Stumbleupon*/<br />&nbsp;ifr=document.createElement("iframe");<br />&nbsp;ifr.style.height="62px";<br />&nbsp;ifr.style.width="56px";<br />&nbsp;ifr.style.border="none";<br />&nbsp;ifr.src=&#8217;http://badge.stumbleupon.com/badge/embed/5/?url=&#8217;+window.location;<br />&nbsp;document.getElementById(&#8216;subinsblogshare&#8217;).appendChild(ifr);<br />&nbsp;ifr2=document.createElement("a");<br />&nbsp;ifr2.href="http://sag-3.blogspot.com/2013/09/floating-share-box-to-blogger-blog.html";<br />&nbsp;ifr2.style.color="black";<br />&nbsp;ifr2.style.textDecoration="none";<br />&nbsp;ifr2.style.marginTop="10px";<br />&nbsp;ifr2.target="_blank";<br />&nbsp;ifr2.style.display="block";<br />&nbsp;ifr2.innerHTML="Get This";<br />&nbsp;document.getElementById(&#8216;subinsblogshare&#8217;).appendChild(ifr2);<br />&nbsp;</script><br /></div><br /><style><br />#subinsblogshare{<br />&nbsp;position:fixed;<br />&nbsp;left:40px;<br />&nbsp;height: 380px;<br />&nbsp;top:15%;<br />&nbsp;bottom:25%;<br />&nbsp;background:rgba(255,255,255,.8);<br />&nbsp;opacity:.8;<br />&nbsp;padding:0px 15px 10px 15px;<br />&nbsp;border-radius:10px;<br />&nbsp;border:1.5px solid black;<br />}<br />#subinsblogshare:hover{<br />&nbsp;opacity:1;<br />}<br />#subinsblogshare iframe{<br />&nbsp;display:block;<br />&nbsp;margin-top:10px;<br />}<br /></style> </p> </blockquote> <p> Yes, It&#8217;s a long code. If you want it less, Here is the compressed version : </p> <blockquote class="tr_bq"> <p> <div id="subinsblogshare" title="Like and Share this to your friends"><script>/*Floating Share Box [http://sag-3.blogspot.com/2013/09/floating-share-box-to-blogger-blog.html] Copyright Subin Siby 2013*//*Facebook*/ifr=document.createElement("iframe"); ifr.style.height="62px"; ifr.style.width="56px"; ifr.style.border="none"; ifr.src="https://www.facebook.com/plugins/like.php?layout=box_count&width=56&colorscheme=light&show_faces=false&send=true&href="+window.location; document.getElementById(&#8216;subinsblogshare&#8217;).appendChild(ifr); /*Twitter*/ifr=document.createElement("iframe"); ifr.style.height="62px"; ifr.style.width="56px"; ifr.style.border="none"; ifr.src="https://platform.twitter.com/widgets/tweet_button.1375828408.html#_=1377268257182&count=vertical&id=twitter-widget-2&lang=en&size=m&url="+window.location; document.getElementById(&#8216;subinsblogshare&#8217;).appendChild(ifr); /*Google +*/ifr=document.createElement("div");ifr.style.height="80px";ifr.style.marginTop="10px";subinsblogp=document.createElement("div");subinsblogp.setAttribute("class","g-plusone");subinsblogp.setAttribute("data-size","tall");ifr.appendChild(subinsblogp);(function() {var po = document.createElement("script"); po.type = "text/javascript"; po.async = true;po.src = "https://apis.google.com/js/plusone.js";var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(po, s);})();document.getElementById(&#8216;subinsblogshare&#8217;).appendChild(ifr);/*Pinterest*/ifr=document.createElement("a"); subinsblogp=document.createElement("img"); subinsblogp.src="//assets.pinterest.com/images/pidgets/pin_it_button.png"; ifr.appendChild(subinsblogp); img="http://goo.gl/3i1AG";/*Change this url to your desired image.*/ds="Check out this Blog Post. You Will love it.";/*Change this to your desired description.*/ds=ds.replace(" ","%20"); ifr.href="//www.pinterest.com/pin/create/button/?url="+window.location+"&media="+img+"&description="+ds; ifr.setAttribute("data-pin-do","buttonPin");ifr.setAttribute("data-pin-config","above"); document.getElementById(&#8216;subinsblogshare&#8217;).appendChild(ifr); (function(d){var f = d.getElementsByTagName(&#8216;SCRIPT&#8217;)[0], p = d.createElement(&#8216;SCRIPT&#8217;); p.type = &#8216;text/javascript&#8217;; p.async = true; p.src = &#8216;//assets.pinterest.com/js/pinit.js&#8217;; f.parentNode.insertBefore(p, f); }(document)); /*Stumbleupon*/ifr=document.createElement("iframe");ifr.style.height="62px"; ifr.style.width="56px"; ifr.style.border="none"; ifr.src=&#8217;http://badge.stumbleupon.com/badge/embed/5/?url=&#8217;+window.location; document.getElementById(&#8216;subinsblogshare&#8217;).appendChild(ifr); ifr2=document.createElement("a"); ifr2.href="http://sag-3.blogspot.com/2013/09/floating-share-box-to-blogger-blog.html"; ifr2.style.color="black"; ifr2.style.textDecoration="none"; ifr2.style.marginTop="10px"; ifr2.target="_blank"; ifr2.style.display="block"; ifr2.innerHTML="Get This"; document.getElementById(&#8216;subinsblogshare&#8217;).appendChild(ifr2); </script></div><style>#subinsblogshare{position:fixed;left:40px;height:380px;top:15%;bottom:25%;background:rgba(255,255,255,.8);opacity:.8;padding:0px 15px 10px 15px;border-radius:10px;border:1.5px solid black;}#subinsblogshare:hover{opacity:1;}#subinsblogshare iframe{display:block;margin-top:10px;}</style> </p> </blockquote> <p> Be sure to change the values accordingly. The values to change are : </p> <ol style="text-align: left;"> <li> Pinterest Image URL </li> <li> Pinterest Description </li> </ol> <p> Please don&#8217;t change variable names or any piece of the code, because it may cause problems in the working of the floating share box.<br />If there&#8217;s any problems/suggestions/feedback just say it out in the comment box below.</div> Automatically Redirect A Blogger Blog To Another URL https://subinsb.com/automatically-redirect-a-blogger-blog-to-another-url/ Fri, 13 Sep 2013 06:37:00 +0000 https://subinsb.com/automatically-redirect-a-blogger-blog-to-another-url/ <div dir="ltr" style="text-align: left;" trbidi="on"> <span style="font-family: inherit;">You can redirect your blog to another <b>URL</b>. This redirection can be done using <b>JavaScript</b>&nbsp;or by adding a special <b>meta</b>&nbsp;tag. This redirection is useful when you want to redirect your old blog users to your new blog. The function we use in <b>JavaScript</b>&nbsp;is <b>window.location </b>and the <b>meta</b>&nbsp;tag has <b>http-equiv</b>&nbsp;attribute.</span></p> <div style="text-align: center;"> <span style="background-color: #6aa84f; border-radius: 10px; border: 2px solid black; display: inline-block; font-family: inherit; margin: 10px; padding: 10px; width: 150px;"><a href="http://simsuteam.blogspot.com/" style="color: white; text-decoration: none;" >DEMO</a></span> </div> <p> <span style="font-family: inherit;">So Let&#8217;s begin.</span><br /><span style="font-family: inherit;"><br /></span><span style="font-family: inherit;">Go to <b>Blogger </b>-> <b>Blog to be redirected&nbsp;</b>-> <b>Template</b>&nbsp;-> <b>Edit HTML</b>.</span><br /><span style="font-family: inherit;">You will get a box with a lot of text. Use one of the following methods to redirect :</span><br /><span style="font-family: inherit;"><br /></span> </p> <h3 style="text-align: left;"> <b><span style="font-family: inherit; font-size: large;">1st method (JavaScript)</span></b> </h3> <p> <span style="font-family: inherit;">Add the following code just below <b><head></b>&nbsp;:</span> </p> <blockquote class="tr_bq"> <p> <span style="font-family: inherit;"><script></span><br /><span style="font-family: inherit;">window.location="http://sag-3.blogspot.com";/*Change the URL to your desired one.*/</span><br /><span style="font-family: inherit;"></script></span> </p> </blockquote> <div class="separator" style="clear: both; text-align: center;"> <span style="font-family: inherit; margin-left: 1em; margin-right: 1em;"><a href="//3.bp.blogspot.com/-A-NKJt5JK8E/UjKxcSzhWEI/AAAAAAAADAE/WTjBELsvqnA/s1600/0042.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="//3.bp.blogspot.com/-A-NKJt5JK8E/UjKxcSzhWEI/AAAAAAAADAE/WTjBELsvqnA/s1600/0042.png" /></a></span> </div> <div class="separator" style="clear: both; text-align: center;"> </div> <h3 style="text-align: left;"> <b><span style="font-family: inherit; font-size: large;">2nd method (META Tag)</span></b> </h3> <div> <span style="font-family: inherit;">Add the following code just below <b><head></b>&nbsp;:</span> </div> <blockquote class="tr_bq"> <p> <span style="font-family: inherit;"><meta content=&#8217;5;url=<span style="background-color: yellow;">http://www.REDIRECT_TO.com</span>/&#8217; http-equiv=&#8217;refresh&#8217;/></span> </p> </blockquote> <div> <span style="font-family: inherit;">&nbsp;Change the <span style="background-color: yellow;">yellow background</span> url to the url you want to redirect to.</span><br /><span style="font-family: inherit;"><br /></span> </div> <h3 style="text-align: left;"> <b><span style="font-family: inherit; font-size: large;">What&#8217;s the Difference ?</span></b> </h3> <div> <span style="font-family: inherit;">The <b>JavaScript</b>&nbsp;redirection is executed when the page starts to load, but the meta tag method can be configured to set the no of seconds to wait before redirecting. The second is mentioned just before the <b>;url</b>. To set the no of seconds to <b>10</b>&nbsp;just use the following code :</span> </div> <div> <blockquote class="tr_bq"> <p> <span style="font-family: inherit;"><meta content=&#8217;<span style="background-color: yellow;">10</span>;url=<span style="background-color: yellow;">http://sag-3.blogsppot.com</span>/&#8217; http-equiv=&#8217;refresh&#8217;/></span> </p> </blockquote> </div> <div> <span style="font-family: inherit;">The first <span style="background-color: yellow;">yellow backgrounded</span> text is the no of seconds to wait before redirecting.</span><br /><span style="background-color: white; color: #5b5b5b; line-height: 20px;"><span style="font-family: inherit;">If there&#8217;s any problems/suggestion/feedback just echo out in the comment box below.</span></span> </div> </div> Send Email using GMail SMTP server in PHP https://subinsb.com/send-email-using-gmail-smtp-server-in-php/ Fri, 13 Sep 2013 04:42:00 +0000 https://subinsb.com/send-email-using-gmail-smtp-server-in-php/ <div dir="ltr" style="text-align: left;" trbidi="on"> <div class="tr_bq"> This tutorial was suggested by <a href="http://disqus.com/disqus_vTWBKfAyps/" >SWDS</a>. To send an e-mail using GMail&#8217;s <b>SMTP</b>&nbsp;server, you need extra help. Download the latest version of&nbsp;<b>Swift Mailer</b> Package from <a href="http://swiftmailer.org/" >here</a>. </div> <div class="tr_bq"> This mailing class is simple, that&#8217;s why I recommend you to use <b>Swift Mailer</b>.<br />If you have enabled <a href="https://support.google.com/accounts/answer/185833?hl=en" >application specific password</a> feature on <b>Google Accounts</b>, you may have to generate a new application password and use that password for <b>SMTP</b>&nbsp;authentication. Otherwise the example won&#8217;t be able to login to your <b>google account</b>.</p> <pre><code>&lt;p&gt; Let&amp;#8217;s get started. &lt;/p&gt; </code></pre> </div> <p> Create a file named <b>send.php </b>: </p> <blockquote> <p> ini_set("display_errors",1);<br />require_once &#8216;../path/to/lib/swift_required.php&#8217;;<br />// Configuration<br />$transport = Swift_SmtpTransport::newInstance(&#8216;ssl://smtp.gmail.com&#8217;, 465)<br />&nbsp; &nbsp; ->setUsername(&#8216;<span style="background-color: yellow;">[email protected]</span>&#8216;) // Your Gmail Username<br />&nbsp; &nbsp; ->setPassword(&#8216;<span style="background-color: yellow;">my_secure_gmail_password</span>&#8216;); // Your Gmail Password<br />$mailer = Swift_Mailer::newInstance($transport);<br />// Create a message<br />$message = Swift_Message::newInstance(&#8216;Wonderful Subject Here&#8217;)<br />&nbsp; &nbsp; ->setFrom(array(&#8216;<span style="background-color: yellow;">[email protected]</span>&#8216; => &#8216;<span style="background-color: yellow;">My Name</span>&#8216;)) // can be $_POST[&#8217;email&#8217;] etc&#8230;<br />&nbsp; &nbsp; ->setTo(array(&#8216;<span style="background-color: yellow;">[email protected]</span>&#8216; => &#8216;<span style="background-color: yellow;">A guy</span>&#8216;)) // your email / multiple supported.<br />&nbsp; &nbsp; ->setBody(&#8216;Here is the <strong>message</strong> itself. It can be text or <h1>HTML</h1>.&#8217;, &#8216;text/html&#8217;);<br />if ($mailer->send($message)) {<br />&nbsp; &nbsp; echo &#8216;Mail sent successfully. Time to celebrate&#8217;;<br />} else {<br />&nbsp; &nbsp; echo &#8216;Some error occurred. Check your configuration&#8217;;<br />} </p> </blockquote> <p> The above example has configured with the following credentials :<span style="background-color: white;"></span> </p> <blockquote class="tr_bq"> <p> Username &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;: [email protected]<br />Password &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; : my_secure_gmail_password<br />Send From &nbsp; &nbsp; &nbsp; &nbsp; : [email protected]<br />Sender Name &nbsp; &nbsp; : My Name<br />Receiver &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; : [email protected]<br />Receiver Name &nbsp; : A guy </p> </blockquote> <p> You should change the credentials to meet your conditions. If the mailing didn&#8217;t work, make sure the configuration is correct. If there&#8217;s any problems/suggestion/feedback just echo out in the comment box below. </p> </div> Setting up Google DNS in Ubuntu https://subinsb.com/setting-up-google-dns-in-ubuntu/ Thu, 12 Sep 2013 17:01:00 +0000 https://subinsb.com/setting-up-google-dns-in-ubuntu/ <div dir="ltr" style="text-align: left;" trbidi="on"> <b>Google</b>&#8216;s <b>DNS</b>&nbsp;service is spreading rapidly. It&#8217;s time for you to use it. I used it and noticed some great speed changes even though my internet is just a dial up connection. Here is how to set up <b>Google</b>&#8216;s <b>DNS</b>&nbsp;on your <b>Ubuntu Linux</b>.<br />Open Network Settings (network-admin) by going to <b>System -> Preferences -> Network Connections</b>. Go to your default net connection and click on <b>Edit</b>&nbsp;button.</p> <div class="separator" style="clear: both; text-align: center;"> <a href="//3.bp.blogspot.com/-r18b5XEvKX0/UjHq_ZQEt7I/AAAAAAAAC_s/QXrT-bIgfgs/s1600/0040.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="//3.bp.blogspot.com/-r18b5XEvKX0/UjHq_ZQEt7I/AAAAAAAAC_s/QXrT-bIgfgs/s1600/0040.png" /></a> </div> <p> You will get a window like below : </p> <div class="separator" style="clear: both; text-align: center;"> <a href="//4.bp.blogspot.com/-XVdhIwVntMk/UjHraKB3TMI/AAAAAAAAC_0/ufI_wVjx7FY/s1600/0041.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="//4.bp.blogspot.com/-XVdhIwVntMk/UjHraKB3TMI/AAAAAAAAC_0/ufI_wVjx7FY/s1600/0041.png" /></a> </div> <p> Change the Method option to <b>Automatic (PPP) addresses only</b>. Then change the <b>DNS servers</b>&nbsp;field to the following text(IP addresses): </p> <blockquote class="tr_bq"> <p> 8.8.8.8, 8.8.4.4 </p> </blockquote> <p> Finally, click on <b>Apply</b> button. Now the settings have been saved. To try the new settings either disconnect the active internet connections and start a new connection or reboot your computer.</div> Execute Command Without Waiting For It To Finish https://subinsb.com/how-to-execute-command-without-waiting-for-it-to-finish-in-php/ Sat, 07 Sep 2013 03:41:00 +0000 https://subinsb.com/how-to-execute-command-without-waiting-for-it-to-finish-in-php/ <div dir="ltr" style="text-align: left;"> If you just execute a terminal command using <b>exec</b>ย or <b>system</b>ย in <b>PHP</b>, the page will only load completely until the command has been finished. If you are running commands to run a <b>websocket</b>ย <b>server</b>, the page will not load, because the start server command won&#8217;t terminate. So to avoid this problem you should just do a simple trick, Just addย <b>> /dev/null &</b>ย after the command you&#8217;re running.<br /> Here is a quick example :</p> <blockquote class="tr_bq"> <p> exec("php -q server.php"); </p> </blockquote> <p> becomes: </p> <blockquote class="tr_bq"> <p> exec("php -q server.php ย > /dev/null &"); </p> </blockquote> <p> Or you can wrap it all in a function to run the commands in bothย <b>Windows </b>and <b>Linux</b>ย : </p> <pre class="prettyprint"><code>function &lt;span style="color: red;">bgExec&lt;/span>($cmd) { ย if(substr(php_uname(), 0, 7) == "Windows"){ ย  pclose(popen("start /B ". $cmd, "r")); ย }else { ย  exec($cmd . " &gt; /dev/null &"); ย } }</code></pre> <p> So, by the function you can call the command like this : </p> <blockquote class="tr_bq"> <p> bgExec("php -q server.php"); </p> </blockquote> <p> Use it as you wish. </p> </div> Upload Image To Remote Server With PHP cURL & Handle File in Remote Server https://subinsb.com/upload-image-to-remote-server-with-php-curl-and-handling-file-in-remote-server/ Sun, 01 Sep 2013 15:12:00 +0000 https://subinsb.com/upload-image-to-remote-server-with-php-curl-and-handling-file-in-remote-server/ <div dir="ltr" style="text-align: left;"> If you want to upload images to an external serverย which is uploaded to your site by a client, you are at the right tutorial.<br /> For this submission we will use <b>2</b>ย files :</p> <ol style="text-align: left;"> <li> <b>form.php</b>ย &#8211; The Page Where we will show the client the form. This file also sends the uploaded data to the external server. </li> <li> <b>handle.php</b>ย &#8211; The Page on the external server which receives the uploaded data from <b>form.php </b>using <b>cURL</b>. </li> </ol> <p> We won&#8217;t copy the uploaded file by the client to our server, instead we will directly send the file to the external server. For sending we will encrypt the file with <b>base64</b>.<br /> OK. Lets&#8217; Start. First, Let&#8217;s create the <b>FORM</b>ย page : </p> <pre class="prettyprint"><code>&lt;form enctype="multipart/form-data" encoding='multipart/form-data' method='post' action="form.php"&gt; ย  &lt;input name="uploadedfile" type="file" value="choose"&gt; ย  &lt;input type="submit" value="Upload"&gt; &lt;/form&gt; &lt;? if ( isset($_FILES['uploadedfile']) ) { ย $filename = $_FILES['uploadedfile']['tmp_name']; ย $handle = fopen($filename, "r"); ย $data = fread($handle, filesize($filename)); ย $POST_DATA = array( 'file' =&gt; base64_encode($data) ); ย $curl = curl_init(); ย curl_setopt($curl, CURLOPT_URL, '&lt;span style="color: red;">http://extserver.com/handle.php&lt;/span>'); ย curl_setopt($curl, CURLOPT_TIMEOUT, 30); ย curl_setopt($curl, CURLOPT_POST, 1); ย curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); ย curl_setopt($curl, CURLOPT_POSTFIELDS, $POST_DATA); ย $response = curl_exec($curl); ย curl_close ($curl); ย echo "&lt;h2&gt;File Uploaded&lt;/h2&gt;"; } ?&gt;</code></pre> <p> Now the code of the <b>handle.php</b>ย in <b>external server</b>ย where we sent the data using <b>cURL </b>: </p> <pre class="prettyprint"><code>$encoded_file = $_POST['file']; $decoded_file = base64_decode($encoded_file); /* Now you can copy the uploaded file to your server. */ file_put_contents('&lt;span style="color: red;">subins&lt;/span>', $decoded_file);</code></pre> <p> The above code will receive the <b>base64</b>ย <b>encoded</b> file and it will <b>decode</b>ย and put the <b>image</b>ย to its server folder. This might come in handy when you want to have your own <b>user file storage</b>ย system. This trick is used by <b>ImgUr</b> and other file hosting services likeย <strong>Google</strong>. </p> </div> Password Protect folder in AppFog https://subinsb.com/password-protect-folder-in-appfog/ Fri, 30 Aug 2013 15:45:00 +0000 https://subinsb.com/password-protect-folder-in-appfog/ <div dir="ltr" style="text-align: left;" trbidi="on"> You won&#8217;t know the location of the <b>.htpasswd</b>&nbsp;file in <b>AppFog</b>. Hence you won&#8217;t be able to password protect folders in the normal way. To password protect folders in <b>AppFog</b>&nbsp;you should use a different way. You should add the following location of <b>.htpasswd</b>&nbsp;instead of the full location.<br />If the full location is :</p> <blockquote class="tr_bq"> <p> /home/simsu/projects/TestPalace/Blog/Password_Protect/.htpasswd </p> </blockquote> <p> The Location of <b>.htpasswd</b>&nbsp;in <b>.htaccess</b>&nbsp;deployed in&nbsp;<b>AppFog</b>&nbsp;should be : </p> <blockquote class="tr_bq"> <p> ../app/Blog/Password_Protect/.htpasswd </p> </blockquote> <p> If the file is on the root directory, then the location would be : </p> <blockquote class="tr_bq"> <p> ../app/.htpasswd </p> </blockquote> <p> If you have any suggestions/feedback/problems just <b>echo</b> it out in the comments below.</div> Password protect folder using HTACCESS https://subinsb.com/password-protect-folder-using-htaccess/ Fri, 30 Aug 2013 15:35:00 +0000 https://subinsb.com/password-protect-folder-using-htaccess/ <div dir="ltr" style="text-align: left;" trbidi="on"> <b>HTACCESS</b>&nbsp;is able to protect folders with passwords. To password protect folders you should mention the location of&nbsp;<b>.htpasswd</b>&nbsp;&#8211; a file that contains the username and password to unlock the folder.<br />First of all create a <b>.htaccess</b>&nbsp;file if doesn&#8217;t exists and create a <b>.htpasswd</b>&nbsp;file.<br />Now Add username and password to the <b>.htpasswd</b>&nbsp;file which you can get from this <a href="http://demos.subinsb.com/htpasswd-password-generator/" >simple tool</a>.</p> <p> Add the following text in <b>.htaccess</b>&nbsp;: </p> <blockquote class="tr_bq"> <p> AuthName "This folder requires a login"<br />AuthType Basic<br />AuthUserFile <span style="color: red;">/home/simsu/projects/TestPalace/Blog/Password_Protect/.htpasswd</span>AuthGroupFile /dev/null<br />require valid-user </p> </blockquote> <p> Replace the red highlighted text above to the location of the <b>.htpasswd</b>&nbsp;file. Now open the folder on the site and you will get a screen like below : </p> <div class="separator" style="clear: both; text-align: center;"> <a href="//1.bp.blogspot.com/-j4SXoUi90k8/UiC7PfWTkvI/AAAAAAAAC_U/v0tXAadEJnI/s1600/0039.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="//1.bp.blogspot.com/-j4SXoUi90k8/UiC7PfWTkvI/AAAAAAAAC_U/v0tXAadEJnI/s1600/0039.png" /></a> </div> </div> Split Name in PHP and Javascript https://subinsb.com/split-name-in-php-and-javascript/ Fri, 30 Aug 2013 13:41:00 +0000 https://subinsb.com/split-name-in-php-and-javascript/ <div dir="ltr" style="text-align: left;" trbidi="on"> If you have a user with a long name and want to short it because it won&#8217;t fit into the element that contains the name, you can either do it on the server or the client. In this post I am going to tell you how to accomplish this with <b>PHP</b>&nbsp;and <b>JavaScript</b>.<br />Suppose We have a user named&nbsp;<b>Paul Steve Panakkal</b>&nbsp;(my cousin). To separate the first name, middle name and last name you can do the following in <b>PHP</b>&nbsp;:</p> <blockquote class="tr_bq"> <p> <?<br />$name="Paul Steve Panakkal";<br />$parts=explode(&#8216; &#8216;,$name);<br />$first_name=$parts[0];<br />$middle_name=$parts[1];<br />$last_name=$parts[2];<br />echo $first_name."<br/>";<br />echo $middle_name."<br/>";<br />echo $last_name;<br />?> </p> </blockquote> <p> The above code would print out : </p> <blockquote class="tr_bq"> <p> Paul<br />Steve<br />Panakkal </p> </blockquote> <p> There you go! Now Let&#8217;s do this with <b>JavaScript</b>&nbsp;: </p> <blockquote class="tr_bq"> <p> <script><br />var name="Paul Steve Panakkal";<br />var parts=name.split(" ");<br />first_name=parts[0];<br />middle_name=parts[1];<br />last_name=parts[2];<br />document.write(first_name+"<br>"+middle_name+"<br>"+last_name);<br /></script> </p> </blockquote> <p> The above code will also print out : </p> <blockquote class="tr_bq"> <p> Paul<br />Steve<br />Panakkal </p> </blockquote> <p> Now you know how to split up names in to first name, middle name and last name in <b>PHP</b>&nbsp;and <b>JavaScript</b>.<br />If you have any suggestions/feedback/problems just <b>echo</b>&nbsp;it out in the comments below.</div> Prevent Directory Listing using HTACCESS https://subinsb.com/prevent-directory-listing-using-htaccess/ Fri, 30 Aug 2013 03:30:00 +0000 https://subinsb.com/prevent-directory-listing-using-htaccess/ <div dir="ltr" style="text-align: left;" trbidi="on"> If you don&#8217;t want your site users to see your directory listing, you can do a simple trick in&nbsp;<b>.htaccess</b>&nbsp;file.<br />Here is a screenshot of a directory listing on <b>Apache Server</b>&nbsp;:</p> <div class="separator" style="clear: both; text-align: center;"> <a href="//3.bp.blogspot.com/-RtCUJR3z8Bc/Uh9tnU-hDKI/AAAAAAAAC-o/s9CVng4OVGc/s1600/0036.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="//3.bp.blogspot.com/-RtCUJR3z8Bc/Uh9tnU-hDKI/AAAAAAAAC-o/s9CVng4OVGc/s1600/0036.png" /></a> </div> <p> <span id="goog_1988981101"></span><span id="goog_1988981102"></span>Now, to disable directory listing of all types of files, type in the following code in <b>.htaccess</b>&nbsp;: </p> <blockquote class="tr_bq"> <p> IndexIgnore * </p> </blockquote> <p> This will change the directory listing to this : </p> <div class="separator" style="clear: both; text-align: center;"> <a href="//3.bp.blogspot.com/-BoM8drKvtWs/Uh9uWwgcCII/AAAAAAAAC-w/4vKYszE8Ifo/s1600/0037.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="//3.bp.blogspot.com/-BoM8drKvtWs/Uh9uWwgcCII/AAAAAAAAC-w/4vKYszE8Ifo/s1600/0037.png" /></a> </div> <p> The empty directory listing looks ugly. To make it beautiful, you can add an index page for all directory listings without adding each index files on each directory. Use the following code on <b>.htaccess</b>&nbsp;for that. </p> <blockquote class="tr_bq"> <p> DirectoryIndex index.php /<span style="color: red;">primary.php</span> </p> </blockquote> <p> The above code will make all directory&#8217;s index file <b>primary.php</b>&nbsp;which is kept in the root directory of the site <b>if</b>&nbsp;there isn&#8217;t an <b>index.php</b>&nbsp;file in the directory. I have made a <b>primary.php</b>&nbsp;file and added it as the <b>index</b>&nbsp;file of directory and It looks like below : </p> <div class="separator" style="clear: both; text-align: center;"> <a href="https://2.bp.blogspot.com/-1TONH8ftbfo/Uh9wD3tfETI/AAAAAAAAC-8/hOZ9CR_g9eA/s1600/0038.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://2.bp.blogspot.com/-1TONH8ftbfo/Uh9wD3tfETI/AAAAAAAAC-8/hOZ9CR_g9eA/s1600/0038.png" /></a> </div> <p> </div> Program to Replace localhost links with website url https://subinsb.com/program-to-replace-localhost-links-with-website-url/ Sat, 24 Aug 2013 03:30:00 +0000 https://subinsb.com/program-to-replace-localhost-links-with-website-url/ <div dir="ltr" style="text-align: left;" trbidi="on"> If you are working on a project and wants to upload the project to your site, then you have to manually replace all the localhost links with the site url. I created a small <b>Python</b>&nbsp;program that will replace localhost links with your <b>WWW</b>&nbsp;site url.<br />Here is the <b>Python</b>&nbsp;code :</p> <blockquote class="tr_bq"> <p> #!/usr/bin/python<br />import os<br />indir = &#8216;<span style="color: red;">/var/www/mysite</span>&#8216; #!Folder of your localhost site.<br />for root, dirs, filenames in os.walk(indir):<br />&nbsp;for f in filenames:<br />&nbsp; log = open(os.path.join(root, f), &#8216;r+&#8217;)<br />&nbsp; f=log.read() &nbsp; <br />&nbsp; n=f.replace("<span style="color: red;">http://localhost</span>", "<span style="color: red;">http://mysite.com</span>")<br />&nbsp; log.seek(0)<br />&nbsp; log.truncate()<br />&nbsp; log.write(n)<br />&nbsp; log.close()<br />print "Successfully Replaced." </p> </blockquote> <p> Change the location of your localhost site and the <b>localhost</b>&nbsp;link and <b>mysite</b> link to your site address&nbsp;above if you want to change it. Then save this file as <b>link-replace.py</b>. <a href="http://sag-3.blogspot.com/2013/07/making-file-executable-linux.html" >Make the file executable</a>&nbsp;and run it in <b>terminal</b>. The program will automatically replace the links and will print out "<b>Successfully Replaced</b>" if the program completed replacing links.</div> Cross Origin Communication โ€“ window.postMessage https://subinsb.com/cross-origin-communication-window-postmessage/ Tue, 20 Aug 2013 03:30:00 +0000 https://subinsb.com/cross-origin-communication-window-postmessage/ <div dir="ltr" style="text-align: left;" trbidi="on"> The <b>Window.postMessage</b>&nbsp;helps to make scripts talk over different domain connections. When you call a function on an external iframe from the parent window, <b>Javascript</b>&nbsp;won&#8217;t allow it.<br />That&#8217;s because of the <b>Cross Domain Policy</b>&nbsp;that makes this not possible. But it&#8217;s possible since <b>Javascript</b>&nbsp;introduced <b>postMessage</b>&nbsp;function.</p> <p> Suppose you want to call a function on an cross domain <b>iframe</b> with id <b>monu</b>. Let the function be <b>subins()</b>. Here&#8217;s how to do it using <b>postMessage</b>&nbsp;technic. </p> <blockquote class="tr_bq"> <p> window.frames[&#8216;monu&#8217;].postMessage(&#8216;alert&#8217;,&#8217;*&#8217;); </p> </blockquote> <p> The <b>alert</b>&nbsp;in the code above is not a function. The parameter <b>targetOrigin</b>&nbsp;is set to <b>*</b>&nbsp;because we don&#8217;t know the url of the iframe. Now the code in the <b>iframe</b>&nbsp;: </p> <blockquote class="tr_bq"> <p> function subins(){<br />&nbsp;alert("Support Wikipedia");<br />}<br />window.addEventListener("message",function(e){<br />&nbsp;if(e.origin==&#8217;http://example.com&#8217;){<br />&nbsp; subins();<br />&nbsp;}<br />},false); </p> </blockquote> <p> When a <b>postmessage</b>&nbsp;callback is received on the <b>iframe</b>&nbsp;the origin where the <b>postMessage</b>&nbsp;callback is called is checked on the script in <b>iframe </b>and if it is true, <b>subins()</b>&nbsp;is called and it will alert the text <b>Support Wikipedia</b>.<br />So now you know how to communicate between <b>cross</b>&nbsp;<b>domains</b>. Code Great.</div> Loading Bar until page loads completely using Javascript https://subinsb.com/loading-bar-until-page-loads-completely-using-javascript/ Thu, 15 Aug 2013 03:30:00 +0000 https://subinsb.com/loading-bar-until-page-loads-completely-using-javascript/ <p>This tutorial was requested by Sumit. In this tutorial Iโ€™m going to tell how to put up a loading screen until the page has loaded completely.</p> <center> <span style="background-color: #6aa84f; border-radius: 10px; border: 2px solid black; display: inline-block; font-size: medium; padding: 10px; width: 150px;"><a style="color: white;" href="http://subin-demos.blogspot.in/">DEMO</a></span> </center>Here is the screenshot of loading screen : <p><a style="margin-left: 1em; margin-right: 1em;" href="//1.bp.blogspot.com/-mQVSLDWX03g/UguA1UTiynI/AAAAAAAAC8c/QpPXA5hO4fg/s1600/0035.png"><img class="aligncenter" src="//1.bp.blogspot.com/-mQVSLDWX03g/UguA1UTiynI/AAAAAAAAC8c/QpPXA5hO4fg/s640/0035.png" width="640" height="324" border="0" /></a></p> <p>The loading bar will fade out when loading is completed.</p> <p>This code will work for all sites including <strong>Blogger Blogs</strong>, <strong>WordPress Blogs</strong>ย except <strong>Dynamic Views Template</strong>ย of **Blogger **(because it uses ajax loading). You can change the image if you want. I have created an image of my own :</p> <p><a style="margin-left: 1em; margin-right: 1em;" href="//4.bp.blogspot.com/-4WVJgCO93zc/UgpU2Y60CjI/AAAAAAAAC8E/R3XujnTjz3Y/s1600/initializing.png"><img class="aligncenter" style="background: black;" src="//4.bp.blogspot.com/-4WVJgCO93zc/UgpU2Y60CjI/AAAAAAAAC8E/R3XujnTjz3Y/s320/initializing.png" width="320" height="270" border="0" /></a></p> <p>Ok. Now letโ€™s get down to the code. This code is pure <strong>Javascript</strong>, no <strong>jQuery</strong>ย because the site might be loading <strong>jQuery</strong>ย and we should have to show the loading bar before the loading of <strong>jQuery</strong>.</p> <p>Here is the code. You have to place it just after <strong><head></strong></p> <pre class="prettyprint"><code>subinsblogla = 0; setInterval(function() { if (document.readyState != 'complete') { document.documentElement.style.overflow = "hidden"; var subinsblog = document.createElement("div"); subinsblog.id = "subinsblogldiv"; var polu = 999999999; subinsblog.style.zIndex = polu; subinsblog.style.background = "black url(&lt;strong>https://lh4.googleusercontent.com/-4WVJgCO93zc/UgpU2Y60CjI/AAAAAAAAC8E/R3XujnTjz3Y/s474/initializing.png&lt;/strong>) 50% 50% no-repeat"; subinsblog.style.backgroundPositionX = "50%"; subinsblog.style.backgroundPositionY = "50%"; subinsblog.style.position = "absolute"; subinsblog.style.right = "0px"; subinsblog.style.left = "0px"; subinsblog.style.top = "0px"; subinsblog.style.bottom = "0px"; if (subinsblogla === 0) { document.documentElement.appendChild(subinsblog); subinsblogla = 1; } } else if (document.getElementById('subinsblogldiv') != null) { document.getElementById('subinsblogldiv').style.display = "none"; document.documentElement.style.overflow = "auto"; } }, 1000);</code></pre> <p>You may replace the variable names, but make sure that the variable name is unique.</p> <p>If you want to change the Loading Image just change the</p> <blockquote class="tr_bq"> <p> <b>https://lh4.googleusercontent.com/-4WVJgCO93zc/UgpU2Y60CjI/AAAAAAAAC8E/R3XujnTjz3Y/s474/initializing.pngย </b> </p> </blockquote> <p>url in the variableย <strong>subinsblog.style.background</strong>.</p> <p>Well thatโ€™s it for now. If you have any problems/suggestions/feedback, just say it out in the comment form below and <strong>Happy Independence Day</strong>ย to all <strong>Indians</strong>ย and <strong>Pakistanis</strong>.</p> Setting Iframe height to its content height using Javascript https://subinsb.com/setting-iframe-height-to-its-content-height-using-javascript/ Thu, 08 Aug 2013 03:30:00 +0000 https://subinsb.com/setting-iframe-height-to-its-content-height-using-javascript/ <div dir="ltr" style="text-align: left;" trbidi="on"> While loading an iframe on page the most difficult thing is to set it&#8217;s height to the height of the content of the iframe. I looked around the web and got the code. This is pure <b>Javascript</b>, doesn&#8217;t contain&nbsp;<b>jQuery</b>&nbsp;or any other libraries. Set these functions :</p> <blockquote class="tr_bq"> <p> function getDocHeight(doc) {<br />&nbsp; &nbsp; doc = doc || document;<br />&nbsp; &nbsp; var body = doc.body, html = doc.documentElement;<br />&nbsp; &nbsp; var height = Math.max( body.scrollHeight, body.offsetHeight,<br />&nbsp; &nbsp; &nbsp; &nbsp; html.clientHeight, html.scrollHeight, html.offsetHeight );<br />&nbsp; &nbsp; return height;<br />}<br />function setIframeHeight(id) {<br />&nbsp; &nbsp; var ifrm = id;<br />&nbsp; &nbsp; var doc = ifrm.contentDocument? ifrm.contentDocument: ifrm.contentWindow.document;<br />&nbsp; &nbsp; ifrm.style.visibility = &#8216;hidden&#8217;;<br />&nbsp; &nbsp; ifrm.style.height = "10px"; // reset to minimal height in case going from longer to shorter doc<br />&nbsp; &nbsp; // some IE versions need a bit added or scrollbar appears<br />&nbsp; &nbsp; ifrm.style.height = getDocHeight( doc ) + 4 + "px";<br />&nbsp; &nbsp; ifrm.style.visibility = &#8216;visible&#8217;;<br />} </p> </blockquote> <p> Now add an event listener to the iframe : </p> <blockquote class="tr_bq"> <p> onload=&#8217;setIframeHeight(this)&#8217; </p> </blockquote> <p> After adding the event listener, the iframe element will look like this : </p> <blockquote class="tr_bq"> <p> <iframe&nbsp;onload="setIframeHeight(this)" src="subins.html"></iframe> </p> </blockquote> <p> When the iframe completes loading the function will check it&#8217;s content height and set the height of the iframe to it&#8217;s content height. Pretty Neat, Huh ? </p> </div> Create MySQL Injection free Secure Login System in PHP https://subinsb.com/php-secure-login-system/ Wed, 07 Aug 2013 03:30:00 +0000 https://subinsb.com/php-secure-login-system/ <p>There were a lot of people who created tutorials to create a <strong>PHP</strong>ย Login System. But they were all vulnerable to <strong>MySQL</strong>ย Injection. In this post Iโ€™m going to demonstrate a login system free of this vulnerability. It is very secure. There are <strong>mysqli</strong>ย and <strong>PDO</strong>ย in <strong>PHP</strong>ย to escape these injections. We are going to use **PDO <strong>(ย PHP Data Object</strong>ย **).</p> <div class="padlinks"> <a class="download" href="http://demos.subinsb.com/down.php?id=v8xwuepqlefmot8&class=1">Download</a> <a class="demo" href="http://demos.subinsb.com/secure-php-login-system">Demo</a> </div> <h1 id="update-8211-logsys">UPDATE โ€“ logSys</h1> <p>There is a new, free, better Advanced Login System which you can check out <a href="//subinsb.com/php-logsys" title="PHP Secure, Advanced Login System">here</a>.</p> <p>First of all create a file named <strong>login.php</strong>, <strong>home.php</strong>, <strong>logout.php</strong></p> <h2 id="create-users-table">Create Users Table</h2> <p>****<span style="line-height: 1.5em;">For storing user information you have to create a table named </span><b style="line-height: 1.5em;">users</b><span style="line-height: 1.5em;">. Here is the </span><b style="line-height: 1.5em;">SQL</b><span style="line-height: 1.5em;">ย code to create the table.</span></p> <pre class="prettyprint"><code>CREATE TABLE IF NOT EXISTS `users` ( `id` int(11) NOT NULL AUTO_INCREMENT, `username` text NOT NULL, `password` text NOT NULL, `psalt` text NOT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;</code></pre> <ol style="text-align: left;"> <li> The column <b>username</b>ย is to store the <b>e-mail</b>ย of the user. This e-mail is used as the username. </li> <li> The column <b>password</b>ย is to store user&#8217;s password which will be heavily encrypted using <b>SHA256</b>. </li> <li> The column <b>psalt</b>ย contains a random text to check if password is true. </li> </ol> <p>Now we should add a user to the table. Execute the following <strong>SQL</strong>ย code to create a user.</p> <pre class="prettyprint"><code>INSERT INTO `users` ( `id`, `username`, `password`, `psalt` ) VALUES ( NULL, '[email protected]', '4f8ee01c497c8a7d6f44334dc15bd44fe5acea9aed07f67e34a22ec490cfced1', 's*vl%/?s8b*b4}b/w%w4' );</code></pre> <p>The user is inserted with the following values: <a href="//1.bp.blogspot.com/-3hts0gYWk4E/UgB-1cse2FI/AAAAAAAAC38/CfhndrRg-6Q/s1600/0033.png"><img class="aligncenter" src="//1.bp.blogspot.com/-3hts0gYWk4E/UgB-1cse2FI/AAAAAAAAC38/CfhndrRg-6Q/s1600/0033.png" alt="" border="0" /></a></p> <h2 id="bloginphpb"><b>login.php</b></h2> <p>Create a login form :</p> <pre class="prettyprint"><code>&lt;form method="POST" action="login.php" style="border:1px solid black;display:table;margin:0px auto;padding-left:10px;padding-bottom:5px;"&gt; &lt;table width="300" cellpadding="4" cellspacing="1"&gt; &lt;tr&gt;&lt;td&gt;&lt;td colspan="3"&gt;&lt;strong&gt;User Login&lt;/strong&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt;&lt;td width="78"&gt;E-Mail&lt;/td&gt;&lt;td width="6"&gt;:&lt;/td&gt;&lt;td width="294"&gt;&lt;input size="25" name="mail" type="text"&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt;&lt;td&gt;Password&lt;/td&gt;&lt;td&gt;:&lt;/td&gt;&lt;td&gt;&lt;input name="pass" size="25" type="password"&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt;&lt;td&gt;&lt;/td&gt;&lt;td&gt;&lt;/td&gt;&lt;td&gt;&lt;input type="submit" name="Submit" value="Login"&gt;&lt;/td&gt;&lt;/tr&gt; &lt;/table&gt; Login System provided by &lt;a target="_blank" href='http://sag-3.blogspot.com/2013/08/secure-injection-free-login-system-php.html'&gt;Subins&lt;/a&gt; &lt;/form&gt;</code></pre> <p>Now we should add the <strong>PHP</strong>ย code to check whether the <strong>username</strong>ย and <strong>password</strong>ย is correct. You should add the <strong>PHP</strong>ย code before <strong>&lt;/form</strong>&gt; we just added in <strong>login.php</strong>.</p> <pre class="prettyprint"><code>&lt;?php session_start(); if(isset($_SESSION['user']) && $_SESSION['user']!=''){header("Location:home.php");} $dbh=new PDO('mysql:dbname=db;host=127.0.0.1', 'username', 'password');/*Change The Credentials to connect to database.*/ $email=$_POST['mail']; $password=$_POST['pass']; if(isset($_POST) && $email!='' && $password!=''){ $sql=$dbh-&gt;prepare("SELECT id,password,psalt FROM users WHERE username=?"); $sql-&gt;execute(array($email)); while($r=$sql-&gt;fetch()){ $p=$r['password']; $p_salt=$r['psalt']; $id=$r['id']; } $site_salt="subinsblogsalt";/*Common Salt used for password storing on site. You can't change it. If you want to change it, change it when you register a user.*/ $salted_hash = hash('sha256',$password.$site_salt.$p_salt); if($p==$salted_hash){ $_SESSION['user']=$id; header("Location:home.php"); }else{ echo "&lt;h2&gt;Username/Password is Incorrect.&lt;/h2&gt;"; } } ?&gt;</code></pre> <h2 id="bhomephpb"><b>home.php</b></h2> <pre class="prettyprint"><code>&lt;html&gt;&lt;head&gt;&lt;/head&gt; &lt;body&gt; &lt;? session_start(); if($_SESSION['user']==''){ header("Location:login.php"); }else{ $dbh=new PDO('mysql:dbname=db;host=127.0.0.1', 'root', 'backstreetboys'); $sql=$dbh-&gt;prepare("SELECT * FROM users WHERE id=?"); $sql-&gt;execute(array($_SESSION['user'])); while($r=$sql-&gt;fetch()){ echo "&lt;center&gt;&lt;h2&gt;Hello, ".$r['username']."&lt;/h2&gt;&lt;/center&gt;"; } } ?&gt; &lt;/body&gt; &lt;/html&gt;</code></pre> <h2 id="blogoutphpb"><b>logout.php</b></h2> <p>This file is simple. Just add the following :</p> <pre class="prettyprint"><code>&lt;? session_start(); session_destroy(); ?&gt;</code></pre> <p>Now login using username as <strong><a href="mailto:[email protected]">[email protected]</a></strong>ย and password as <strong>subinsiby</strong>. You will be redirected to <strong>home.php</strong>ย and it will say the following:</p> <div class="separator" style="clear: both; text-align: center;"> <a style="margin-left: 1em; margin-right: 1em;" href="//3.bp.blogspot.com/-mbpIZ8S5k7I/UgCIQd-ynMI/AAAAAAAAC4M/NhXZLikRMhg/s1600/0034.png"><img src="//3.bp.blogspot.com/-mbpIZ8S5k7I/UgCIQd-ynMI/AAAAAAAAC4M/NhXZLikRMhg/s1600/0034.png" alt="" border="0" /></a> </div> <h2 id="registerphp">register.php</h2> <p>Whatโ€™s logging in without registering ? Hereโ€™s a sample Registration page :</p> <pre class="prettyprint"><code>&lt;? session_start(); if(isset($_SESSION['user']) && $_SESSION['user']!=''){ header("Location:home.php"); } ?&gt; &lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt;&lt;/head&gt; &lt;body&gt; &lt;form action="register.php" method="POST"&gt; &lt;label&gt;E-Mail &lt;input name="user" /&gt;&lt;/label&gt;&lt;br/&gt; &lt;label&gt;Password &lt;input name="pass" type="password"/&gt;&lt;/label&gt;&lt;br/&gt; &lt;button name="submit"&gt;Register&lt;/button&gt; &lt;/form&gt; &lt;? if(isset($_POST['submit'])){ $musername = "root"; $mpassword = "backstreetboys"; $hostname = "127.0.0.1"; $db = "p"; $port = 3306; $dbh=new PDO('mysql:dbname='.$db.';host='.$hostname.";port=".$port,$musername, $mpassword);/*Change The Credentials to connect to database.*/ if(isset($_POST['user']) && isset($_POST['pass'])){ $password=$_POST['pass']; $sql=$dbh-&gt;prepare("SELECT COUNT(*) FROM `users` WHERE `username`=?"); $sql-&gt;execute(array($_POST['user'])); if($sql-&gt;fetchColumn()!=0){ die("User Exists"); }else{ function rand_string($length) { $str=""; $chars = "subinsblogabcdefghijklmanopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; $size = strlen($chars); for($i = 0;$i &lt; $length;$i++) { $str .= $chars[rand(0,$size-1)]; } return $str; /* http://subinsb.com/php-generate-random-string */ } $p_salt = rand_string(20); /* http://subinsb.com/php-generate-random-string */ $site_salt="subinsblogsalt"; /*Common Salt used for password storing on site.*/ $salted_hash = hash('sha256', $password.$site_salt.$p_salt); $sql=$dbh-&gt;prepare("INSERT INTO `users` (`id`, `username`, `password`, `psalt`) VALUES (NULL, ?, ?, ?);"); $sql-&gt;execute(array($_POST['user'], $salted_hash, $p_salt)); echo "Successfully Registered."; } } } ?&gt; &lt;/body&gt; &lt;/html&gt;</code></pre> <p>Note to change the Database credentials on above code.</p> <p>This login system is totally <strong>99%</strong>ย secure. Itโ€™s very hard to crack for a hacker and itโ€™s completely **MySQL Injection **free. It took me less than 1 hour to create this system and create this post. Happy Logging. If you have any problems/suggestions/feedbacks just comment. I will help you.</p> Better Google Chrome History Page https://subinsb.com/better-google-chrome-history-page/ Mon, 05 Aug 2013 03:30:00 +0000 https://subinsb.com/better-google-chrome-history-page/ <div dir="ltr" style="text-align: left;" trbidi="on"> <span style="background-color: white; font-family: Times, Times New Roman, serif;">As you know, <b>Google Chrome</b>&#8216;s Browser History is not efficient. It&#8217;s history is not like any other browsers. I think they made the <b>History</b>&nbsp;page in a hurry. If we want to search for a page we visited before, we won&#8217;t get it by searching on <b>History</b>&nbsp;page. That&#8217;s the main problem.</span><br /><span style="background-color: white; font-family: Times, Times New Roman, serif;">This problem was solved when a lot of users created an alternate <b>History</b>&nbsp;Page extension on <b>Chrome Webstore</b>.</span><br /><span style="background-color: white; font-family: Times, Times New Roman, serif;">In this post I&#8217;m gonna tell the most used <b>History</b>&nbsp;Alternate Extension. It&#8217;s <b>Better History</b>&nbsp;extension. You can download the extension from&nbsp;<a href="https://chrome.google.com/webstore/detail/obciceimmggglbmelaidpjlmodcebijb" >here</a>.</span><br /><img src="https://lh4.googleusercontent.com/ftqlRdjF7Kq2Eo08QQHXdDoXtd7qJHXJaXmUsJyG7fuFZsK2ZsVr8X5vX_Yf7KE-zpYvTEF_oQ=s640-h400-e365-rw" /><br /><b><span style="font-size: large;">Deleting:</span></b></p> <ul> <li> Delete all visits for a day </li> <li> Delete individual visits </li> <li> Delete visits to the same domain </li> <li> Delete all history </li> </ul> <p> <b><span style="font-size: large;">Grouping:</span></b> </p> <ul style="text-align: left;"> <li> Group visits by 60, 30, or 15 minutes </li> <li> Group visits to the same domain </li> <li> Format hours to 12 or 24 </li> <li> Customizable grouping behavior </li> </ul> <p> <b><span style="font-size: large;">Organizing:</span></b> </p> <ul> <li> Filter visits by day </li> </ul> <p> <b><span style="font-size: large;">Searching:</span></b> </p> <ul> <li> Search the last few months </li> <li> Search by date, url, and page title </li> <li> Highlighted search terms </li> <li> Right click option to search by domain </li> <li> Right click option to search by selected text </li> </ul> <p> <b><span style="font-size: large;">Styling:</span></b> </p> <ul> <li> Styled with Chrome UI </li> <li> Access from button in toolbar&nbsp; </li> <li> Remembers closing state </li> <li> Back button support </li> </ul> </div> Setting Infinite Width on an element โ€“ HTML https://subinsb.com/setting-infinite-width-on-an-element-html/ Sun, 04 Aug 2013 03:30:00 +0000 https://subinsb.com/setting-infinite-width-on-an-element-html/ <div dir="ltr" style="text-align: left;" trbidi="on"> The maximum width we can add on a div is&nbsp;<b>100%</b>. What if you want more than that ? The solution is not to add more percentage to div but to do something other. Adding <b>white-space</b>&nbsp;property.<br />This will only work on the main parent elements such as elements with <b>display</b>&nbsp;property as follows:</p> <ol style="text-align: left;"> <li> block </li> <li> table </li> <li> inline-block </li> </ol> <p> So now you know what are the main parent elements. Now back to the point, to add infinite width set the <b>white-space</b>&nbsp;property to the value&nbsp;<b>nowrap</b>. Example: </p> <blockquote class="tr_bq"> <p> div{<br />&nbsp;white-space:nowrap;<br />} </p> </blockquote> <p> and put <b>display:inline-block</b>&nbsp;on all the children elements.<br />Now the div will get an infinite width. Enjoy !!!</div> Generating Random String in PHP https://subinsb.com/php-generate-random-string/ Fri, 02 Aug 2013 03:30:00 +0000 https://subinsb.com/php-generate-random-string/ <p>In <strong>PHP</strong>ย you can generate random number by using <strong>rand</strong>ย function, but there is no specific function to generate a random text or string. In this post Iโ€™m going to show the <strong>function</strong>ย that will generate a random string of length mentioned.</p> <p>Here is the function:</p> <pre class="prettyprint"><code>function rand_string($length) { $str=""; ย $chars = "subinsblogabcdefghijklmanopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; $size = strlen($chars); ย for($i = 0;$i &lt; $length;$i++) { ย  $str .= $chars[rand(0,$size-1)]; ย } return $str; }</code></pre> <h2 style="text-align: left;"> Usage </h2> <p>To generate a random string use <strong>rand_string()</strong>ย function with the parameter of length of the to be generated string. Hereโ€™s an example:</p> <pre class="prettyprint"><code>echo rand_string(6);</code></pre> <p>The above code will print out something like this :</p> <pre class="prettyprint"><code>oSuN1R</code></pre> <p>Note that the above printed out string will be different for everyone, not the same.</p> <h2 style="text-align: left;"> Explanation </h2> <ol style="text-align: left;"> <li> The first variableย <strong>$str</strong> is the variable where the function adds random single strings to make the long random string. </li> <li> The variableย <strong>$chars</strong> contains lots of characters including integers and alphabetic letters. You can change it if you want. </li> <li> The <strong>$size</strong> variable contains the number of characters in the <b>$chars</b>ย string. </li> <li> Now it&#8217;s looped at <b>n </b>times where <b>n </b>is the length of to be generated string we mentioned in the function. </li> <li> At each loop a character is added to the <b>$str</b>ย variable from random letter got from the <b>$chars</b>ย variable. </li> <li> And finally the generated string is returned. </li> </ol> Installing Wine 1.6 on Ubuntu 10.04 https://subinsb.com/installing-wine-1-6-on-ubuntu-10-04/ Sun, 28 Jul 2013 03:30:00 +0000 https://subinsb.com/installing-wine-1-6-on-ubuntu-10-04/ <div dir="ltr" style="text-align: left;" trbidi="on"> <b>Wine 1.6</b>&nbsp;is not latest version for&nbsp;<b>Ubuntu 10.04</b>, but you can install it by compiling the source code and it works perfectly. See demo <a href="http://sag-3.blogspot.com/2013/07/nfs-most-wanted-running-on-wine-16.html" >here</a>. To install <b>Wine 1.6</b>&nbsp;follow the instructions.</p> <h4 style="text-align: left;"> <b><span style="font-size: large;"><u>Optional :</u></span></b> </h4> <div> <b>Wine Team</b>&nbsp;recommend you to uninstall previous <b>Wine </b>versions when installing a compiled version. But its optional. If the <b>Wine 1.6</b>&nbsp;fails you can uninstall <b>1.6</b>&nbsp;and use the old version. </div> <h4 style="text-align: left;"> <b><span style="font-size: large;"><u>Steps :</u></span></b> </h4> <div> Download the <b>Wine</b>&nbsp;<b>1.6</b>&nbsp;<b>Source Code</b>&nbsp;from <a href="http://get-subins.hp.af.cm/view.php?id=351" >here</a>. Extract the <b>wine- 1.6</b>&nbsp;folder in the archive file to a place you desire. For Now, place it on your home directory. </div> <div> The <b>Wine-1.6</b>&nbsp;folder will look something like this: </div> <div class="separator" style="clear: both; text-align: center;"> <a href="https://2.bp.blogspot.com/-4fMRUQbuxxQ/UfPSpqVaOCI/AAAAAAAAC3I/3kdAmcLfTuU/s1600/0031.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://2.bp.blogspot.com/-4fMRUQbuxxQ/UfPSpqVaOCI/AAAAAAAAC3I/3kdAmcLfTuU/s1600/0031.png" /></a> </div> <div> Right click on blank space and click <b>Open In Terminal</b>. </div> <div> Do the following command: </div> <blockquote class="tr_bq"> <p> sudo&nbsp;make install </p> </blockquote> <div> The program will automatically compile and install <b>Wine</b>. Also sometimes it might want some software to work and the software they want will be printed on terminal. Install it. If you need instructions <b>Google</b>&nbsp;It. </div> <div> It might take up to <b>30</b>&nbsp;minutes to compile and install or maybe more. After installation the <b>Wine</b>&nbsp;<b>Config</b>&nbsp; window will look like below: </div> <div class="separator" style="clear: both; text-align: center;"> <a href="//4.bp.blogspot.com/-TFMu8BsvGp8/UfPUJF5lXKI/AAAAAAAAC3Y/q2OKPsrqZjA/s1600/0032.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="//4.bp.blogspot.com/-TFMu8BsvGp8/UfPUJF5lXKI/AAAAAAAAC3Y/q2OKPsrqZjA/s1600/0032.png" /></a> </div> <div> The styles of button are changed in the above window of <b>Wine</b>&nbsp;because <i>I have installed a theme.</i> </div> </div> Javascript code Compressor Tool https://subinsb.com/javascript-code-compressor-tool/ Fri, 26 Jul 2013 03:30:00 +0000 https://subinsb.com/javascript-code-compressor-tool/ <div dir="ltr" style="text-align: left;" trbidi="on"> If long long <b>Javascript</b>&nbsp;codes are compressed, it will make the page load faster. In this post I&#8217;m going to suggest a perfect tool for compressing <b>Javascript</b>&nbsp;code. The tool is <b>JsCompress</b>.<br />Go to <a href="http://blimptontech.com/?utm_source=subinsblog" >http://blimptontech.com/</a>&nbsp;to see the compressor in action.<br />You have three options:</p> <ol style="text-align: left;"> <li> Paste Code and Compress </li> <li> Compress code in files </li> <li> Compress Multiple files into one. </li> </ol> <p> It&#8217;s a great tool and it will help you reduce the file size up to <b>100&nbsp;KB</b>. This site is similar to the <b>JsCompressor</b>&nbsp;tool&nbsp;@ <a href="http://jscompress.com/" >http://jscompress.com</a>.&nbsp;</div> Preventing double encode of URL in PHP https://subinsb.com/preventing-double-encode-of-url-in-php/ Mon, 22 Jul 2013 03:30:00 +0000 https://subinsb.com/preventing-double-encode-of-url-in-php/ <div dir="ltr" style="text-align: left;" trbidi="on"> There is no practical way to check whether an <b>URL</b>&nbsp;is encoded or not to <b>encode </b>if it&#8217;s not encoded. But you can do encode the URL by first decoding like below:</p> <blockquote class="tr_bq"> <p> $string = url_decode($url); </p> </blockquote> <p> And then you should encode as to prevent double encoding. </p> <blockquote class="tr_bq"> <p> $string = url_encode($url); </p> </blockquote> <p> By doing this we can prevent double encoding of <b>URL</b>&#8216;s.</div> NFS Most Wanted running on Wine 1.6 https://subinsb.com/nfs-most-wanted-running-on-wine-1-6/ Sun, 21 Jul 2013 03:30:00 +0000 https://subinsb.com/nfs-most-wanted-running-on-wine-1-6/ <div dir="ltr" style="text-align: left;" trbidi="on"> <span style="font-size: large;">These are the screenshots of <b>Need For Speed Most Wanted</b>&nbsp;running in <b>Wine 1.6&nbsp;</b>on <b>Ubuntu 10.04</b>.</span></p> <div class="separator" style="clear: both; text-align: center;"> <a href="https://2.bp.blogspot.com/-erTVqCYMDjI/UeqxeC-VC-I/AAAAAAAAC2k/aJ8qIXpKpAQ/s1600/Screenshot1.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://2.bp.blogspot.com/-erTVqCYMDjI/UeqxeC-VC-I/AAAAAAAAC2k/aJ8qIXpKpAQ/s1600/Screenshot1.png" /></a> </div> <p> </p> <div class="separator" style="clear: both; text-align: center;"> <a href="https://2.bp.blogspot.com/-Rv7pxtm7CuY/UeqxZ9S9JPI/AAAAAAAAC2c/jpxaY1pB66g/s1600/Screenshot2.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://2.bp.blogspot.com/-Rv7pxtm7CuY/UeqxZ9S9JPI/AAAAAAAAC2c/jpxaY1pB66g/s1600/Screenshot2.png" /></a> </div> <p> </p> <div class="separator" style="clear: both; text-align: center;"> <a href="//1.bp.blogspot.com/-pGcE-M7Bh04/Ueqx0jM6SpI/AAAAAAAAC20/WbrmrjyrRhA/s1600/Screenshot3.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="//1.bp.blogspot.com/-pGcE-M7Bh04/Ueqx0jM6SpI/AAAAAAAAC20/WbrmrjyrRhA/s1600/Screenshot3.png" /></a> </div> <p> </p> <div class="separator" style="clear: both; text-align: center;"> <a href="//1.bp.blogspot.com/-E4dXhhSwjLE/Ueqxn1unCJI/AAAAAAAAC2s/58Eu7-gC9a8/s1600/Screenshot.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="//1.bp.blogspot.com/-E4dXhhSwjLE/Ueqxn1unCJI/AAAAAAAAC2s/58Eu7-gC9a8/s1600/Screenshot.png" /></a> </div> <p> </div> Wine 1.6 is released with 10,000 changes https://subinsb.com/wine-1-6-is-released-with-10000-changes/ Sat, 20 Jul 2013 03:30:00 +0000 https://subinsb.com/wine-1-6-is-released-with-10000-changes/ <div dir="ltr" style="text-align: left;" trbidi="on"> <span style="font-family: inherit;">After 16 months of development, <b>Wine</b>&nbsp;version <b>1.6&nbsp;</b>has been officially released by the <b>Wine Team</b>. <b>Wine</b>&nbsp;is the <b>Windows</b>&nbsp;Program emulator for <b>Linux</b>&nbsp;and <b>Mac</b>. You can download the source files from <a href="http://prdownloads.sourceforge.net/wine/wine-1.6.tar.bz2">here</a>. You can only get the source files now.&nbsp;<span style="background-color: white;">Binary packages are in the process of being built. If it&#8217;s been build you can d</span>ownload the <b>Wine</b>&nbsp;<b>1.6</b>&nbsp;version from <a href="http://www.winehq.org/download" >here</a>.</span></p> <h2 style="text-align: left;"> <b><span style="font-family: inherit; font-size: large;">What&#8217;s New ?</span></b> </h2> <ol style="text-align: left;"> <li> <span style="font-family: inherit;">New User Interface</span> </li> <li> <span style="font-family: inherit;">Networking capabilities</span> </li> <li> <span style="font-family: inherit;">Support for <b>Windows</b>&nbsp;Transparency</span> </li> <li> <span style="font-family: inherit;">Graphics improved</span> </li> <li> <span style="font-family: inherit;">JoyStick Installing</span> </li> <li> <span style="background-color: white;"><span style="font-family: inherit;">Mono package for .NET applications support</span></span> </li> <li> <span style="background-color: white;"><span style="font-family: inherit;">Support of new softwares and games.</span></span> </li> <li> <span style="background-color: white;"><span style="font-family: inherit;">Improved Input validation</span></span> </li> <li> <span style="background-color: white;"><span style="font-family: inherit;">Mac Driver</span></span> </li> <li> Direct3D </li> </ol> <p> <span style="font-family: inherit;">and more. <b>Wine Team</b>&nbsp;officially said that the new <b>Wine </b>version&nbsp;more than <b>10,000</b>&nbsp;changes.&nbsp;</span></div> Encode/Decode URL in Javascript and PHP https://subinsb.com/encodedecode-url-in-javascript-and-php/ Fri, 19 Jul 2013 03:30:00 +0000 https://subinsb.com/encodedecode-url-in-javascript-and-php/ <div dir="ltr" style="text-align: left;"> <b>URL</b>ย encoding and decoding can be done in both <b>Javascript</b>ย and <b>PHP</b>. In this post I&#8217;m going to tell you the functions used in both languages for url encoding/decoding.<br /> <b><span style="font-size: x-large;"><span style="text-decoration: underline;">Javascript</span></span></b><br /> <b><span style="font-size: large;">ย Encoding</span></b></p> <blockquote class="tr_bq"> <p> <span style="background-color: white; font-family: inherit; white-space: pre-wrap;">encodeURIComponent(url);</span> </p> </blockquote> <p> <span style="background-color: white; white-space: pre-wrap;"><span style="font-family: inherit; font-size: large;"><b> Decoding</b></span></span> </p> <blockquote class="tr_bq"> <p> <span style="background-color: white; white-space: pre-wrap;">decodeURIComponent(url);</span> </p> </blockquote> <p> <b><span style="font-size: x-large;"><span style="text-decoration: underline;">PHP</span></span></b><br /> <b><span style="font-size: large;">ย Encoding</span></b> </p> <blockquote class="tr_bq"> <p> <span style="background-color: white; font-family: inherit; white-space: pre-wrap;">urlencode(url);</span> </p> </blockquote> <p> <span style="background-color: white; white-space: pre-wrap;"><span style="font-family: inherit; font-size: large;"><b> Decoding</b></span></span> </p> <blockquote class="tr_bq"> <p> <span style="background-color: white; white-space: pre-wrap;">urldecode(url);</span> </p> </blockquote> <p> <span style="white-space: pre-wrap;">There is<b> </b>an <b>encodeURI</b> and <b>decodeURI</b> function in <b>Javascript</b> but it won&#8217;t encode/decode the url. Note that the the word used in <b>Javascript</b> is <b>URI</b> not <b>URL</b>. But in <b>PHP</b> both are <b>URL</b>. Don&#8217;t mistake the word.</span> </p> </div> Fix: Dynamic Views failed to load properly https://subinsb.com/fix-dynamic-views-failed-to-load-properly/ Thu, 18 Jul 2013 03:30:00 +0000 https://subinsb.com/fix-dynamic-views-failed-to-load-properly/ <div dir="ltr" style="text-align: left;" trbidi="on"> <span style="font-family: inherit;">Well, this problem is pretty annoying to everyone who is using <b>Dynamic Views</b>, even to me. It&#8217;s a <b>Blogger</b>&nbsp;fault as always and there has not been a solution to the problem since it started on the <b>Dynamic Views</b>&nbsp;launch.&nbsp;<span style="background-color: white;">Pรคivi & Santeri of&nbsp;</span><span style="background-color: white;"><b><a href="http://www.2globalnomads.info/" >Global Nomads</a></b>&nbsp;founded a solution to this problem. Oh! I didn&#8217;t said the problem was. The problem is that the whole <b>Blog</b>&nbsp;will fail to load completely/properly. Some of the problems happen when the blog won&#8217;t properly load are listed below:</span></span></p> <ol style="text-align: left;"> <li> <span style="background-color: white; font-family: inherit;">Page List will become blank</span> </li> <li> Custom <b>CSS</b>&nbsp;won&#8217;t load. </li> <li> Ugly Blog. </li> <li> Visitor Disaprovement </li> </ol> <p> and many more. Let&#8217;s get back to the solution which is pretty simple.<br />Go to <b>Blogger</b>&nbsp;-> <b>Template</b>&nbsp;-> <b>Edit HTML</b>.<br />Search for&nbsp;<b>blogger.ui().configure()</b><br />You will get a code like this: </p> <blockquote class="tr_bq"> <p> <script language=&#8217;javascript&#8217; type=&#8217;text/javascript&#8217;><br />&nbsp;setTimeout(function() {<br />&nbsp;blogger.ui().configure().view();<br />&nbsp;}, 0);<br /></script> </p> </blockquote> <p> The only thing you should do is to replace the <b>seTimeout</b>&nbsp;value from <b></b>&nbsp;to <b>500</b>. And the final code will be: </p> <blockquote class="tr_bq"> <p> <script language=&#8217;javascript&#8217; type=&#8217;text/javascript&#8217;><br />&nbsp;setTimeout(function() {<br />&nbsp;blogger.ui().configure().view();<br />&nbsp;}, 1000);<br /></script> </p> </blockquote> <p> If you have any problems/feedback/suggestions then feel free to comment below on <b>Disqus</b>.</div> Vertically center align an element using CSS https://subinsb.com/vertically-center-align-an-element-using-css/ Wed, 17 Jul 2013 03:30:00 +0000 https://subinsb.com/vertically-center-align-an-element-using-css/ <div dir="ltr" style="text-align: left;" trbidi="on"> Vertical alignment is difficult to find a solution. But I will tell you a simple way to align a div vertically center. The <b>CSS</b>&nbsp;property you&#8217;re going to use for this purpose is <b>vertical-align</b>.<br />Here is the code of a div aligned vertically.</p> <blockquote class="tr_bq"> <p> #adiv{<br />display:inline-block;<br />vertical-align:middle;<br />} </p> </blockquote> <p> This only works for div with the display property <b>inline-block</b>&nbsp;and some others which I don&#8217;t know. But it&#8217;s better to use <b>inline-block</b>.</div> Check whether request is made from Ajax โ€“ PHP https://subinsb.com/check-whether-request-is-made-from-ajax-php/ Tue, 16 Jul 2013 03:30:00 +0000 https://subinsb.com/check-whether-request-is-made-from-ajax-php/ <div dir="ltr" style="text-align: left;" trbidi="on"> To check whether a request has been made is from <b>Ajax</b>&nbsp;or not you can use&nbsp;<b>$_SERVER[&#8216;HTTP_X_REQUESTED_WITH&#8217;]</b>. See the following example:</p> <blockquote class="tr_bq"> <p> <?php<br />if(strtolower($_SERVER[&#8216;HTTP_X_REQUESTED_WITH&#8217;])==&#8217;xmlhttprequest&#8217;){<br />&nbsp;echo "The request is from an Ajax Call";<br />}else{<br />&nbsp;echo "The request is not from an Ajax Call";<br />}<br />?> </p> </blockquote> <p> There you go. You now know how to check whether request made to file is from an <b>Ajax</b>&nbsp;Call or not in <b>PHP</b>.</div> Scroll Horizontally Without Scrollbar Using jQuery https://subinsb.com/scroll-horizontally-without-scrollbar-using-jquery/ Mon, 15 Jul 2013 03:30:00 +0000 https://subinsb.com/scroll-horizontally-without-scrollbar-using-jquery/ <p>To scroll horizontally withย <strong>CSS</strong>ย is very annoying, because the whole page will move vertically and sometimes the <strong>Y</strong>ย axis will scroll. So I decided to use <strong>jQuery</strong>ย and itโ€™s very simple. Only <strong>237</strong>ย characters which is only <strong>2</strong>ย lines. Here is the **jQueryย **code with the div id <strong>#scrollho</strong>.</p> <h2 id="jquery">jQuery</h2> <pre class="prettyprint"><code>$('#scrollho').on('mousewheel',function(e){ ย e.preventDefault(); scrollLeft=$('#scrollho').scrollLeft(); ย if(e.originalEvent.wheelDeltaY.toString().slice(0,1)=='-'){ ย  $('#scrollho').scrollLeft(scrollLeft+100); ย }else{ ย  $('#scrollho').scrollLeft(scrollLeft-100); ย } });</code></pre> <h2 id="css">CSS</h2> <pre class="prettyprint"><code>#scrollho{ overflow:hidden; }</code></pre> <h2 id="explanation">Explanation</h2> <p>The <strong>#scrollho</strong>ย divโ€™s scrollbars are hidden with <strong>CSS</strong>. When a <strong>mousewheel</strong>ย event occurs on <strong>#scrollho</strong>ย the default event is neutralized and the div is scrolled horizontally to the direction of the mousewheel usingย <strong>e.originalEvent.wheelDeltaY</strong>.ย **e.originalEvent.wheelDeltaY **is converted into string as to do the <strong>slice</strong>ย function to check whether the number is negative or not.</p> The main reason why adsense was disapproved https://subinsb.com/the-main-reason-why-adsense-was-disapproved/ Sun, 14 Jul 2013 03:30:00 +0000 https://subinsb.com/the-main-reason-why-adsense-was-disapproved/ <div dir="ltr" style="text-align: left;" trbidi="on"> From my experience with <b>Adsense</b>&nbsp;I got disapproved after a visit from a <b>URL</b>&nbsp;to my blog. The <b>URL</b>&nbsp;was <b>SPAM </b>which is known as <b><a href="http://sag-3.blogspot.com/2013/04/spam-urls-in-blogger-traffic-source.html" >REFERRAL SPAM</a></b>. See more about <b>REFERRAL</b>&nbsp;<b>SPAM</b>&nbsp;<a href="http://sag-3.blogspot.com/2013/04/spam-urls-in-blogger-traffic-source.html" >here</a>.</p> <h4 style="text-align: left;"> <span style="font-size: large;">Why Adsense account got disapproved of Referral SPAM&nbsp;?</span> </h4> <div> In the <b>Google</b>&nbsp;<b>Adsense</b>&nbsp;policies, It says that you should not pay someone to visit your blog/site. When you are placing the ad on your blog, <b>Google</b>&nbsp;tracks each visit to your blog. When they see a suspicious <b>URL</b>&nbsp;in the traffic sources they count it as a paid to click <b>URL</b>. Hence you will get disapproved.</p> </div> <h4 style="text-align: left;"> <span style="font-size: large;">What should I do If I got disapproved&nbsp;</span><span style="font-size: large;">of Referral SPAM&nbsp;</span><span style="font-size: large;">?</span> </h4> <div> You should appeal to <b>Google</b>&nbsp;<b>Adsense</b>&nbsp;that you didn&#8217;t violated any policies. <a href="https://support.google.com/adsense/troubleshooter/2707037?hl=en" >Click this link to appeal</a>. You will be asked some questions. The <b>sample answers</b> of those questions with <b>can login</b> option are below: </div> <blockquote class="tr_bq"> <p> Contact E-Mail address ? </p> <pre><code>&lt;p&gt; [email protected] &lt;/p&gt; </code></pre> </blockquote> <blockquote class="tr_bq"> <p> Have you ever purchased traffic to your site(s) ? </p> <pre><code>&lt;p&gt; No &lt;/p&gt; </code></pre> </blockquote> <blockquote class="tr_bq"> <p> How do users get to your site? How do you promote your site? </p> <pre><code>&lt;p&gt; Users get to my site mostly from &lt;b&gt;Google Search&lt;/b&gt;. I promote my site using &lt;b&gt;Google&lt;/b&gt;&amp;nbsp;Adwords, Chatting (Facebook, Google+ etc&amp;#8230;.) &lt;/p&gt; </code></pre> </blockquote> <blockquote class="tr_bq"> <p> <span style="color: #222222; line-height: 18.200000762939453px;"><span style="font-family: inherit;">Have you or your site ever violated the AdSense program policies or Terms & Conditions? If so, how? Also, include any relevant information that you believe may have resulted in invalid activity. *</span></span><span style="color: #222222; line-height: 18.200000762939453px;"><span style="font-family: inherit;"><br /></span></span><span style="color: #222222; line-height: 18.200000762939453px;"><span style="font-family: inherit;"><br /></span></span><span style="color: #222222; line-height: 18.200000762939453px;"><span style="font-family: inherit;">No. There are SPAM url&#8217;s on my traffic sources. Adsense may have disapproved because of the invalid visits from these SPAM sites.</span></span> </p> </blockquote> <blockquote> <p> <span style="color: #222222; line-height: 18.200000762939453px;"><span style="font-family: inherit;">Please include any data from your site traffic logs or reports that indicate suspicious IP addresses, referrers, or requests which could explain invalid activity. *</span></span><span style="color: #222222; line-height: 18.200000762939453px;"><span style="font-family: inherit;"><br /></span></span><span style="color: #222222; line-height: 18.200000762939453px;"><span style="font-family: inherit;"><br /></span></span><span style="color: #222222; line-height: 18.200000762939453px;">http://www.filmhill.com/redirect.php?url=http://flf-course.com?a_aid=510d2acc92117&a_bid=6f93443e</span><br /><span style="color: #222222; font-family: inherit; line-height: 18.200000762939453px;">http://vampirestat.com</span><br />http://r-e-f-e-r-e-r.com/<br />http://t.co/MaAptuGFVu6 </p> </blockquote> </div> Add GET or POST parameters on include files in PHP https://subinsb.com/add-get-or-post-parameters-on-include-files-in-php/ Sat, 13 Jul 2013 03:30:00 +0000 https://subinsb.com/add-get-or-post-parameters-on-include-files-in-php/ <div dir="ltr" style="text-align: left;"> If you want to add <b>GET</b>ย parameters or <b>POST</b>ย parameters to files loading using <b>include</b>ย function in <b>PHP</b>ย then you should know the following:</p> <h4 style="text-align: left;"> <span style="color: red; font-size: large;">It&#8217;s not possible. But it is in a different way.</span> </h4> <p> If you are adding <b>GET </b>parameters to file name like the following, then it won&#8217;t work: </p> <blockquote class="tr_bq"> <p> <?php include(&#8216;file.php?user=subin&#8217;);?> </p> </blockquote> <p> The above code won&#8217;t load the file, because PHPย Includeย function only looks for files, it won&#8217;t send any parameters. It will search for <b>file.php?user=subin</b>ย in the directory for the case above. You can make it work in a different way. </p> <p> We use <b>$_GET</b>ย and <b>$_POST</b>ย to get the parameters sent for each type. You should know that these variables areย <b>Arrays</b>ย and not <b>Strings</b>. So you can just add a <b>key</b>ย and <b>value</b>ย to the array. </p> <p> So to add the key and valueย just use the following code along with the <b>include</b>ย function : </p> <blockquote class="tr_bq"> <p> <?php<br /> $_GET[&#8216;user&#8217;]="Subin";<br /> include(&#8216;file.php&#8217;);<br /> ?> </p> </blockquote> <p> The above code works with the same as <b>$_POST</b>. When the <b>file.php</b>ย is loaded you will get the parameters using <b>$_GET</b>ย or <b>$_POST</b>. </p> </div> How to access a remote computer using SSH in Ubuntu Linux https://subinsb.com/how-to-access-a-remote-computer-using-ssh-in-ubuntu-linux/ Fri, 12 Jul 2013 03:30:00 +0000 https://subinsb.com/how-to-access-a-remote-computer-using-ssh-in-ubuntu-linux/ <div dir="ltr" style="text-align: left;" trbidi="on"> <b>SSH</b>&nbsp;is the easiest way to access a remote computer not in graphical interface but in character interface.</p> <div> To access a remote computer you should need the computer&#8217;s <b>ip address</b>&nbsp;& a username of the computer. Now connect using the credentials you now have. For Example: </div> <blockquote class="tr_bq"> <p> ssh [email protected] </p> </blockquote> <div> Type the password of the user and hit enter. You now entered the user&#8217;s system. </div> <div> You can <b>logout</b>, <b>shut down</b>&nbsp;the computer if you ssh <b>root</b>&nbsp;user. For that use the following <b>ssh</b>&nbsp;command: </div> <blockquote class="tr_bq"> <p> ssh [email protected] </p> </blockquote> <div> Type the password of the <b>root&nbsp;</b>user and hit enter. You now entered the user&#8217;s system with full privilege. </div> <div> You can shut down using <b>poweroff </b>command and to <b>log out</b> see <a href="http://sag-3.blogspot.com/2013/07/logout-using-terminal-ubuntu-linux.html" >this post</a>. </div> </div> Revert back to normal resolution after running a fullscreen app in Wine https://subinsb.com/revert-back-to-normal-resolution-after-running-a-fullscreen-app-in-wine/ Thu, 11 Jul 2013 03:30:00 +0000 https://subinsb.com/revert-back-to-normal-resolution-after-running-a-fullscreen-app-in-wine/ <div dir="ltr" style="text-align: left;" trbidi="on"> While running a <b>fullscreen</b>&nbsp;app in <b>Wine</b>&nbsp;such as games, you might not get the screen resolution back after you close the app. It&#8217;s because <b>Linux</b>&nbsp;won&#8217;t automatically change it&#8217;s resolution like <b>Windows</b>.</p> <p> But you could if you run a simple file in terminal. Here is how you could do it.<br />Create a file named <b>normal.sh</b>&nbsp;in your <b>Desktop </b>with the following contents: </p> <blockquote class="tr_bq"> <p> #!/bin/bash<br />xrandr -s 0 </p> </blockquote> <p> Save it on a place where you can open it easily. Make the file&nbsp;<b>Executable</b>&nbsp;to run it in a terminal. See <a href="http://sag-3.blogspot.com/2013/07/making-file-executable-linux.html" >this post</a> to see how you could make a file executable. </p> <p> After you run a full screen program and closed it, run the file we created to return back to the normal resolution. </p> <div class="separator" style="clear: both; text-align: center;"> <a href="//1.bp.blogspot.com/-R2xYTfVaSR8/Udra0x13VtI/AAAAAAAAC18/f5Np776DYo0/s1600/0029.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="//1.bp.blogspot.com/-R2xYTfVaSR8/Udra0x13VtI/AAAAAAAAC18/f5Np776DYo0/s1600/0029.png" /></a> </div> <p> If you get a dialog like above when executing the <b>normal.sh</b>&nbsp;click on <b>Run in Terminal</b>&nbsp;button.</div> How to make a file executable in Ubuntu Linux https://subinsb.com/how-to-make-a-file-executable-in-ubuntu-linux/ Wed, 10 Jul 2013 03:30:00 +0000 https://subinsb.com/how-to-make-a-file-executable-in-ubuntu-linux/ <div dir="ltr" style="text-align: left;" trbidi="on"> <b>Executable</b> files are files that can be used to run a program or to do a specific purpose specified in the file. Normally not all files defaultly would be executable in <b>Linux</b>&nbsp;because of security reasons. If all files are defaultly executable then the scripts can do whatever the hell they want to do in your computer. As we call them <b>VIRUSES</b>. This is one of the main reasons why you should use <b>Linux</b>. It&#8217;s virus free.</p> <p> If you want a file executable you can do it with a simple trick in <b>Ubuntu</b>.<br />Right click on the file and click <b>Properties</b>. Choose the tab <b>Permissions</b>&nbsp;and click on <b>Allow executing file as program</b>. </p> <div class="separator" style="clear: both; text-align: center;"> <a href="//3.bp.blogspot.com/-vyc_rUSU6ac/UdratpZDCiI/AAAAAAAAC10/krSRAiRw4Jo/s1600/0028.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="//3.bp.blogspot.com/-vyc_rUSU6ac/UdratpZDCiI/AAAAAAAAC10/krSRAiRw4Jo/s1600/0028.png" /></a> </div> <div class="separator" style="clear: both; text-align: left;"> After clicking close the dialog. Now the file is <b>executable</b>. While opening the file you will get a dialog : </div> <div class="separator" style="clear: both; text-align: center;"> <a href="//1.bp.blogspot.com/-ReDQr3AFPRY/UdrbA73fRCI/AAAAAAAAC2E/KB3wbLQERDg/s1600/0029.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="//1.bp.blogspot.com/-ReDQr3AFPRY/UdrbA73fRCI/AAAAAAAAC2E/KB3wbLQERDg/s1600/0029.png" /></a> </div> <div class="separator" style="clear: both; text-align: left;"> You want to execute the file so click <b>Run in Terminal</b>. </div> </div> How To Log Out Using Terminal in Ubuntu Linux https://subinsb.com/how-to-logout-using-terminal-in-ubuntu-linux/ Mon, 08 Jul 2013 22:00:00 +0000 https://subinsb.com/how-to-logout-using-terminal-in-ubuntu-linux/ <p>There is no specific command to <strong>logout</strong>ย in an <strong>Ubuntu</strong>ย system.</p> <h2 id="why-">Why ?</h2> <p>Hereโ€™s how it works. The desktop youโ€™re seeing is a separate software. They are calledย <strong>Desktopย Environments</strong> (DE). The default DE ofย <strong>Ubuntu</strong> isย <strong>Unity</strong> from Ubuntuโ€™s 11.04 versions. Before it wasย <strong>GNOME</strong>. There are many DEs for Ubuntu. Some of them are :</p> <ul> <li>Openbox</li> <li>XFCE</li> <li>LXDE</li> </ul> <p>and many more.. There are also separateย <strong>Login Managers</strong> to provide the login screen while Ubuntu is loaded. When you log in, the Login Manager starts the default DE set up on your system and when this DE program is closed or terminated, it will go back to the Login Screen or Login Manager.</p> <p>So, as to log out the user, you have to terminate the DE program. This is why there is no special command to log out.</p> <h2 id="how-">How ?</h2> <p>Now, let me show you how to terminate the DE program. Itโ€™s very easy, just like closing an application.</p> <p>First, we need to find which DEย <strong>Ubuntu</strong> is using on your system. You can find it from the small Ubuntu icon on your login screen just near Username field. Here are some other clues :</p> <ul> <li>Unity โ€“ Stylish Sidebar with icons and the Dashboard menu appears when you press Super/Windows key</li> <li>GNOME โ€“ A Footprint logo on desktop</li> <li>XFCE โ€“ Thereโ€™s a mice logo somewhere on your desktop</li> <li>LXDE โ€“ Have a Windows like Panel at the bottom</li> </ul> <p>And here are the program names of the above DE except for Unity :</p> <ul> <li>GNOME โ€“ gnome-session</li> <li>XFCE โ€“ xfce4-session</li> <li>LXDE โ€“ lxsession</li> </ul> <p>Open a Terminal (CTRL + ALT + T) and do one of the two methods shown below :</p> <h2 id="method-1">Method 1</h2> <p>Do the following command :</p> <pre class="prettyprint"><code>ps aux | grep &lt;DE_program&gt;</code></pre> <p>Replaceย &quot;&lt;DE_program&gt;&quot; in the above command with the program name of DE.</p> <p>You will get a list of processes running. Find the DE program name from the list.ย Get the process id of that process from column no 2. Suppose the id is <strong>1728</strong>. To logout you should <strong>kill</strong>ย the process. For that use the following command:</p> <pre class="prettyprint"><code>kill &lt;process_id&gt;</code></pre> <p>If the process id is <strong>1728</strong>ย the code will be :</p> <pre class="prettyprint"><code>kill 1728</code></pre> <p>What the above command does is that it terminates the DE program.</p> <h2 id="method-2">Method 2</h2> <p>You can directly kill the DE program by mentioning itโ€™s program name, like this :</p> <pre class="prettyprint"><code>pkill &lt;DE_program&gt;</code></pre> <p>Replaceย &quot;&lt;DE_program&gt;&quot; in the above command with the program name of DE and execute it. This will also kill the program just like the 1st method.</p> <h2 id="unity">Unity</h2> <p>Unity has some special consideration. The log out can be initiated without killing any program. Run the command :</p> <p><span style="color: #222222;"></span></p> <pre class="prettyprint"><code>gnome-session-quit --no-prompt</code></pre> <p><span style="color: #222222;"></span></p> <p>The above will work on Unity even though the command is forย <strong>GNOME</strong>, because the program is included with every installation of Ubuntu.</p> Disabling sidebar from fading out in Blogger Dynamic Views Template https://subinsb.com/disabling-sidebar-from-fading-out-in-blogger-dynamic-views-template/ Sun, 07 Jul 2013 03:30:00 +0000 https://subinsb.com/disabling-sidebar-from-fading-out-in-blogger-dynamic-views-template/ <div dir="ltr" style="text-align: left;"> The <b>black</b>ย sidebar on the right side of the blog is hidden and is only visible when mouse is over it. This is a problem because most of the users who are visiting your blog won&#8217;t even see the sidebar. The following list shows the advantages of having a sidebar not fading out :</p> <ol style="text-align: left;"> <li> Googleย + Followers Increases </li> <li> More people will subscribe to your blog </li> <li> People will know the popularity of your blog when they see the blog stats </li> <li> and others&#8230;&#8230;. </li> </ol> <p> So I&#8217;m gonna tell you how to prevent the sidebar from fading out to the right side.<br /> First of all Go to <b>Blogger</b>ย -> <b>Template</b>ย -><b>ย Customise</b><br /> Choose <b>Advanced </b>option and click on the <b>Add CSS</b>ย button from the sub options. Paste the following code in the white box: </p> <blockquote class="tr_bq"> <p> #gadget-dock{right: 0px !important;} </p> </blockquote> <p> Screenshot: </p> <div class="separator" style="clear: both; text-align: center;"> <a style="margin-left: 1em; margin-right: 1em;" href="https://2.bp.blogspot.com/-wl7rIvS2yNA/Uda3BN6qY4I/AAAAAAAAC1k/UYqOBzYFL-U/s1600/0027.png"><img alt="" src="https://2.bp.blogspot.com/-wl7rIvS2yNA/Uda3BN6qY4I/AAAAAAAAC1k/UYqOBzYFL-U/s1600/0027.png" border="0" /></a> </div> <p> Now go to your blog and see the sidebar not moving anywhere and is standing still. </p> </div> How to execute a PHP PDO prepared statement https://subinsb.com/how-to-execute-a-php-pdo-prepared-statement/ Sat, 06 Jul 2013 03:30:00 +0000 https://subinsb.com/how-to-execute-a-php-pdo-prepared-statement/ <div dir="ltr" style="text-align: left;"> <b>PDO </b>&#8211; a method used to execute<b>ย SQLย </b>statements risk free. Fast, secure and easy when compared to <b>mysqli </b>and <b>mysql</b>ย functions in <b>PHP</b>.<br /> A lot of newbies including me heard about <b>PDO</b>ย mostly in the <b>2010</b>ย &#8211; <b>2013</b>ย years when a lot of sites got hacked of <b>Mysql</b>ย <b>Injection</b>. <b>PDO</b>ย is the easiest and safest way to execute an <b>SQL</b>ย code, complete risk free.<br /> In this post I&#8217;m gonna tell you how to execute a prepared statement in <b>PDO </b>and the common mistakes made by programmers which results an error while executing <b>SQL</b>ย code.</p> <div id="toc_container" class="no_bullets"> <p class="toc_title"> Contents </p> <pre><code>&lt;ul class=&quot;toc_list&quot;&gt; &lt;li&gt; &lt;a href=&quot;#how-to-execute-a-prepared-statement&quot;&gt;&lt;span class=&quot;toc_number toc_depth_1&quot;&gt;1&lt;/span&gt; How to execute a prepared statement ?&lt;/a&gt; &lt;/li&gt; &lt;li&gt; &lt;a href=&quot;#common-mistakes&quot;&gt;&lt;span class=&quot;toc_number toc_depth_1&quot;&gt;2&lt;/span&gt; Common mistakes&lt;/a&gt;&lt;ul&gt; &lt;li&gt; &lt;ul&gt; &lt;li&gt; &lt;a href=&quot;#-right-way&quot;&gt;&lt;span class=&quot;toc_number toc_depth_3&quot;&gt;2.0.1&lt;/span&gt; ย  ย Right Way:&lt;/a&gt; &lt;/li&gt; &lt;li&gt; &lt;a href=&quot;#-right-way-2&quot;&gt;&lt;span class=&quot;toc_number toc_depth_3&quot;&gt;2.0.2&lt;/span&gt; ย  ย Right Way:&lt;/a&gt; &lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;/ul&gt; </code></pre> </div> <h1 style="text-align: left;"> <span id="how-to-execute-a-prepared-statement"><b><span style="font-size: large;">How to execute a prepared statement ?</span></b></span> </h1> <div> The following example shows how to execute an <b>INSERT</b>ย statement with the credentials <b>{database_name:"db",host:"localhost",username:"root",password:"subins",table:"users",fields:"name,age,city"</b><b>}</b>. </div> <pre class="prettyprint"><code>&lt;?php $name=$_POST['name']; $age=$_POST['age']; $city=$_POST['city']; $db = new PDO('mysql:dbname=&lt;span style="color: red;">db&lt;/span>;host=&lt;span style="color: red;">127.0.0.1&lt;/span>', '&lt;span style="color: red;">root&lt;/span>', '&lt;span style="color: red;">subins&lt;/span>'); $sql=$db-&gt;prepare("INSERT INTO users (name,age,city) VALUES(?,?,?)"); $sql-&gt;execute(array($name,$age,$city)); ?&gt;</code></pre> <h1 style="text-align: left;"> <span id="common-mistakes"><span style="font-size: large;"><b>Common mistakes</b></span></span> </h1> <div> Now the common mistakes made while executing a code like above. </div> <div> 1. Some will put variables inside <b>execute</b>ย function instead of putting it in <b>array</b>ย like below: </div> <blockquote class="tr_bq"> <p> $sql->execute($name,$age,$city); </p> </blockquote> <div> <h3 style="text-align: left;"> <span id="-right-way"><span style="color: #6aa84f; font-size: large;"><b>ย  ย Right Way:</b></span></span> </h3> </div> <blockquote class="tr_bq"> <p> $sql->execute(array($name,$age,$city)); </p> </blockquote> <div> 2. The other mistake is calling a function from <b>$db</b>ย instead of <b>$sql</b>ย like the following: </div> <div> <blockquote class="tr_bq"> <p> $sql=$db->prepare("INSERT INTO users (name,age,city) VALUES(?,?,?)");<br /> $db->execute(array($name,$age,$city)); </p> </blockquote> </div> <div> <h3 style="text-align: left;"> <span id="-right-way-2"><b style="color: #6aa84f; font-size: x-large;">ย  ย </b><b style="color: #6aa84f;"><span style="font-size: large;">Right Way:</span></b></span> </h3> </div> <div> <blockquote class="tr_bq"> <p> $sql=$db->prepare("INSERT INTO users (name,age,city) VALUES(?,?,?)");<br /> $sql->execute(array($name,$age,$city)); </p> </blockquote> </div> <div> </div> </div> How to redirect users to a page in PHP https://subinsb.com/how-to-redirect-users-to-a-page-in-php/ Fri, 05 Jul 2013 03:30:00 +0000 https://subinsb.com/how-to-redirect-users-to-a-page-in-php/ <div dir="ltr" style="text-align: left;" trbidi="on"> If you want to redirect users to a specific page or url like when user is not logged in or something in <b>PHP&nbsp;</b>then you can accomplish this with <b>header</b>&nbsp;function or by <b>Javascript</b>&nbsp;printed by&nbsp;<b>echo </b>function.<br />The following example will redirect user to <b>http://subins.hp.af.cm</b></p> <blockquote class="tr_bq"> <p> <?php header("Location: http://subins.hp.af.cm"); ?> </p> </blockquote> <p> Or you can use the normal <b>Javascript </b>: </p> <blockquote class="tr_bq"> <p> <?php echo "<script>window.location=&#8217;http://subins.hp.af.cm&#8217;;</script>"; ?> </p> </blockquote> <p> <span style="font-size: large;"><b>What&#8217;s the difference ?</b></span><br /><b><br /></b><b>header</b>&nbsp;function is called in server itself not when the page reaches the browser. So no content will load, instead the client&#8217;s page will be redirected to the specified url. </p> <p> <b>Javascript</b>&nbsp;redirection takes place in browser. So when the page loads to the <b>Javascript</b>&nbsp;redirect call the user will be redirected. It takes some time if you put the redirection code below<b>&nbsp;</b>script loading or stylesheet loading. </p> <p> So it&#8217;s <b>better to use header</b>&nbsp;than calling a redirection in&nbsp;<b>Javascript</b>. If <b>header </b>function won&#8217;t work then you can use <b>Javascript</b>&nbsp;redirection. It&#8217;s that simple.</div> How To Integrate Disqus Into Blogger Dynamic Views https://subinsb.com/how-to-integrate-disqus-into-blogger-dynamic-views/ Thu, 04 Jul 2013 03:30:00 +0000 https://subinsb.com/how-to-integrate-disqus-into-blogger-dynamic-views/ <p><strong>Disqus</strong>ย works in normal <strong>Blogger</strong>ย template but wonโ€™t work in <strong>Dynamic Views</strong>ย because it donโ€™t support <strong>HTML/Javascript</strong>ย widget. But you can edit the contents in <strong>head</strong>ย tag of Template and I found a way to integrate the <strong>Disqus</strong>ย commenting system in to <strong>Blogger</strong>. Iโ€™m gonna show you how to do that.</p> <div class="padlinks"> <a class="demo" href="http://gadgetsyoulike.blogspot.in/">DEMO</a> </div> <h1 id="works-on">Works On</h1> <ol> <li>Sidebar</li> <li>Classic</li> <li>Flipcard</li> <li>Magazine</li> <li>Mosaic</li> <li>Snapshot</li> <li>Timeslide</li> </ol> <h1 id="disadvantages">Disadvantages</h1> <p>On Classic Templates <strong>Disqus</strong> will only be available for the first post, because they wonโ€™t allow you to put more than 1ย <strong>Disqus</strong>ย Comment box on a page</p> <h1 id="dependencies">Dependencies</h1> <ol> <li>Sharing buttons below posts should be Enabled</li> <li>Google + Comments should be hidden</li> <li>Blogger Default Comments should be hidden</li> </ol> <h1 id="current-version">Current Version</h1> <p>Updated on 2017 July 29.</p> <div class="separator" style="clear: both; text-align: center;"> <a style="margin-left: 1em; margin-right: 1em;" href="//4.bp.blogspot.com/-KX5aGPTMgK8/UdQ1klD4sMI/AAAAAAAAC1Q/PHjGEz__13s/s1366/0026.png"><img src="//4.bp.blogspot.com/-KX5aGPTMgK8/UdQ1klD4sMI/AAAAAAAAC1Q/PHjGEz__13s/s1600/0026.png" alt="" border="0" /></a> </div> <p>First of all go to <strong>Blogger</strong>ย -&gt;**ย Settings**ย -&gt; **Posts and Comments **and change the **Comment Location **option to <strong>Hide</strong>. If you enabled <strong>Googleย + Comments</strong>, Please disable that too.</p> <p>You have two options :</p> <ul> <li>Include the code below in &quot;Text/JavaScript&quot; widget of Blogger</li> <li>Include the code below in your Blogger Template</li> </ul> <p>Go toย **Bloggerย **-&gt;ย **Templateย **-&gt;ย <strong>Edit HTML</strong> and Paste the following code beforeย <strong>&lt;/head&gt;</strong> :</p> <pre class="prettyprint"><code>&lt;script type='text/javascript'&gt; /** * Disqus in Blogger Dynamic views integrated by Subin Siby [http://goo.gl/jPb8TR] */ window.disqus_shortname = "<span style="background-color: #ff0;">example</span>"; // required: replace example with your forum shortname var d = document, o = d.createElement(&quot;script&quot;); o.type = &quot;text/javascript&quot;, o.async = true, o.src = &quot;https://lab.subinsb.com/projects/Francium/dibd/load.min.js&quot;; d.getElementsByTagName(&#39;head&#39;)[0].appendChild(o); &lt;/script&gt;</code></pre> <p>Replace the <span style="background-color: #ff0;">yellow color background</span> text <code>example</code> in the above code with your <strong>Disqus</strong>ย shortname. Example:ย <strong>subinsdemos</strong>ย from <strong>subinsdemos.disqus.com</strong>.</p> <p>Itโ€™s that simple. Your blog posts will now have a <strong>Disqus</strong>ย comment box. Enjoy !!</p> <ul> <li><strong>UPDATE</strong> : &quot;2015-07-14&quot; The Sidebar first post problem has been fixed.</li> <li><strong>UPDATE</strong> : &quot;2015-09-24&quot; An Improved version was released.</li> <li><strong>UPDATE</strong> : &quot;2016-02-05&quot; Fixed bugs. Thanks <a href="//subinsb.com/how-to-integrate-disqus-into-blogger-dynamic-views/#comment-2497491925">Spikeren</a>.</li> <li><strong>UPDATE</strong> : &quot;2017-07-29&quot; Changed URL to HTTPS. Thanks <a href="//subinsb.com/how-to-integrate-disqus-into-blogger-dynamic-views/#comment-3436277830">Transmission Radio</a>.</li> <li><strong>UPDATE</strong> : &quot;2019-11-07&quot; Fixed bug in code display. Thanks <a href="//subinsb.com/how-to-integrate-disqus-into-blogger-dynamic-views/#comment-4678866719">Amber</a>.</li> </ul> <p>If you have any problems/suggestions/feedback just comment inย <strong>Disqus</strong>ย below.</p> Check whether a site is XSS vulnerable or not. https://subinsb.com/check-whether-a-site-is-xss-vulnerable-or-not/ Wed, 03 Jul 2013 03:30:00 +0000 https://subinsb.com/check-whether-a-site-is-xss-vulnerable-or-not/ <div dir="ltr" style="text-align: left;" trbidi="on"> <span style="font-family: inherit;"><b>XSS</b>&nbsp;is a method to hack sites which most of the newbie programmers don&#8217;t know. Here is a quick way to identify if a site is vulnerable to it. Go to a site which offers searching or other <b>GET</b>&nbsp;parameters which are outputted in the site&#8217;s page.</span><br /><span style="font-family: inherit;"><br /></span><span style="font-family: inherit;">Instead of the value in one of the&nbsp;<b>GET</b>&nbsp;parameter use the following value :</span></p> <blockquote class="tr_bq"> <p> <span style="font-family: inherit;"><span style="background-color: white; color: #3d3b3b; line-height: 24px;"><h1>XSS Vulnerability checker by Subin Siby<h1></span><span style="background-color: white; color: #3d3b3b; line-height: 24px;"><script>alert(&#8216;Site is XSS Vulnerable&#8217;)</script></span></span> </p> </blockquote> <p> <span style="background-color: white; color: #3d3b3b; font-family: 'Droid Sans'; font-size: 16px; line-height: 24px;">For example a site with the <b>GET</b>&nbsp;parameter <b>query </b>with value <b>subins</b>&nbsp;and the url will be :</span> </p> <blockquote class="tr_bq"> <p> <span style="background-color: white; color: #3d3b3b; font-family: 'Droid Sans'; font-size: 16px; line-height: 24px;">http://subins.com/search.php?query=</span><span style="background-color: #bf9000; font-family: 'Droid Sans'; font-size: 16px; line-height: 24px;"><span style="color: white;">subins</span></span> </p> </blockquote> <p> <span style="color: #3d3b3b; font-family: Droid Sans;"><span style="line-height: 24px;">For such a site you have to replace the parameter value with this:</span></span> </p> <blockquote class="tr_bq"> <p> <span style="background-color: white; color: #3d3b3b; line-height: 24px;"><h1>XSS Vulnerability checker by Subin Siby<h1></span><span style="background-color: white; color: #3d3b3b; line-height: 24px;"><script>alert(&#8216;Site is XSS Vulnerable&#8217;)</script></span> </p> </blockquote> <p> <span style="background-color: white; color: #3d3b3b; line-height: 24px;">If the site outputs the <b>GET</b>&nbsp;type&nbsp;parameter then you will get a javascript alert. The alert means that the site is vulnerable to <b>XSS</b>.</span><br /><span style="background-color: white; color: #3d3b3b; line-height: 24px;">This trick can be also used in <b>POST</b>&nbsp;type parameter by injecting the code mentioned to the input field.</span></div> Why you should switch to Linux from Windows 8 https://subinsb.com/why-you-should-switch-to-linux-from-windows-8/ Tue, 02 Jul 2013 16:10:00 +0000 https://subinsb.com/why-you-should-switch-to-linux-from-windows-8/ <div dir="ltr" style="text-align: left;" trbidi="on"> <div class="separator" style="clear: both; text-align: left;"> <span style="font-size: large;">Definition of <b>Windows</b> : An Operating System that helps <b>Microsoft Corporation</b>&nbsp;increase their income and helps you to empty your wallet.</span> </div> <div class="separator" style="clear: both; text-align: left;"> <span style="font-size: large;"><br /></span> </div> <div class="separator" style="clear: both; text-align: left;"> <span style="font-size: large;">Definition of <b>Linux</b>&nbsp;: An Operating System that helps users in a great manner and not for the profit of the company.</span> </div> <div class="separator" style="clear: both; text-align: left;"> <span style="font-size: large;"><br /></span> </div> <div class="separator" style="clear: both; text-align: left;"> Here is why you should switch to <b>Linux</b>&nbsp;from <b>Windows</b> </div> <div class="separator" style="clear: both; text-align: left;"> </div> <div class="separator" style="clear: both; text-align: center;"> <a href="//4.bp.blogspot.com/-YqA3qcSDipw/UdL6YQMYoqI/AAAAAAAAC1A/de516bs-S8s/s1600/0025.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="//4.bp.blogspot.com/-YqA3qcSDipw/UdL6YQMYoqI/AAAAAAAAC1A/de516bs-S8s/s1600/0025.png" /></a> </div> </div> Is embedding video from YouTube an Adsense violation ? https://subinsb.com/is-embedding-video-from-youtube-an-adsense-violation/ Tue, 02 Jul 2013 03:30:00 +0000 https://subinsb.com/is-embedding-video-from-youtube-an-adsense-violation/ <div dir="ltr" style="text-align: left;" trbidi="on"> Many embed <b>YouTube</b>&nbsp;video in to their blogs. This is a adsense violation if the video has:</p> <ul style="text-align: left;"> <li> Copyright content </li> <li> Owner is not you </li> <li> Video is Copyrighted and no one is allowed to put it on a site </li> </ul> <p> The reasons above may be a reason why your <b>Adsense</b>&nbsp;application was rejected. Please <b><span style="font-size: large;">THINK BEFORE YOU ACT</span></b>&nbsp;while writing each blog posts. You should make sure that the post you are about to write isn&#8217;t a copied content or doesn&#8217;t contain a copyrighted material such as images, videos etc&#8230;&#8230;<br />These rules not only applicable to <b>YouTube</b>&nbsp;videos but to all sites that offer video uploads and embedding such as <b>DailyMotion</b>, <b>Vimeo</b>&nbsp;etc&#8230;.</div> How to show Disqus comment count in Blogger https://subinsb.com/how-to-show-disqus-comment-count-in-blogger/ Mon, 01 Jul 2013 03:30:00 +0000 https://subinsb.com/how-to-show-disqus-comment-count-in-blogger/ <p>Many of sites have switched to <strong>Disqus</strong>ย comment system. Itโ€™s fast, easy and simple to use. Many wanted to show the comment count on their homepages. For showing the comment count on your **Blogger Blogย **you can just do a simple trick.</p> <p>Go to <strong>Blogger <strong>-&gt;</strong>ย Template</strong>ย -&gt; <strong>Edit HTML</strong>.</p> <p>Place this <strong>Javascript</strong>ย code above <strong></body></strong>.</p> <pre class="prettyprint"><code>&lt;script type="text/javascript"&gt; /* * * CONFIGURATION VARIABLES: EDIT BEFORE PASTING INTO YOUR WEBPAGE * * */ var disqus_shortname = '&lt;span style="background-color: yellow;">subinsblog&lt;/span>'; // required: replace example with your forum shortname /* * * DON'T EDIT BELOW THIS LINE * * */ (function () { var s = document.createElement('script'); s.async = true; s.type = 'text/javascript'; s.src = 'http://' + disqus_shortname + '.disqus.com/count.js'; (document.getElementsByTagName('HEAD')[0] || document.getElementsByTagName('BODY')[0]).appendChild(s); }()); &lt;/script&gt;</code></pre> <p>Replace the <span style="background-color: yellow;">yellow background</span> text above to your **Disqus **shortname example: <strong>subinsblog</strong>ย from <strong>subinsblog.disqus.com</strong>ย is the <strong>shortname</strong>.</p> <p>Now place the following code anywhere on the template where you want to show comment count :</p> <pre class="prettyprint"><code>&lt;a expr:href="data:post.url + &quot;#disqus_thread&quot;"&gt;0ย Comments&lt;/a&gt;</code></pre> <p>You should place the above code anywhere insideย <strong>&lt;div class=โ€™post hentryโ€™&gt;</strong>ย or else the code wonโ€™t work.</p> How students do Hindi Homeworks https://subinsb.com/how-students-do-hindi-homeworks/ Sun, 30 Jun 2013 16:12:00 +0000 https://subinsb.com/how-students-do-hindi-homeworks/ <div dir="ltr" style="text-align: left;" trbidi="on"> <div class="separator" style="clear: both; text-align: center;"> <a href="//4.bp.blogspot.com/-6sUVJAQgkXA/UdBYY-fo39I/AAAAAAAAC0w/Bc6mKNyr4W4/s780/hindi.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="//4.bp.blogspot.com/-6sUVJAQgkXA/UdBYY-fo39I/AAAAAAAAC0w/Bc6mKNyr4W4/s1600/hindi.png" /></a> </div> <p> </div> Cohesion Force : You just canโ€™t stand it https://subinsb.com/cohesion-force-you-just-cant-stand-it/ Sun, 30 Jun 2013 16:05:00 +0000 https://subinsb.com/cohesion-force-you-just-cant-stand-it/ <div dir="ltr" style="text-align: left;" trbidi="on"> <div class="separator" style="clear: both; text-align: center;"> <a href="//3.bp.blogspot.com/-xP0kviL_MGc/UdBW3VjdsQI/AAAAAAAAC0g/awUUQnIJYs4/s1600/cohesion.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="//3.bp.blogspot.com/-xP0kviL_MGc/UdBW3VjdsQI/AAAAAAAAC0g/awUUQnIJYs4/s1600/cohesion.png" /></a> </div> <p> </div> Creating a Contact Me page for Blogger Blog https://subinsb.com/creating-a-contact-me-page-for-blogger-blog/ Fri, 28 Jun 2013 06:08:00 +0000 https://subinsb.com/creating-a-contact-me-page-for-blogger-blog/ <div dir="ltr" style="text-align: left;" trbidi="on"> <span style="font-family: inherit;"><b>Blogger </b>has added a new widget in their widget page. This widget is a <b>Contact Me</b>&nbsp;widget which allows blog visitors to contact you.</span></p> <div class="separator" style="clear: both; text-align: center;"> <a href="https://2.bp.blogspot.com/-NHz9t7Bhhww/Uc0slEnFCyI/AAAAAAAAC0Q/yrAJ6F9wgCY/s328/0023.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://2.bp.blogspot.com/-NHz9t7Bhhww/Uc0slEnFCyI/AAAAAAAAC0Q/yrAJ6F9wgCY/s1600/0023.png" /></a> </div> <p> <span style="font-family: inherit;"><br /></span> </p> <div class="separator" style="clear: both; text-align: center;"> <a href="//3.bp.blogspot.com/-0MIXMyRVXyI/Uc0eBfNy9cI/AAAAAAAACzw/MNCjZ_d8MG4/s678/0022.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><span style="font-family: inherit;"><img border="0" src="//3.bp.blogspot.com/-0MIXMyRVXyI/Uc0eBfNy9cI/AAAAAAAACzw/MNCjZ_d8MG4/s1600/0022.png" /></span></a> </div> <div> <span style="font-family: inherit;"><br /></span> </div> <div> <span style="font-family: inherit;">This can be added in your blog sidebar or footer. In this tutorial I will tell you to how to add this to a blog page.</span> </div> <div> <span style="font-family: inherit;">Create a blank page from <b>Blogger -> Pages -> New Page -> Blank Page</b></span> </div> <div> <span style="font-family: inherit;">Toggle to tab <b>HTML</b>&nbsp;and paste these code in the <b>HTML</b>&nbsp;textarea :</span> </div> <div> <blockquote> <p> <span style="font-family: inherit;"><div class="contact-form-widget"></span><br /><span style="font-family: inherit;"><div class="form"></span><br /><span style="font-family: inherit;"><form name="contact-form"></span><br /><span style="font-family: inherit;">Name</span><br /><span style="font-family: inherit;"><br /></span><br /><span style="font-family: inherit;"><input class="contact-form-name" id="ContactForm1_contact-form-name" name="name" size="30&#8243; type="text" value="" /></span><br /><span style="font-family: inherit;">Email</span><br /><span style="font-family: inherit;"><span style="font-weight: bolder;">*</span></span><br /><span style="font-family: inherit;"><br /></span><br /><span style="font-family: inherit;"><input class="contact-form-email" id="ContactForm1_contact-form-email" name="email" size="30&#8243; type="text" value="" /></span><br /><span style="font-family: inherit;">Message</span><br /><span style="font-family: inherit;"><span style="font-weight: bolder;">*</span></span><br /><span style="font-family: inherit;"><br /></span><br /><span style="font-family: inherit;"><textarea class="contact-form-email-message" cols="25&#8243; id="ContactForm1_contact-form-email-message" name="email-message" rows="5&#8243;></textarea><br /></span><br /><span style="font-family: inherit;"><br /></span><br /><span style="font-family: inherit;"><input class="</span><span style="background-color: white; font-family: inherit; white-space: pre-wrap;">contact-form-button contact-form-button-submit</span><span style="font-family: inherit;">" id="ContactForm1_contact-form-submit" type="button" value="Send" /></span><p style="display: inline-block;">Powered By <a href="http://sag-3.blogspot.com">Subin&#8217;s Blog</a></p><br /><span style="font-family: inherit;"><div style="max-width: 222px; text-align: center; width: 100%;"></span><br /><span style="font-family: inherit;"><div class="contact-form-error-message" id="ContactForm1_contact-form-error-message"></span><br /><span style="font-family: inherit;"></div></span><br /><span style="font-family: inherit;"><div class="contact-form-success-message" id="ContactForm1_contact-form-success-message"></span><br /><span style="font-family: inherit;"></div></span><br /><span style="font-family: inherit;"></div></span><br /><span style="font-family: inherit;"></form></span><br /><span style="font-family: inherit;"></div></span> </p> </blockquote> </div> <div> Now we have to register the widget to make it work properly. To do that Go to <b>Template -> Edit HTML</b>&nbsp;and scrollto the bottom of the code and paste the following code before <<b>/html></b> </div> <div> <blockquote class="tr_bq"> <p> <script><br />_WidgetManager._RegisterWidget(&#8216;_ContactFormView&#8217;, new _WidgetInfo(&#8216;ContactForm1&#8217;, &#8216;lowerbar2&#8217;, null, document.getElementById(&#8216;ContactForm1&#8217;), {&#8216;contactFormMessageSendingMsg&#8217;: &#8216;Sending&#8230;&#8217;, &#8216;contactFormMessageSentMsg&#8217;: &#8216;Your message has been sent.&#8217;, &#8216;contactFormMessageNotSentMsg&#8217;: &#8216;Message could not be sent. Please try again later.&#8217;, &#8216;contactFormInvalidEmailMsg&#8217;: &#8216;A valid email address is required.&#8217;, &#8216;contactFormEmptyMessageMsg&#8217;: &#8216;Message field cannot be empty.&#8217;, &#8216;title&#8217;: &#8216;Contact Form&#8217;, &#8216;blogId&#8217;: &#8216;<span class="str" style="background: wheat;">YOUR BLOG ID</span>&#8216;, &#8216;contactFormNameMsg&#8217;: &#8216;Name&#8217;, &#8216;contactFormEmailMsg&#8217;: &#8216;Email&#8217;, &#8216;contactFormMessageMsg&#8217;: &#8216;Message&#8217;, &#8216;contactFormSendMsg&#8217;: &#8216;Send&#8217;, &#8216;submitUrl&#8217;: &#8216;http://www.blogger.com/contact-form.do&#8217;}, &#8216;displayModeFull&#8217;));<br /></script> </p> </blockquote> <pre><code>&lt;div&gt; &lt;span style=&quot;font-weight: bold;&quot;&gt;Replace the &lt;span style=&quot;color: red;&quot;&gt;Wheat color background text&lt;/span&gt; above to your blog id&lt;/span&gt;. See &lt;a href=&quot;http://sag-3.blogspot.com/2013/06/find-blogger-blog-id.html&quot; &gt;this post&lt;/a&gt; to see how you can find blogger blog id. &lt;/div&gt; </code></pre> </div> <div> </div> <div> When a user submits the <b>Contact Me</b>&nbsp;form you will get a mail from&nbsp;<b>Blogger </b>like this : </div> <div class="separator" style="clear: both; text-align: center;"> <a href="https://2.bp.blogspot.com/-LKR0EUOdHLg/Uc0oCbyGqgI/AAAAAAAAC0A/vxI0JhzSqhY/s855/0024.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://2.bp.blogspot.com/-LKR0EUOdHLg/Uc0oCbyGqgI/AAAAAAAAC0A/vxI0JhzSqhY/s1600/0024.png" /></a> </div> </div> How to find Blogger Blog ID https://subinsb.com/how-to-find-blogger-blog-id/ Fri, 28 Jun 2013 06:00:00 +0000 https://subinsb.com/how-to-find-blogger-blog-id/ <div dir="ltr" style="text-align: left;" trbidi="on"> You may need your <b>blogger blog id</b> for various needs. Here&#8217;s a simple tutorial on how to find the <b>blog id</b>.</p> <div> Go to your blog dashboard on <b>Blogger</b>. See the url of the page in the location bar. </div> <div> In the page url you can see a text <b>blogID= </b>followed by a number until it stops with <b>#</b>. </div> <div> Here&#8217;s a sample url : </div> <blockquote class="tr_bq"> <p> http://www.blogger.com/blogger.g?blogID=<span style="color: red;background:wheat;">123456789101112</span>#overview/src=dashboard </p> </blockquote> <div> The wheat color background text in the above url is the blog id of that blog. </div> </div> How to remove keyring password dialog in All Ubuntu versions https://subinsb.com/how-to-remove-keyring-password-dialog-in-all-ubuntu-versions/ Wed, 26 Jun 2013 12:34:00 +0000 https://subinsb.com/how-to-remove-keyring-password-dialog-in-all-ubuntu-versions/ <div dir="ltr" style="text-align: left;" trbidi="on"> You will be getting a <b>keyring unlocker</b>&nbsp;dialog to type your password to unlock the keyrings such as:</p> <ul style="text-align: left;"> <li> Password you stored in <b>Web Browsers</b>&nbsp;(Google Chrome, Chromium) </li> <li> Passwords stored in Chat and Mail Applications (Empathy, Pidgin, Evolution) </li> <li> and other passwords </li> </ul> <p> This passwords should be unlocked each time you login but won&#8217;t automatically unlock when you login. To automatically unlock you can do as follows:<br />Open Terminal (<b>CTRL&nbsp;+ ALT&nbsp;+ T</b>) and do the following command: </p> <blockquote class="tr_bq"> <p> seahorse </p> </blockquote> <p> You will get the <b>Passwords & Encryption Keys</b>&nbsp;window : </p> <div class="separator" style="clear: both; text-align: center;"> <a href="//4.bp.blogspot.com/-5KK-VyQpIhs/UcnJQbsSIbI/AAAAAAAACyg/87ANmOEd-EQ/s1600/0018.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="//4.bp.blogspot.com/-5KK-VyQpIhs/UcnJQbsSIbI/AAAAAAAACyg/87ANmOEd-EQ/s1600/0018.png" /></a> </div> <p> Right click on the folder <b>Password: default</b>&nbsp;and choose <b>Change Password </b>: </p> <div class="separator" style="clear: both; text-align: center;"> <a href="//1.bp.blogspot.com/-gYkEGrm1Bd0/UcnJNQuxQGI/AAAAAAAACyc/H1tjfZRS-Q4/s1600/0019.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="//1.bp.blogspot.com/-gYkEGrm1Bd0/UcnJNQuxQGI/AAAAAAAACyc/H1tjfZRS-Q4/s1600/0019.png" /></a> </div> <div class="separator" style="clear: both; text-align: left;"> Type the old password you used to unlock the keyring and leave the other two fields empty and click on <b>OK</b>&nbsp;button. </div> <p> You will be asked to keep passwords unencrypted :<span id="goog_397668772"></span> </p> <div class="separator" style="clear: both; text-align: center;"> <a href="//3.bp.blogspot.com/-kCmjCK_fKpw/UcrfIxH9vGI/AAAAAAAACy4/wjfVJS5H1n4/s1600/0020.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="//3.bp.blogspot.com/-kCmjCK_fKpw/UcrfIxH9vGI/AAAAAAAACy4/wjfVJS5H1n4/s1600/0020.png" /></a> </div> <div class="separator" style="clear: both; text-align: left;"> Click on <b>Use Unsafe Storage</b>&nbsp;and it&#8217;s done. The dialog won&#8217;t be seen again after you login. </div> </div> Facebook Hacker Cup 2013:Beautiful Strings solution in PHP https://subinsb.com/facebook-hacker-cup-2013beautiful-strings-solution-in-php/ Thu, 20 Jun 2013 16:31:00 +0000 https://subinsb.com/facebook-hacker-cup-2013beautiful-strings-solution-in-php/ <div dir="ltr" style="text-align: left;" trbidi="on"> <span style="font-family: inherit;">Here is the solution for FHC 2013 <b>Beautiful Strings</b> problem in <b>PHP</b>:</span></p> <blockquote class="tr_bq"> <p> <span style="font-family: inherit;">$ip = fopen(&#8216;<span style="color: red;">input.txt</span>&#8216;, "r");<br />$test_cases = trim(fgets($ip));<br />&nbsp; &nbsp; $c=1;<br />&nbsp; &nbsp; while($c!= $test_cases+1){<br />&nbsp; &nbsp; &nbsp; &nbsp; $case=preg_replace(&#8216;/[^a-z]+/&#8217;, ", strtolower(trim(fgets($ip))));<br />&nbsp; &nbsp; &nbsp; &nbsp; $vals=array_count_values(str_split($case));<br />&nbsp; &nbsp; &nbsp; &nbsp; arsort($vals);<br />&nbsp; &nbsp; &nbsp; &nbsp; $beauty=26;<br />&nbsp; &nbsp; &nbsp; &nbsp; $max_b=0;<br />&nbsp; &nbsp; &nbsp; &nbsp; foreach($vals as $v){<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $max_b +=$v*$beauty;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $beauty&#8211;;<br />&nbsp; &nbsp; &nbsp; &nbsp; }<br />&nbsp; &nbsp; &nbsp; &nbsp; print("Case #".$c.": ".$max_b);<br />&nbsp; &nbsp; &nbsp; &nbsp; if($c < $test_cases){<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; print("<br/>");<br />&nbsp; &nbsp; &nbsp; &nbsp; }<br />&nbsp; &nbsp; &nbsp; &nbsp; $c++;<br />&nbsp; &nbsp; }</span> </p> </blockquote> <p> <span style="font-family: inherit;">Replace the red highlighted text with the input file name.</span><br /><b><span style="font-family: inherit; font-size: large;"><u>Sample Output</u></span></b> </p> <blockquote class="tr_bq"> <p> Case #1: 152<br />Case #2: 754<br />Case #3: 491<br />Case #4: 729<br />Case #5: 646 </p> </blockquote> </div> Advanced Rest Client : Create and Test custom HTTP requests. https://subinsb.com/advanced-rest-client-create-and-test-custom-http-requests/ Sat, 08 Jun 2013 07:42:00 +0000 https://subinsb.com/advanced-rest-client-create-and-test-custom-http-requests/ <div dir="ltr" style="text-align: left;" trbidi="on"> I recently noticed a <b>Google Chrome Webstore</b>&nbsp;app that can be used for making a request to a web site or local site. I loved the app from the beginning. You can send a request to any site with header data, form data etc&#8230;</p> <p> You can also attach a file to the form. <span style="color: red;"><b>Ain&#8217;t that Awesome</b>.</span><br />Every web developer must have this app. Install it from <b><a href="https://chrome.google.com/webstore/detail/advanced-rest-client/hgmloofddffdnphfgcellkdfbfbjeloo" >Chrome&nbsp;Webstore</a></b> </p> <h3 style="text-align: left;"> <span style="font-size: large;">Features</span> </h3> <ul style="text-align: left;"> <li> &#8211; Integrated with Google Drive </li> <li> &#8211; It&#8217;s own backend service to store and share data between coworkers </li> <li> &#8211; convenient HTTP headers and payload editor thanks CodeMirror </li> <li> &#8211; Make a HTTP request (via XmlHttpRequest level 2) </li> <li> &#8211; Debug socket (via web socket API). </li> <li> &#8211; JSON response viewer </li> <li> &#8211; XML response viewer </li> <li> &#8211; set custom headers &#8211; even does not supported by XmlHttpRequest object </li> <li> &#8211; help with filling HTTP headers (hint + code completion) </li> <li> &#8211; add headers list as raw data or via form </li> <li> &#8211; construct POST or PUT body via raw input, form or send file(s) with request </li> <li> &#8211; set custom form encoding </li> <li> &#8211; remember latest request (save current form state and restore on load) </li> <li> &#8211; save (Ctrl+S) and open (Ctrl+O) saved request forms </li> <li> &#8211; history support </li> <li> &#8211; data import/export </li> </ul> <p> </p> <div class="separator" style="clear: both; text-align: center; vertical-align: top;"> </div> <p> <span style="vertical-align: top;">I am giving this app </span><span style="color: red; font-size: x-large; vertical-align: top;">4/5 </span><span style="font-size: x-large; vertical-align: top;">stars&nbsp;</span><br />It&#8217;s <b>4</b>&nbsp;because it doesn&#8217;t support image mime types and it gives a <b>Unexpected Token</b>&nbsp;while parsing some <b>JSON</b>&nbsp;responses.</div> Connecting database to both mysqli and mysql entension https://subinsb.com/connecting-database-to-both-mysqli-and-mysql-entension/ Sat, 08 Jun 2013 07:26:00 +0000 https://subinsb.com/connecting-database-to-both-mysqli-and-mysql-entension/ <div dir="ltr" style="text-align: left;" trbidi="on"> You can use both <b>mysql</b>&nbsp;and <b>mysqli</b>&nbsp;extension for executing <b>SQL</b>&nbsp;queries. Here is a tutorial on how to connect both the extensions to a database.</p> <p> Create a file named <b>config.php</b>&nbsp;where you will connect to the database. Put the following code in it: </p> <blockquote class="tr_bq"> <p> <?<br />$mysqli = new mysqli("<span style="color: red;">localhost</span>", "<span style="color: red;">username</span>", "<span style="color: red;">password</span>", "<span style="color: red;">db</span>");<br />if ($mysqli->connect_errno) {<br />&nbsp; &nbsp; echo "Failed to connect to MySQL: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error;<br />}<br />$bd = mysql_connect("<span style="color: red;">localhost</span>", "<span style="color: red;">username</span>", "<span style="color: red;">password</span>") or die(mysql_error());<br />mysql_select_db("<span style="color: red;">db</span>",$bd) or die(mysql_error());<br />?> </p> </blockquote> <p> Replace the red highlighted text with the credentials of your database connection. </p> </div> Check whether mysqli connection is made or not in php https://subinsb.com/check-whether-mysqli-connection-is-made-or-not-in-php/ Wed, 29 May 2013 16:37:00 +0000 https://subinsb.com/check-whether-mysqli-connection-is-made-or-not-in-php/ <div dir="ltr" style="text-align: left;" trbidi="on"> <span style="font-family: inherit;">This function helps to check whether connection the mysql server has been made or not.</span></p> <div> <span style="font-family: inherit;">Here is the code:</span> </div> <blockquote class="tr_bq"> <p> <span style="font-family: inherit;"><span style="background-color: white;"><span style="color: #007700;">if&nbsp;(</span><span style="color: #0000bb;">$mysqli</span><span style="color: #007700;">-></span><span style="color: #0000bb;">ping</span><span style="color: #007700;">())&nbsp;{</span></span></span><br /><span style="font-family: inherit;"><span style="background-color: white;"><span style="color: #007700;">echo</span><span style="color: #0000bb;">&nbsp;</span><span style="color: #007700;">(</span><span style="color: #dd0000;">"Our&nbsp;connection&nbsp;is&nbsp;ok!n"</span><span style="color: #007700;">);<br />}&nbsp;else&nbsp;{&nbsp;&nbsp;</span></span></span><span style="font-family: inherit;"><span style="background-color: white;"><span style="color: #007700;"><br /></span></span></span><span style="font-family: inherit;"><span style="background-color: white;"><span style="color: #007700;">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000bb;">printf&nbsp;</span><span style="color: #007700;">(</span><span style="color: #dd0000;">"Error:&nbsp;%sn"</span><span style="color: #007700;">,&nbsp;</span><span style="color: #0000bb;">$mysqli</span><span style="color: #007700;">-></span><span style="color: #0000bb;">error</span></span><span style="color: #007700;"><span style="background-color: white;">);<br />}</span></span></span> </p> </blockquote> <div> The <b>$mysqli</b>&nbsp;variable is a connection made via <b>mysqli</b>&nbsp;function. </div> <div> Know more about <b>mysqli ping</b>&nbsp;function <a href="http://in2.php.net/manual/en/mysqli.ping.php" >here</a>. </div> </div> Hide File Extensions In Browsers Using .htaccess https://subinsb.com/hide-file-extensions-in-client-browser-using-htaccess/ Wed, 29 May 2013 04:12:00 +0000 https://subinsb.com/hide-file-extensions-in-client-browser-using-htaccess/ <p><span style="background-color: white; font-family: inherit;">Many of us programmers want to hide the file extension of server files such as <b>.php</b>, <b>.jsp</b>, <b>.py</b>ย etcโ€ฆ.</span></p> <div> <span style="background-color: white; font-family: inherit;">You can easily hide these extensions with the help of a <b>.htaccess</b>ย file. This feature is only available to Apache servers.</span> </div> <div> <span style="background-color: white; font-family: inherit;">Create a file named <b>.htaccess</b>ย if your root directory of site doesn&#8217;t have one.</span> </div> <div> <span style="background-color: white; font-family: inherit;">Add these lines to the <b>.htaccess</b>ย file :</span> </div> <div> <pre class="prettyprint"><code>&lt;span style="background-color: white; font-family: inherit;">&lt;span class="kw1" style="border: 0px; color: #2060a0; line-height: 18.200000762939453px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; white-space: nowrap;">RewriteEngine&lt;/span>&lt;span style="line-height: 18.200000762939453px; white-space: nowrap;">ย &lt;/span>&lt;span class="kw2" style="border: 0px; color: #2060a0; line-height: 18.200000762939453px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; white-space: nowrap;">on&lt;/span>&lt;/span> &lt;span style="background-color: white; font-family: inherit;">&lt;span class="kw1" style="border: 0px; color: #2060a0; line-height: 18.200000762939453px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; white-space: nowrap;">RewriteCond&lt;/span>&lt;span style="line-height: 18.200000762939453px; white-space: nowrap;">ย %{REQUEST_FILENAME} !-d&lt;/span>&lt;/span> &lt;span style="background-color: white; font-family: inherit;">&lt;span class="kw1" style="border: 0px; color: #2060a0; line-height: 18.200000762939453px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; white-space: nowrap;">RewriteCond&lt;/span>&lt;span style="line-height: 18.200000762939453px; white-space: nowrap;">ย %{REQUEST_FILENAME}.php -f&lt;/span>&lt;/span> &lt;span style="background-color: white; font-family: inherit;">&lt;span class="kw1" style="border: 0px; color: #2060a0; line-height: 18.200000762939453px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; white-space: nowrap;">RewriteRule&lt;/span>&lt;span style="line-height: 18.200000762939453px; white-space: nowrap;">ย .* $0.php&lt;/span>&lt;/span></code></pre> </div> <div> The above lines wll hide the <b>PHP</b>ย extension. If you want to hide the <b>HTML</b>ย and other extensionย <span style="line-height: 18.200000762939453px; white-space: nowrap;">too add these line afterย </span> </div> <div> <pre class="prettyprint"><code>&lt;span class="kw1" style="border: 0px; color: #2060a0; line-height: 18.200000762939453px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; white-space: nowrap;">RewriteCond&lt;/span>&lt;span style="line-height: 18.200000762939453px; white-space: nowrap;">ย %{REQUEST_FILENAME}.php -f&lt;/span></code></pre> </div> <div> <span style="line-height: 18.200000762939453px; white-space: nowrap;">as you want. You can also replace it if you don&#8217;t want php extensions to hide.</span> </div> <h2 id="html">HTML</h2> <div> <pre class="prettyprint"><code>&lt;span class="kw1" style="border: 0px; color: #2060a0; line-height: 18.200000762939453px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; white-space: nowrap;">RewriteCond&lt;/span>&lt;span style="line-height: 18.200000762939453px; white-space: nowrap;">ย %{REQUEST_FILENAME}.html -f&lt;/span></code></pre> </div> <h2 id="jsp">JSP</h2> <div> <pre class="prettyprint"><code>&lt;span class="kw1" style="border: 0px; color: #2060a0; line-height: 18.200000762939453px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; white-space: nowrap;">RewriteCond&lt;/span>&lt;span style="line-height: 18.200000762939453px; white-space: nowrap;">ย %{REQUEST_FILENAME}.jsp -f&lt;/span></code></pre> </div> <h2 id="asp">ASP</h2> <div> <pre class="prettyprint"><code>&lt;span class="kw1" style="border: 0px; color: #2060a0; line-height: 18.200000762939453px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; white-space: nowrap;">RewriteCond&lt;/span>&lt;span style="line-height: 18.200000762939453px; white-space: nowrap;">ย %{REQUEST_FILENAME}.asp -f&lt;/span></code></pre> </div> <h2 id="py">PY</h2> <div> <pre class="prettyprint"><code>&lt;span class="kw1" style="border: 0px; color: #2060a0; line-height: 18.200000762939453px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; white-space: nowrap;">RewriteCond&lt;/span>&lt;span style="line-height: 18.200000762939453px; white-space: nowrap;">ย %{REQUEST_FILENAME}.py -f&lt;/span></code></pre> </div> <h2 id="js">JS</h2> <div> <pre class="prettyprint"><code>&lt;span class="kw1" style="border: 0px; color: #2060a0; line-height: 18.200000762939453px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; white-space: nowrap;">RewriteCond&lt;/span>&lt;span style="line-height: 18.200000762939453px; white-space: nowrap;">ย %{REQUEST_FILENAME}.js -f&lt;/span></code></pre> </div> <div> <span style="background-color: white; font-family: inherit;">You really should go into each page and delete the extensions, but I believe you can redirect them by adding another rule :</span> </div> <div> <pre class="prettyprint"><code>&lt;span style="color: #2060a0;">RewriteRule &lt;/span>(.*).&lt;span style="color: red;">html&lt;/span> $1 [R=301,NC]</code></pre> </div> <div> <span style="background-color: white; line-height: 18.200000762939453px; white-space: nowrap;"><span style="font-family: inherit;">The above rule will redirect all <b>.html</b>ย pages to non <b>.html</b>ย extension page.</span></span> </div> <div> <span style="background-color: white; line-height: 18.200000762939453px; white-space: nowrap;"><span style="font-family: inherit;">Replace the <span style="color: red;">red </span>highlighted text with any extension you want to redirect.</span></span> </div> Create Facebook Like System With jQuery, MySQL, PDO In PHP https://subinsb.com/create-facebook-like-system-with-jquery-mysql-pdo-in-php/ Fri, 24 May 2013 08:14:00 +0000 https://subinsb.com/create-facebook-like-system-with-jquery-mysql-pdo-in-php/ <div dir="ltr" style="text-align: left;"> <p> <span style="font-family: inherit;">Facebook have it&#8217;s own like system which pretty good. This post will tell you how to create a "Like system" like that of Facebook. All you have to need is <strong>jQuery</strong>,ย <strong>MySQL</strong> Database andย <strong>PDO</strong> <strong>PHP</strong> extension. This technic is partially used in my social network, <a href="http://open.subinsb.com">Open</a>. See the demo there in the social network. But you have to signup.</span> </p> <div> <div class="padlinks"> <a class="demo" href="http://open.subinsb.com">DEMO</a> </div> </div> <div> <div> <span style="color: red; font-family: inherit;">You should create a user table with users data includingย <b>user id</b>,ย <b>username</b>,ย <b>password</b>,ย <b>email</b>ย etc&#8230;</span> </div> <pre><code>&lt;div&gt; &lt;span style=&quot;color: red; font-family: inherit;&quot;&gt;The table should be like this:&lt;/span&gt; &lt;/div&gt; </code></pre> </div> <div class="separator" style="clear: both; text-align: center;"> <span style="font-family: inherit;"><a style="margin-left: 1em; margin-right: 1em;" href="//3.bp.blogspot.com/-EP5ux4A5LHo/UZ8U5arHNfI/AAAAAAAACnQ/hRNPcrJPA9I/s1600/users.png"><img src="//3.bp.blogspot.com/-EP5ux4A5LHo/UZ8U5arHNfI/AAAAAAAACnQ/hRNPcrJPA9I/s1600/users.png" alt="" border="0" /></a></span> </div> <div> <span style="font-family: inherit;">Let&#8217;s start by creating a <b>likes</b>ย table where we store the like actions by the user.</span> </div> <p> <img class="aligncenter" style="line-height: 1.5em;" src="//3.bp.blogspot.com/-jd5tvgcmVlg/UZ8U8a-svNI/AAAAAAAACnc/It5MUN4TyKo/s1600/fdlikes.png" alt="" border="0" /> </p> <p> Here is the SQL code that create the likes table : </p> <pre class="prettyprint"><code>CREATE TABLE `fdlikes` ( `id` int(11) NOT NULL PRIMARY KEY AUTO_INCREMENT, `pid` int NOT NULL PRIMARY KEY , `user` varchar(25) NOT NULL UNIQUE );</code></pre> <p> <span style="font-family: inherit;">The <b>pid</b>ย field is for the <b>post</b>ย id. The <b>user</b>ย field is for the user <b>id</b>.</span> </p> <p> Create a <b>post</b>ย table to insert posts created by users. </p> </div> <pre class="prettyprint"><code>CREATE TABLE `fdposts` ( `id` int(11) NOT NULL PRIMARY KEY AUTO_INCREMENT, `user` varchar(25) NOT NULL, `message` varchar(200) NOT NULL, `likes` int(11) DEFAULT NULL, `posted` varchar(20) NOT NULL, );</code></pre> <div class="separator" style="clear: both; text-align: center;"> <a style="margin-left: 1em; margin-right: 1em;" href="//1.bp.blogspot.com/-wnAT7G4Rqj4/UZ8U7wYqNnI/AAAAAAAACnY/F8weoNZtPQg/s1600/fdposts.png"><span style="font-family: inherit;"><img src="//1.bp.blogspot.com/-wnAT7G4Rqj4/UZ8U7wYqNnI/AAAAAAAACnY/F8weoNZtPQg/s1600/fdposts.png" alt="" border="0" /></span></a> </div> <p><span style="font-family: inherit;">The <b>id </b>field is an auto increment field which decides the <b>post id</b>. <b>User</b>ย field is the userโ€™s id and <b>likes</b>ย field contains number of users who liked the post. <b>Posted</b>ย field contains the date and time in which the post was created.</span></p> <p><span style="font-family: inherit;">First of all create a <b>config</b>ย file that will connect to database. We are going to use <b>PDO</b>.</span></p> <h1 style="text-align: left;"> <span id="configphp">config.php</span> </h1> <p>This file contains theย <strong>$dbh</strong> variable which is theย <strong>PDO</strong> object weโ€™re going to use for executingย <strong>SQL</strong> queries.</p> <pre class="prettyprint"><code>$dbh = new PDO('mysql:dbname=database;host=127.0.0.1', 'username', 'password');</code></pre> <h1 style="text-align: left;"> <span id="showing-likeunlike-button"><span style="font-family: inherit;">Showing Like/Unlike Button</span></span> </h1> <pre class="prettyprint"><code>&lt;?php require_once "config.php"; $pid='1'; //Post id - Post is "Hi everybody" $uid='1'; //User id - User is "Subin Siby" $sql=$dbh-&gt;prepare("SELECT * FROM fdlikes WHERE pid=? and user=?"); $sql-&gt;execute(array($pid, $uid)); if($sql-&gt;rowCount()==1){ echo '&lt;a href="#" class="like" id="'.$pid.'" title="Unlike"&gt;Unlike&lt;/a&gt;'; }else{ echo '&lt;a href="#" class="like" id="'.$pid.'" title="Like"&gt;Like&lt;/a&gt;'; } ?&gt;</code></pre> <p>Place the above code anywhere you like.</p> <div> <h1 style="text-align: left;"> <span id="jquery-code-to-post-likeunlike-action">jQuery code to post like/unlike action</span> </h1> <div> <pre class="prettyprint"><code>&lt;span style="line-height: 16px;">&lt;span style="font-family: inherit;">$(document).ready(function(){ $(document).on('click', '.like', function(){&lt;/span>&lt;/span> &lt;span style="line-height: 16px;">&lt;span style="font-family: inherit;">if($(this).attr('title') == 'Like'){&lt;/span>&lt;/span> &lt;span style="line-height: 16px;">&lt;span style="font-family: inherit;"> $that = $(this); $.post('action.php', {pid:$(this).attr('id'), action:'like'},function(){&lt;/span>&lt;/span> &lt;span style="line-height: 16px;">&lt;span style="font-family: inherit;"> ย $that.text('Unlike');&lt;/span>&lt;/span> &lt;span style="line-height: 16px;">&lt;span style="font-family: inherit;"> ย $that.attr('title','Unlike');&lt;/span>&lt;/span> &lt;span style="line-height: 16px;">&lt;span style="font-family: inherit;"> });&lt;/span>&lt;/span> &lt;span style="line-height: 16px;">&lt;span style="font-family: inherit;">}else{&lt;/span>&lt;/span> &lt;span style="line-height: 16px;">&lt;span style="font-family: inherit;"> if($(this).attr('title') == 'Unlike'){&lt;/span>&lt;/span> &lt;span style="line-height: 16px;">&lt;span style="font-family: inherit;"> ย $that = $(this); $.post('action.php', {pid:$(this).attr('id'), action:'unlike'},function(){&lt;/span>&lt;/span> &lt;span style="line-height: 16px;">&lt;span style="font-family: inherit;"> ย  $that.text('Like');&lt;/span>&lt;/span> &lt;span style="line-height: 16px;">&lt;span style="font-family: inherit;"> ย  $that.attr('title','Like');&lt;/span>&lt;/span> &lt;span style="line-height: 16px;">&lt;span style="font-family: inherit;"> ย });&lt;/span>&lt;/span> &lt;span style="line-height: 16px;">&lt;span style="font-family: inherit;"> }&lt;/span>&lt;/span> &lt;span style="line-height: 16px;">&lt;span style="font-family: inherit;">}&lt;/span>&lt;/span> &lt;span style="line-height: 16px;">&lt;span style="font-family: inherit;"> }); });&lt;/span>&lt;/span></code></pre> <pre><code>&lt;p&gt; The above code can be placed insideย &lt;strong&gt;script&lt;/strong&gt; element or as an external file. &lt;/p&gt; </code></pre> </div> <h1 style="text-align: left;"> <span id="php-code-to-likeunlike-to-which-jquery-sends-request">PHP code to like/unlike to which jQuery sends request</span> </h1> <p> <span style="font-family: inherit;"><span style="line-height: 16px;">This file is <b>action.php</b></span></span> </p> <pre class="prettyprint"><code>&lt;?php require_once "config.php"; $pid=$_POST['pid']; $user=$_COOKIE['user']; $action=$_POST['action']; if ($action=='like'){ $sql=$dbh-&gt;prepare("SELECT * FROM fdlikes WHERE pid=? and user=?"); $sql-&gt;execute(array($pid,$user)); $matches=$sql-&gt;rowCount(); if($matches==0){ $sql=$dbh-&gt;prepare("INSERT INTO fdlikes (pid, user) VALUES(?, ?)"); $sql-&gt;execute(array($pid,$user)); $sql=$dbh-&gt;prepare("UPDATE fdposts SET likes=likes+1 WHERE id=?"); $sql-&gt;execute(array($pid)); }else{ die("There is No Post With That ID"); } } if ($action=='unlike'){ $sql = $dbh-&gt;prepare("SELECT 1 FROM `fdlikes` WHERE pid=? and user=?"); $sql-&gt;execute(array($pid,$user)); $matches = $sql-&gt;rowCount(); if ($matches != 0){ $sql=$dbh-&gt;prepare("DELETE FROM fdlikes WHERE pid=? AND user=?"); $sql-&gt;execute(array($pid,$user)); $sql=$dbh-&gt;prepare("UPDATE fdposts SET likes=likes-1 WHERE id=?"); $sql-&gt;execute(array($pid)); } } ?&gt;</code></pre> <p> <span style="font-family: inherit;">That&#8217;s it. Try it out. If there&#8217;s any bugs, problems or questions feel free to comment below on Disqus.</span> </p> </div> Friendshood Update new feature โ€“ Post to Facebook https://subinsb.com/friendshood-update-new-feature-post-to-facebook/ Fri, 10 May 2013 14:33:00 +0000 https://subinsb.com/friendshood-update-new-feature-post-to-facebook/ <div dir="ltr" style="text-align: left;" trbidi="on"> I updated <b><a href="http://fd-subins.hp.af.cm/" >Friendshood</a></b>. The new feature is that the user can post status update and photos to <b>Facebook</b>&nbsp;along with posting in <b><a href="http://fd-subins.hp.af.cm/" >Friendshood</a></b>. I implemented this function using <b>Facebook PHP SDK</b>. You can download the <b>SDK</b>&nbsp;<a href="http://get-subins.hp.af.cm/view.php?id=346" >here</a>.</p> <p> It was not quite easy. It was hard to make <b>Picture</b>&nbsp;uploading function along with the normal status update. Next I&#8217;m gonna implement twitter posting from <a href="http://fd-subins.hp.af.cm/" >Friendshood</a>. </p> <p> I&#8217;m gonna tell you how to post a status update in the following posts. Wait for it. </p> </div> How to get Facebook PHP SDK and install it https://subinsb.com/how-to-get-facebook-php-sdk-and-install-it/ Fri, 10 May 2013 13:59:00 +0000 https://subinsb.com/how-to-get-facebook-php-sdk-and-install-it/ <div dir="ltr" style="text-align: left;" trbidi="on"> Download&nbsp;<b>Facebook PHP SDK</b>&nbsp;from <a href="http://get-subins.hp.af.cm/view.php?id=346" >here</a>.<br /><span style="color: red;">Extract the folder <b>src</b>&nbsp;in the&nbsp;zip file to a folder named <b>fbsdk </b>in the home directory of your app.</span></p> <p> <b><span style="font-size: large;"><u>Installation</u></span></b> </p> <p> There is no installation. You can run the functions in the file if you put this line at top of each file you run the <b>SDK</b>&nbsp;functions : </p> <blockquote class="tr_bq"> <p> include(&#8216;fbsdk/facebook.php&#8217;); </p> </blockquote> <p> <b>Facebook</b>&nbsp;<b>SDK</b>&nbsp;requires the following to work properly<b>&nbsp;:</b> </p> <ol style="text-align: left;"> <li> <b>JSON PHP extension.</b> </li> <li> <b>CURL PHP extension.</b> </li> </ol> </div> How to get Current Time and date in Javascript https://subinsb.com/how-to-get-current-time-and-date-in-javascript/ Tue, 07 May 2013 05:47:00 +0000 https://subinsb.com/how-to-get-current-time-and-date-in-javascript/ <div dir="ltr" style="text-align: left;" trbidi="on"> This tutorial will help you to get current date and time at which the function is executed. Here is the function:</p> <blockquote class="tr_bq"> <p> function ctime(){<br />var currentdate = new Date();<br />var time=currentdate.getFullYear()+"-"+(currentdate.getMonth()+1)+"-"+currentdate.getDate()+" "+currentdate.getHours()+":"+currentdate.getMinutes()+":"+currentdate.getSeconds();<br />return time;<br />} </p> </blockquote> <div> <div> Just print out <b>ctime()</b>&nbsp;function to get the date and time in the format <b>YEAR/MONTH/DAY HOUR:MINUTE:SECOND&nbsp;</b> </div> </div> <div> <b><br /></b> </div> <div> <u><b><span style="font-size: x-large;">Explanation :</span></b></u> </div> <div> <b><br /></b> </div> <div> <b>new Date()</b>&nbsp;function prints out the current date and time in a disorderly way. You can order it in any way as I did in the <b>time()</b>&nbsp;function. </div> <div> </div> <div> <b>currentdate.getFullYear()</b> will get the year from <b>new Date()</b>&nbsp;which is in the variable currentdate </div> <div> </div> <div> <b>currentdate.getMonth() </b>will get the month from&nbsp;<b>new Date() </b>function. The program <b>adds 1</b> to the month because <b>Javascript</b>&nbsp;always count the month from <b></b>. So we should add a&nbsp;<b>+1</b>. </div> <div> </div> <div> <b>currentdate.getDate() </b>will get the day of the month in which the function is executed. </div> <div> </div> <div> <b>currentdate.getHours() </b>will give the <b>Hour</b>&nbsp;of the time. </div> <div> </div> <div> <b>currentdate.getMinutes() </b>will give the Minute in which the script is executed. </div> <div> </div> <div> <b>currentdate.getSeconds() </b>This function will give the seconds of the time at which the script is executed. </div> </div> The best age calculation code in PHP https://subinsb.com/the-best-age-calculation-code-in-php/ Thu, 02 May 2013 14:36:00 +0000 https://subinsb.com/the-best-age-calculation-code-in-php/ <div dir="ltr" style="text-align: left;" trbidi="on"> Age calculation is a tricky calculation especially in <b>Programming Languages</b>. I&#8217;m going to tell you a simple way to find out age in <b>PHP</b>.&nbsp;This is a simple function that will calculate age if it is given a birthday date in the format <b>date/month/year</b>. For example : <b>20/01/2000</b>&nbsp;or <b>04/12/1990</b><br />Here is the function :</p> <blockquote class="tr_bq"> <p> function age($birthday){<br />&nbsp;list($day,$month,$year) = explode("/",$birthday);<br />&nbsp;$year_diff &nbsp;= date("Y") &#8211; $year;<br />&nbsp;$month_diff = date("m") &#8211; $month;<br />&nbsp;$day_diff &nbsp; = date("d") &#8211; $day;<br />&nbsp;if ($day_diff < 0 && $month_diff==0){$year_diff&#8211;;}<br />&nbsp;if ($day_diff < 0 && $month_diff < 0){$year_diff&#8211;;}<br />&nbsp;return $year_diff;<br />} </p> </blockquote> <p> You can print out the age like this: </p> <blockquote class="tr_bq"> <p> echo age(&#8217;20/01/2000&#8242;); </p> </blockquote> <p> This echo function will write <b>13</b>. See another example : </p> <blockquote class="tr_bq"> <p> echo age(&#8217;04/12/1990&#8242;); </p> </blockquote> <p> This echo function will write&nbsp;<b>22</b>.</div> How to check if the mouse is over an element in jQuery? https://subinsb.com/how-to-check-if-the-mouse-is-over-an-element-in-jquery/ Sun, 28 Apr 2013 15:56:00 +0000 https://subinsb.com/how-to-check-if-the-mouse-is-over-an-element-in-jquery/ <div dir="ltr" style="text-align: left;"> <span style="font-family: inherit;">Here is a simple plugin to check if the mouse is over an element in <b>JQuery</b>. Open your <b>jQuery</b>ย source file and search forย <b>window.jQuery = window.$ = jQuery;ย </b></span></p> <div> <span style="font-family: inherit;">Paste the code shown below after the code you have just found.</span> </div> <div> <blockquote> <p> <span style="font-family: inherit;"><code style="background-color: white; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">&lt;span class="pln" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;"> $&lt;/span>&lt;span class="pun" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">.&lt;/span>&lt;span class="pln" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">mlp &lt;/span>&lt;span class="pun" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">=&lt;/span>&lt;span class="pun" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">{&lt;/span>&lt;span class="pln" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">x&lt;/span>&lt;span class="pun" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">:&lt;/span>&lt;span class="lit" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">0&lt;/span>&lt;span class="pun" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">,&lt;/span>&lt;span class="pln" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">y&lt;/span>&lt;span class="pun" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">:&lt;/span>&lt;span class="lit" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">0&lt;/span>&lt;span class="pun" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">};&lt;/span></code><code style="background-color: white; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">&lt;span class="kwd" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">function&lt;/span>&lt;span class="pln" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;"> documentHandler&lt;/span>&lt;span class="pun" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">(){&lt;/span></code><code style="background-color: white; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">&lt;span class="kwd" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">var&lt;/span>&lt;span class="pln" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;"> $current &lt;/span>&lt;span class="pun" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">=&lt;/span>&lt;span class="kwd" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">this&lt;/span>&lt;span class="pun" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">===&lt;/span>&lt;span class="pln" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;"> document &lt;/span>&lt;span class="pun" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">?&lt;/span>&lt;span class="pln" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;"> $&lt;/span>&lt;span class="pun" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">(&lt;/span>&lt;span class="kwd" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">this&lt;/span>&lt;span class="pun" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">)&lt;/span>&lt;span class="pun" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">:&lt;/span>&lt;span class="pln" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;"> $&lt;/span>&lt;span class="pun" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">(&lt;/span>&lt;span class="kwd" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">this&lt;/span>&lt;span class="pun" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">).&lt;/span>&lt;span class="pln" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">contents&lt;/span>&lt;span class="pun" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">();&lt;/span></code><code style="background-color: white; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">&lt;span class="pln" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;"> $current&lt;/span>&lt;span class="pun" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">.&lt;/span>&lt;span class="pln" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">mousemove&lt;/span>&lt;span class="pun" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">(&lt;/span>&lt;span class="kwd" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">function&lt;/span>&lt;span class="pun" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">(&lt;/span>&lt;span class="pln" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">e&lt;/span>&lt;span class="pun" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">){&lt;/span>&lt;span class="pln" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">jQuery&lt;/span>&lt;span class="pun" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">.&lt;/span>&lt;span class="pln" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">mlp &lt;/span>&lt;span class="pun" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">=&lt;/span>&lt;span class="pun" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">{&lt;/span>&lt;span class="pln" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">x&lt;/span>&lt;span class="pun" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">:&lt;/span>&lt;span class="pln" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">e&lt;/span>&lt;span class="pun" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">.&lt;/span>&lt;span class="pln" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">pageX&lt;/span>&lt;span class="pun" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">,&lt;/span>&lt;span class="pln" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">y&lt;/span>&lt;span class="pun" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">:&lt;/span>&lt;span class="pln" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">e&lt;/span>&lt;span class="pun" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">.&lt;/span>&lt;span class="pln" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">pageY&lt;/span>&lt;span class="pun" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">}});&lt;/span></code><code style="background-color: white; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">&lt;span class="pln" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;"> $current&lt;/span>&lt;span class="pun" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">.&lt;/span>&lt;span class="pln" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">find&lt;/span>&lt;span class="pun" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">(&lt;/span>&lt;span class="str" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">"iframe"&lt;/span>&lt;span class="pun" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">).&lt;/span>&lt;span class="pln" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">load&lt;/span>&lt;span class="pun" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">(&lt;/span>&lt;span class="pln" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">documentHandler&lt;/span>&lt;span class="pun" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">);&lt;/span></code><code style="background-color: white; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">&lt;span class="pun" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">}&lt;/span></code><code style="background-color: white; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">&lt;span class="pln" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">$&lt;/span>&lt;span class="pun" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">(&lt;/span>&lt;span class="pln" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">documentHandler&lt;/span>&lt;span class="pun" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">);&lt;/span></code><code style="background-color: white; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">&lt;span class="pln" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;"> $&lt;/span>&lt;span class="pun" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">.&lt;/span>&lt;span class="pln" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">fn&lt;/span>&lt;span class="pun" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">.&lt;/span>&lt;span class="pln" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">ismouseover &lt;/span>&lt;span class="pun" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">=&lt;/span>&lt;span class="kwd" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">function&lt;/span>&lt;span class="pun" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">(&lt;/span>&lt;span class="pln" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">overThis&lt;/span>&lt;span class="pun" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">)&lt;/span>&lt;span class="pun" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">{&lt;/span></code><code style="background-color: white; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">&lt;span class="kwd" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">var&lt;/span>&lt;span class="pln" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;"> result &lt;/span>&lt;span class="pun" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">=&lt;/span>&lt;span class="kwd" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">false&lt;/span>&lt;span class="pun" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">;&lt;/span></code><code style="background-color: white; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">&lt;span class="kwd" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">this&lt;/span>&lt;span class="pun" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">.&lt;/span>&lt;span class="pln" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">eq&lt;/span>&lt;span class="pun" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">(&lt;/span>&lt;span class="lit" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">0&lt;/span>&lt;span class="pun" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">).&lt;/span>&lt;span class="pln" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">each&lt;/span>&lt;span class="pun" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">(&lt;/span>&lt;span class="kwd" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">function&lt;/span>&lt;span class="pun" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">()&lt;/span>&lt;span class="pun" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">{&lt;/span></code><code style="background-color: white; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">&lt;span class="kwd" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">var&lt;/span>&lt;span class="pln" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;"> $current &lt;/span>&lt;span class="pun" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">=&lt;/span>&lt;span class="pln" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;"> $&lt;/span>&lt;span class="pun" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">(&lt;/span>&lt;span class="kwd" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">this&lt;/span>&lt;span class="pun" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">).&lt;/span>&lt;span class="kwd" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">is&lt;/span>&lt;span class="pun" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">(&lt;/span>&lt;span class="str" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">"iframe"&lt;/span>&lt;span class="pun" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">)&lt;/span>&lt;span class="pun" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">?&lt;/span>&lt;span class="pln" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;"> $&lt;/span>&lt;span class="pun" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">(&lt;/span>&lt;span class="kwd" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">this&lt;/span>&lt;span class="pun" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">).&lt;/span>&lt;span class="pln" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">contents&lt;/span>&lt;span class="pun" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">().&lt;/span>&lt;span class="pln" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">find&lt;/span>&lt;span class="pun" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">(&lt;/span>&lt;span class="str" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">"body"&lt;/span>&lt;span class="pun" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">)&lt;/span>&lt;span class="pun" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">:&lt;/span>&lt;span class="pln" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;"> $&lt;/span>&lt;span class="pun" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">(&lt;/span>&lt;span class="kwd" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">this&lt;/span>&lt;span class="pun" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">);&lt;/span></code><code style="background-color: white; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">&lt;span class="kwd" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">var&lt;/span>&lt;span class="pln" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;"> offset &lt;/span>&lt;span class="pun" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">=&lt;/span>&lt;span class="pln" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;"> $current&lt;/span>&lt;span class="pun" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">.&lt;/span>&lt;span class="pln" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">offset&lt;/span>&lt;span class="pun" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">();&lt;/span>&lt;span class="pln" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;"> result&lt;br /> &lt;/span></code><code style="background-color: white; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">&lt;span class="pln" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;"> result &lt;/span>&lt;span class="pun" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">=&lt;/span>&lt;span class="pln" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;"> offset&lt;/span>&lt;span class="pun" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">.&lt;/span>&lt;span class="pln" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">left&lt;/span>&lt;span class="pun" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">&lt;=&lt;/span>&lt;span class="pln" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">$&lt;/span>&lt;span class="pun" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">.&lt;/span>&lt;span class="pln" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">mlp&lt;/span>&lt;span class="pun" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">.&lt;/span>&lt;span class="pln" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">x &lt;/span>&lt;span class="pun" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">&&&lt;/span>&lt;span class="pln" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;"> offset&lt;/span>&lt;span class="pun" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">.&lt;/span>&lt;span class="pln" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">left &lt;/span>&lt;span class="pun" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">+&lt;/span>&lt;span class="pln" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;"> $current&lt;/span>&lt;span class="pun" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">.&lt;/span>&lt;span class="pln" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">outerWidth&lt;/span>&lt;span class="pun" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">()&lt;/span>&lt;span class="pun" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">&gt;&lt;/span>&lt;span class="pln" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;"> $&lt;/span>&lt;span class="pun" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">.&lt;/span>&lt;span class="pln" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">mlp&lt;/span>&lt;span class="pun" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">.&lt;/span>&lt;span class="pln" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">x &lt;/span>&lt;span class="pun" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">&&&lt;/span></code><code style="background-color: white; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">&lt;span class="pln" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;"> offset&lt;/span>&lt;span class="pun" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">.&lt;/span>&lt;span class="pln" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">top&lt;/span>&lt;span class="pun" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">&lt;=&lt;/span>&lt;span class="pln" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">$&lt;/span>&lt;span class="pun" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">.&lt;/span>&lt;span class="pln" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">mlp&lt;/span>&lt;span class="pun" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">.&lt;/span>&lt;span class="pln" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">y &lt;/span>&lt;span class="pun" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">&&&lt;/span>&lt;span class="pln" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;"> offset&lt;/span>&lt;span class="pun" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">.&lt;/span>&lt;span class="pln" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">top &lt;/span>&lt;span class="pun" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">+&lt;/span>&lt;span class="pln" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;"> $current&lt;/span>&lt;span class="pun" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">.&lt;/span>&lt;span class="pln" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">outerHeight&lt;/span>&lt;span class="pun" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">()&lt;/span>&lt;span class="pun" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">&gt;&lt;/span>&lt;span class="pln" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;"> $&lt;/span>&lt;span class="pun" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">.&lt;/span>&lt;span class="pln" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">mlp&lt;/span>&lt;span class="pun" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">.&lt;/span>&lt;span class="pln" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">y&lt;/span>&lt;span class="pun" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">;&lt;/span></code><code style="background-color: white; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">&lt;span class="pun" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">});&lt;/span></code><code style="background-color: white; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">&lt;span class="kwd" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">return&lt;/span>&lt;span class="pln" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;"> result&lt;/span>&lt;span class="pun" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">;&lt;/span></code><code style="background-color: white; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">&lt;span class="pun" style="border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">};&lt;/span></code></span> </p> </blockquote> </div> <div> <span style="font-family: inherit;">To check if mouse is hovering an element, just check it like this:</span> </div> <blockquote class="tr_bq"> <p> <span style="font-family: inherit;">$("div")<span class="pun" style="border: 0px; line-height: 18px; margin: 0px; padding: 0px; vertical-align: baseline;">.</span><span class="pln" style="border: 0px; line-height: 18px; margin: 0px; padding: 0px; vertical-align: baseline;">ismouseover</span><span class="pun" style="border: 0px; line-height: 18px; margin: 0px; padding: 0px; vertical-align: baseline;">()</span></span> </p> </blockquote> <div> <span style="font-family: inherit;">Theย <span class="pun" style="border: 0px; line-height: 18px; margin: 0px; padding: 0px; vertical-align: baseline;">.</span><span class="pln" style="border: 0px; line-height: 18px; margin: 0px; padding: 0px; vertical-align: baseline;">ismouseover</span><span class="pun" style="border: 0px; line-height: 18px; margin: 0px; padding: 0px; vertical-align: baseline;">() function will return <b>true</b>ย if the mouse is hovering the element and <b>false</b>ย if it&#8217;s not hovering.</span></span> </div> <div> <span class="pun" style="border: 0px; line-height: 18px; margin: 0px; padding: 0px; vertical-align: baseline;"><span style="background-color: white;"><span style="font-family: inherit;">This function is tested on <b>IE7</b>+,<b> Chrome 1</b>+ and<b>ย Firefox 4</b>.ย It is working properly on all these browsers.</span></span></span><span class="pun" style="border: 0px; line-height: 18px; margin: 0px; padding: 0px; vertical-align: baseline;"><span style="background-color: white;"><span style="font-family: inherit;"><br /> </span></span></span> </div> <p> <span style="font-size: large;"><span style="font-family: inherit;"><span class="pun" style="border: 0px; line-height: 18px; margin: 0px; padding: 0px; vertical-align: baseline;"><span style="background-color: white;"><span style="color: red;">NOTEย </span>:ย </span></span>The solution does not work if the element is anย </span>iframe. Because theย mousemoveย event does not fire over theย iframe, and theย Mouseย Lastย Positionย is not updated.</span> </p> </div> SPAM URLโ€™s in Blogger Traffic Source Stats : What should I do ? https://subinsb.com/spam-urls-in-blogger-traffic-source-stats-what-should-i-do/ Sun, 28 Apr 2013 14:34:00 +0000 https://subinsb.com/spam-urls-in-blogger-traffic-source-stats-what-should-i-do/ <div dir="ltr" style="text-align: left;"> <div dir="ltr" style="text-align: left;"> <span style="font-family: inherit;">You might have noticed a great volume of sites you never heard of coming to your site apart from Search Engine URL&#8217;s. Some of those <b>URL&#8217;s</b>ย are <b>filmhill.com</b>ย and <b>vampirestat.com</b>.</span><br /> <span style="font-family: inherit;"><br /> </span> <span style="font-family: inherit;">These kind of <b>URL</b>&#8216;s are <b>SPAM</b>. The SPAMย site is referring your site but they are not persons, they&#8217;re <b>BOTS</b>.ย These bots are visiting your site just for fun. These bots don&#8217;t read your posts or anything. They&#8217;re just a pile of robots. The bot is<b>ย </b>ran by a script. Probably <b>PHP</b>.</span><br /> <span style="font-family: inherit;">This scripts visits your site using CURLย function with the referrer of their site. In PHPย if you echoย $_SERVER[&#8216;HTTP_REFERER&#8217;]ย you will get the site where the user just came from. <b>Blogger</b>ย is using the same function but not PHPย to record the traffic sources.</span><span style="font-family: inherit;"><br /> </span></p> <pre><code>&lt;h1&gt; What&amp;#8217;s the benefit for my blog and the SPAM site ? &lt;/h1&gt; &lt;p&gt; &lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;b&gt;My Blogย &lt;/b&gt;: Your stats will rise up. Even though the visitor is a &lt;b&gt;bot,&lt;/b&gt;ย &lt;b&gt;Blogger&lt;/b&gt;ย will still count it as a visitor. The human viewers will see the &lt;b&gt;rise up in your blog&amp;#8217;s stats&lt;/b&gt; making them believe that your blog is a popular blog.&lt;/span&gt;&lt;br /&gt; &lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt; &lt;/span&gt; &lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;b&gt;SPAM&lt;/b&gt;ย &lt;b&gt;Site&lt;/b&gt;ย : The site do this because they want to promote their site to you. When the blog owner sees this traffic source, they will click the link to check it out. Hence the SPAMย site&amp;#8217;sย stats will also rise and more advertisersย will come to advertise on the SPAMย site.&lt;/span&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt; &lt;/span&gt; &lt;/p&gt; &lt;h1&gt; What&amp;#8217;s the disadvantage ? &lt;/h1&gt; &lt;p&gt; &lt;b&gt;Ad&lt;/b&gt;ย &lt;b&gt;Networks&lt;/b&gt;ย such as &lt;b&gt;Google Adsense&lt;/b&gt;ย and &lt;b&gt;BuySellAds&lt;/b&gt;ย tracks all the visits coming to your blog. When they sees the &lt;b&gt;SPAM&lt;/b&gt;ย URL&amp;#8217;s visiting, they count it as a &lt;b&gt;paid-to-click&lt;/b&gt;ย visit.ย According to the &lt;b&gt;Adsense&lt;/b&gt;ย Policies, You shouldn&amp;#8217;t use a &lt;b&gt;Pay To Click&lt;/b&gt;ย service. Hence your Adsenseย Account will get &lt;b&gt;disapproved&lt;/b&gt;.&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt; &lt;/span&gt; &lt;/p&gt; &lt;h1&gt; What should I do ? &lt;/h1&gt; &lt;p&gt; &lt;span style=&quot;font-family: inherit;&quot;&gt;You can&amp;#8217;t do anything to stop these traffic sources, Only Blogger can. But you can do two things : &lt;/span&gt; &lt;/p&gt; &lt;ol&gt; &lt;li&gt; Don&amp;#8217;t click on these kind of URL&amp;#8217;s &lt;/li&gt; &lt;li&gt; Don&amp;#8217;t add those URL&amp;#8217;s to your blog pages. &lt;/li&gt; &lt;/ol&gt; &lt;p&gt; &lt;span style=&quot;font-family: inherit;&quot;&gt;If you link the SPAM URL&amp;#8217;s they will keep coming to your blog.&lt;/span&gt; &lt;/p&gt; &lt;p&gt; &lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;b&gt;&lt;br /&gt; &lt;/b&gt;&lt;/span&gt; &lt;span style=&quot;font-family: inherit;&quot;&gt;Here is a list of &lt;b&gt;SPAM&lt;/b&gt;ย sites found in Blogger Traffic Sources.&lt;b&gt;&lt;/b&gt;&lt;/span&gt; &lt;/p&gt; </code></pre> </div> <table style="line-height: 25px;" border="1"> <tr> <td> http://www.omgmachines.com/?hop=gerbill3 </td> </tr> <pre><code>&lt;tr&gt; &lt;td&gt; http://gsniper2.com/?hop=gerbill3 &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; http://0rz.tw/orp80 &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; http://t.co/6kSaxKTT &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; http://www3.t-8jy1o8pij.trickip.net/ &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; http://6dd260ed.urlbeat.net &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; http://adsenserrors.info &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; http://software.refererx.com/ &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; http://www.elebda3.net/redirect.php?url=t.co/TpCBMDg9 &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; http://zombiestat.com/ &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; http://uglystat.com/ &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; http://adsensewatchdog.com &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; http://adsresultpages.com/?aff=5801&amp;saff=1&amp;source=1&amp;q=buy+viagra &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; http://bit.ly/FreeDownloadMoneyMakingPackage &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; http://tinyurl.com/EarnMoneyFromADFLY &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; http://myhealthscore.com/frame.cfm?page=http%3a%2f%2ft.co%2fz1v6ZazZ &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; http://www.stumbleupon.com/su/2gA2gc/t.co/TIlBBraD &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; http://tr.netlog.com/go/out/url=http%3a%2f%2ft.co%2fcM5qnlnl?kjKJHl8HKd23 &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; http://www.filmhill.com/redirect.php?url=http%3A%2F%2Ft.co%2F5UQiESCF &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; http://www.filmhill.com/redirect.php?url=http://flf-course.com?a_aid=510d2acc92117&amp;a_bid=6f93443e &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; http://www.filmhill.com &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; http://www.vampirestat.com &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; http://yandex.ru/yandsearch? &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; http://www.meendo.com/?partner=2631 &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; http://pregolom.com/find/in/index.php &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; http://super-online-search.com/find/in/index.php &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; http://www.elebda3.net/redirect.php?url=t.co/TpCBMDg9 &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; http://www.youtube.com/watch?v=s4p9PjdqHN4 &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; http://bytovaya-tehnika.blogspot.ru/ &amp;#8211; Dec. 2012 &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; http://electronika-tech.blogspot.ru/ &amp;#8211; Dec. 2012 &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; http://obo-vsem-blog.blogspot.ru/ &amp;#8211; Dec. 2012 &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; http://lshirlene.github.com/166.html &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; http://thesecrettool.blogspot.com &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; http://kechinf.phpnet.us &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; http://members.multimania.co.uk &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; http://olshopu.netai.net &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; http://flf-course.com/?a_aid=517d0f042c205 &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; http://r-e-f-e-r-e-r.com/ &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; http://r-e-f-e-r-r-e-r.com/ &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; http://www.linkedin.com/redir/redirect?url=http%3A%2F%2Fflf-course%2Ecom%3Fa_aid%3D517d0f042c205&amp;urlhash=e75j5 &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; http://t.co/MaAptuGFVu6 &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; http://www.kmzackblogger.com &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; http://kallery.net/ &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; http://7secretsearch.com/ &lt;/td&gt; &lt;/tr&gt; </code></pre> </table> <p> <span style="font-family: inherit;">Thank youย <span class="publisher-anchor-color" style="box-sizing: border-box; line-height: 17px;">Rahul Saitand</span><span style="line-height: 17px;">ย &ย </span>Brittny for reporting some <b>SPAM</b>ย <b>URL&#8217;s</b>.</span><br /> <span style="font-family: inherit;"><b><br /> </b></span><span style="color: red;">If you have any other URL&#8217;s than this, please report it via comments.</span> </p> </div> NimBuzz Official Website hacked by Iranian Hackers https://subinsb.com/nimbuzz-official-website-hacked-by-iranian-hackers/ Fri, 26 Apr 2013 17:53:00 +0000 https://subinsb.com/nimbuzz-official-website-hacked-by-iranian-hackers/ <div dir="ltr" style="text-align: left;" trbidi="on"> <div style="text-align: left;"> Just now. <b>Nimbuzz </b>main site <b>nimbuzz.com</b>&nbsp;was hacked by someone identified as&nbsp;<b>Sourena</b>.&nbsp; </div> <div style="text-align: left;"> The hacker defaced the main site to this </div> <div style="text-align: center;"> </div> <div style="text-align: left;"> <div class="separator" style="clear: both; text-align: center;"> <a href="//3.bp.blogspot.com/-EECObtiEntg/Ub1MfOrJPwI/AAAAAAAACsc/SS02rJuACNU/s1600/0002.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="317" src="//3.bp.blogspot.com/-EECObtiEntg/Ub1MfOrJPwI/AAAAAAAACsc/SS02rJuACNU/s640/0002.png" width="640" /></a> </div> <pre><code>&lt;p&gt; &lt;/div&gt; &lt;div style=&quot;text-align: left;&quot;&gt; As a proof he saved a mirror at &lt;a href=&quot;http://zone-h.com/mirror/id/19693441&quot; style=&quot;font-weight: bold;&quot; &gt;Zone-H&lt;/a&gt;. The &lt;b&gt;Nimbuzz&lt;/b&gt;&amp;nbsp;website can&amp;#8217;t be accessed right now. Google Chrome gives an error &quot;&lt;b&gt;Oops! Google Chrome could not connect to nimbuzz.com&lt;/b&gt;&quot; &lt;/div&gt; &lt;div style=&quot;text-align: left;&quot;&gt; &lt;/div&gt; &lt;div style=&quot;text-align: left;&quot;&gt; &lt;b&gt;Nimbuzz &lt;/b&gt;is one of the popular chat clients in &lt;b&gt;PC &lt;/b&gt;and mobile phones. After this attack, it&amp;#8217;s sure that users will move out of &lt;b&gt;Nimbuzz&lt;/b&gt;. &lt;/div&gt; &lt;div style=&quot;text-align: left;&quot;&gt; &lt;/div&gt; &lt;div style=&quot;text-align: left;&quot;&gt; &lt;span style=&quot;font-size: large;&quot;&gt;Earlier in the &lt;b&gt;Nimbuzz &lt;/b&gt;Blog They said that they would give &lt;b&gt;Cash&lt;/b&gt;&amp;nbsp;if anyone reports security issues.&lt;/span&gt; &lt;/div&gt; &lt;div style=&quot;text-align: left;&quot;&gt; See the blog post &lt;a href=&quot;http://blog.nimbuzz.com/2013/04/03/report-bugs-and-win-cash-prizes-and-more-with-nimbuzz/&quot; &gt;here&lt;/a&gt;. &lt;/div&gt; &lt;div style=&quot;text-align: left;&quot;&gt; &lt;/div&gt; &lt;div style=&quot;text-align: left;&quot;&gt; They also said &quot;&lt;span style=&quot;background-color: white; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; line-height: 18px;&quot;&gt;&lt;b&gt;Each week we would announce one winner and his photo would be up here on the Global Blog and will get Nimbuzz Merchandise. After 6 weeks we would then pick one of these 6 winners and that winner would get Cash prize.&lt;/b&gt;&lt;span style=&quot;background-color: white; color: #333333; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 12px; line-height: 18px;&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt; &lt;span style=&quot;color: #333333; font-family: Helvetica Neue, Helvetica, Arial, sans-serif;&quot;&gt;&lt;span style=&quot;line-height: 18px;&quot;&gt;One thing is for sure : The hacker&amp;#8217;s photo would be on the Global Blog.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;/div&gt; </code></pre> How to make your Windows 8 PC speak out Time at Every Hour https://subinsb.com/how-to-make-your-windows-8-pc-speak-out-time-at-every-hour/ Fri, 26 Apr 2013 17:33:00 +0000 https://subinsb.com/how-to-make-your-windows-8-pc-speak-out-time-at-every-hour/ <div dir="ltr" style="text-align: left;" trbidi="on"> <div style="text-align: left;"> <span style="background-color: white; font-family: inherit;">Thanks for this useful information by <a href="http://www.nextofwindows.com/?source=subinsblog" >NextOfWindows</a></span><br /><span style="background-color: white; font-family: inherit;">This small tutorial will make your <b>PC</b>&nbsp;speak out the time every hour. This will help <b>especially if you&#8217;re a programer</b>. <b>Because programmers usually lose track of time.</b></span> </div> <div style="text-align: left;"> <b><span style="background-color: white; font-family: inherit;"><br /></span></b> </div> <div style="text-align: left;"> <span style="background-color: white; font-family: inherit;">Most Programmers don&#8217;t use a <b>Windows </b>OS. But there are some ! This tutorial is for those people.</span> </div> <div style="text-align: left;"> <span style="background-color: white; font-family: inherit;">Create a file named <b>time.vbs</b>&nbsp;containing these code :</span> </div> <div> <blockquote class="tr_bq"> <p> <span style="background-color: white; font-family: inherit;">Dim speaks, speech</span> </p> <pre><code> &lt;div style=&quot;text-align: left;&quot;&gt; &lt;span style=&quot;background-color: white;&quot;&gt;&lt;span style=&quot;font-family: inherit; line-height: 25px; text-align: center;&quot;&gt;speaks = &quot;It is &quot; &amp; hour(time) &amp; &quot; Oโ€™clock&quot;&lt;/span&gt;&lt;/span&gt; &lt;/div&gt; &lt;p&gt; &lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;span style=&quot;background-color: white;&quot;&gt;&lt;/span&gt;&lt;/span&gt; &lt;/p&gt; &lt;div style=&quot;text-align: left;&quot;&gt; &lt;span style=&quot;background-color: white;&quot;&gt;&lt;span style=&quot;font-family: inherit; line-height: 25px; text-align: center;&quot;&gt;Set speech = CreateObject(&quot;sapi.spvoice&quot;)&lt;/span&gt;&lt;/span&gt; &lt;/div&gt; &lt;p&gt; &lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;span style=&quot;background-color: white;&quot;&gt;&lt;/span&gt;&lt;/span&gt; &lt;/p&gt; &lt;div style=&quot;text-align: left;&quot;&gt; &lt;span style=&quot;background-color: white;&quot;&gt;&lt;span style=&quot;font-family: inherit; line-height: 25px; text-align: center;&quot;&gt;speech.Speak speaks&lt;/span&gt;&lt;/span&gt; &lt;/div&gt; &lt;p&gt; &lt;span style=&quot;background-color: white; font-family: inherit;&quot;&gt;&lt;/span&gt; &lt;/p&gt; &lt;/blockquote&gt; &lt;p&gt; &lt;span style=&quot;background-color: white; font-family: inherit;&quot;&gt;Save the file wherever you want.&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;background-color: white; font-family: inherit;&quot;&gt;Open the &lt;b&gt;Run &lt;/b&gt;dialog&lt;b&gt;&amp;nbsp;&lt;/b&gt;by pressing&amp;nbsp;&lt;b&gt;WIN&amp;nbsp;+ R&lt;/b&gt;. Type &lt;b&gt;taskschd.msc&lt;/b&gt;&amp;nbsp;and hit &lt;b&gt;Enter&lt;/b&gt;&amp;nbsp;to run the program.&lt;/span&gt; &lt;/p&gt; &lt;div style=&quot;text-align: center;&quot;&gt; &lt;/div&gt; &lt;p&gt; &lt;span style=&quot;background-color: white; font-family: inherit;&quot;&gt;&lt;b&gt;WIN =&amp;nbsp;&lt;/b&gt;Windows button on keyboard.&lt;/span&gt; &lt;/p&gt; &lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt; &lt;a href=&quot;//4.bp.blogspot.com/-jQKV82iZM4M/Ub1P7qOCdQI/AAAAAAAACsw/09G1Rhp9dpU/s1600/0003.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;//4.bp.blogspot.com/-jQKV82iZM4M/Ub1P7qOCdQI/AAAAAAAACsw/09G1Rhp9dpU/s1600/0003.png&quot; /&gt;&lt;/span&gt;&lt;/a&gt; &lt;/div&gt; &lt;p&gt; &lt;span style=&quot;background-color: white; font-family: inherit;&quot;&gt;&lt;br /&gt;&lt;/span&gt; &lt;/p&gt; &lt;div style=&quot;text-align: left;&quot;&gt; &lt;span style=&quot;background-color: white; font-family: inherit;&quot;&gt;&lt;span style=&quot;line-height: 22px; text-align: center;&quot;&gt;In &lt;b&gt;Task Scheduler&lt;/b&gt;, click&amp;nbsp;&lt;/span&gt;&lt;strong style=&quot;border: 0px; font-style: inherit; line-height: 22px; margin: 0px; outline: 0px; padding: 0px; text-align: center; vertical-align: baseline;&quot;&gt;Create Task&lt;/strong&gt;&lt;span style=&quot;line-height: 22px; text-align: center;&quot;&gt;.&lt;/span&gt;&lt;/span&gt; &lt;/div&gt; &lt;div style=&quot;border: 0px; line-height: 22px; margin-bottom: 20px; outline: 0px; padding: 0px; text-align: left; vertical-align: baseline;&quot;&gt; &lt;span style=&quot;background-color: white; font-family: inherit; margin: 0px; padding: 0px;&quot;&gt;Give the name &lt;b&gt;Time&lt;/b&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;background-color: white;&quot;&gt;under&amp;nbsp;&lt;/span&gt;&lt;strong style=&quot;border: 0px; font-style: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;General&lt;/strong&gt;&lt;span style=&quot;background-color: white;&quot;&gt;&amp;nbsp;tab&lt;/span&gt;&lt;span style=&quot;background-color: white; font-family: inherit;&quot;&gt;.&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;Run the task repeatedly every hour by adding a trigger. Like below:&lt;/span&gt;&lt;/p&gt; &lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt; &lt;/div&gt; &lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt; &lt;a href=&quot;//1.bp.blogspot.com/-ZT7BBT-AXco/Ub1QdM6-S2I/AAAAAAAACtE/7lY7AOF9EMM/s1600/0004.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;553&quot; src=&quot;//1.bp.blogspot.com/-ZT7BBT-AXco/Ub1QdM6-S2I/AAAAAAAACtE/7lY7AOF9EMM/s640/0004.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt; &lt;/div&gt; &lt;p&gt; &lt;span style=&quot;background-color: white;&quot;&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;span style=&quot;background-color: white;&quot;&gt;Point the location of the &lt;b&gt;time.vbs&lt;/b&gt;&amp;nbsp;file in &lt;b&gt;Program/Script&lt;/b&gt;&amp;nbsp;field, like below:&lt;/span&gt;&lt;/span&gt; &lt;/p&gt; &lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt; &lt;a href=&quot;//4.bp.blogspot.com/-Fgvwu8Hrvck/Ub1P9vDn2RI/AAAAAAAACtA/hiPv8jRDI6c/s1600/0005.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;//4.bp.blogspot.com/-Fgvwu8Hrvck/Ub1P9vDn2RI/AAAAAAAACtA/hiPv8jRDI6c/s1600/0005.png&quot; /&gt;&lt;/a&gt; &lt;/div&gt; &lt;p&gt; &lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;Change the program input to the path where you saved &lt;/span&gt;&lt;b style=&quot;font-family: inherit;&quot;&gt;time.vbs&lt;/b&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;.Click &lt;/span&gt;&lt;b style=&quot;font-family: inherit;&quot;&gt;OK&lt;/b&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;&amp;nbsp;button.&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;That&amp;#8217;s it for today. I will post something more cool next ti&lt;/span&gt;&lt;/div&gt; &lt;/div&gt; &lt;div style=&quot;border: 0px; line-height: 22px; margin-bottom: 20px; outline: 0px; padding: 0px; text-align: left; vertical-align: baseline;&quot;&gt; &lt;div style=&quot;background-color: white; border: 0px; color: #373737; font-family: 'Segoe UI', Segoe, 'Helvetica Neue', Verdana, Geneva, Arial; font-size: 1.1em; margin-bottom: 20px; outline: 0px; padding: 0px; text-align: left; vertical-align: baseline;&quot;&gt; &lt;span style=&quot;margin: 0px; padding: 0px;&quot;&gt;&lt;/span&gt; &lt;/div&gt; &lt;/div&gt;&lt;/div&gt; </code></pre> Login with Google OAuth without using Google PHP Library https://subinsb.com/login-with-google-oauth-without-using-google-php-library/ Thu, 25 Apr 2013 04:50:00 +0000 https://subinsb.com/login-with-google-oauth-without-using-google-php-library/ <div dir="ltr" style="text-align: left;"> <b>Google PHP</b> Library is very hard to use and is very long. It wasted a lot of my time. So I decided to do it manually.<br /> I created a new library for <b>Google OAuth</b> inย <b>PHP</b>.</p> <div class="padlinks"> <a class="download" href="http://get-subins.hp.af.cm/view.php?id=341">Download</a> <a class="demo" href="http://demos.subinsb.com/google-php-lib-simple/">Demo</a> </div> <p> It is very simple to use and you don&#8217;t have to worry about a thing. </p> <h1> <b><span style="font-size: x-large;">FAQ</span></b> </h1> <div style="text-align: left;"> <b><span style="font-size: large;">How to get a client Id and Client Secret ?</span></b> </div> <p> 1) Go to <b><a href="https://code.google.com/apis/console">https://code.google.com/apis/console</a></b> and create a new project.<br /> 2) Fill up the form.<br /> 3) In the redirect URL&#8217;s type in the URL of the index.php in your site.<br /> 4) Add your site URL as trusted Origin.<br /> You will now get a client Id and a Client Secret Id. Type both of those in each <b>$client_id</b> and <b>$client_secret</b> variable of Configuration section in <b>index.php</b> file.<span style="font-size: large;"><br /> </span> </p> <h1 style="text-align: left;"> <b><span style="font-size: large;">What should I type in $redirect_url variable ?</span></b> </h1> <p> Open the page index.php in your browser and you will be redirected to the Google Oauth site and when the user authorised your app they will reach the <b>redirect_url</b> you specified in index.php configuration section. </p> <h1 style="text-align: left;"> <b><span style="font-size: large;">Where can I get the list of scopes ?</span></b> </h1> <p> I have made a blog post containing the list of scopes. View the post @ <a href="http://sag-3.blogspot.com/2013/04/list-google-oauth-scopes.html">http://sag-3.blogspot.com/2013/04/list-google-oauth-scopes.html</a> </p> </div> List of Google OAuth Scopes https://subinsb.com/list-of-google-oauth-scopes/ Wed, 24 Apr 2013 07:45:00 +0000 https://subinsb.com/list-of-google-oauth-scopes/ <div dir="ltr" style="text-align: left;" trbidi="on"> <div dir="ltr" style="text-align: left;" trbidi="on"> Here is the list of <b>Google OAuth</b> Scopes. It can be used for different purposes.</p> </div> <div class="shadow" style="opacity: 0;"> </div> <table border="1" style="line-height: 25px;"> <tr class="op-menutrstitem op-menuchecktrstitem multiple" val="https://www.googleapis.com/auth/adsense"> <td style="margin-right: 20px;"> Adsense Management </td> <pre><code> &lt;td class=&quot;secondary&quot;&gt; https://www.googleapis.com/auth/adsense &lt;/td&gt; &lt;/tr&gt; &lt;tr class=&quot;op-menutrstitem op-menuchecktrstitem multiple&quot; val=&quot;https://www.googleapis.com/auth/gan&quot;&gt; &lt;td style=&quot;margin-right: 20px;&quot;&gt; Google Affitrate Network &lt;/td&gt; &lt;td class=&quot;secondary&quot;&gt; https://www.googleapis.com/auth/gan &lt;/td&gt; &lt;/tr&gt; &lt;tr class=&quot;op-menutrstitem op-menuchecktrstitem multiple&quot; val=&quot;https://www.googleapis.com/auth/analytics.readonly&quot;&gt; &lt;td style=&quot;margin-right: 20px;&quot;&gt; Analytics &lt;/td&gt; &lt;td class=&quot;secondary&quot;&gt; https://www.googleapis.com/auth/analytics.readonly &lt;/td&gt; &lt;/tr&gt; &lt;tr class=&quot;op-menutrstitem op-menuchecktrstitem multiple&quot; val=&quot;https://www.googleapis.com/auth/books&quot;&gt; &lt;td style=&quot;margin-right: 20px;&quot;&gt; Google Books &lt;/td&gt; &lt;td class=&quot;secondary&quot;&gt; https://www.googleapis.com/auth/books &lt;/td&gt; &lt;/tr&gt; &lt;tr class=&quot;op-menutrstitem op-menuchecktrstitem multiple&quot; val=&quot;https://www.googleapis.com/auth/blogger&quot;&gt; &lt;td style=&quot;margin-right: 20px;&quot;&gt; Blogger &lt;/td&gt; &lt;td class=&quot;secondary&quot;&gt; https://www.googleapis.com/auth/blogger &lt;/td&gt; &lt;/tr&gt; &lt;tr class=&quot;op-menutrstitem op-menuchecktrstitem multiple&quot; val=&quot;https://www.googleapis.com/auth/calendar&quot;&gt; &lt;td style=&quot;margin-right: 20px;&quot;&gt; Calendar &lt;/td&gt; &lt;td class=&quot;secondary&quot;&gt; https://www.googleapis.com/auth/calendar &lt;/td&gt; &lt;/tr&gt; &lt;tr class=&quot;op-menutrstitem op-menuchecktrstitem multiple&quot; val=&quot;https://www.googleapis.com/auth/devstorage.read_write&quot;&gt; &lt;td style=&quot;margin-right: 20px;&quot;&gt; Google Cloud Storage &lt;/td&gt; &lt;td class=&quot;secondary&quot;&gt; https://www.googleapis.com/auth/devstorage.read_write &lt;/td&gt; &lt;/tr&gt; &lt;tr class=&quot;op-menutrstitem op-menuchecktrstitem multiple&quot; val=&quot;https://www.google.com/m8/feeds/&quot;&gt; &lt;td style=&quot;margin-right: 20px;&quot;&gt; Contacts &lt;/td&gt; &lt;td class=&quot;secondary&quot;&gt; https://www.google.com/m8/feeds/ &lt;/td&gt; &lt;/tr&gt; &lt;tr class=&quot;op-menutrstitem op-menuchecktrstitem multiple&quot; val=&quot;https://www.googleapis.com/auth/structuredcontent&quot;&gt; &lt;td style=&quot;margin-right: 20px;&quot;&gt; Content API for Shopping &lt;/td&gt; &lt;td class=&quot;secondary&quot;&gt; https://www.googleapis.com/auth/structuredcontent &lt;/td&gt; &lt;/tr&gt; &lt;tr class=&quot;op-menutrstitem op-menuchecktrstitem multiple&quot; val=&quot;https://www.googleapis.com/auth/chromewebstore.readonly&quot;&gt; &lt;td style=&quot;margin-right: 20px;&quot;&gt; Chrome Web Store &lt;/td&gt; &lt;td class=&quot;secondary&quot;&gt; https://www.googleapis.com/auth/chromewebstore.readonly &lt;/td&gt; &lt;/tr&gt; &lt;tr class=&quot;op-menutrstitem op-menuchecktrstitem multiple&quot; val=&quot;https://docs.google.com/feeds/&quot;&gt; &lt;td style=&quot;margin-right: 20px;&quot;&gt; Documents trst &lt;/td&gt; &lt;td class=&quot;secondary&quot;&gt; https://docs.google.com/feeds/ &lt;/td&gt; &lt;/tr&gt; &lt;tr class=&quot;op-menutrstitem op-menuchecktrstitem multiple&quot; val=&quot;https://www.googleapis.com/auth/drive&quot;&gt; &lt;td style=&quot;margin-right: 20px;&quot;&gt; Google Drive &lt;/td&gt; &lt;td class=&quot;secondary&quot;&gt; https://www.googleapis.com/auth/drive &lt;/td&gt; &lt;/tr&gt; &lt;tr class=&quot;op-menutrstitem op-menuchecktrstitem multiple&quot; val=&quot;https://www.googleapis.com/auth/drive.file&quot;&gt; &lt;td style=&quot;margin-right: 20px;&quot;&gt; Google Drive Files &lt;/td&gt; &lt;td class=&quot;secondary&quot;&gt; https://www.googleapis.com/auth/drive.file &lt;/td&gt; &lt;/tr&gt; &lt;tr class=&quot;op-menutrstitem op-menuchecktrstitem multiple&quot; val=&quot;https://mail.google.com/mail/feed/atom&quot;&gt; &lt;td style=&quot;margin-right: 20px;&quot;&gt; Gmail &lt;/td&gt; &lt;td class=&quot;secondary&quot;&gt; https://mail.google.com/mail/feed/atom &lt;/td&gt; &lt;/tr&gt; &lt;tr class=&quot;op-menutrstitem op-menuchecktrstitem multiple&quot; val=&quot;https://www.googleapis.com/auth/plus.me&quot;&gt; &lt;td style=&quot;margin-right: 20px;&quot;&gt; Google+ &lt;/td&gt; &lt;td class=&quot;secondary&quot;&gt; https://www.googleapis.com/auth/plus.me &lt;/td&gt; &lt;/tr&gt; &lt;tr class=&quot;op-menutrstitem op-menuchecktrstitem multiple&quot; val=&quot;https://www.googleapis.com/auth/plus.me&quot;&gt; &lt;td style=&quot;margin-right: 20px;&quot;&gt; Google+ Friend list &lt;/td&gt; &lt;td class=&quot;secondary&quot;&gt; https://www.googleapis.com/auth/plus.login &lt;/td&gt; &lt;/tr&gt; &lt;tr class=&quot;op-menutrstitem op-menuchecktrstitem multiple&quot; val=&quot;https://apps-apis.google.com/a/feeds/groups/&quot;&gt; &lt;td style=&quot;margin-right: 20px;&quot;&gt; Groups Provisioning &lt;/td&gt; &lt;td class=&quot;secondary&quot;&gt; https://apps-apis.google.com/a/feeds/groups/ &lt;/td&gt; &lt;/tr&gt; &lt;tr class=&quot;op-menutrstitem op-menuchecktrstitem multiple&quot; val=&quot;https://www.googleapis.com/auth/latitude.all.best https://www.googleapis.com/auth/latitude.all.city&quot;&gt; &lt;td style=&quot;margin-right: 20px;&quot;&gt; Google Latitude &lt;/td&gt; &lt;td class=&quot;secondary&quot;&gt; https://www.googleapis.com/auth/latitude.all.best https://www.googleapis.com/auth/latitude.all.city &lt;/td&gt; &lt;/tr&gt; &lt;tr class=&quot;op-menutrstitem op-menuchecktrstitem multiple&quot; val=&quot;https://www.googleapis.com/auth/moderator&quot;&gt; &lt;td style=&quot;margin-right: 20px;&quot;&gt; Moderator &lt;/td&gt; &lt;td class=&quot;secondary&quot;&gt; https://www.googleapis.com/auth/moderator &lt;/td&gt; &lt;/tr&gt; &lt;tr class=&quot;op-menutrstitem op-menuchecktrstitem multiple&quot; val=&quot;https://apps-apis.google.com/a/feeds/atras/&quot;&gt; &lt;td style=&quot;margin-right: 20px;&quot;&gt; Nicknames Provisioning &lt;/td&gt; &lt;td class=&quot;secondary&quot;&gt; https://apps-apis.google.com/a/feeds/atras/ &lt;/td&gt; &lt;/tr&gt; &lt;tr class=&quot;op-menutrstitem op-menuchecktrstitem multiple&quot; val=&quot;https://www.googleapis.com/auth/orkut&quot;&gt; &lt;td style=&quot;margin-right: 20px;&quot;&gt; Orkut &lt;/td&gt; &lt;td class=&quot;secondary&quot;&gt; https://www.googleapis.com/auth/orkut &lt;/td&gt; &lt;/tr&gt; &lt;tr class=&quot;op-menutrstitem op-menuchecktrstitem multiple&quot; val=&quot;https://picasaweb.google.com/data/&quot;&gt; &lt;td style=&quot;margin-right: 20px;&quot;&gt; Picasa Web &lt;/td&gt; &lt;td class=&quot;secondary&quot;&gt; https://picasaweb.google.com/data/ &lt;/td&gt; &lt;/tr&gt; &lt;tr class=&quot;op-menutrstitem op-menuchecktrstitem multiple&quot; val=&quot;https://sites.google.com/feeds/&quot;&gt; &lt;td style=&quot;margin-right: 20px;&quot;&gt; Sites &lt;/td&gt; &lt;td class=&quot;secondary&quot;&gt; https://sites.google.com/feeds/ &lt;/td&gt; &lt;/tr&gt; &lt;tr class=&quot;op-menutrstitem op-menuchecktrstitem multiple&quot; val=&quot;https://spreadsheets.google.com/feeds/&quot;&gt; &lt;td style=&quot;margin-right: 20px;&quot;&gt; Spreadsheets &lt;/td&gt; &lt;td class=&quot;secondary&quot;&gt; https://spreadsheets.google.com/feeds/ &lt;/td&gt; &lt;/tr&gt; &lt;tr class=&quot;op-menutrstitem op-menuchecktrstitem multiple&quot; val=&quot;https://www.googleapis.com/auth/tasks&quot;&gt; &lt;td style=&quot;margin-right: 20px;&quot;&gt; Tasks &lt;/td&gt; &lt;td class=&quot;secondary&quot;&gt; https://www.googleapis.com/auth/tasks &lt;/td&gt; &lt;/tr&gt; &lt;tr class=&quot;op-menutrstitem op-menuchecktrstitem multiple&quot; val=&quot;https://www.googleapis.com/auth/urlshortener&quot;&gt; &lt;td style=&quot;margin-right: 20px;&quot;&gt; URL Shortener &lt;/td&gt; &lt;td class=&quot;secondary&quot;&gt; https://www.googleapis.com/auth/urlshortener &lt;/td&gt; &lt;/tr&gt; &lt;tr class=&quot;op-menutrstitem op-menuchecktrstitem multiple&quot; val=&quot;https://www.googleapis.com/auth/userinfo.email&quot;&gt; &lt;td style=&quot;margin-right: 20px;&quot;&gt; Userinfo &amp;#8211; Email &lt;/td&gt; &lt;td class=&quot;secondary&quot;&gt; https://www.googleapis.com/auth/userinfo.email &lt;/td&gt; &lt;/tr&gt; &lt;tr class=&quot;op-menutrstitem op-menuchecktrstitem multiple&quot; val=&quot;https://www.googleapis.com/auth/userinfo.profile&quot;&gt; &lt;td style=&quot;margin-right: 20px;&quot;&gt; Userinfo &amp;#8211; Profile &lt;/td&gt; &lt;td class=&quot;secondary&quot;&gt; https://www.googleapis.com/auth/userinfo.profile &lt;/td&gt; &lt;/tr&gt; &lt;tr class=&quot;op-menutrstitem op-menuchecktrstitem multiple&quot; val=&quot;https://apps-apis.google.com/a/feeds/user/&quot;&gt; &lt;td style=&quot;margin-right: 20px;&quot;&gt; User Provisioning &lt;/td&gt; &lt;td class=&quot;secondary&quot;&gt; https://apps-apis.google.com/a/feeds/user/ &lt;/td&gt; &lt;/tr&gt; &lt;tr class=&quot;op-menutrstitem op-menuchecktrstitem multiple&quot; val=&quot;https://www.google.com/webmasters/tools/feeds/&quot;&gt; &lt;td style=&quot;margin-right: 20px;&quot;&gt; Webmaster Tools &lt;/td&gt; &lt;td class=&quot;secondary&quot;&gt; https://www.google.com/webmasters/tools/feeds/ &lt;/td&gt; &lt;/tr&gt; &lt;tr class=&quot;op-menutrstitem op-menuchecktrstitem multiple&quot; val=&quot;https://gdata.youtube.com&quot;&gt; &lt;td style=&quot;margin-right: 20px;&quot;&gt; YouTube &lt;/td&gt; &lt;td class=&quot;secondary&quot;&gt; https://gdata.youtube.com &lt;/td&gt; &lt;/tr&gt; </code></pre> </table> <p> <span style="font-size: large;">See <a href="http://sag-3.blogspot.com/2013/04/login-with-google-oauth-without-using.html" >this post</a> to know how to login/signup your users without using&nbsp;<b>Google OAuth PHP</b>&nbsp;Library.</span></div> How to display errors in a PHP file ? https://subinsb.com/how-to-display-errors-in-a-php-file/ Wed, 17 Apr 2013 05:42:00 +0000 https://subinsb.com/how-to-display-errors-in-a-php-file/ <div dir="ltr" style="text-align: left;" trbidi="on"> <span style="font-family: inherit;">When you code <b>PHP</b>&nbsp;some errors might have happened. But you won&#8217;t know that and the program don&#8217;t work. You can use <b>PHP</b>&#8216;s <b>error_reporting</b> function to display errors. Here&#8217;s how to do it:</span><br /><span style="font-family: inherit;"><br /></span> <span style="font-family: inherit;">Create a file named <b>errors.php</b>&nbsp;in the folder where the file with errors exist.</span><br /><span style="font-family: inherit;">Open the <b>errors.php</b>&nbsp;file in text editor and paste these codes in the file:</span></p> <blockquote class="tr_bq"> <p> <span style="font-family: inherit;"><span style="font-family: inherit;"><?<br /></span><span style="font-family: inherit;">error_reporting(E_ALL);</span><span style="font-family: inherit;"><br /></span><span style="font-family: inherit;">ini_set("display_errors", 1);</span><span style="font-family: inherit;"><br /></span><span style="font-family: inherit;">include("filename</span>.ph<span style="font-family: inherit;">p</span><span style="font-family: inherit;">"</span><span style="font-family: inherit;">);</span><span style="font-family: inherit;"><br /></span><span style="font-family: inherit;">?></span></span> </p> </blockquote> <p> Replace <b>filename.php</b>&nbsp;with the name of the file that has errors.<br />Open the <b>errors.php</b>&nbsp;file in browser. You can now see the errors in the file.</div> jQuery .live function removed in V 1.9. What is the best replacement for .live function ? https://subinsb.com/jquery-live-function-removed-in-v-1-9-what-is-the-best-replacement-for-live-function/ Tue, 16 Apr 2013 04:09:00 +0000 https://subinsb.com/jquery-live-function-removed-in-v-1-9-what-is-the-best-replacement-for-live-function/ <div dir="ltr" style="text-align: left;" trbidi="on"> <div dir="ltr" style="text-align: left;" trbidi="on"> <span style="font-family: Times, Times New Roman, serif;">As of <b>jQuery</b>&nbsp;version 1.9, the <b>.live</b>&nbsp;function has been removed which means it is no longer available to use. Instead of this function you can use <b>.on</b>&nbsp;function which also has the same function as <b>.live</b>.&nbsp;</span><br /><span style="font-family: Times, Times New Roman, serif;"><br />Both of them a<span style="background-color: white; line-height: 22.5px;">ttach an event handler for all elements which match the current selector, now and in the future.</span></span><br /><span style="font-family: Times, Times New Roman, serif; line-height: 22.5px;">Since <b>.live</b>&nbsp;has been removed you can use <b>.on</b>&nbsp;function. Here&#8217;s how we should do it.</span><br /><span style="font-family: Times, Times New Roman, serif; line-height: 22.5px;">Replace <b>.live</b>&nbsp;function with <b>.on</b>. It&#8217;s that simple.</span><br /><span style="font-family: Times, Times New Roman, serif; font-size: large; line-height: 22.5px;"><u><b>Example:</b></u></span></p> <pre><code>&lt;div class=&quot;container&quot; style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: auto !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: relative !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt; &lt;blockquote class=&quot;tr_bq&quot;&gt; &lt;p&gt; &lt;span style=&quot;font-family: Times, Times New Roman, serif;&quot;&gt;$(&lt;span class=&quot;string&quot; style=&quot;box-sizing: border-box; color: #dd1144;&quot;&gt;&quot;&lt;span style=&quot;color: red;&quot;&gt;#dataTable tbody tr&lt;/span&gt;&quot;&lt;/span&gt;).live(&lt;span class=&quot;string&quot; style=&quot;box-sizing: border-box; color: #dd1144;&quot;&gt;&quot;&lt;span style=&quot;color: red;&quot;&gt;click&lt;/span&gt;&quot;&lt;/span&gt;, &lt;span class=&quot;keyword&quot; style=&quot;box-sizing: border-box; font-weight: bold;&quot;&gt;function&lt;/span&gt;(event){&lt;br /&gt;&lt;span style=&quot;background-color: white;&quot;&gt; alert($(&lt;span class=&quot;keyword&quot; style=&quot;box-sizing: border-box; color: red; font-weight: bold;&quot;&gt;this&lt;/span&gt;).text());&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;background-color: white;&quot;&gt;});&lt;/span&gt;&lt;/span&gt; &lt;/p&gt; &lt;/blockquote&gt; &lt;/div&gt; </code></pre> </div> <p> <span style="font-family: Times, Times New Roman, serif;"><span style="line-height: 22.5px;">With :</span></span> </p> <blockquote class="tr_bq"> <p> <span style="font-family: Times, Times New Roman, serif;"><span style="line-height: 22.5px;"><span style="line-height: normal; white-space: pre;">$(</span><span class="string" style="box-sizing: border-box; color: #dd1144;">"<span style="color: red;">#dataTable tbody tr</span>"</span><span style="line-height: normal; white-space: pre;">).on(</span><span class="string" style="box-sizing: border-box; color: #dd1144;">"<span style="color: red;">click</span>"</span><span style="line-height: normal; white-space: pre;">, </span><span class="keyword" style="box-sizing: border-box; font-weight: bold;">function</span><span style="line-height: normal; white-space: pre;">(event){</span></span><br /><span style="line-height: 22.5px;"><span style="background-color: white;"> alert($(<span class="keyword" style="box-sizing: border-box; color: red; font-weight: bold;">this</span>).text());</span></span><br /><span style="line-height: 22.5px;"><span style="background-color: white;">});</span></span></span> </p> </blockquote> <p> <span style="line-height: 22.5px;"><span style="background-color: white; font-family: Times, Times New Roman, serif;">Use a software such as <a href="http://adf.ly/J9Rdm" >regexxer</a> to replace all <b>.live(</b> word with <b>.on(</b> word.</span></span></div> How to make sure that a CSS file will load on your site using PHP https://subinsb.com/how-to-make-sure-that-a-css-file-will-load-on-your-site-using-php/ Mon, 15 Apr 2013 13:50:00 +0000 https://subinsb.com/how-to-make-sure-that-a-css-file-will-load-on-your-site-using-php/ <div dir="ltr" style="text-align: left;" trbidi="on"> This is a simple trick. Most of the web developers worry that the Stylesheet file will not load completely. This happens if your <b>CSS</b>&nbsp;file&#8217;s size is too large. The fail in complete loading of the file mostly happens to users who are using slower connections like me.</p> <div> </div> <div> The page will look disgusting if the <b>CSS</b>&nbsp;file don&#8217;t load. To avoid the file not getting loaded you can do this simple trick using <b>PHP</b>. </div> <div> </div> <div> Open your <b>PHP</b>&nbsp;page and replace the lines that embed the stylesheet file. </div> <div> <span style="font-size: large;"><b>Example:</b></span> </div> <div> Replace this: </div> <blockquote class="tr_bq"> <p> <link href="<a href="https://subins.hp.af.cm/files/css/all.php"><span style="color: red;">https://subins.hp.af.cm/files/css/all.php</span></a>" rel="stylesheet" /> </p> </blockquote> <div> With this: </div> <blockquote class="tr_bq"> <p> <style><?echo file_get_contents(&#8216;<a href="https://subins.hp.af.cm/files/css/all.php"><span style="color: red;">https://subins.hp.af.cm/files/css/all.php</span></a>&#8216;);?></style> </p> </blockquote> <div> When the page loads the <b>CSS</b>&nbsp;styles of the external file will be loaded in the <b><style></b>&nbsp;tag. This method won&#8217;t fail. <b>PHP</b>&nbsp;make sure that the <b>CSS</b>&nbsp;file loads. </div> <div> </div> <div> You can also do this technique with <b>Javascript</b>&nbsp;files. </div> </div> Subins Update 1.2 https://subinsb.com/subins-update-1-2/ Mon, 01 Apr 2013 04:45:00 +0000 https://subinsb.com/subins-update-1-2/ <div dir="ltr" style="text-align: left;" trbidi="on"> Subins has been updated to 1.2. The new changes have been made on Subins and is updated today. The sites that affected the changes are:</p> <div id="toc_container" class="no_bullets"> <p class="toc_title"> Contents </p> <pre><code>&lt;ul class=&quot;toc_list&quot;&gt; &lt;li&gt; &lt;a href=&quot;#subins-chat&quot;&gt;&lt;span class=&quot;toc_number toc_depth_1&quot;&gt;1&lt;/span&gt; Subins Chat&lt;/a&gt; &lt;/li&gt; &lt;li&gt; &lt;a href=&quot;#accounts&quot;&gt;&lt;span class=&quot;toc_number toc_depth_1&quot;&gt;2&lt;/span&gt; Accounts&lt;/a&gt; &lt;/li&gt; &lt;li&gt; &lt;a href=&quot;#subins&quot;&gt;&lt;span class=&quot;toc_number toc_depth_1&quot;&gt;3&lt;/span&gt; Subins&lt;/a&gt; &lt;/li&gt; &lt;li&gt; &lt;a href=&quot;#friendshood&quot;&gt;&lt;span class=&quot;toc_number toc_depth_1&quot;&gt;4&lt;/span&gt; Friendshood&lt;/a&gt; &lt;/li&gt; &lt;li&gt; &lt;a href=&quot;#subins-get&quot;&gt;&lt;span class=&quot;toc_number toc_depth_1&quot;&gt;5&lt;/span&gt; Subins GET&lt;/a&gt; &lt;/li&gt; &lt;/ul&gt; </code></pre> </div> <h2 style="text-align: left;"> <span id="subins-chat"><u><a href="http://chat-subins.hp.af.cm/" >Subins Chat</a></u></span> </h2> <div> In <b>Subins</b>&nbsp;<b>Chat </b>the design has been changed. The bugs have been fixed and It&#8217;s more fast than before.<br /><b>Subins Chat</b>&nbsp;is not only a group chat but a place for submitting <b>suggestions, bugs, errors and feedback</b>.<br />Please report any errors or bugs&nbsp;happening on any of the sites of <b>Subins</b>&nbsp;in&nbsp;<b>Subins Chat</b>.</p> <pre><code>&lt;h2 style=&quot;text-align: left;&quot;&gt; &lt;span id=&quot;accounts&quot;&gt;&lt;u&gt;&lt;a href=&quot;http://accounts-subins.hp.af.cm/&quot; &gt;Accounts&lt;/a&gt;&lt;/u&gt;&lt;/span&gt; &lt;/h2&gt; </code></pre> </div> <div> Only the <b>PHP</b>&nbsp;code is changed. Others are all the same. Added extra security measures. </div> <h2 style="text-align: left;"> <span id="subins"><u><a href="http://subins.hp.af.cm/" >Subins</a></u></span> </h2> <div> <b>PHP</b>&nbsp;code changed. The pagination <b>CSS</b>&nbsp;has been changed. More colourful. Automatic adding of results. </div> <h2 style="text-align: left;"> <span id="friendshood"><u><a href="http://fd-subins.hp.af.cm/" >Friendshood</a></u></span> </h2> <div> <b>Friendshood</b> was discontinued a while back, but now it has been restored. <b>Friendshood</b>&#8216;s style has been changed. <b>Like</b>&nbsp;button, <b>Comment</b>&nbsp;button and<b>&nbsp;Share</b>&nbsp;button style is changed to new and attarctive style. <b>Uploading</b>&nbsp;<b>Image</b>&nbsp;bug has been fixed, Thanks to <b>ImgUr</b>.&nbsp; </div> <h2 style="text-align: left;"> <span id="subins-get"><u><a href="http://get-subins.hp.af.cm/" >Subins GET</a></u></span> </h2> <div> <b>Subins Apps</b>&nbsp;and <b>Subins Games</b>&nbsp;have been merged to <b>Subins GET</b>.&nbsp; </div> <div> <b>Subins GET </b>has a new function which&nbsp;<b>Converts YouTube video to MP3</b>. The converted MP3 file is added to <b>Subins GET&nbsp;</b>&nbsp;database with the video picture, <b>URL</b>&nbsp;and uploader name.&nbsp; </div> <div> <b>Subins GET</b>&nbsp;is the site which has a lot of changes in this update. </div> <div class="separator" style="clear: both; text-align: center;"> <a href="https://2.bp.blogspot.com/-54eg75gVyWI/UVkQchwwwoI/AAAAAAAACdE/KO0_x6NhJmU/s1600/logo.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="146" src="https://2.bp.blogspot.com/-54eg75gVyWI/UVkQchwwwoI/AAAAAAAACdE/KO0_x6NhJmU/s400/logo.png" width="400" /></a> </div> <div> </div> </div> What is SQL Injection and how to make your PHP site free from SQL Injection hacking https://subinsb.com/what-is-sql-injection-and-how-to-make-your-php-site-free-from-sql-injection-hacking/ Wed, 27 Mar 2013 13:32:00 +0000 https://subinsb.com/what-is-sql-injection-and-how-to-make-your-php-site-free-from-sql-injection-hacking/ <div dir="ltr" style="text-align: left;" trbidi="on"> <b><a href="http://en.wikipedia.org/wiki/SQL_injection" >SQL Injection (SQLi)</a></b> is a very dangerous thing that a hacker can do to your site. This happens mostly in <b>SQL</b>&nbsp;queries. Let me make you understand this in a simple way. Suppose you&#8217;re <b>SQL</b>&nbsp;query code is this:</p> <blockquote class="tr_bq"> <p> $user=$_GET[&#8216;user&#8217;];<br />$sql=mysql_query("SELECT * FROM users WHERE user='".$user."&#8216;"); </p> </blockquote> <div> It&#8217;s a normal code. <b>BUT</b>&nbsp;it is a very easy method for hacker to easily destroy your database. </div> <div> The user ID is getting from a <b>GET</b>&nbsp;request. If the file&#8217;s name (where the request is going) is <b>user.php</b>. The <b>URL</b>&nbsp;may be like this: </div> <blockquote class="tr_bq"> <p> http://example.com/user.php?user=<span style="color: red;">subin</span> </p> </blockquote> <div> and the <b>SQL</b>&nbsp;query will be : </div> <div> <blockquote class="tr_bq"> <p> SELECT * FROM users WHERE user=&#8217;<span style="color: red;">subin</span>&#8216; </p> </blockquote> </div> <div> The file will print out user information and other stuffs. But what if the hacker put on more values in the user variable in the <b>URL</b>. Suppose like this: </div> <blockquote class="tr_bq"> <p> http://example.com/user.php?user=<span style="color: red;">subin&#8217;;DROP TABLE users;</span><span style="color: red;">SELECT * FROM user WHERE user=&#8217;otherguy</span> </p> </blockquote> <div> OR like this: </div> <blockquote class="tr_bq"> <p> http://example.com/user.php?user=<span style="color: red;">subin";DROP TABLE users;SELECT * FROM user WHERE user=&#8217;otherguy</span> </p> </blockquote> <div> and the SQL query will be: </div> <blockquote class="tr_bq"> <p> SELECT * FROM users WHERE user=&#8217;<span style="color: red;">subin</span>&#8216;;DROP TABLE users;SELECT * FROM user WHERE user=&#8217;otherguy&#8217;; </p> </blockquote> <div> You know what will happen. Yes that&#8217;s right. The table &#8216;users&#8217; will be deleted and your entire table is lost. The hacker can also delete the database if he/she wants. So now you understand what is&nbsp;<b>SQL Injection</b><br /><b><br /></b> </div> <div style="text-align: left;"> <u><span style="font-size: large;"><b>How to make your PHP site free from SQL Injection hacking</b></span></u> </div> <div style="text-align: left;"> <u><span style="font-size: large;"><b><br /></b></span></u> </div> <div> This method is real simple. All you have to do is add&nbsp;<b>mysql_real_escape_string()</b> function in variables in an &nbsp;<b>SQL</b>&nbsp;query. Example: </div> <blockquote class="tr_bq"> <p> $user=<b><span style="color: red;">mysql_real_escape_string(</span></b>$_GET[&#8216;user&#8217;]<span style="color: red;">)</span>;<br />$sql=mysql_query("SELECT * FROM users WHERE user='".$user."&#8216;"); </p> </blockquote> <div> Enjoy un-hackable site. </div> </div> Create a free .tk domain website with free hosting by AppFog https://subinsb.com/create-a-free-tk-domain-website-with-free-hosting-by-appfog/ Sun, 24 Feb 2013 05:57:00 +0000 https://subinsb.com/create-a-free-tk-domain-website-with-free-hosting-by-appfog/ <div class="padlinks"> <a class="demo" href="http://msurl.tk/">DEMO</a> </div> <p>This free <strong>.tk</strong>ย domain is made available by a company called <strong>Dotย TK</strong>ย and the free hosting is provided by <strong>AppFog</strong>.</p> <div style="text-align: center;"> <div class="separator" style="clear: both; text-align: center;"> <a style="margin-left: 1em; margin-right: 1em;" href="//3.bp.blogspot.com/-oNdKese_CrQ/Ub1UK4o6PiI/AAAAAAAACtU/M0GTKNzJaBs/s1600/0006.png"><img src="//3.bp.blogspot.com/-oNdKese_CrQ/Ub1UK4o6PiI/AAAAAAAACtU/M0GTKNzJaBs/s1600/0006.png" alt="" border="0" /></a> </div> <h1 class="separator" style="clear: both; text-align: left;"> Create free hosting for site </h1> </div> <div> Go to <b><a href="http://adf.ly/JiFq8">AppFogย Signup page</a></b> </div> <div class="separator" style="clear: both; text-align: center;"> <a style="margin-left: 1em; margin-right: 1em;" href="//1.bp.blogspot.com/-l3TncKL2Qc0/USmgS8bMIAI/AAAAAAAACbc/tcyx5l9bxDw/s1600/appfogform.png"><img src="//1.bp.blogspot.com/-l3TncKL2Qc0/USmgS8bMIAI/AAAAAAAACbc/tcyx5l9bxDw/s1600/appfogform.png" alt="" border="0" /></a> </div> <div> Fill up the form and click <b>Signup</b>. </div> <div> Go to <a href="https://console.appfog.com/apps/new">Create an app</a> </div> <div> </div> <div> Choose an application: </div> <div> </div> <div class="separator" style="clear: both; text-align: center;"> <a style="margin-left: 1em; margin-right: 1em;" href="//1.bp.blogspot.com/-VpN_T3s6dMg/USmhlf2NN1I/AAAAAAAACbk/aovb3Soc3CU/s1600/chooseapp.png"><img src="//1.bp.blogspot.com/-VpN_T3s6dMg/USmhlf2NN1I/AAAAAAAACbk/aovb3Soc3CU/s640/chooseapp.png" alt="" width="640" height="395" border="0" /></a> </div> <div> </div> <div> Choose a infrastructure and a subdomain (I use <b>HP</b>): </div> <div> </div> <div class="separator" style="clear: both; text-align: center;"> <a style="margin-left: 1em; margin-right: 1em;" href="//3.bp.blogspot.com/-J0m61xZ0AHg/USmiRs9yCCI/AAAAAAAACbs/DHaoTrxQ3xY/s1600/infra.png"><img src="//3.bp.blogspot.com/-J0m61xZ0AHg/USmiRs9yCCI/AAAAAAAACbs/DHaoTrxQ3xY/s640/infra.png" alt="" width="640" height="392" border="0" /></a> </div> <div> </div> <div> After filling up form, click on <b>Create App</b>. </div> <div class="separator" style="clear: both; text-align: center;"> <a style="margin-left: 1em; margin-right: 1em;" href="//1.bp.blogspot.com/-WAeqLdze3BQ/USmi1XPjskI/AAAAAAAACb0/pX2wufKD5Rs/s1600/buliding-appfog.png"><img src="//1.bp.blogspot.com/-WAeqLdze3BQ/USmi1XPjskI/AAAAAAAACb0/pX2wufKD5Rs/s640/buliding-appfog.png" alt="" width="640" height="420" border="0" /></a> </div> <div> </div> <div> You will be automatically redirected to the app panel. </div> <div> That&#8217;s it. You created your <b>AppFog</b>ย app. </div> <div> To learn how to upload files to your app. Here are some pages that will help you understand about <b>AppFog</b>. </div> <div> <ul style="text-align: left;"> <li> <b><a href="http://adf.ly/JiHkv">Installing AF CLI Tool</a></b> </li> <li> <b><a href="http://adf.ly/JiHsX">Uploading files to app in Windows.</a></b> </li> <li> <b><a href="http://adf.ly/JiHzq">Uploading files to app in Mac OSX & Linux.</a></b> </li> <li> <b><a href="http://sag-3.blogspot.com/2012/12/appfog-linux-updation.html">Uploading files to app in Ubuntu (alternate way).</a></b> </li> </ul> </div> <div> Theย createdย app domain will be <b>.hp.af.cm</b>. You can link this app to <b>Dot TK</b>. See How to do that below. </div> <h1 style="text-align: left;"> Create Free Website </h1> <div> Go to <b><a href="http://adf.ly/JiEP2">Dot TK</a></b>ย website. </div> <div> Login with a service provider (Google, Facebook etc&#8230;) </div> <div> Go to <a href="http://adf.ly/JiFCZ">Add Domain</a> </div> <div class="separator" style="clear: both; text-align: center;"> <a style="margin-left: 1em; margin-right: 1em;" href="//3.bp.blogspot.com/-PzyisBlI-eA/USmfZrSttBI/AAAAAAAACbU/iylPpAFmKEE/s1600/domainadd.png"><img src="//3.bp.blogspot.com/-PzyisBlI-eA/USmfZrSttBI/AAAAAAAACbU/iylPpAFmKEE/s640/domainadd.png" alt="" width="640" height="276" border="0" /></a> </div> <div> Fill up the form and click <b>NEXT</b>. </div> <div> A new page will be visible and in it click theย <span style="background-color: white; font-family: Arial, sans-serif; font-size: 15px;"><b>Use DNS for this domain</b></span><span style="font-family: Arial, sans-serif; font-size: 15px;">ย button.</span> </div> <div> <span style="font-family: Arial, sans-serif; font-size: 15px;">Go to <a href="http://adf.ly/JiIxA"><b>AppFog</b>ย panel</a> in another tab. Click your app and from the app panel click <b>Domain Names.</b></span> </div> <div> <span style="font-family: Arial, sans-serif;"><span style="font-size: 15px;"><b>Type </b>the url of site you made in <b>Dot TK </b>in the input box as shown in the picture:</span></span> </div> <div class="separator" style="clear: both; text-align: center;"> <a style="margin-left: 1em; margin-right: 1em;" href="//3.bp.blogspot.com/-tAgDHW3_Bcs/USmnu-bZkwI/AAAAAAAACb8/YmvIuHndTN0/s1600/adddomain-dot-tk-appfog.png"><img src="//3.bp.blogspot.com/-tAgDHW3_Bcs/USmnu-bZkwI/AAAAAAAACb8/YmvIuHndTN0/s640/adddomain-dot-tk-appfog.png" alt="" width="640" height="288" border="0" /></a> </div> <div> <span style="font-family: Arial, sans-serif;"><span style="font-size: 15px;">ย </span></span> </div> <div> <span style="font-family: Arial, sans-serif;"><span style="font-size: 15px;">Then Click on <b>Update</b>ย button.</span></span> </div> <div> <span style="font-family: Arial, sans-serif;"><span style="font-size: 15px;">ย </span></span> </div> <h3 style="text-align: left;"> <span style="font-family: Arial, sans-serif;"><span style="text-decoration: underline;">Getting the <b>IP</b>ย address of <b>AppFog</b>ย app<span style="font-size: 15px;">.</span></span></span> </h3> <div> <span style="font-family: Arial, sans-serif;"><span style="font-size: 15px;">Open a new tab and go toย <a href="http://www.getip.com/">http://www.getip.com/</a></span></span> </div> <div> <span style="font-family: Arial, sans-serif;"><span style="font-size: 15px;">Type the <b>URL</b>ย of the <b>AppFog </b>app in to the <b>selfseo</b> input box and click <b>Get IP</b>.</span></span> </div> <div class="separator" style="clear: both; text-align: center;"> <a style="margin-left: 1em; margin-right: 1em;" href="//1.bp.blogspot.com/-TxyNyLwl0WU/USmpir1VcXI/AAAAAAAACcE/HZFc1_ZN3sQ/s1600/ip-find.png"><img src="//1.bp.blogspot.com/-TxyNyLwl0WU/USmpir1VcXI/AAAAAAAACcE/HZFc1_ZN3sQ/s640/ip-find.png" alt="" width="640" height="248" border="0" /></a> </div> <div> <span style="font-family: Arial, sans-serif;"><span style="font-size: 15px;">ย </span></span> </div> <div> <span style="font-family: Arial, sans-serif;"><span style="font-size: 15px;">The page will show the <b>IP address</b>ย of the site :</span></span> </div> <div class="separator" style="clear: both; text-align: center;"> <a style="margin-left: 1em; margin-right: 1em;" href="//3.bp.blogspot.com/-P4uIQeDfQzY/USmpqG4P3QI/AAAAAAAACcM/0obcAYV0uOs/s1600/ip-found.png"><img src="//3.bp.blogspot.com/-P4uIQeDfQzY/USmpqG4P3QI/AAAAAAAACcM/0obcAYV0uOs/s1600/ip-found.png" alt="" border="0" /></a> </div> <div class="separator" style="clear: both; text-align: left;"> Go to the <b>Dot TK</b>ย tab we already opened. Type the <b>IP </b>address we just found on to the twoย <b>IP address </b>input box : </div> <div class="separator" style="clear: both; text-align: center;"> <a style="margin-left: 1em; margin-right: 1em;" href="//3.bp.blogspot.com/-ldKiljbSxcA/USmqZgVjDTI/AAAAAAAACcU/nrmOz92hYHc/s1600/fillup-form-tk.png"><img src="//3.bp.blogspot.com/-ldKiljbSxcA/USmqZgVjDTI/AAAAAAAACcU/nrmOz92hYHc/s640/fillup-form-tk.png" alt="" width="640" height="462" border="0" /></a> </div> <div class="separator" style="clear: both; text-align: left;"> Change the <b>Registration </b>length to <b>12 months</b>. </div> <div class="separator" style="clear: both; text-align: left;"> Type the verification code in the picture and click on the <b>Next</b>ย button. </div> <div class="separator" style="clear: both; text-align: left;"> </div> <div class="separator" style="clear: both; text-align: left;"> Visit the site you created on <b>Dot TK </b>to verify that your site is created<b>.</b> </div> <div class="separator" style="clear: both; text-align: left;"> <b>If you have any doubts or problems, feel free to comment the problem/doubt.</b> </div> Get Google Profile Picture URL by email id using PHP https://subinsb.com/get-google-profile-picture-url-by-email-id-using-php/ Thu, 21 Feb 2013 05:46:00 +0000 https://subinsb.com/get-google-profile-picture-url-by-email-id-using-php/ <div dir="ltr" style="text-align: left;" trbidi="on"> This is a trick using <b>Google Profile</b>.<br />First of all we are going to set a variable with a <b>Google&nbsp;E-mail</b>&nbsp;address<b>&nbsp;</b>(<b>Gmail </b>address). We are going to set it with my E-mail address</p> <blockquote class="tr_bq"> <p> $email=&#8217;<span style="color: red;">subins2000</span>@gmail.com&#8217;;&nbsp; </p> </blockquote> <p> Then we are going to split <b>@</b> from&nbsp;the mail address. </p> <blockquote class="tr_bq"> <p> list($id, $domain) = split("@",$email); </p> </blockquote> <p> Next we are going to send a request to <b>Google Profiles</b>&nbsp;to fetch the <b>IMAGE</b>&nbsp;url. </p> <blockquote class="tr_bq"> <p> $headers = get_headers("https://profiles.google.com/s2/photos/profile/".$id, 1); </p> </blockquote> <p> The variable <b>$id</b>&nbsp;above is from the splitted part.<br />Finally we have to get the <b>URL</b>&nbsp;of the user&#8217;s profile picture. </p> <blockquote class="tr_bq"> <p> $url = $headers[&#8216;Location&#8217;]; </p> </blockquote> <p> We have now got the <b>Image</b>&nbsp;URL. The overall code will be : </p> <blockquote class="tr_bq"> <p> $email=$_GET[&#8216;gmail&#8217;];<br />list($id, $domain) = split("@",$email);<br />$headers = get_headers("https://profiles.google.com/s2/photos/profile/".$id, 1);<br />$url = $headers[&#8216;Location&#8217;]; </p> </blockquote> <p> You could do whatever with the <b>IMAGE</b>&nbsp;URL.</div> 10 Songs for Making Programming Better https://subinsb.com/10-songs-for-making-programmingweb-developing-better/ Fri, 15 Feb 2013 16:07:00 +0000 https://subinsb.com/10-songs-for-making-programmingweb-developing-better/ <p>When I am coding my site <a href="http://open.subinsb.com">Open</a> or my blog, I hear a lot of songs along with coding. It makes me energetic and will help calm me down when an error occurs. The error probably will be a simple mistake but causes a lot of time to solve it. To calm me down I will play a song and <strong>BINGO !</strong> I fixed the error.</p> <p>Here are the songs that make my coding easier and refreshes my mind. The text in brackets are the detail of which the song do to my mind.</p> <ol> <li><strong>Outasight โ€“ Now Or Never</strong></li> <li><strong>Outasight โ€“ Tonight Is The Night</strong></li> <li><strong>Outasight โ€“ Outasight โ€“ Iโ€™ll Drink To That</strong></li> <li><strong>Train โ€“ 50 ways to say goodbye (Erases my pain of errors)</strong></li> <li><strong>Back Street Boys โ€“ show me the meaning of being lonely</strong></li> <li><strong>Back Street Boys โ€“ everybody Backstreetโ€™s Back (makes me energetic)</strong></li> <li><strong>Flo Rida-Turn Around (makes me happy)</strong></li> <li><strong>The Wanted โ€“ Chasing The Sun</strong></li> <li><strong>3 Days Grace โ€“ Never Too Late (makes me energetic)</strong></li> <li><strong>Matt Willis โ€“ Crash (makes me energetic)</strong></li> </ol> <p>Music make <strong>programming/web developing</strong> easier and better to me. I think music are the best in the world. Itโ€™s just my opinion. What do you think about it ? Post it in the comments.</p> <p>Try coding with a song playing. I am sure. It will make coding better. <strong>Try It Out</strong>.</p> How to edit/clear Ubuntu Terminal commands history ? https://subinsb.com/how-to-editclear-ubuntu-terminal-commands-history/ Thu, 14 Feb 2013 14:44:00 +0000 https://subinsb.com/how-to-editclear-ubuntu-terminal-commands-history/ <div dir="ltr" style="text-align: left;" trbidi="on"> This simple trick will help you to clear or edit terminal commands you entered in <b>Terminal </b>of <b>Ubuntu</b>.<br />Open the file <b>/home/<span style="color: red;">user</span>/.bash_history</b>&nbsp;(Replace red text with your username.</p> <p> To make it simple Go to your home folder and Press <b>CTRL&nbsp;+ H</b>. It will show hidden files.<br />search for the file&nbsp;<b>.bash_history</b><br /><b>Edit the file</b>.<br />You can see all the&nbsp;commands you entered in&nbsp;<b>Terminal</b>. </p> <p> <b>Remove what you don&#8217;t want and save.</b></div> How to replace protocol in links with the window URL protocol https://subinsb.com/how-to-replace-protocol-in-links-with-the-window-url-protocol/ Tue, 12 Feb 2013 17:22:00 +0000 https://subinsb.com/how-to-replace-protocol-in-links-with-the-window-url-protocol/ <div dir="ltr" style="text-align: left;" trbidi="on"> The best way to this is by replacing every <b>HTTP </b>& <b>HTTPS</b>&nbsp;in the <b>HTML</b>&nbsp;<b>file</b>&nbsp;with <b>//</b>. For Example:</p> <blockquote class="tr_bq"> <p> <a href="http://subins.tk">Subins</a> </p> </blockquote> <p> With : </p> <blockquote class="tr_bq"> <p> <a href="//subins.tk">Subins</a> </p> </blockquote> <p> If the location protocol is <b>HTTPS </b>&nbsp;all links&#8217; protocol will be changed to<b>&nbsp;HTTPS</b>&nbsp;and&nbsp;If the location protocol is&nbsp;<b>HTTP&nbsp;</b>&nbsp;all links&#8217; protocol will be changed to<b>&nbsp;HTTP</b>. </p> <p> For a <b>mass replacement </b>of links USE <b><a href="http://adf.ly/J9Rdm" >Regexxer</a>.</b></div> New : Change background of Subins Network. https://subinsb.com/new-change-background-of-subins-network/ Mon, 28 Jan 2013 14:57:00 +0000 https://subinsb.com/new-change-background-of-subins-network/ <div dir="ltr" style="text-align: left;" trbidi="on"> You can now change background of this blog and the whole Subins Network. You can only do this if you have a account in Subins. If you don&#8217;t have an account you can signup&nbsp;@ <a href="http://accounts-subins.hp.af.cm/signup.php">http://accounts-subins.hp.af.cm/signup.php</a>.&nbsp;</p> <div> </div> <div> To change background you must go to <a href="http://accounts-subins.hp.af.cm/">My Account</a> in Subins. In the left sidebar click <b>Appearance</b>. </div> <div> Click <b>Themes</b>&nbsp;or <b>Background</b>&nbsp;to change the background. </div> <div> </div> <div> Hope you like it. </div> </div> Using Regex to validate E-mail and Phone Number https://subinsb.com/using-regex-to-validate-e-mail-and-phone-number/ Sat, 26 Jan 2013 08:45:00 +0000 https://subinsb.com/using-regex-to-validate-e-mail-and-phone-number/ <div dir="ltr" style="text-align: left;" trbidi="on"> <span style="font-family: inherit;">Here is the <b>RegEx</b>&nbsp;expression to validate Phone number and E-mail.</span></p> <div> <span style="font-family: inherit;"><b>RegEx</b>&nbsp;expression for validating E-mail :</span> </div> <blockquote class="tr_bq"> <p> <span style="font-family: inherit;">/^(([^<>()[].,;:s@"]+(.[^<>()[].,;:s@"]+)*)|(".+"))@(([[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}])|(([a-zA-Z-0-9]+.)+[a-zA-Z]{2,}))$/</span> </p> </blockquote> <div> <span style="font-family: inherit;">and the&nbsp;<b>RegEx</b>&nbsp;expression for validating Phone number :</span> </div> <blockquote class="tr_bq"> <p> <span style="font-family: inherit;">/^(?([0-9]{3}))?[-. ]?([0-9]{3})[-. ]?([0-9]{4})$/</span> </p> </blockquote> <div> <span style="font-family: inherit;">Here is an example of usage of these <b>RegEx</b>&nbsp;expressions in <b>JavaScript</b>.</span> </div> <blockquote class="tr_bq"> <p> <span style="font-family: inherit;">var emailregex=/^(([^<>()[].,;:s@"]+(.[^<>()[].,;:s@"]+)*)|(".+"))@(([[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}])|(([a-zA-Z-0-9]+.)+[a-zA-Z]{2,}))$/;</span><span style="font-family: inherit;">var phoneregex=/^(?([0-9]{3}))?[-. ]?([0-9]{3})[-. ]?([0-9]{4})$/;</span><span style="font-family: inherit;">if (emailregex.test(<span style="color: red;">string</span>)){</span><span style="font-family: inherit;">// valid email</span><span style="font-family: inherit;">}else{</span><span style="font-family: inherit;">// Invalid email</span><span style="font-family: inherit;">}</span><span style="font-family: inherit;">if (phoneregex.test(<span style="color: red;">string</span>)){</span><span style="font-family: inherit;">// valid phone number</span><span style="font-family: inherit;">}else{</span><span style="font-family: inherit;">// Invalid phone number</span><span style="font-family: inherit;">}</span> </p> </blockquote> <div> <span style="font-family: inherit;">You can replace string with whatever you want. For Example:</span> </div> <blockquote class="tr_bq"> <p> <span style="font-family: inherit;">if (phoneregex.test($("#phone").val())){</span><span style="font-family: inherit;">// valid phone number</span><span style="font-family: inherit;">}else{</span><span style="font-family: inherit;">// Invalid phone number</span><span style="font-family: inherit;">}</span> </p> </blockquote> <p> Enjoy !!. </p> </div> My Short URL โ€“ a site for shortening URLโ€™s https://subinsb.com/my-short-url-a-site-for-shortening-urls/ Fri, 25 Jan 2013 17:40:00 +0000 https://subinsb.com/my-short-url-a-site-for-shortening-urls/ <div dir="ltr" style="text-align: left;" trbidi="on"> <b>My Short URL</b>&nbsp;is my latest invention. A site for shortening URL&#8217;s like <b>goo.gl</b>&nbsp;and<b>&nbsp;bit.ly</b>.</p> <div> </p> <pre><code>&lt;div&gt; You can short URL&amp;#8217;s on the site &lt;a href=&quot;http://msurl.tk/&quot; style=&quot;font-weight: bold;&quot;&gt;MSURL.TK&lt;/a&gt;. &lt;/div&gt; &lt;div&gt; &lt;/div&gt; </code></pre> </div> <div> As other projects the site is also hosted by <b><a href="http://appfog.com/">AppFog</a></b>&nbsp;and the free domain is given by <a href="http://my.dot.tk/" style="font-weight: bold;">My.Dot.TK</a>. </div> <div> The project was created under <b>30 minutes</b>&nbsp;and the lines of code is less that <b>64</b>. </div> <div> It&#8217;s written in&nbsp;<b>PHP</b>&nbsp;as you already know it.&nbsp; </div> <div> The shortened <b>URL</b>&nbsp;only has <b>13</b>&nbsp;characters (without <b>HTTP://</b>). </div> <div> The shortened <b>URL</b>&nbsp;will not have <b>.php</b>&nbsp;extension. I will tell you how to view page without file extension on the next tutorial. </div> <div> </div> <div> Enjoy Shortening URL ! </div> </div> Stop playback in HTML5 audio using Javascript https://subinsb.com/stop-playback-in-html5-audio-using-javascript/ Sun, 13 Jan 2013 17:00:00 +0000 https://subinsb.com/stop-playback-in-html5-audio-using-javascript/ <div dir="ltr" style="text-align: left;" trbidi="on"> You may wanted to stop playback of an audio playing via <b>audio</b>&nbsp;<b>HTML5</b>&nbsp;tag.<br />Here is the code :</p> <blockquote class="tr_bq"> <p> document.getElementById(&#8216;audio&#8217;).currentTime = 0;//By ID<br />document.getElementsByTagName(&#8216;audio&#8217;).currentTime = 0;//By Tag </p> </blockquote> <p> It&#8217;s that simple. Just use&nbsp;<b>currentTime = 0</b>.</div> Jquery ExtAjax Plugin V 1.2: Submit forms to external files with preview using Jquery https://subinsb.com/jquery-extajax-plugin-v-1-2-submit-forms-to-external-files-with-preview-using-jquery/ Thu, 10 Jan 2013 15:45:00 +0000 https://subinsb.com/jquery-extajax-plugin-v-1-2-submit-forms-to-external-files-with-preview-using-jquery/ <div dir="ltr" style="text-align: left;" trbidi="on"> If you don&#8217;t know what this plugin will do then visit the page of the previous version <a href="http://sag-3.blogspot.com/2012/09/jquery-extajax-plugin-submit-forms-to.html" >here</a>.<br />The last version of <b>Jquery ExtAjax </b>plugin didn&#8217;t have preview feature. But in this version it have a preview feature.<br />The latest version is <b>V 1.2</b></p> <h3 style="text-align: left;"> <b><u>What&#8217;s New in this version</u></b> </h3> <div> <ul style="text-align: left;"> <li> Faster </li> <li> Preview feature.&nbsp; </li> </ul> </div> <div> <h3 style="text-align: left;"> <span style="color: #333333; font-family: inherit;"><span style="line-height: 16px;"><u>What should I do after downloading.</u></span></span> </h3> <pre><code>&lt;div&gt; &lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;line-height: 16px;&quot;&gt;After downloading upload &quot;&lt;b&gt;extajax.js&lt;/b&gt;&quot;, &quot;&lt;b&gt;asdva.php&lt;/b&gt;&quot; to your server.&lt;/span&gt;&lt;/span&gt; &lt;/div&gt; &lt;div&gt; &lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;line-height: 16px;&quot;&gt;Before you do this configure the place in &lt;b&gt;JS&lt;/b&gt;&amp;nbsp;file&amp;nbsp;where &lt;b&gt;asdva.php&lt;/b&gt;&amp;nbsp;is located.&lt;/span&gt;&lt;/span&gt; &lt;/div&gt; &lt;h4 style=&quot;text-align: left;&quot;&gt; &lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;line-height: 16px;&quot;&gt;&amp;nbsp;&lt;b&gt;How can I configure ?&lt;/b&gt;&lt;/span&gt;&lt;/span&gt; &lt;/h4&gt; &lt;div&gt; &lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;line-height: 16px;&quot;&gt;&lt;b&gt;&amp;nbsp;&lt;/b&gt;Go to &lt;b&gt;extajax.js&lt;/b&gt;&amp;nbsp;file. Search for&amp;nbsp;&lt;b&gt;var asdvafile&amp;nbsp;&lt;/b&gt;. Enter the location of the &lt;b&gt;asdva.php &lt;/b&gt;if the file is not in the same folderas &lt;b&gt;extajax.js&lt;/b&gt;.&lt;/span&gt;&lt;/span&gt; &lt;/div&gt; &lt;div&gt; &lt;span style=&quot;color: #333333;&quot;&gt;&lt;span style=&quot;line-height: 16px;&quot;&gt;&lt;a name='more'&gt;&lt;/a&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt; &lt;/div&gt; &lt;p&gt; &lt;span style=&quot;color: #333333; font-family: inherit;&quot;&gt;&lt;span style=&quot;line-height: 16px;&quot;&gt;Jquery Code :&lt;/span&gt;&lt;/span&gt; &lt;/p&gt; &lt;blockquote class=&quot;tr_bq&quot;&gt; &lt;p&gt; &lt;span style=&quot;background-color: white; color: #333333; font-family: Courier, monospace, 'Courier New'; font-size: 13px; font-weight: bold; line-height: 16px;&quot;&gt;&lt;script&gt;&lt;/span&gt;&lt;span style=&quot;background-color: white; color: #333333; font-family: Courier, monospace, 'Courier New'; font-size: 13px; font-weight: bold; line-height: 16px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;background-color: white; color: #333333; font-family: Courier, monospace, 'Courier New'; font-size: 13px; font-weight: bold; line-height: 16px;&quot;&gt;$(&quot;&lt;/span&gt;&lt;span style=&quot;background-color: white; color: red; font-family: Courier, monospace, 'Courier New'; font-size: 13px; font-weight: bold; line-height: 16px;&quot;&gt;#form&lt;/span&gt;&lt;span style=&quot;background-color: white; color: #333333; font-family: Courier, monospace, 'Courier New'; font-size: 13px; font-weight: bold; line-height: 16px;&quot;&gt;&quot;).submit(function(){&lt;/span&gt;&lt;span style=&quot;background-color: white; color: #333333; font-family: Courier, monospace, 'Courier New'; font-size: 13px; font-weight: bold; line-height: 16px;&quot;&gt;event.preventDefault();&lt;/span&gt;&lt;span style=&quot;background-color: white; color: #333333; font-family: Courier, monospace, 'Courier New'; font-size: 13px; font-weight: bold; line-height: 16px;&quot;&gt;$(&quot;&lt;/span&gt;&lt;span style=&quot;background-color: white; color: red; font-family: Courier, monospace, 'Courier New'; font-size: 13px; font-weight: bold; line-height: 16px;&quot;&gt;#form&lt;/span&gt;&lt;span style=&quot;background-color: white; color: #333333; font-family: Courier, monospace, 'Courier New'; font-size: 13px; font-weight: bold; line-height: 16px;&quot;&gt;&quot;).extajax({target:&quot;&lt;/span&gt;&lt;span style=&quot;background-color: white; font-family: Courier, monospace, 'Courier New'; font-size: 13px; font-weight: bold; line-height: 16px;&quot;&gt;&lt;span style=&quot;color: red;&quot;&gt;#preview&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;background-color: white; color: #333333; font-family: Courier, monospace, 'Courier New'; font-size: 13px; font-weight: bold; line-height: 16px;&quot;&gt;&quot;});&lt;/span&gt;&lt;span style=&quot;background-color: white; color: #333333; font-family: Courier, monospace, 'Courier New'; font-size: 13px; font-weight: bold; line-height: 16px;&quot;&gt;&lt;br /&gt;});&lt;/span&gt;&lt;span style=&quot;background-color: white; color: #333333; font-family: Courier, monospace, 'Courier New'; font-size: 13px; font-weight: bold; line-height: 16px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;background-color: white; color: #333333; font-family: Courier, monospace, 'Courier New'; font-size: 13px; font-weight: bold; line-height: 16px;&quot;&gt;&lt;/script&gt;&lt;/span&gt; &lt;/p&gt; &lt;/blockquote&gt; &lt;p&gt; &lt;span style=&quot;background-color: white; color: #333333; font-family: Courier, monospace, 'Courier New'; font-size: 13px; font-weight: bold; line-height: 16px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;border: 2px solid black;&quot;&gt;&lt;span style=&quot;color: white;&quot;&gt;&lt;span style=&quot;background-color: #6aa84f;&quot;&gt;&lt;a href=&quot;http://subins.tk/labs/extajax/index.html&quot; &gt;View Demo&lt;/a&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;span style=&quot;background-color: #6aa84f; border: 2px solid black;&quot;&gt;&lt;span style=&quot;color: white;&quot;&gt;&lt;a href=&quot;https://drive.google.com/uc?export=download&amp;id=0B2VjYaTkCpiQbTJtY1ZyNmFjZUk&quot; &gt;Download(ZIP)&lt;/a&gt;&lt;/span&gt;&lt;/span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;span style=&quot;background-color: #6aa84f; border: 2px solid black; color: white;&quot;&gt;&lt;a href=&quot;https://drive.google.com/uc?export=download&amp;id=0B2VjYaTkCpiQcXRreFNxLXRCam8&quot; &gt;Download(Javascript file)&lt;/a&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;/div&gt; </code></pre> Storing JSON object in HTML5 Local Storage : Stringify https://subinsb.com/storing-json-object-in-html5-local-storage-stringify/ Wed, 09 Jan 2013 08:08:00 +0000 https://subinsb.com/storing-json-object-in-html5-local-storage-stringify/ <div dir="ltr" style="text-align: left;" trbidi="on"> This tutorial will help you to store <b>JSON</b>&nbsp;Object in LocalStorage.</p> <div> This method uses a function called&nbsp;<b>stringify</b>. </div> <div> Suppose we have a <b>JSON</b>&nbsp;object like this : </div> <blockquote class="tr_bq"> <p> var data = {name:&#8217;subin&#8217;,class:&#8217;8A&#8217;}; </p> </blockquote> <div> If we want to store this <b>JSON </b>object in <b>Local Storage</b>&nbsp;then use the function below: </div> <blockquote class="tr_bq"> <p> localStorage[&#8216;<span style="color: red;">info</span>&#8216;]=JSON.stringify(<span style="color: red;">data</span>); </p> </blockquote> <div> That&#8217;s it. <b>JSON</b>&nbsp;Object is now stored in your <b>Local Storage</b>. </div> </div> Subins Games : A new Game site from Subins https://subinsb.com/subins-games-a-new-game-site-from-subins/ Mon, 07 Jan 2013 16:37:00 +0000 https://subinsb.com/subins-games-a-new-game-site-from-subins/ <div dir="ltr" style="text-align: left;" trbidi="on"> This is my 5th project. <b><a href="http://games-subins.hp.af.cm/" >The Subins Games</a></b>. This site is for playing games.&nbsp;</p> <h3 style="text-align: left;"> <u>Functions</u> </h3> <div> <ul style="text-align: left;"> <li> Commenting </li> <li> Score saving </li> <li> Play History </li> <li> Add your game </li> <li> Game stats </li> </ul> </div> <div> &nbsp;(And adding new ones!) </div> <div> </div> <div> Like all the other projects this project has used Javascript Library&nbsp;<b>Jquery</b>&nbsp;and the server side language is <b>PHP</b>. </div> <div> This site&#8217;s games is the combination of old <b><a href="http://pfogb.blogspot.com/" >PFOGB</a></b>&nbsp;and <a href="http://g2enjoy.blogspot.com/" style="font-weight: bold;" >G2E</a>. </div> <div> </div> <div> The main problem I faced was the merging of two blogs to one. It was very difficult to merge manually. </div> <div> So I used <b>WordPress</b>&nbsp;in my localhost to import posts from blogger and exported the posts in <b>XML</b>&nbsp;format. </div> <div> Then I used <b>PHP </b>to insert the <b>XML</b>&nbsp;file contents to <b>MySql</b>&nbsp;Database. Thankyou <b>WordPress</b>. </div> <div class="separator" style="clear: both; text-align: center;"> <a href="http://games-subins.hp.af.cm/" ><img border="0" src="//3.bp.blogspot.com/-4ZwBt1WxCWs/UOr5s-aTRHI/AAAAAAAACZI/wspKoWF2swI/s1600/logo.png" /></a> </div> <div> </div> </div> The best method to find clientโ€™s IP Address in PHP. https://subinsb.com/the-best-method-to-find-clients-ip-address-in-php/ Sat, 05 Jan 2013 13:27:00 +0000 https://subinsb.com/the-best-method-to-find-clients-ip-address-in-php/ <div dir="ltr" style="text-align: left;" trbidi="on"> This simple function will help you to find the client&#8217;s IP. You could use <b>$_SERVER[&#8216;REMOTE_ADDR&#8217;]</b>&nbsp;, but this method will not returns the actual IP address.</p> <p> To get the real IP address use this method. </p> <blockquote class="tr_bq"> <p> function getUserIpAddr(){<br />&nbsp; &nbsp; if (!empty($_SERVER[&#8216;HTTP_CLIENT_IP&#8217;])){<br />&nbsp; &nbsp; &nbsp; &nbsp; return $_SERVER[&#8216;HTTP_CLIENT_IP&#8217;];<br />&nbsp; &nbsp; }else if (!empty($_SERVER[&#8216;HTTP_X_FORWARDED_FOR&#8217;])){<br />&nbsp; &nbsp; &nbsp; &nbsp; $ite=explode(&#8216;,&#8217;,$_SERVER[&#8216;HTTP_X_FORWARDED_FOR&#8217;]); return str_replace(" ",",$ite[0]);<br />&nbsp; &nbsp; }else{<br />&nbsp; &nbsp; &nbsp; &nbsp; return $_SERVER[&#8216;REMOTE_ADDR&#8217;];<br />&nbsp; &nbsp; }<br />}&nbsp;$cip=getUserIpAddr(); </p> </blockquote> <p> The above function will returns the IP address of the client. You could use the variable <b>$cip</b>&nbsp;to get the IP.<br />Example (printing client&#8217;s IP) : </p> <blockquote class="tr_bq"> <p> echo "Your IP Address is ".$cip; </p> </blockquote> </div> How to view or Download Google Drive files on your site https://subinsb.com/how-to-view-or-download-google-drive-files-on-your-site/ Fri, 04 Jan 2013 14:07:00 +0000 https://subinsb.com/how-to-view-or-download-google-drive-files-on-your-site/ <div dir="ltr" style="text-align: left;" trbidi="on"> Many of you wanted to show images, videos etc&#8230; on your site which is uploaded on your Google Drive.</p> <div> The link of the file will not be the same at all times due to security reasons.&nbsp; </div> <div> So Google provides another method to show or download a file. </div> <div> </div> <div> For this method you need to get the file id. For that open your file.&nbsp; </div> <div> Look at the url box of your browser. </div> <div class="separator" style="clear: both; text-align: center;"> <a href="https://2.bp.blogspot.com/-LK-tP7By0gQ/UObaHiNSCnI/AAAAAAAACYY/kiGA8HQbF-s/s1600/drive.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://2.bp.blogspot.com/-LK-tP7By0gQ/UObaHiNSCnI/AAAAAAAACYY/kiGA8HQbF-s/s1600/drive.png" /></a> </div> <div class="separator" style="clear: both; text-align: left;"> As shown in the image you should select the word before <b>/edit</b>&nbsp;and after <b>d/</b>. </div> <div class="separator" style="clear: both; text-align: left;"> This selected text will be the file id. Copy the file id. </div> <h3 style="text-align: left;"> <u>To View</u> </h3> <blockquote class="tr_bq"> <p> https://drive.google.com/uc?export=view&id=<b><span style="color: red;">fileid</span></b> </p> </blockquote> <div class="separator" style="clear: both; text-align: left;"> Replace the red text with the file id. You can use this url to show an image or any other file. </div> <div class="separator" style="clear: both; text-align: left;"> An Example: </div> <blockquote class="tr_bq"> <p> <img src="https://drive.google.com/uc?export=view&id=0B2VjYaTkCpiQT0tRSWQzVHMxR1U"> </p> </blockquote> <h3 style="text-align: left;"> <u>To Download</u> </h3> <blockquote class="tr_bq"> <p> https://drive.google.com/uc?export=download&id=<b><span style="color: red;">fileid</span></b> </p> </blockquote> <div> <b><span style="color: red;"><br /></span></b> </div> <div> <div class="separator" style="clear: both;"> Replace the red text with the file id. You can use this url to download a file. </div> <pre><code>&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt; An Example: &lt;/div&gt; &lt;blockquote class=&quot;tr_bq&quot;&gt; &lt;p&gt; &lt;a href=&quot;https://drive.google.com/uc?export=download&amp;id=0B2VjYaTkCpiQT0tRSWQzVHMxR1U&quot;&gt;Download this file&lt;/a&gt; &lt;/p&gt; &lt;/blockquote&gt; &lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt; This method helped me a lot for developing &lt;a href=&quot;http://games-subins.hp.af.cm/&quot; &gt;Subins Games&lt;/a&gt;. &lt;/div&gt; </code></pre> </div> </div> Finding Clientโ€™s IP address, Country, State, City using NetIP.de api in PHP https://subinsb.com/finding-clients-ip-address-country-state-city-using-netip-de-api-in-php/ Wed, 26 Dec 2012 05:39:00 +0000 https://subinsb.com/finding-clients-ip-address-country-state-city-using-netip-de-api-in-php/ <div dir="ltr" style="text-align: left;" trbidi="on"> If you want to get client&#8217;s IP address you will use <b>$_SERVER[&#8216;REMOTE_ADDR&#8217;] </b>function in <b>PHP</b>.<br />But you will not get the real <b>IP</b>&nbsp;address of the client. To get the real <b>IP</b>&nbsp;address You can use the method I used.<br />Also With this method you can also find the City, State, Country client&#8217;s in.<br />The code is pretty simple. With the help of <b><a href="http://netip.de/">NetIP.de</a></b>&nbsp;it was pretty easy.</p> <blockquote class="tr_bq"> <p> $response=@file_get_contents(&#8216;http://www.netip.de&#8217;);if (empty($response)){throw new InvalidArgumentException("Error contacting Geo-IP-Server");}$patterns=array();<span class="pln" style="border: 0px; line-height: 18px; margin: 0px; padding: 0px; vertical-align: baseline;">$patterns</span><span class="pun" style="border: 0px; line-height: 18px; margin: 0px; padding: 0px; vertical-align: baseline;">[</span><span class="str" style="border: 0px; line-height: 18px; margin: 0px; padding: 0px; vertical-align: baseline;">"state"</span><span class="pun" style="border: 0px; line-height: 18px; margin: 0px; padding: 0px; vertical-align: baseline;">]</span><span class="pln" style="border: 0px; line-height: 18px; margin: 0px; padding: 0px; vertical-align: baseline;">&nbsp;</span><span class="pun" style="border: 0px; line-height: 18px; margin: 0px; padding: 0px; vertical-align: baseline;">=</span><span class="pln" style="border: 0px; line-height: 18px; margin: 0px; padding: 0px; vertical-align: baseline;">&nbsp;</span><span class="str" style="border: 0px; line-height: 18px; margin: 0px; padding: 0px; vertical-align: baseline;">&#8216;#State/Region: (.*?)<br#i&#8217;</span><span class="pun" style="border: 0px; line-height: 18px; margin: 0px; padding: 0px; vertical-align: baseline;">;</span>$patterns["IP"] = &#8216;#IP: (.*?)&nbsp;#i&#8217;;$patterns["country"] = &#8216;#Country: (.*?)&nbsp;#i&#8217;;$patterns["city"] = &#8216;#City: (.*?)<br#i&#8217;;foreach ($patterns as $key => $pattern){$ipInfo[$key] = preg_match($pattern,$response,$value) && !empty($value[1]) ? $value[1] : &#8216;not found&#8217;;} $uct=$ipInfo["state"];$uip=$ipInfo["IP"];$uci=$ipInfo["city"];$ipInfo=explode(&#8216;-&#8216;,$ipInfo["country"]);$ucs=$ipInfo[0];$uco=$ipInfo[1]; </p> </blockquote> <p> Below are the variables for different purposes. </p> <p> $uip //IP address<br />$uco //Client&#8217;s Country<br />$uci //Client&#8217;s City<br />$ucs //Client&#8217;s Country in Short Form(eg: if user is from INDIA then the variable will be "IN")<br />$uct //Client&#8217;s State </p> <p> You should <b>echo</b>&nbsp;the variables as needed. Hope it helps.</div> Vishnu โ€“ I will never forget you. https://subinsb.com/vishnu-i-will-never-forget-you/ Mon, 24 Dec 2012 03:37:00 +0000 https://subinsb.com/vishnu-i-will-never-forget-you/ <div dir="ltr" style="text-align: left;" trbidi="on"> <span style="background-color: white; color: #333333; font-family: 'lucida grande', tahoma, verdana, arial, sans-serif; font-size: 13px; line-height: 18px;">He was a closest friend of mine. He always told other people about me. He was so so nice to me. I am very sad. I don&#8217;t know what to say. Just Sad. Very Sad. I saw his face and it melted my heart.</span><br /><br style="background-color: white; color: #333333; font-family: 'lucida grande', tahoma, verdana, arial, sans-serif; font-size: 13px; line-height: 18px;" /><span style="background-color: white; color: #333333; font-family: 'lucida grande', tahoma, verdana, arial, sans-serif; font-size: 13px; line-height: 18px;">He may have died But he will always be in my heart.</span><a data-hovercard="/ajax/hovercard/user.php?id=100004071632555&extragetparams=%7B%22group_id%22%3A0%7D" href="https://www.facebook.com/vishnu.vijayan.52687?group_id=0" style="background-color: white; color: #3b5998; cursor: pointer; font-family: 'lucida grande', tahoma, verdana, arial, sans-serif; font-size: 13px; line-height: 18px; text-decoration: none;">Vishnu Vijayan</a><span style="background-color: white; color: #333333; font-family: 'lucida grande', tahoma, verdana, arial, sans-serif; font-size: 13px; line-height: 18px;">&nbsp;You will always be in my heart forever. I will not forget you.</span><br /><span style="background-color: white; color: #333333; font-family: 'lucida grande', tahoma, verdana, arial, sans-serif; font-size: 13px; line-height: 18px;"><br /></span><a href="https://fbcdn-sphotos-d-a.akamaihd.net/hphotos-ak-ash4/399327_381433631949981_2038803701_n.jpg" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" src="https://fbcdn-sphotos-d-a.akamaihd.net/hphotos-ak-ash4/399327_381433631949981_2038803701_n.jpg" style="-webkit-user-select: none;" /></a><span style="background-color: white; color: #333333; font-family: 'lucida grande', tahoma, verdana, arial, sans-serif; font-size: 13px; line-height: 18px;"><br /></span><span style="background-color: white; color: #333333; font-family: 'lucida grande', tahoma, verdana, arial, sans-serif; font-size: 13px; line-height: 18px;">He died in this cheerful Christmas which make my Christmas the worst. I was so sad but then I realised that some things will happen for a reason.</span><br /><span style="background-color: white; color: #333333; font-family: 'lucida grande', tahoma, verdana, arial, sans-serif; font-size: 13px; line-height: 18px;"><br /></span><span style="background-color: white; color: #333333; font-family: 'lucida grande', tahoma, verdana, arial, sans-serif; font-size: 13px; line-height: 18px;">May GOD bless his soul.</span> </div> Make Snowfall on your site/blog using Javascript https://subinsb.com/make-snowfall-on-your-siteblog-using-javascript/ Sat, 22 Dec 2012 12:43:00 +0000 https://subinsb.com/make-snowfall-on-your-siteblog-using-javascript/ <div dir="ltr" style="text-align: left;" trbidi="on"> <div dir="ltr" style="text-align: left;" trbidi="on"> It&#8217;s Christmas. It&#8217;s time for snowing. Want to have a snowfall on your site just like in my blog. Here&#8217;s the <b>Java script</b> for snowing.<br /><b><span style="color: red;">Note &#8211; This code is for websites. Code for blogger is below this code</span></b></p> <pre><code>&lt;blockquote class=&quot;tr_bq&quot;&gt; &lt;p&gt; &lt;script&gt;&lt;br /&gt;&amp;nbsp; //Configure below to change URL path to the snow image&lt;br /&gt;&amp;nbsp; var snowsrc=&quot;http://subins.hp.af.cm/files/images/snow.gif&quot;&lt;br /&gt;&amp;nbsp; // Configure below to change number of snow to render&lt;br /&gt;&amp;nbsp; var no = 20;&lt;br /&gt;&amp;nbsp; // Configure whether snow should disappear after x seconds (0=never):&lt;br /&gt;&amp;nbsp; var hidesnowtime = 0;&lt;br /&gt;&amp;nbsp; // Configure how much snow should drop down before fading (&quot;windowheight&quot; or &quot;pageheight&quot;)&lt;br /&gt;&amp;nbsp; var snowdistance = &quot;pageheight&quot;;&lt;br /&gt;///////////Stop Config//////////////////////////////////&lt;br /&gt;&amp;nbsp; var ie4up = (document.all) ? 1 : 0;&lt;br /&gt;&amp;nbsp; var ns6up = (document.getElementById&amp;&amp;!document.all) ? 1 : 0;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;function iecompattest(){&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;return (document.compatMode &amp;&amp; document.compatMode!=&quot;BackCompat&quot;)? document.documentElement : document.body&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;br /&gt;&amp;nbsp; var dx, xp, yp; &amp;nbsp; &amp;nbsp;// coordinate and position variables&lt;br /&gt;&amp;nbsp; var am, stx, sty; &amp;nbsp;// amplitude and step variables&lt;br /&gt;&amp;nbsp; var i, doc_width = 800, doc_height = 600;&lt;br /&gt;&amp;nbsp; if (ns6up) {&lt;br /&gt;&amp;nbsp; &amp;nbsp; doc_width = self.innerWidth;&lt;br /&gt;&amp;nbsp; &amp;nbsp; doc_height = self.innerHeight;&lt;br /&gt;&amp;nbsp; } else if (ie4up) {&lt;br /&gt;&amp;nbsp; &amp;nbsp; doc_width = iecompattest().clientWidth;&lt;br /&gt;&amp;nbsp; &amp;nbsp; doc_height = iecompattest().clientHeight;&lt;br /&gt;&amp;nbsp; }&lt;br /&gt;&amp;nbsp; dx = new Array();&lt;br /&gt;&amp;nbsp; xp = new Array();&lt;br /&gt;&amp;nbsp; yp = new Array();&lt;br /&gt;&amp;nbsp; am = new Array();&lt;br /&gt;&amp;nbsp; stx = new Array();&lt;br /&gt;&amp;nbsp; sty = new Array();&lt;br /&gt;&amp;nbsp; snowsrc=(snowsrc.indexOf(&quot;subins.hp.af.cm&quot;)!=-1)? &quot;http://subins.hp.af.cm/files/images/snow.gif&quot; : snowsrc&lt;br /&gt;&amp;nbsp; for (i = 0; i &lt; no; ++ i) { &lt;br /&gt;&amp;nbsp; &amp;nbsp; dx[i] = 0; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;// set coordinate variables&lt;br /&gt;&amp;nbsp; &amp;nbsp; xp[i] = Math.random()*(doc_width-50); &amp;nbsp;// set position variables&lt;br /&gt;&amp;nbsp; &amp;nbsp; yp[i] = Math.random()*doc_height;&lt;br /&gt;&amp;nbsp; &amp;nbsp; am[i] = Math.random()*20; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // set amplitude variables&lt;br /&gt;&amp;nbsp; &amp;nbsp; stx[i] = 0.02 + Math.random()/10; // set step variables&lt;br /&gt;&amp;nbsp; &amp;nbsp; sty[i] = 0.7 + Math.random(); &amp;nbsp; &amp;nbsp; // set step variables&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;if (ie4up||ns6up) {&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; if (i == 0) {&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; document.write(&quot;&lt;div id=&quot;dot&quot;+ i +&quot;&quot; style=&quot;POSITION: absolute; Z-INDEX: &quot;+ i +&quot;; VISIBILITY: visible; TOP: 15px; LEFT: 15px;&quot;&gt;&lt;a href=&quot;http://sag-3.blogspot.com/2012/12/snowfall-using-js.html&quot;&gt;&lt;img src='&quot;+snowsrc+&quot;&amp;#8216; border=&quot;0&amp;#8243;&gt;&lt;/a&gt;&lt;/div&gt;&quot;);&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; } else {&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; document.write(&quot;&lt;div id=&quot;dot&quot;+ i +&quot;&quot; style=&quot;POSITION: absolute; Z-INDEX: &quot;+ i +&quot;; VISIBILITY: visible; TOP: 15px; LEFT: 15px;&quot;&gt;&lt;img src='&quot;+snowsrc+&quot;&amp;#8216; border=&quot;0&amp;#8243;&gt;&lt;/div&gt;&quot;);&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;&amp;nbsp; &amp;nbsp; }&lt;br /&gt;&amp;nbsp; }&lt;br /&gt;&amp;nbsp; function snowIE_NS6() { &amp;nbsp;// IE and NS6 main animation function&lt;br /&gt;&amp;nbsp; &amp;nbsp; doc_width = ns6up?window.innerWidth-10 : iecompattest().clientWidth-10;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;doc_height=(window.innerHeight &amp;&amp; snowdistance==&quot;windowheight&quot;)? window.innerHeight : (ie4up &amp;&amp; snowdistance==&quot;windowheight&quot;)? &amp;nbsp;iecompattest().clientHeight : (ie4up &amp;&amp; !window.opera &amp;&amp; snowdistance==&quot;pageheight&quot;)? iecompattest().scrollHeight : iecompattest().offsetHeight;&lt;br /&gt;&amp;nbsp; &amp;nbsp; for (i = 0; i &lt; no; ++ i) { &amp;nbsp;// iterate for every dot&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; yp[i] += sty[i];&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; if (yp[i] &gt; doc_height-50) {&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; xp[i] = Math.random()*(doc_width-am[i]-30);&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; yp[i] = 0;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; stx[i] = 0.02 + Math.random()/10;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; sty[i] = 0.7 + Math.random();&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; dx[i] += stx[i];&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; document.getElementById(&quot;dot&quot;+i).style.top=yp[i]+&quot;px&quot;;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; document.getElementById(&quot;dot&quot;+i).style.left=xp[i] + am[i]*Math.sin(dx[i])+&quot;px&quot;; &lt;br /&gt;&amp;nbsp; &amp;nbsp; }&lt;br /&gt;&amp;nbsp; &amp;nbsp; snowtimer=setTimeout(&quot;snowIE_NS6()&quot;, 25);//Set Timeout&lt;br /&gt;&amp;nbsp; }&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;function hidesnow(){&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;if (window.snowtimer) clearTimeout(snowtimer)&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;for (i=0; i&lt;no; i++) document.getElementById(&quot;dot&quot;+i).style.visibility=&quot;hidden&quot;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;if (ie4up||ns6up){&lt;br /&gt;&amp;nbsp; &amp;nbsp; snowIE_NS6();&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;if (hidesnowtime&gt;0)&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;setTimeout(&quot;hidesnow()&quot;, hidesnowtime*1000)&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;br /&gt;&lt;/script&gt; &lt;/p&gt; &lt;/blockquote&gt; </code></pre> </div> <h3 style="text-align: left;"> <u><b>Blogger Code</b></u> </h3> <p> Go to <b>Template</b> -> <b>Edit HTML</b><br />Paste this code after <b><body></b> tag. </p> <blockquote class="tr_bq"> <p> <script><br />&nbsp; //Configure below to change URL path to the snow image<br />&nbsp; var snowsrc="http://subins.hp.af.cm/files/images/snow.gif"<br />&nbsp; // Configure below to change number of snow to render<br />&nbsp; var no = 20;<br />&nbsp; // Configure whether snow should disappear after x seconds (0=never):<br />&nbsp; var hidesnowtime = 0;<br />&nbsp; // Configure how much snow should drop down before fading ("windowheight" or "pageheight")<br />&nbsp; var snowdistance = "pageheight";<br />///////////Stop Config//////////////////////////////////<br />&nbsp; var ie4up = (document.all) ? 1 : 0;<br />&nbsp; var ns6up = (document.getElementById&&!document.all) ? 1 : 0;<br />&nbsp;function iecompattest(){<br />&nbsp;return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body<br />&nbsp;}<br />&nbsp; var dx, xp, yp; &nbsp; &nbsp;// coordinate and position variables<br />&nbsp; var am, stx, sty; &nbsp;// amplitude and step variables<br />&nbsp; var i, doc_width = 800, doc_height = 600;<br />&nbsp; if (ns6up) {<br />&nbsp; &nbsp; doc_width = self.innerWidth;<br />&nbsp; &nbsp; doc_height = self.innerHeight;<br />&nbsp; } else if (ie4up) {<br />&nbsp; &nbsp; doc_width = iecompattest().clientWidth;<br />&nbsp; &nbsp; doc_height = iecompattest().clientHeight;<br />&nbsp; }<br />&nbsp; dx = new Array();<br />&nbsp; xp = new Array();<br />&nbsp; yp = new Array();<br />&nbsp; am = new Array();<br />&nbsp; stx = new Array();<br />&nbsp; sty = new Array();<br />&nbsp; snowsrc=(snowsrc.indexOf("subins.hp.af.cm")!=-1)? "http://subins.hp.af.cm/files/images/snow.gif" : snowsrc<br />&nbsp; for (i = 0; i < no; ++ i) {<br />&nbsp; &nbsp; dx[i] = 0; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// set coordinate variables<br />&nbsp; &nbsp; xp[i] = Math.random()*(doc_width-50); &nbsp;// set position variables<br />&nbsp; &nbsp; yp[i] = Math.random()*doc_height;<br />&nbsp; &nbsp; am[i] = Math.random()*20; &nbsp; &nbsp; &nbsp; &nbsp; // set amplitude variables<br />&nbsp; &nbsp; stx[i] = 0.02 + Math.random()/10; // set step variables<br />&nbsp; &nbsp; sty[i] = 0.7 + Math.random(); &nbsp; &nbsp; // set step variables<br />&nbsp; if (ie4up||ns6up) {<br />&nbsp; &nbsp; &nbsp; if (i == 0) {<br />&nbsp; &nbsp; &nbsp; &nbsp; document.write("<div id=&#8217;dot"+ i +"&#8216; style=&#8217;POSITION: absolute; Z-INDEX: "+ i +"; VISIBILITY: visible; TOP: 15px; LEFT: 15px;&#8217;><a href=&#8217;http://subins.hp.af.cm&#8217;><img src='"+snowsrc+"&#8216; border=&#8217;0&#8217; /></a></div>");<br />&nbsp; &nbsp; &nbsp; } else {<br />&nbsp; &nbsp; &nbsp; &nbsp; document.write("<div id=&#8217;dot"+ i +"&#8216; style=&#8217;POSITION: absolute; Z-INDEX: "+ i +"; VISIBILITY: visible; TOP: 15px; LEFT: 15px;&#8217;><img src='"+snowsrc+"&#8216; border=&#8217;0&#8217; /></div>");<br />&nbsp; &nbsp; &nbsp; }<br />&nbsp; &nbsp; }<br />&nbsp; }<br />&nbsp; function snowIE_NS6() { &nbsp;// IE and NS6 main animation function<br />&nbsp; &nbsp; doc_width = ns6up?window.innerWidth-10 : iecompattest().clientWidth-10;<br />&nbsp; doc_height=(window.innerHeight && snowdistance=="windowheight")? window.innerHeight : (ie4up && snowdistance=="windowheight")? &nbsp;iecompattest().clientHeight : (ie4up && !window.opera && snowdistance=="pageheight")? iecompattest().scrollHeight : iecompattest().offsetHeight;<br />&nbsp; &nbsp; for (i = 0; i < no; ++ i) { &nbsp;// iterate for every dot<br />&nbsp; &nbsp; &nbsp; yp[i] += sty[i];<br />&nbsp; &nbsp; &nbsp; if (yp[i] > doc_height-50) {<br />&nbsp; &nbsp; &nbsp; &nbsp; xp[i] = Math.random()*(doc_width-am[i]-30);<br />&nbsp; &nbsp; &nbsp; &nbsp; yp[i] = 0;<br />&nbsp; &nbsp; &nbsp; &nbsp; stx[i] = 0.02 + Math.random()/10;<br />&nbsp; &nbsp; &nbsp; &nbsp; sty[i] = 0.7 + Math.random();<br />&nbsp; &nbsp; &nbsp; }<br />&nbsp; &nbsp; &nbsp; dx[i] += stx[i];<br />&nbsp; &nbsp; &nbsp; document.getElementById("dot"+i).style.top=yp[i]+"px";<br />&nbsp; &nbsp; &nbsp; document.getElementById("dot"+i).style.left=xp[i] + am[i]*Math.sin(dx[i])+"px";<br />&nbsp; &nbsp; }<br />&nbsp; &nbsp; snowtimer=setTimeout("snowIE_NS6()", 25);//Set Timeout<br />&nbsp; }<br />&nbsp;function hidesnow(){<br />&nbsp; if (window.snowtimer) clearTimeout(snowtimer)<br />&nbsp; for (i=0; i<no; i++) document.getElementById("dot"+i).style.visibility="hidden"<br />&nbsp;} &nbsp;if (ie4up||ns6up){<br />&nbsp; &nbsp; snowIE_NS6();<br />&nbsp; if (hidesnowtime>0)<br />&nbsp; setTimeout("hidesnow()", hidesnowtime*1000)<br />&nbsp; }<br /></script> </p> </blockquote> </div> FriendsHood โ€“ A new Social Network from Subins https://subinsb.com/friendshood-a-new-social-network-from-subins/ Fri, 14 Dec 2012 05:26:00 +0000 https://subinsb.com/friendshood-a-new-social-network-from-subins/ <div dir="ltr" style="text-align: left;"> Friendshood is vulnerable to MySQL Injection and shouldn&#8217;t be used anymore. Please see my latest project :ย <a href="//subinsb.com/2013/12/open-an-open-source-social-network-is-released">http://subinsb.com/2013/12/open-an-open-source-social-network-is-released</a> </div> <div dir="ltr" style="text-align: left;"> Original Post : </div> <div dir="ltr" style="text-align: left; padding-left: 30px;"> Many of you now know the project I&#8217;ve been working on. In that project I have created a social Network called <b><a href="http://fd-subins.hp.af.cm/?utm_source=blog">FriendsHood</a></b>. I created this social network because my friends have been telling me to create a social network. They told me because School said to block <b><a href="http://facebook.com/?utm_source=Subin'sBlog">Facebook</a> </b>and no student should use <b><a href="http://facebook.com/?utm_source=Subin'sBlog">Facebook</a></b>.</p> <div style="padding-left: 30px;"> </div> <div style="padding-left: 30px;"> So I decided to create a social network. I started to create <b><a href="http://fd-subins.hp.af.cm/?utm_source=blog">FriendsHood</a></b>ย before the creation of <b>Subins</b>. </div> <div style="padding-left: 30px;"> Now <b><a href="http://fd-subins.hp.af.cm/?utm_source=blog">FriendsHood</a></b>ย has <b>like function</b>,ย <b>Comment Function</b> & <b>Share function</b>. </div> <div style="padding-left: 30px;"> </div> <div style="padding-left: 30px;"> Note that <b>FriendsHood </b>is currently under development. Some functions will not work. Check out <b><a href="http://fd-subins.hp.af.cm/?utm_source=blog">Friendshood</a></b>ย <a href="http://fd-subins.hp.af.cm/?utm_source=blog">here</a>. </div> <div style="padding-left: 30px;"> </div> <div style="padding-left: 30px;"> With the help of <b><a href="http://appfog.com/?utm_source=Subin'sBlog">AppFog</a>ย </b>I got to host <b>FriendsHood</b>ย for free @ the link <a href="http://fd-subins.hp.af.cm/">http://fd-subins.hp.af.cm</a>. </div> <div style="padding-left: 30px;"> </div> <div style="padding-left: 30px;"> Please <a href="http://accounts-subins.hp.af.cm/signup.php">Signup</a>. </div> </div> Happy Birthday, Simon Helberg aka Howard Wolowitz https://subinsb.com/happy-birthday-simon-helberg-aka-howard-wolowitz/ Sun, 09 Dec 2012 13:32:00 +0000 https://subinsb.com/happy-birthday-simon-helberg-aka-howard-wolowitz/ <div dir="ltr" style="text-align: left;" trbidi="on"> <span style="background-color: white; color: #333333; font-family: 'lucida grande', tahoma, verdana, arial, sans-serif; line-height: 18px;">He may not be a doctor or a ladies man &#8211; but we love Howard Wolowitz all the same!</span><br style="background-color: white; color: #333333; font-family: 'lucida grande', tahoma, verdana, arial, sans-serif; line-height: 18px;" /><br style="background-color: white; color: #333333; font-family: 'lucida grande', tahoma, verdana, arial, sans-serif; line-height: 18px;" /></p> <div class="separator" style="clear: both; text-align: center;"> <span style="background-color: white; color: #333333; font-family: 'lucida grande', tahoma, verdana, arial, sans-serif; line-height: 18px; text-align: left;"><span style="font-size: x-large;"><br /></span></span> </div> <div class="separator" style="clear: both; text-align: center;"> <span style="background-color: white; color: #333333; font-family: 'lucida grande', tahoma, verdana, arial, sans-serif; line-height: 18px; text-align: left;"><span style="font-size: x-large;">Happy Birthday, Simon Helberg!</span></span> </div> <div class="separator" style="clear: both; text-align: center;"> <span style="background-color: white; color: #333333; font-family: 'lucida grande', tahoma, verdana, arial, sans-serif; line-height: 18px; text-align: left;"><br /></span> </div> <div class="separator" style="clear: both; text-align: center;"> <a href="//4.bp.blogspot.com/-Nsh-Q9Uq1uA/UMSSVUw3b5I/AAAAAAAACUQ/xCaFtQUz6tk/s1600/happybirthday.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="//4.bp.blogspot.com/-Nsh-Q9Uq1uA/UMSSVUw3b5I/AAAAAAAACUQ/xCaFtQUz6tk/s1600/happybirthday.jpg" /></a> </div> <p> </div> How to add Subins Like button to blogger/blogspot https://subinsb.com/how-to-add-subins-like-button-to-bloggerblogspot/ Sun, 09 Dec 2012 08:07:00 +0000 https://subinsb.com/how-to-add-subins-like-button-to-bloggerblogspot/ <div dir="ltr" style="text-align: left;" trbidi="on"> <span style="font-family: inherit;">You might have know <b>The Subins Project</b>&nbsp;created by me. It is hosted by <b><a href="http://appfog.com/?utm_source=subinsblog" >AppFog</a></b>. If you want to add Subins Like button to your blog, then follow these steps.</span></p> <div> <span style="font-family: inherit;">Go to <b><a href="http://blogger.com/?utm_source=subinsblog" >Blogger</a></b></span> </div> <div> <span style="font-family: inherit;">Place this code where you want to add the <b>Subins</b>&nbsp;<b>Like Button</b>.</span> </div> <div> <blockquote class="tr_bq"> <p> <span style="font-family: inherit;"><script src="http://subins.hp.af.cm/dev/all.js" type="text/javascript"></script><br /><div class="subins-like" data-href=&#8217;<span style="color: red;">BLOG URL</span>&#8216;></div></span> </p> </blockquote> </div> <div> <span style="font-family: inherit;">If you want to add like button on post footer then follow the steps mentioned below.</span> </div> <div> <span style="font-family: inherit;">Go to <b><a href="http://blogger.com/?utm_source=subinsblog" >Blogger</a></b>&nbsp;-> <b>Template</b>&nbsp;-><b>&nbsp;Edit HTML</b></span> </div> <div> <span style="font-family: inherit;">Click <b>Expand Widget Templates</b>.</span> </div> <div> <span style="font-family: inherit;">Search for the line <b>post-footer&#8217; </b>(within the quote).</span> </div> <div> <span style="font-family: inherit;">Add this code after the first line you just founded.</span> </div> <div> <blockquote class="tr_bq"> <p> <span style="font-family: inherit;"><script src=&#8217;http://subins.hp.af.cm/dev/all.js&#8217; type=&#8217;text/javascript&#8217;/></span><span style="font-family: inherit;"><div class=&#8217;subins-like&#8217; expr:data-href=&#8217;data:post.url&#8217;></div></span> </p> </blockquote> </div> <div> That&#8217;s it. Check your blog to see your new <b>Subins Like button</b>. </div> <div> <b><a href="http://appfog.com/?utm_source=subinsblog" >AppFog</a></b>&nbsp;servers are a little slow so sometimes you might get this error<b> this webpage isn&#8217;t available</b>. </div> </div> Updating site in App Fog on Linux / Uploading site files to App Fog Server https://subinsb.com/updating-site-in-app-fog-on-linux-uploading-site-files-to-app-fog-server/ Thu, 06 Dec 2012 17:12:00 +0000 https://subinsb.com/updating-site-in-app-fog-on-linux-uploading-site-files-to-app-fog-server/ <div dir="ltr" style="text-align: left;" trbidi="on"> You might have know what is <b><a href="http://appfog.com/?utm_source=subinsblog" >App Fog</a></b> in my previous post. In this tutorial I am going to tell you how to upload your site files to their servers. For that first install <b>Ruby </b>by using this command :</p> <blockquote class="tr_bq"> <p> sudo apt-get install ruby </p> </blockquote> <div> Then install <b>Ruby Gem</b>&nbsp;: </div> <blockquote class="tr_bq"> <p> sudo apt-get install gem </p> </blockquote> <div> <b><a href="http://appfog.com/?utm_source=subinsblog" >AppFog</a> </b>uses a gem named <b>AF</b>. Install the <b>AF</b>&nbsp;gem by using the command : </div> <blockquote class="tr_bq"> <p> sudo gem install af </p> </blockquote> <div> Wait some time. After the installation is finished you can use <b>AF</b> command. </div> <div> To upload the files first you need to <b>CD</b>&nbsp;to the folder where the files of your site is. To do that&nbsp;use the command below: </div> <blockquote class="tr_bq"> <p> cd <span style="color: red;">/pathtoyourfolder</span> </p> </blockquote> <div> Then you only need to upload the files by using the command below: </div> <blockquote class="tr_bq"> <p> sudo af&nbsp;update <span style="color: red;">sitename</span> </p> </blockquote> <div> Be patient. It will finish fast depending on the size of the folder. This process may require a restart of your site. </div> <div> <b>Note &#8211; </b>&nbsp;sometimes the command <b>af</b>&nbsp;may not work and you will get the error : </div> <blockquote class="tr_bq"> <p> af: command not found </p> </blockquote> <div> To fix this replace af with ruby <b>/home/<span style="color: red;">username</span>/.gem/ruby/1.8/gems/af-0.3.18.11/bin/af</b> on all of the commands using <b>af</b>. </div> <div> For Example :&nbsp; </div> <blockquote class="tr_bq"> <p> <b>ruby /home/simsu/.gem/ruby/1.8/gems/af-0.3.18.11/bin/af update subins</b> </p> </blockquote> <div> Thank you for visiting my blog. Hope it helped you. If this post helped you please signup for <b>Subins</b>&nbsp;<a href="http://accounts-subins.hp.af.cm/signup.php?utm_source=sagblog" >here</a>. </div> </div> Subins Project Online โ€“ Thanks to App Fog https://subinsb.com/subins-project-online-thanks-to-app-fog/ Tue, 04 Dec 2012 16:24:00 +0000 https://subinsb.com/subins-project-online-thanks-to-app-fog/ <div dir="ltr" style="text-align: left;" trbidi="on"> You might have know the project I have been working on. <b>The Subins Project</b>. I have spent a year on this project. My wish was to host this on a site. But I couldn&#8217;t afford the hosting charges cause I&#8217;m 12 and my dad won&#8217;t lend me money.</p> <p> I took a leave because of fever. On that day I was browsing the internet and out of nowhere I saw a post about a site named <b><a href="http://appfog.com/?utm_source=subinsblog" >AppFog</a></b>. The post said that <b><a href="http://appfog.com/?utm_source=subinsblog" >AppFog</a></b>&nbsp;gives free hosting on their servers under their domain name. So quickly I went to <b><a href="http://appfog.com/?utm_source=subinsblog" >AppFog</a></b>&nbsp;and signed up. It was pretty easy. I created my site in the domain <a href="http://subins.hp.af.cm/?utm_source=subinsblog" style="font-weight: bold;" >subins.hp.af.cm</a>. </p> <p> I uploaded my project using a&nbsp;<b>RubyGem </b>named <b>AF</b>. I just need to install the <b>GEM</b>&nbsp;and use the command <b>af.</b>&nbsp;Since I uses <b>Linux</b>&nbsp;it was pretty easy. I Love <a href="http://appfog.com/?utm_source=subinsblog" >AppFog</a>. </p> <p> Then I created more sites associated with <b>Subins</b>. The services which have been uploaded and full working are the following :- </p> <ol style="text-align: left;"> <li> <a href="http://subins.hp.af.cm/?utm_source=subinsblog" >Subins</a> </li> <li> <a href="http://accounts-subins.hp.af.cm/?utm_source=subinsblog" >Accounts</a> </li> <li> <a href="http://chat-subins.hp.af.cm/?utm_source=subinsblog" >Chat</a> </li> <li> <a href="http://fd-subins.hp.af.cm/?utm_source=subinsblog" >Friendshood</a> </li> </ol> <p> I am working on uploading more services I created but I don&#8217;t have time cause <b>Christmas Exam</b>&nbsp;is coming soon and mom won&#8217;t let me use the internet. <b>Exams </b>will start on 13 December and will end on 21 December. I will upload more services after the exams. </p> <p> BTW signup for <b>Subins </b>@ <a href="http://accounts-subins.hp.af.cm/signup.php" style="font-weight: bold;" >Subins Signup Page</a>.<br />Hope you like it ๐Ÿ™‚</div> How to alert user that he is the ___th visitor of blogger/blogspot blog? https://subinsb.com/how-to-alert-user-that-he-is-the-___th-visitor-of-bloggerblogspot-blog/ Thu, 22 Nov 2012 13:18:00 +0000 https://subinsb.com/how-to-alert-user-that-he-is-the-___th-visitor-of-bloggerblogspot-blog/ <div dir="ltr" style="text-align: left;" trbidi="on"> <span style="font-family: inherit;">If you ever visited my blog on the day it&#8217;s reaching a big view (<b>24000</b> , <b>25000</b>) you will get a javascript alert saying you are the <b>24000</b>th visitor like this :</span></p> <div class="separator" style="clear: both; text-align: center;"> <a href="//1.bp.blogspot.com/-R0PFGsxOylg/UK4bf9bsjTI/AAAAAAAACTo/8H9o8VpHUkc/s1600/alert.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><span style="font-family: inherit;"><img border="0" src="//1.bp.blogspot.com/-R0PFGsxOylg/UK4bf9bsjTI/AAAAAAAACTo/8H9o8VpHUkc/s1600/alert.png" /></span></a> </div> <div class="separator" style="clear: both; text-align: left;"> <span style="font-family: inherit;">The above image shows that the blog alerted when the user was the <b>23000</b>&nbsp;visitor. It will also change the background to <a href="http://themes.googleusercontent.com/image?id=0BwVBOzw_-hbMYWRiZmQ3NDctZGQyZC00MWU0LWE0ZDMtMGFlZWI0MWM4NzQ1" >this</a>. Want to have this feature on your blog ???&nbsp;</span><span style="font-family: inherit;">You are in the right place.</span> </div> <div class="separator" style="clear: both; text-align: left;"> <span style="font-family: inherit;"><br /></span> </div> <div class="separator" style="clear: both; text-align: left;"> <u style="font-family: inherit;"><b><span style="font-size: large;">Requirements</span></b></u> </div> <div class="separator" style="clear: both; text-align: left;"> <u style="font-family: inherit; font-size: x-large;"><br /></u> </div> <div> <span style="font-family: inherit;">One Stats Widget (Only one).</span> </div> <div> <span style="font-family: inherit;"><br /></span> </div> <div class="separator" style="clear: both; text-align: left;"> <span style="font-family: inherit;"><span style="background-color: white; color: #333333; line-height: 20px;">Add this code before&nbsp;</span><b style="background-color: white; color: #333333; line-height: 20px;"></head></b><span style="background-color: white; color: #333333; line-height: 20px;">&nbsp;if you haven&#8217;t yet added a&nbsp;</span><b style="background-color: white; color: #333333; line-height: 20px;">script src</b><span style="background-color: white; color: #333333; line-height: 20px;">&nbsp;of&nbsp;</span><b style="background-color: white; color: #333333; line-height: 20px;">Jquery</b><span style="background-color: white; color: #333333; line-height: 20px;">&nbsp;</span><b style="background-color: white; color: #333333; line-height: 20px;">Library</b><span style="background-color: white; color: #333333; line-height: 20px;">.</span></span> </div> <blockquote class="tr_bq"> <p> <script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"></script> </p> </blockquote> <div class="separator" style="clear: both; text-align: left;"> <span style="font-family: inherit;"><span style="background-color: white; color: #333333; line-height: 18px; white-space: pre; word-spacing: -3px;">Add this Code before </span><b style="background-color: white; color: #333333; line-height: 18px; white-space: pre; word-spacing: -3px;"></head></b><span style="background-color: white; color: #333333; line-height: 18px; white-space: pre; word-spacing: -3px;"> tag.</span></span> </div> <blockquote class="tr_bq"> <p> <span style="font-family: inherit;"><span style="background-color: white;"><span style="line-height: 18px; white-space: pre; word-spacing: -3px;"><span style="color: #333333;">if($(&#39;#Stats1_totalCount&#39;).text()==&#39;</span><span style="color: orange;"><b>25000</b> </span><span style="color: #333333;">&#39;){ $(&#39;body&#39;).css({background: &quot;#111 url(//themes.googleusercontent.com/image?id=0BwVBOzw_-hbMYWRiZmQ3NDctZGQyZC00MWU0LWE0ZDMtMGFlZWI0MWM4NzQ1) repeat-x fixed top center /* Credit: michieldb (http://www.istockphoto.com/googleimages.php?id=4252213&platform=blogger) */&quot;}, 900); if(localStorage[</span></span></span><span style="background-color: white;"><span style="line-height: 18px; white-space: pre; word-spacing: -3px;"><span style="color: #333333;">$(&#39;body&#39;).css({background: &quot;#111 url(//themes.googleusercontent.com/image?id=0BwVBOzw_-hbMYWRiZmQ3NDctZGQyZC00MWU0LWE0ZDMtMGFlZWI0MWM4NzQ1) repeat-x fixed top center /* Credit: michieldb (http://www.istockphoto.com/googleimages.php?id=4252213&platform=blogger) */&quot;}, 900);</span></span></span><span style="background-color: white;"><span style="line-height: 18px; white-space: pre; word-spacing: -3px;"><span style="color: #333333;">if(localStorage[</span><span style="line-height: normal; white-space: normal; word-spacing: 0px;"><span style="line-height: 18px; white-space: pre; word-spacing: -3px;"><span style="color: #333333;">&quot;a</span>&quot;+</span></span><span style="color: #333333;">$(&quot;#Stats1_totalCount&quot;).text()</span><span style="line-height: 17px; white-space: normal; word-spacing: 0px;">.</span><span style="line-height: 17px; white-space: normal; word-spacing: 0px;">substr(</span><span style="line-height: 17px; white-space: normal; word-spacing: 0px;">0, 4</span><span style="line-height: 17px; white-space: normal; word-spacing: 0px;">)</span><span style="color: #333333;">]==&#39;s&#39;){}else{ alert(&quot;Congratulations, You are our &#39;+$(&quot;#Stats1_totalCount&quot;).text()+&#39;Vistor !!!!!&quot;);</span></span></span><span style="background-color: white;"><span style="line-height: 18px; white-space: pre; word-spacing: -3px;"><span style="color: #333333;"><br /></span></span></span><span style="background-color: white;"><span style="line-height: 18px; white-space: pre; word-spacing: -3px;"><span style="color: #333333;">localStorage[&quot;a</span>&quot;+</span></span><span style="background-color: white; color: #333333; line-height: 18px; white-space: pre; word-spacing: -3px;">$(&quot;#Stats1_totalCount&quot;).text()</span><span style="background-color: white; line-height: 17px;">.</span><span style="line-height: 17px;">substr(</span><span style="background-color: white; line-height: 17px;">0, 4</span><span style="line-height: 17px;">)</span><span style="background-color: white; color: #333333; line-height: 18px; white-space: pre; word-spacing: -3px;">] = &#39;s&#39;;</span><span style="background-color: white;"><span style="line-height: 18px; white-space: pre; word-spacing: -3px;"><span style="color: #333333;">}</span></span></span><span style="background-color: white;"><span style="line-height: 18px; white-space: pre; word-spacing: -3px;"><span style="color: #333333;">}</span></span></span></span> </p> </blockquote> <div class="separator" style="clear: both; text-align: left;"> <span style="font-family: inherit;"><span style="background-color: white;"><span style="color: #333333;"><b>Replace the orange colored number&nbsp;</b></span></span><b style="background-color: white; color: #333333;">the next upcoming milestone stat of your blog</b><span style="background-color: white; color: #333333;">.</span></span> </div> <div class="separator" style="clear: both; text-align: left;"> <span style="background-color: white; font-family: inherit;"><span style="color: red;">Note </span>:- You have to do the steps mentioned above every time when your blog is going to reach the milestone.</span> </div> </div> Free Palestine https://subinsb.com/free-palestine/ Wed, 21 Nov 2012 13:13:00 +0000 https://subinsb.com/free-palestine/ <div dir="ltr" style="text-align: left;" trbidi="on"> <div class="separator" style="clear: both; text-align: left;"> <b>Israel</b>&nbsp;again bombed <b>Palestine</b>. Why are they doing this ? We all are equal irrespective of religion. We all got an education.&nbsp; </div> <div class="separator" style="clear: both; text-align: left;"> </div> <div class="separator" style="clear: both; text-align: left;"> Grow up people. <b>Muslims, Jews</b>&#8230;. everyone are same. Don&#8217;t look people by religion. Why they want to start a <b>World War 3</b>&nbsp;??? Why can&#8217;t they no we can all just get along ???&nbsp; </div> <div class="separator" style="clear: both; text-align: left;"> </div> <div class="separator" style="clear: both; text-align: left;"> You can&#8217;t kill people in the name name of religion. How can the <b>Israelis </b>live with these much blood on their hands. They not only killed adults but children too. So sad to see this. Even <b>GOD</b>&nbsp;won&#8217;t forgive the people who killed the <b>Palestini </b>people.&nbsp; </div> <div class="separator" style="clear: both; text-align: left;"> </div> <div class="separator" style="clear: both; text-align: left;"> <b>Israel</b>&nbsp;must end this war now. Don&#8217;t kill more people. We all can get along. Please don&#8217;t kill any more people. You don&#8217;t want more blood on your hands&#8230;&#8230; </div> <div class="separator" style="clear: both; text-align: left;"> </div> <div class="separator" style="clear: both; text-align: left;"> Support <b>Palestine </b>by visiting&nbsp;<b><a href="http://www.avaaz.org/en/palestine_worlds_next_nation_a/?utm_source=subinsblog" >Avaaz</a></b>&nbsp;and&nbsp;<b><a href="https://plus.google.com/s/%23freepalestine?utm_source=subinsblog" >Google+</a></b>. </div> <div class="separator" style="clear: both; text-align: center;"> <a href="//3.bp.blogspot.com/-hJu_CIc6_Tg/UKzOYXpwLpI/AAAAAAAACTg/Q3beT9X-mq8/s1600/382131_516592905018359_1312122105_n.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="//3.bp.blogspot.com/-hJu_CIc6_Tg/UKzOYXpwLpI/AAAAAAAACTg/Q3beT9X-mq8/s1600/382131_516592905018359_1312122105_n.jpg" /></a> </div> <p> </div> SQL Query in another SQL Query = SQL Subquery https://subinsb.com/sql-query-in-another-sql-query-sql-subquery/ Sat, 17 Nov 2012 14:30:00 +0000 https://subinsb.com/sql-query-in-another-sql-query-sql-subquery/ <div dir="ltr" style="text-align: left;" trbidi="on"> You might have wanted to do a <b>SQL</b>&nbsp;query inside an another <b>SQL</b>&nbsp;query. You can do this using <b>SQL Subquery</b>. It&#8217;s simple as <b>ABC</b>.&nbsp;Here&#8217;s an example :</p> <blockquote class="tr_bq"> <p> SELECT * FROM&nbsp;`fdposts`&nbsp;WHERE user IN (SELECT friend FROM `fdfriends` WHERE user=&#8217;subins2000&#8242;) </p> </blockquote> <p> The above code will select rows in table&nbsp;<b>fdposts</b>&nbsp;where user is the value of <b>friend</b> row in the table <b>fdfriends</b>.<br />As you can see it&#8217;s very simple. Here&#8217;s another example : </p> <blockquote class="tr_bq"> <p> SELECT * FROM&nbsp;`posts`&nbsp;WHERE user IN (SELECT name FROM `members` WHERE user=&#8217;subins2000&#8242;) </p> </blockquote> <p> The above code will select rows in table&nbsp;<b>posts </b>where user is the value of the row <b>name</b>&nbsp;in the table <b>members</b>.<br />Enjoy !!!</div> How to run/execute SQL Code https://subinsb.com/how-to-runexecute-sql-code/ Tue, 13 Nov 2012 14:05:00 +0000 https://subinsb.com/how-to-runexecute-sql-code/ <div dir="ltr" style="text-align: left;" trbidi="on"> If you have installed <b><a href="http://sag-3.blogspot.in/2012/10/phpmyadmin-software-to-manage-mysql.html" >phpMyAdmin</a>&nbsp;</b>do as below.<br />Go to <a href="http://localhost/phpmyadmin/server_sql.php" >localhost/phpmyadmin/server_sql.php</a>.<br />Paste the <b>SQL Code</b>&nbsp;in the text box shown in the page and press <b>GO </b>button at the bottom right of the page.</p> <p> If you want to run code in <b>PHP </b>file do as below.<br />Open your<b>&nbsp;PHP </b>file.<br />Add these lines in the file. </p> <blockquote class="tr_bq"> <p> mysql_query("<span style="color: red;">sql code here</span>"); </p> </blockquote> <p> <b>NOTE</b> &#8211; Replace the red line with the&nbsp;<b>SQL</b>&nbsp;code.</div> How to increase your apt cache limit https://subinsb.com/how-to-increase-your-apt-cache-limit/ Tue, 13 Nov 2012 06:12:00 +0000 https://subinsb.com/how-to-increase-your-apt-cache-limit/ <div dir="ltr" style="text-align: left;" trbidi="on"> <span style="background-color: white; font-family: inherit; line-height: 19.200000762939453px;">Increase value APT::Cache-Limit</span></p> <div style="line-height: 19.200000762939453px; padding: 0px 0px 18px;"> <span style="background-color: white; font-family: inherit;">When the time I try to install backtrack unfortunately i got message error in the <b>terminal</b> :</span> </div> <div style="line-height: 19.200000762939453px; padding: 0px 0px 18px;"> <span style="background-color: white; font-family: inherit;"><b><span style="color: red;">Reading package listsโ€ฆ Error!<br />E: Dynamic MMap ran out of room. Please increase the size of APT::Cache-Limit. Current value: 25165824. (man 5 apt<a href="http://aziest.wordpress.com/2011/01/24/how-to-increase-your-apt-cache-limit/www.aziest.wordpress.com" style="text-decoration: none;">.</a>conf)<br />E: Error occurred while processing riece (NewVersion1)<br />E: Problem with MergeList /var/lib/apt/lists/archive.offensive-security.com_dists_pwnsauce_universe_binary-i386_Packages<br />W: Unable to munmap<br />E: The package lists or status file could not be parsed or opened.</span></b><br /><span id="more-112"></span></span> </div> <div style="line-height: 19.200000762939453px; padding: 0px 0px 18px;"> <span style="background-color: white; font-family: inherit;">and solution to fix it is just increase the value <b>APT::Cache-Limit</b> at the <b>/etc/apt/apt.conf.d/70debconf</b></span> </div> <blockquote class="tr_bq"> <p> <span style="font-family: inherit;"><code style="background-color: white; padding: 0px 2px;">sudo gedit /etc/apt/apt.conf.d/70debconf</code></span> </p> </blockquote> <p> <span style="background-color: white; font-family: inherit;">Then put this code</span> </p> <blockquote class="tr_bq"> <p> <span style="font-family: inherit;"><code style="background-color: white; padding: 0px 2px;">APT::Cache-Limit "100000000";</code></span> </p> </blockquote> <p> <span style="background-color: white; font-family: inherit;">at the below on that file and then save it.</span> </p> <div style="line-height: 19.200000762939453px; padding: 0px 0px 18px;"> <span style="background-color: white; font-family: inherit;">You wonโ€™t find <b>apt cache limit</b> again in the next time.</span> </div> </div> Creating a custom 404 Not Found page in Apache Server. https://subinsb.com/creating-a-custom-404-not-found-page-in-apache-server/ Sun, 11 Nov 2012 07:22:00 +0000 https://subinsb.com/creating-a-custom-404-not-found-page-in-apache-server/ <div dir="ltr" style="text-align: left;" trbidi="on"> <a href="http://subins.hp.af.cm/sdfvd" >DEMO</a><br />You might have seen a <b>404</b>&nbsp;page on different sites such as <b>Google</b>,<b>Yahoo</b>&nbsp;etc&#8230; You can make this on your website too if you are using <b>Apache Server</b>. The default <b>404</b>&nbsp;page will be like this :</p> <div class="separator" style="clear: both; text-align: center;"> <a href="//1.bp.blogspot.com/-8sSNV-hTWWw/UJ9OXA9xtrI/AAAAAAAACQ4/gedQz1-kwls/s1600/404.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="66" src="//1.bp.blogspot.com/-8sSNV-hTWWw/UJ9OXA9xtrI/AAAAAAAACQ4/gedQz1-kwls/s640/404.png" width="640" /></a> </div> <div class="separator" style="clear: both; text-align: left;"> It&#8217;s just simple plain <b>HTML</b>&nbsp;<b>404</b>&nbsp;page and it&#8217;s ugly. To Change the default <b>404</b>&nbsp;page Do as below. </div> <div class="separator" style="clear: both; text-align: left;"> Go to your <b>site&#8217;s folder</b>. </div> <div class="separator" style="clear: both; text-align: left;"> Create a <b>file</b>&nbsp;named<b>&nbsp;.htaccess</b>&nbsp;(just <b>.htaccess</b>&nbsp;no name only file extension). </div> <div class="separator" style="clear: both; text-align: left;"> Open the file and add the line. </div> <blockquote class="tr_bq"> <p> ErrorDocument 404 <span style="color: red;">/pathtofile</span> </p> </blockquote> <p> <b>Replace&nbsp;</b><span style="color: red;">/pathtofile </span>with your&nbsp;<b>404</b>&nbsp;page&nbsp;file name which should be situated in the same folder as the file <b>.htaccess</b>&nbsp;. The custom <b>404</b>&nbsp;file can be in <b>PHP</b>&nbsp;or <b>HTML</b>.<br />You can also add <b>HTML </b>to it&nbsp;like this: </p> <blockquote class="tr_bq"> <p> ErrorDocument 404&nbsp;&#8216;<html><head></head><body><h1>404 Not Found-Subin&#8217;s Blog</h1></body></html>&#8217; </p> </blockquote> <p> You don&#8217;t have to reload Apache Server ! It&#8217;s finished. Test it out. Here&#8217;s an example of a custom <b>404</b>&nbsp;page. </p> <div class="separator" style="clear: both; text-align: center;"> <a href="https://2.bp.blogspot.com/-Vwo_1y6EDmI/UJ9RgZ5eOJI/AAAAAAAACRE/6-n5BzTx_rY/s1600/404-custom.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="312" src="https://2.bp.blogspot.com/-Vwo_1y6EDmI/UJ9RgZ5eOJI/AAAAAAAACRE/6-n5BzTx_rY/s640/404-custom.png" width="640" /></a> </div> <p> </div> Selecting a particular parent in Jquery https://subinsb.com/selecting-a-particular-parent-in-jquery/ Fri, 09 Nov 2012 17:59:00 +0000 https://subinsb.com/selecting-a-particular-parent-in-jquery/ <div dir="ltr" style="text-align: left;" trbidi="on"> If you want to select a particular parent div. Then you should use <b>parents()</b>&nbsp;function. If you use <b>parent()</b>&nbsp;function It won&#8217;t work. For Example:<br /><b>index.html</b></p> <blockquote class="tr_bq"> <p> <div class=&#8217;main&#8217; id=&#8217;p1&#8242;><br />&nbsp;<div id=&#8217;p2&#8242;><br />&nbsp;&nbsp;<div id=&#8217;p3&#8242;><br />&nbsp; &nbsp; <a id=&#8217;click&#8217;>This is the a tag!!</a><br />&nbsp; </div><br />&nbsp;</div><br /></div> </p> </blockquote> <p> If you want to get the <b>id </b>of the main parent<b>&nbsp;</b>which is <b>.main</b>&nbsp;then you should use <b>Jquery</b>&nbsp;code like this: </p> <blockquote class="tr_bq"> <p> $("#click").live(&#8216;click&#8217;, function(){<br />alert($(this).parents(".main").attr(&#8216;id&#8217;));<br />}); </p> </blockquote> <p> The code above will alert the <b>id</b>&nbsp;of the main parent. Try it out yourself.</div> How to remove an item from GRUB boot menu 2nd Way. https://subinsb.com/how-to-remove-an-item-from-grub-boot-menu-2nd-way/ Tue, 06 Nov 2012 12:38:00 +0000 https://subinsb.com/how-to-remove-an-item-from-grub-boot-menu-2nd-way/ <div dir="ltr" style="text-align: left;" trbidi="on"> There is another way to remove items from <b>GRUB</b> menu. By deleting the files in <b>/boot</b>. To remove the item in the GRUB do as shown below.</p> <div> Open <b>Terminal </b>(<b>ALT + CTRL + T</b>) </div> <div> Enter the Command. </div> <blockquote class="tr_bq"> <p> <span style="background-color: white; color: #222222; font-weight: bold; line-height: 16px;"><span style="font-family: inherit;">gedit /boot/grub/grub.cfg</span></span> </p> </blockquote> <div> <span style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20px;">Now search for&nbsp;</span><span style="background-color: lime; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20px;">### BEGIN /etc/grub.d/10_linux ###</span><span style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20px;"><b>.</b></span><br /><span style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20px;">After that line you will see the items of your&nbsp;<b>GRUB </b>menu.</span> </div> <div class="separator" style="clear: both; text-align: center;"> <a href="https://2.bp.blogspot.com/-HJqIM2Gvlyw/UEQ1J6bIjjI/AAAAAAAABuo/6Ja_h0IJnnk/s1600/highlited.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="278" src="https://2.bp.blogspot.com/-HJqIM2Gvlyw/UEQ1J6bIjjI/AAAAAAAABuo/6Ja_h0IJnnk/s640/highlited.png" width="640" /></a> </div> <div> <span style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20px;">Select which is the item you want to remove. Suppose we want to remove&nbsp;</span><span style="color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif;"><span style="font-size: 15px; line-height: 20px;"><b>Ubuntu, with Linux 2.6.32-30-generic</b>. For that find the line. and in between <b>{&#8230;..}</b>&nbsp;the characters find <b>initrd</b>&nbsp;and memorize the location after the text <b>initrd</b>.</span></span> </div> <div> <span style="color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif;"><span style="font-size: 15px; line-height: 20px;">Go to the location. For that do as below.</span></span> </div> <div> Open&nbsp;<b>Terminal&nbsp;</b>(<b>ALT + CTRL + T</b>) </div> <div> <b>Enter </b>the command. </div> <blockquote class="tr_bq"> <p> sudo nautilus </p> </blockquote> <p> <a href="https://2.bp.blogspot.com/-gjnm6X5l7I4/UA6k4mtL05I/AAAAAAAABGA/b8fK3bZ5y8A/s1600/lpane.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="320" src="https://2.bp.blogspot.com/-gjnm6X5l7I4/UA6k4mtL05I/AAAAAAAABGA/b8fK3bZ5y8A/s320/lpane.png" width="72" /></a>A <b>root</b>&nbsp;<b>file browser </b>window will display.<br />Go to <b>/boot</b>&nbsp;folder and find the file with the name after <b>initrd</b>&nbsp;text you found above.<br /><b>Delete the file</b>. But be careful. If you delete the wrong file then you are in danger.<br /><b><span style="color: red;">So be Careful.</span></b></div> How to change/set background image of GRUB bootscreen https://subinsb.com/how-to-changeset-background-image-of-grub-bootscreen/ Fri, 02 Nov 2012 17:45:00 +0000 https://subinsb.com/how-to-changeset-background-image-of-grub-bootscreen/ <div dir="ltr" style="text-align: left;" trbidi="on"> You might have heard of background image in <b>GRUB </b>boot screen. You can change the ugly black background of <b>GRUB</b>&nbsp;using a few little steps.</p> <div style="text-align: center;"> <a href="http://www.youtube.com/watch?v=er8UhdzmLmc&utm_source=subins-blog" ><span style="background-color: #93c47d; color: black; font-size: large;">VIDEO TUTORIAL</span></a> </div> <p> 1 &#8211; Press <b>ALT + F2</b>. Type this in the input box of the window. </p> <blockquote class="tr_bq"> <p> gksu gedit /etc/grub.d/05_debian_theme </p> </blockquote> <p> and press <b>Enter Key</b>. </p> <div class="separator" style="clear: both; text-align: center;"> <a href="//1.bp.blogspot.com/-pvwmtDa3yR8/UJQE9VeqsTI/AAAAAAAACMw/uiPHHHY6Sn8/s1600/Screenshot-Run+Application.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="//1.bp.blogspot.com/-pvwmtDa3yR8/UJQE9VeqsTI/AAAAAAAACMw/uiPHHHY6Sn8/s1600/Screenshot-Run+Application.png" /></a> </div> <div class="separator" style="clear: both; text-align: left;"> The program will ask for your password. After typing the password and pressed the <b>Enter Key</b>&nbsp;a&nbsp;<b>gedit</b>&nbsp;window will appear. Press <b>CTRL + F </b>and search for&nbsp;<b>WALLPAPER= </b>after you found the word copy the location where your background image is and pate the location in <b>quotes</b>&nbsp;after the "=" like in the image shown below. </div> <div class="separator" style="clear: both; text-align: center;"> <a href="//1.bp.blogspot.com/-I5gFN8H16Fc/UJQFvGI1L4I/AAAAAAAACM4/jLTSkHiT_io/s1600/grub-bg.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="//1.bp.blogspot.com/-I5gFN8H16Fc/UJQFvGI1L4I/AAAAAAAACM4/jLTSkHiT_io/s1600/grub-bg.png" /></a> </div> <div class="separator" style="clear: both; text-align: left;"> After editing the file press <b>CTRL + S</b>. After Saving the file press <b>ALT + F2</b>&nbsp;again. This time type :&nbsp; </div> <blockquote class="tr_bq"> <p> gksu update-grub </p> </blockquote> <div class="separator" style="clear: both; text-align: left;"> and press <b>Enter Key</b>. A T<b>erminal window </b>appears and will close after some time. <b>Reboot </b>your computer and you will see your new <b>Background Image</b>. </div> </div> Enabling Desktop Effects in Ubuntu Linux https://subinsb.com/enabling-desktop-effects-in-ubuntu-linux/ Fri, 02 Nov 2012 15:54:00 +0000 https://subinsb.com/enabling-desktop-effects-in-ubuntu-linux/ <div dir="ltr" style="text-align: left;" trbidi="on"> When you are using <b>Windows 7</b>&nbsp;you will notice that it have window effects like shadow on windows opened, animation effects while moving a window. You can also have these kind of effects in Ubuntu.</p> <div> To enable the feature <b>right click</b> on your desktop. </div> <div class="separator" style="clear: both; text-align: center;"> <a href="//4.bp.blogspot.com/-hlpEKfixiIE/UJPqQ_vvDRI/AAAAAAAACMg/oJ367k02l5c/s1600/rclick.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="179" src="//4.bp.blogspot.com/-hlpEKfixiIE/UJPqQ_vvDRI/AAAAAAAACMg/oJ367k02l5c/s320/rclick.png" width="320" /></a> </div> <div class="separator" style="clear: both; text-align: left;"> Choose <b>Change Desktop Background</b>. A window will now open with 4 tabs. Open <b>Visual Effects </b>tab. </div> <div class="separator" style="clear: both; text-align: center;"> <a href="https://2.bp.blogspot.com/-q8vk5f0VpDw/UJPrQrIDN0I/AAAAAAAACMo/cTsY2RkpOnY/s1600/Screenshot-Appearance+Preferences.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="275" src="https://2.bp.blogspot.com/-q8vk5f0VpDw/UJPrQrIDN0I/AAAAAAAACMo/cTsY2RkpOnY/s320/Screenshot-Appearance+Preferences.png" width="320" /></a> </div> <div class="separator" style="clear: both; text-align: left;"> Choose <b>Norma</b>&nbsp;if you have a Graphics Card with a memory of <b>512 MB</b>. Choose <b>Extra&nbsp;</b>if you have <b>1 GB</b>&nbsp;graphics card. A installation will begin. After downloading required files the screen will become blank 1 or 2 times. Don&#8217;t worry! That&#8217;s it. Try out your new <b>Desktop Effects.</b> </div> <div class="separator" style="clear: both; text-align: left;"> </div> <div> </div> </div> Make Image Black & White (grayscale) using CSS In Webkit https://subinsb.com/make-an-image-black-white-grayscale-using-css-in-webkit/ Fri, 02 Nov 2012 04:28:00 +0000 https://subinsb.com/make-an-image-black-white-grayscale-using-css-in-webkit/ <div dir="ltr" style="text-align: left;"> If you want to make images grayscale ie black & white you can use this tutorial. </div> <div dir="ltr" style="text-align: left;"> Note that this trick will only work on browsers that runsย <b>webkit</b>ย which is used by browsers like <b>Google Chrome</b>, <b>Safari</b>,ย <b>Midoriย </b>etc. </div> <div dir="ltr" style="text-align: left;"> Other browsers using different engines do not support the gray scake option. Hence this trick does not support all browsers. </div> <div dir="ltr" style="text-align: left;"> <div class="padlinks"> <a class="demo" href="http://jsfiddle.net/subins2000/AJcFU/show" target="_blank">DEMO</a> </div> <div style="text-align: left;"> <figure id="attachment_2440" class="wp-caption aligncenter"><a href="//lab.subinsb.com/projects/blog/uploads/2012/11/0098.png"><img class="size-medium wp-image-2440" alt="Grayscaled Image Using CSS & Original Image" src="//lab.subinsb.com/projects/blog/uploads/2012/11/0098-300x151.png" width="300" height="151" /></a><figcaption class="wp-caption-text">Grayscaled Image Using CSS & Original Image</figcaption></figure> </div> <div style="text-align: left;"> Here&#8217;s the CSS code which will make all images grayscale.</p> <pre><code>&lt;pre class=&quot;prettyprint&quot;&gt;&lt;code&gt;img{ </code></pre> <p>-webkit-filter: grayscale(100%); }</code></pre></p> <pre><code>&lt;p&gt; If you want to make the image normal when hovered, use the following code : &lt;/p&gt; &lt;pre class=&quot;prettyprint&quot;&gt;&lt;code&gt;img:hover{ </code></pre> <p>-webkit-filter: grayscale(0%); }</code></pre></p> <pre><code>&lt;p&gt; The gray scale effect amount is mentioned as value. &quot;100%&quot; is for full gray scale effect. Making the grayscale value &quot;0%&quot; would remove the grays scale effect on the image. The image will become normal when the value is changed to &quot;0%&quot; or if the value is not present at all. &lt;/p&gt; </code></pre> </div> </div> CSS and Cursors CSS mouse cursor effects with DEMO https://subinsb.com/css-and-cursors-css-mouse-cursor-effects-with-demo/ Wed, 31 Oct 2012 13:25:00 +0000 https://subinsb.com/css-and-cursors-css-mouse-cursor-effects-with-demo/ <div dir="ltr" style="text-align: left;" trbidi="on"> <span style="font-family: inherit;">Ever wanted to change the cursor in your web page ? Well you can change it in <b>CSS</b>. There is a way of doing that, the <b>cursor</b>&nbsp;propery.</span><br /><span style="font-family: inherit;">There is a way in <b>CSS</b>&nbsp;to change the cursor to <b>pointer</b>,<b>cursor</b>,<b>resize</b>,<b>normal</b>&nbsp;etc&#8230;..</span><br /><span style="font-family: inherit;">This table show what will be the cursor when the value of&nbsp;<b>cursor</b>&nbsp;property<b>&nbsp;</b>changes as following.</span></p> <table border="1" bordercolor="#000000" cellpadding="4" cellspacing="0" style="width: 100%px;"> <colgroup> <col width="128*"></col> <col width="128*"></col> </colgroup> <tr valign="TOP"> <td width="50%"> <b><u><span style="font-family: inherit;">Value</span></u></b> </td> <pre><code> &lt;td width=&quot;50%&quot;&gt; &lt;b&gt;&lt;u&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;Cursor&lt;/span&gt;&lt;/u&gt;&lt;/b&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr valign=&quot;TOP&quot;&gt; &lt;td width=&quot;50%&quot;&gt; &lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: inherit; font-size: small;&quot;&gt;&lt;b&gt;Not-allowed,default,inherit,initial,no-drop,vertical-text&lt;/b&gt;&lt;/span&gt;&lt;/span&gt; &lt;/td&gt; &lt;td id=&quot;vattu&quot; width=&quot;50%&quot;&gt; &lt;b&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt; &lt;/span&gt;&lt;/b&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr valign=&quot;TOP&quot;&gt; &lt;td width=&quot;50%&quot;&gt; &lt;b&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;all-scroll&lt;/span&gt;&lt;/b&gt; &lt;/td&gt; &lt;td id=&quot;vattu&quot; width=&quot;50%&quot;&gt; &lt;b&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt; &lt;/span&gt;&lt;/b&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr valign=&quot;TOP&quot;&gt; &lt;td width=&quot;50%&quot;&gt; &lt;b&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;col-resize&lt;/span&gt;&lt;/b&gt; &lt;/td&gt; &lt;td id=&quot;vattu&quot; width=&quot;50%&quot;&gt; &lt;b&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt; &lt;/span&gt;&lt;/b&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr valign=&quot;TOP&quot;&gt; &lt;td width=&quot;50%&quot;&gt; &lt;b&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;crosshair&lt;/span&gt;&lt;/b&gt; &lt;/td&gt; &lt;td id=&quot;vattu&quot; width=&quot;50%&quot;&gt; &lt;b&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt; &lt;/span&gt;&lt;/b&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr valign=&quot;TOP&quot;&gt; &lt;td width=&quot;50%&quot;&gt; &lt;b&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;e-resize&lt;/span&gt;&lt;/b&gt; &lt;/td&gt; &lt;td id=&quot;vattu&quot; width=&quot;50%&quot;&gt; &lt;b&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt; &lt;/span&gt;&lt;/b&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr valign=&quot;TOP&quot;&gt; &lt;td width=&quot;50%&quot;&gt; &lt;b&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;ew-resize&lt;/span&gt;&lt;/b&gt; &lt;/td&gt; &lt;td id=&quot;vattu&quot; width=&quot;50%&quot;&gt; &lt;b&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt; &lt;/span&gt;&lt;/b&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr valign=&quot;TOP&quot;&gt; &lt;td width=&quot;50%&quot;&gt; &lt;b&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;help&lt;/span&gt;&lt;/b&gt; &lt;/td&gt; &lt;td id=&quot;vattu&quot; width=&quot;50%&quot;&gt; &lt;b&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt; &lt;/span&gt;&lt;/b&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr valign=&quot;TOP&quot;&gt; &lt;td width=&quot;50%&quot;&gt; &lt;b&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;move&lt;/span&gt;&lt;/b&gt; &lt;/td&gt; &lt;td id=&quot;vattu&quot; width=&quot;50%&quot;&gt; &lt;b&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt; &lt;/span&gt;&lt;/b&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr valign=&quot;TOP&quot;&gt; &lt;td width=&quot;50%&quot;&gt; &lt;b&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;n-resize&lt;/span&gt;&lt;/b&gt; &lt;/td&gt; &lt;td id=&quot;vattu&quot; width=&quot;50%&quot;&gt; &lt;b&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt; &lt;/span&gt;&lt;/b&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr valign=&quot;TOP&quot;&gt; &lt;td width=&quot;50%&quot;&gt; &lt;b&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;none&lt;/span&gt;&lt;/b&gt; &lt;/td&gt; &lt;td id=&quot;vattu&quot; width=&quot;50%&quot;&gt; &lt;b&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt; &lt;/span&gt;&lt;/b&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr valign=&quot;TOP&quot;&gt; &lt;td width=&quot;50%&quot;&gt; &lt;b&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;ne-resize&lt;/span&gt;&lt;/b&gt; &lt;/td&gt; &lt;td id=&quot;vattu&quot; width=&quot;50%&quot;&gt; &lt;b&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt; &lt;/span&gt;&lt;/b&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr valign=&quot;TOP&quot;&gt; &lt;td width=&quot;50%&quot;&gt; &lt;b&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;nesw-resize&lt;/span&gt;&lt;/b&gt; &lt;/td&gt; &lt;td id=&quot;vattu&quot; width=&quot;50%&quot;&gt; &lt;b&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt; &lt;/span&gt;&lt;/b&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr valign=&quot;TOP&quot;&gt; &lt;td width=&quot;50%&quot;&gt; &lt;b&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;ns-resize&lt;/span&gt;&lt;/b&gt; &lt;/td&gt; &lt;td id=&quot;vattu&quot; width=&quot;50%&quot;&gt; &lt;b&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt; &lt;/span&gt;&lt;/b&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr valign=&quot;TOP&quot;&gt; &lt;td width=&quot;50%&quot;&gt; &lt;b&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;nw-resize&lt;/span&gt;&lt;/b&gt; &lt;/td&gt; &lt;td id=&quot;vattu&quot; width=&quot;50%&quot;&gt; &lt;b&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt; &lt;/span&gt;&lt;/b&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr valign=&quot;TOP&quot;&gt; &lt;td width=&quot;50%&quot;&gt; &lt;b&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;nwse-resize&lt;/span&gt;&lt;/b&gt; &lt;/td&gt; &lt;td id=&quot;vattu&quot; width=&quot;50%&quot;&gt; &lt;b&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt; &lt;/span&gt;&lt;/b&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr valign=&quot;TOP&quot;&gt; &lt;td width=&quot;50%&quot;&gt; &lt;b&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;pointer&lt;/span&gt;&lt;/b&gt; &lt;/td&gt; &lt;td id=&quot;vattu&quot; width=&quot;50%&quot;&gt; &lt;b&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt; &lt;/span&gt;&lt;/b&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr valign=&quot;TOP&quot;&gt; &lt;td width=&quot;50%&quot;&gt; &lt;b&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;Progress,wait&lt;/span&gt;&lt;/b&gt; &lt;/td&gt; &lt;td id=&quot;vattu&quot; width=&quot;50%&quot;&gt; &lt;b&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt; &lt;/span&gt;&lt;/b&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr valign=&quot;TOP&quot;&gt; &lt;td width=&quot;50%&quot;&gt; &lt;b&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;row-resize&lt;/span&gt;&lt;/b&gt; &lt;/td&gt; &lt;td id=&quot;vattu&quot; width=&quot;50%&quot;&gt; &lt;b&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt; &lt;/span&gt;&lt;/b&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr valign=&quot;TOP&quot;&gt; &lt;td width=&quot;50%&quot;&gt; &lt;div align=&quot;LEFT&quot;&gt; &lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: inherit; font-size: small;&quot;&gt;&lt;b&gt;s-resize&lt;/b&gt;&lt;/span&gt;&lt;/span&gt; &lt;/div&gt; &lt;/td&gt; &lt;td id=&quot;vattu&quot; width=&quot;50%&quot;&gt; &lt;b&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt; &lt;/span&gt;&lt;/b&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr valign=&quot;TOP&quot;&gt; &lt;td width=&quot;50%&quot;&gt; &lt;div align=&quot;LEFT&quot;&gt; &lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: inherit; font-size: small;&quot;&gt;&lt;b&gt;se-resize&lt;/b&gt;&lt;/span&gt;&lt;/span&gt; &lt;/div&gt; &lt;/td&gt; &lt;td id=&quot;vattu&quot; width=&quot;50%&quot;&gt; &lt;b&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt; &lt;/span&gt;&lt;/b&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr valign=&quot;TOP&quot;&gt; &lt;td width=&quot;50%&quot;&gt; &lt;div align=&quot;LEFT&quot;&gt; &lt;b&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;sw-resize &lt;/span&gt;&lt;/b&gt; &lt;/div&gt; &lt;/td&gt; &lt;td id=&quot;vattu&quot; width=&quot;50%&quot;&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr valign=&quot;TOP&quot;&gt; &lt;td width=&quot;50%&quot;&gt; &lt;b&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;text&lt;/span&gt;&lt;/b&gt; &lt;/td&gt; &lt;td id=&quot;vattu&quot; width=&quot;50%&quot;&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr valign=&quot;TOP&quot;&gt; &lt;td width=&quot;50%&quot;&gt; &lt;b&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;w-resize&lt;/span&gt;&lt;/b&gt; &lt;/td&gt; &lt;td id=&quot;vattu&quot; width=&quot;50%&quot;&gt; &lt;/td&gt; &lt;/tr&gt; </code></pre> </table> <p> </div> Adding Scroll To Top function in Blogger/Blogspot using Jquery https://subinsb.com/adding-scroll-to-top-function-in-bloggerblogspot-using-jquery/ Mon, 29 Oct 2012 13:27:00 +0000 https://subinsb.com/adding-scroll-to-top-function-in-bloggerblogspot-using-jquery/ <div dir="ltr" style="text-align: left;" trbidi="on"> <div class="tr_bq"> <span style="font-family: inherit;">This Post will help you to add a <b>Scroll To Top </b>function in your <b>Blogger Blog</b>. Follow the steps given below.</span> </p> <pre><code>&lt;div style=&quot;text-align: center;&quot;&gt; &lt;span style=&quot;background-color: #93c47d; border-radius: 10px; font-family: inherit; font-size: x-large; padding: 8px 10px;&quot;&gt;&lt;a href=&quot;http://subin-demos.blogspot.com/#scrolltop&quot; &gt;DEMO&lt;/a&gt;&lt;/span&gt; &lt;/div&gt; </code></pre> </div> <p> <span style="font-family: inherit;"><br /></span> <span style="font-family: inherit;">1 &#8211; Go to <b>Blogger -> Template -> Edit HTML&nbsp;</b></span><br /><span style="font-family: inherit;">2 &#8211; Adding Codes.</span><br /><span style="font-family: inherit;">Add this script before <b></head></b> if you haven&#8217;t added a <b>script src</b> of&nbsp;<b>Jquery</b>&nbsp;<b>Library</b>.</span> </p> <blockquote class="tr_bq"> <p> <span style="background-color: white; font-family: inherit; line-height: 18px; white-space: pre; word-spacing: -3px;"><script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"></script></span> </p> </blockquote> <p> <span style="background-color: white; font-family: inherit; line-height: 18px; white-space: pre; word-spacing: -3px;">Add this Code before <b></head></b> tag.</span> </p> <blockquote> <p> <span style="font-family: inherit; line-height: 18px; white-space: pre; word-spacing: -3px;"><script>$(document).ready(function(){$(&quot;body&quot;).append(&quot;<p id=&#8217;back-top&#8217; style=&#8217;display: block; &#8216;><a href=&#8217;#top&#8217;><span/>Back to Top</a></p>&quot;); $(&quot;#back-top&quot;).hide(); $(function () {$(window).scroll(function () {if ($(this).scrollTop() > 100) {$(&#39;#back-top&#39;).fadeIn(); }else {$(&#39;#back-top&#39;).fadeOut(); }});$(&#39;#back-top a&#39;).click(function () {$(&#39;body,html&#39;).animate({scrollTop: 0 }, 800); return false; }); });});</script></span> </p> </blockquote> <p> <span style="font-family: inherit;">Add this <b>CSS</b>&nbsp;Style sheet code before <b></head></b></span> </p> <blockquote class="tr_bq"> <p> <span style="font-family: inherit;"><style>#back-top { position: fixed; bottom: 30px;right:0px;}#back-top &nbsp;a { width: 108px; display: block; text-align: center; font: 11px/100% Arial, Helvetica, sans-serif; text-transform: uppercase; text-decoration: none; color: #bbb; -webkit-transition: 1s; -moz-transition: 1s; transition: 1s;}#back-top &nbsp;a:hover { color: #000;}#back-top &nbsp;span { width: 108px; height: 108px; display: block; margin-bottom: 7px; background: #ddd url(&#39;//4.bp.blogspot.com/-0mlo-caVkrQ/Ub835FbxwKI/AAAAAAAACv4/y9bfGt2b1fs/s1600/0017.png&#39;) no-repeat center center; -webkit-border-radius: 15px; -moz-border-radius: 15px; border-radius: 15px; -webkit-transition: 1s; -moz-transition: 1s; transition: 1s;}#back-top &nbsp;a:hover span{background-color: #777;}</style></span> </p> </blockquote> <p> <span style="background-color: white; font-family: inherit;">No need of adding any <b>HTML</b> element because the <b>Jquery</b> script is adding the <b>HTML</b> element in <b>BODY</b> tag.</span></div> Create Text Editor like Blogger Using HTML & jQuery https://subinsb.com/create-text-editor-using-html-jquery-like-in-blogger/ Wed, 24 Oct 2012 16:23:00 +0000 https://subinsb.com/create-text-editor-using-html-jquery-like-in-blogger/ <div dir="ltr" style="text-align: left;"> <p> <span style="font-family: inherit;">You might have seen text editors where you can bold a text, italic a text etc&#8230; The perfect example of this the <b>Blogger</b>ย Post <b>Text Editor</b>.ย </span> </p> <div> <span style="font-family: inherit;">This is a simple tutorial that will create a text editor using <b>HTML, Jquery & JavaScript.</b></span> </div> <div class="padlinks"> <a class="download" href="http://demos.subinsb.com/down.php?id=7rdxkdd9wmmd383&class=5">Download</a> <a class="demo" href="http://demos.subinsb.com/text-editor-jquery/">Demo</a> </div> <div style="text-align: left;"> <p> We have two files, <b>index.html</b>ย which contains the <b>HTML</b>ย code and <b>texteditor.js</b>ย which contains the <b>jQuery</b>ย code. You should include the <b>texteditor.js</b>ย in <b>index.html</b>.<b><span style="font-family: inherit; font-size: large;">index.html</span></b> </p> </div> <div style="text-align: left;"> <pre class="prettyprint"><code>&lt;span style="font-family: inherit;">&lt;!DOCTYPE html&gt;&lt;/span>&lt;span style="font-family: inherit;">&lt;html&gt;&lt;/span> &lt;span style="font-family: inherit;">ย &lt;head&gt;&lt;/span> &lt;span style="font-family: inherit;">ย  &lt;script src="http://code.jquery.com/jquery-1.8.0.min.js"&gt;&lt;/script&gt;&lt;/span> &lt;span style="font-family: inherit;">ย  &lt;script src="texteditor.js"&gt;&lt;/script&gt;&lt;/span> &lt;span style="font-family: inherit;">ย &lt;/head&gt;&lt;/span> &lt;span style="font-family: inherit;">ย &lt;body&gt;&lt;/span> &lt;span style="font-family: inherit;">ย  &lt;center style="margin-bottom:20px;"&gt;&lt;/span> &lt;span style="font-family: inherit;">ย  ย &lt;div class="ze ie"&gt;&lt;/div&gt;&lt;/span> &lt;span style="font-family: inherit;">ย  ย &lt;style&gt;&lt;/span> &lt;span style="font-family: inherit;">ย  ย .font-bold.bold{font-weight:bold;}.italic{font-style:italic;}.selected{background-color: orange;}#openpb{margin:15px;}&lt;/span> &lt;span style="font-family: inherit;">ย  ย &lt;/style&gt;&lt;/span> &lt;span style="font-family: inherit;">ย  ย &lt;button type="button" class="g-button g-button-submit" id='stext'&gt;Text&lt;/button&gt;&nbsp;&nbsp;&nbsp;&nbsp;&lt;/span> &lt;span style="font-family: inherit;">ย  ย &lt;button type="button" class="g-button g-button-submit" id='shtml'&gt;HTML&lt;/button&gt;&lt;/span> &lt;span style="font-family: inherit;">ย  ย &lt;div id="controls" style="margin-bottom: 10px;"&gt;&lt;/span> &lt;span style="font-family: inherit;">ย  ย  &lt;a id="bold" style="color:black;display: inline-block;" class="font-bold"&gt;&lt;/span> &lt;span style="font-family: inherit;">ย  ย  ย &lt;button type="button"&gt;B&lt;/button&gt;&lt;/span> &lt;span style="font-family: inherit;">ย  ย  &lt;/a&gt;&nbsp;&nbsp;&nbsp;&lt;/span> &lt;span style="font-family: inherit;">ย  ย  &lt;a id="italic" style="color:black !important;display: inline-block;"class="italic"&gt;&lt;/span> &lt;span style="font-family: inherit;">ย  ย  ย &lt;button type="button"&gt;I&lt;/button&gt;&lt;/span> &lt;span style="font-family: inherit;">ย  ย  &lt;/a&gt;&nbsp;&nbsp;&nbsp;&nbsp;&lt;/span> &lt;span style="font-family: inherit;">ย  ย  &lt;a id="link" class="link" style="display: inline-block;"&gt;&lt;/span> &lt;span style="font-family: inherit;">ย  ย  ย &lt;button type="button"&gt;Link&lt;/button&gt;&lt;/span> &lt;span style="font-family: inherit;">ย  ย  &lt;/a&gt;&nbsp;&nbsp;&nbsp;&nbsp;&lt;/span> &lt;span style="font-family: inherit;">ย  ย  &lt;select id="fonts" class="g-button"&gt;&lt;/span> &lt;span style="font-family: inherit;">ย  ย  ย &lt;option value="Normal"&gt;Normal&lt;/option&gt;&lt;/span> &lt;span style="font-family: inherit;">ย  ย  ย &lt;option value="Arial"&gt;Arial&lt;/option&gt;&lt;/span> &lt;span style="font-family: inherit;">ย  ย  ย &lt;option value="Comic Sans MS"&gt;Comic Sans MS&lt;/option&gt;&lt;/span> &lt;span style="font-family: inherit;">ย  ย  ย &lt;option value="Courier New"&gt;Courier New&lt;/option&gt;&lt;/span> &lt;span style="font-family: inherit;">ย  ย  ย &lt;option value="Monotype Corsiva"&gt;Monotype&lt;/option&gt;&lt;/span> &lt;span style="font-family: inherit;">ย  ย  ย &lt;option value="Tahoma New"&gt;Tahoma&lt;/option&gt;&lt;/span> &lt;span style="font-family: inherit;">ย  ย  ย &lt;option value="Times"&gt;Times&lt;/option&gt;&lt;/span> &lt;span style="font-family: inherit;">ย  ย  ย &lt;option value="Trebuchet New"&gt;Trebuchet&lt;/option&gt;&lt;/span> &lt;span style="font-family: inherit;">ย  ย  ย &lt;option value="Ubuntu"&gt;Ubuntu&lt;/option&gt;&lt;/span> &lt;span style="font-family: inherit;">ย  ย  &lt;/select&gt;&lt;/span> &lt;span style="font-family: inherit;">ย  ย &lt;/div&gt;&lt;/span> &lt;span style="font-family: inherit;">ย  ย &lt;iframe frameborder="0" id="textEditor" style="width:500px; height:80px;border:2px solid #CCC;border-radius:20px;overflow:auto;"&gt;&lt;/iframe&gt;&lt;/span> &lt;span style="font-family: inherit;">ย  &lt;/div&gt;&lt;/span> &lt;span style="font-family: inherit;">ย  &lt;textarea name="text" id='text' style="border-radius:20px;overflow:auto;display:none;padding-left: 10px;" rows="6" cols="53"&gt;&lt;/textarea&gt;&lt;/span> &lt;span style="font-family: inherit;">ย &lt;/center&gt;&lt;/span> &lt;span style="font-family: inherit;">ย &lt;/body&gt;&lt;/span> &lt;span style="font-family: inherit;">&lt;/html&gt;&lt;/span></code></pre> <pre><code>&lt;p&gt; &lt;span style=&quot;font-family: inherit; font-size: large;&quot;&gt;&lt;b&gt;texteditor.js&lt;/b&gt;&lt;/span&gt; &lt;/p&gt; </code></pre> </div> <pre class="prettyprint"><code>&lt;span style="font-family: inherit;">$(document).ready(function(){&lt;/span> &lt;span style="font-family: inherit;">ย document.getElementById('textEditor').contentWindow.document.designMode="on";&lt;/span> &lt;span style="font-family: inherit;">ย document.getElementById('textEditor').contentWindow.document.close();&lt;/span> &lt;span style="font-family: inherit;">ย var edit = document.getElementById("textEditor").contentWindow;&lt;/span> &lt;span style="font-family: inherit;">ย edit.focus();&lt;/span> &lt;span style="font-family: inherit;">ย $("#bold").click(function(){&lt;/span> &lt;span style="font-family: inherit;">ย  if($(this).hasClass("selected")){&lt;/span> &lt;span style="font-family: inherit;">ย  ย $(this).removeClass("selected");&lt;/span> &lt;span style="font-family: inherit;">ย  }else{&lt;/span> &lt;span style="font-family: inherit;">ย  ย $(this).addClass("selected");&lt;/span> &lt;span style="font-family: inherit;">ย  }&lt;/span> &lt;span style="font-family: inherit;">ย  boldIt();&lt;/span> &lt;span style="font-family: inherit;">ย });&lt;/span> &lt;span style="font-family: inherit;">ย $("#italic").click(function(){&lt;/span> &lt;span style="font-family: inherit;">ย  if($(this).hasClass("selected")){&lt;/span> &lt;span style="font-family: inherit;">ย  ย $(this).removeClass("selected");&lt;/span> &lt;span style="font-family: inherit;">ย  }else{&lt;/span> &lt;span style="font-family: inherit;">ย  ย $(this).addClass("selected");&lt;/span> &lt;span style="font-family: inherit;">ย  }&lt;/span> &lt;span style="font-family: inherit;">ย  ItalicIt();&lt;/span> &lt;span style="font-family: inherit;">ย });&lt;/span> &lt;span style="font-family: inherit;">ย $("#fonts").on('change',function(){&lt;/span> &lt;span style="font-family: inherit;">ย  changeFont($("#fonts").val());&lt;/span> &lt;span style="font-family: inherit;">ย });&lt;/span> &lt;span style="font-family: inherit;">ย $("#link").click(function(){&lt;/span> &lt;span style="font-family: inherit;">ย  var urlp=prompt("What is the link:","http://");&lt;/span> &lt;span style="font-family: inherit;">ย  url(urlp);&lt;/span> &lt;span style="font-family: inherit;">ย });ย &lt;/span> &lt;span style="font-family: inherit;">ย $("#stext").click(function(){&lt;/span> &lt;span style="font-family: inherit;">ย  $("#text").hide();&lt;/span> &lt;span style="font-family: inherit;">ย  $("#textEditor").show();&lt;/span> &lt;span style="font-family: inherit;">ย  $("#controls").show()&lt;/span> &lt;span style="font-family: inherit;">ย });&lt;/span> &lt;span style="font-family: inherit;">ย $("#shtml").on('click',function(){&lt;/span> &lt;span style="font-family: inherit;">ย  $("#text").css("display","block");&lt;/span> &lt;span style="font-family: inherit;">ย  $("#textEditor").hide();&lt;/span> &lt;span style="font-family: inherit;">ย  $("#controls").hide();&lt;/span> &lt;span style="font-family: inherit;">ย });&lt;/span> &lt;span style="font-family: inherit;">});&lt;/span> &lt;span style="font-family: inherit;">function boldIt(){&lt;/span> &lt;span style="font-family: inherit;">ย var edit = document.getElementById("textEditor").contentWindow;&lt;/span> &lt;span style="font-family: inherit;">ย edit.focus();&lt;/span> &lt;span style="font-family: inherit;">ย  edit.document.execCommand("bold", false, "");&lt;/span> &lt;span style="font-family: inherit;">ย  edit.focus();&lt;/span> &lt;span style="font-family: inherit;">}&lt;/span> &lt;span style="font-family: inherit;">function ItalicIt(){&lt;/span> &lt;span style="font-family: inherit;">ย var edit = document.getElementById("textEditor").contentWindow;&lt;/span> &lt;span style="font-family: inherit;">ย edit.focus();&lt;/span> &lt;span style="font-family: inherit;">ย edit.document.execCommand("italic", false, "");&lt;/span> &lt;span style="font-family: inherit;">ย edit.focus();&lt;/span> &lt;span style="font-family: inherit;">}&lt;/span> &lt;span style="font-family: inherit;">function changeFont(font){&lt;/span> &lt;span style="font-family: inherit;">ย var edit = document.getElementById("textEditor").contentWindow;&lt;/span> &lt;span style="font-family: inherit;">ย edit.focus();&lt;/span> &lt;span style="font-family: inherit;">ย edit.document.execCommand("FontName", false, font);&lt;/span> &lt;span style="font-family: inherit;">ย edit.focus();&lt;/span> &lt;span style="font-family: inherit;">}&lt;/span> &lt;span style="font-family: inherit;">function url(url){&lt;/span> &lt;span style="font-family: inherit;">ย var edit = document.getElementById("textEditor").contentWindow;&lt;/span> &lt;span style="font-family: inherit;">ย edit.focus();&lt;/span> &lt;span style="font-family: inherit;">ย edit.document.execCommand("Createlink", false, url);&lt;/span> &lt;span style="font-family: inherit;">ย edit.focus();&lt;/span> &lt;span style="font-family: inherit;">}&lt;/span> &lt;span style="font-family: inherit;">setInterval(function(){&lt;/span> &lt;span style="font-family: inherit;">ย var gyt=$("#textEditor").contents().find("body").html().match(/@/g);&lt;/span> &lt;span style="font-family: inherit;">ย if($("#textEditor").contents().find("body").html().match(/@/g)&gt;=0){}else{&lt;/span> &lt;span style="font-family: inherit;">ย  $("#text").val($("#textEditor").contents().find("body").html());&lt;/span> &lt;span style="font-family: inherit;">ย }&lt;/span> &lt;span style="font-family: inherit;">ย $("#text").val($("#textEditor").contents().find("body").html());&lt;/span> &lt;span style="font-family: inherit;">},1000);&lt;/span></code></pre> <div style="text-align: left;"> <span class="js-variable" style="font-family: inherit;">The user will type text in the <b>iframe</b>. The <b>HTML</b>ย of <b>iframe</b> will be added in the <b>textarea</b>. So when the user clicks <b>HTML</b>ย button he sees the <b>HTML</b>ย of <b>iframe</b>. You can pass the <b>textarea</b> value to your database if needed, but use <b>htmlspecialchars</b> when passing in <b>PHP</b>, because the user can inject <b>XSS</b>ย codes.</span> </div> </div> BZFLAG Ubuntu 10.04 Lucid Lynx PPA https://subinsb.com/bzflag-ubuntu-10-04-lucid-lynx-ppa/ Wed, 24 Oct 2012 06:42:00 +0000 https://subinsb.com/bzflag-ubuntu-10-04-lucid-lynx-ppa/ <div dir="ltr" style="text-align: left;" trbidi="on"> Bzflag stopped supporting Ubuntu 10.04 Lucid Lynx. But you can still install the latest version by adding this PPA.<br />To add the PPA follow the steps.<br />1 &#8211; Go to <b>Ubuntu Software Center</b><br />Under Edit Tab Choose <b>Software sources.</b></p> <div class="separator" style="clear: both; text-align: center;"> </div> <p> <a href="//1.bp.blogspot.com/-CBeHXGjRxLw/UIa5a9_BX-I/AAAAAAAACFE/2ddIGem0uFI/s1600/Screenshot-Software+Sources.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="//1.bp.blogspot.com/-CBeHXGjRxLw/UIa5a9_BX-I/AAAAAAAACFE/2ddIGem0uFI/s1600/Screenshot-Software+Sources.png" /></a><br />Click <b>Add</b>&nbsp;button.<br />Type this in the <b>APT line </b>field. </p> <blockquote class="tr_bq"> <p> ppa:ferramroberto/game/ubuntu </p> </blockquote> <p> and click <b>Add Source</b>. </p> <div class="separator" style="clear: both; text-align: center;"> <a href="//4.bp.blogspot.com/-7qKkK6T6hbg/UIeKXUFHChI/AAAAAAAACFM/ClK3xhNS9No/s1600/Screenshot-Untitled+Window.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="//4.bp.blogspot.com/-7qKkK6T6hbg/UIeKXUFHChI/AAAAAAAACFM/ClK3xhNS9No/s1600/Screenshot-Untitled+Window.png" /></a> </div> <div class="separator" style="clear: both; text-align: left;"> <b>BZFLAG PPA </b>&nbsp;is now added. Close the <b>Software Resources</b>&nbsp;dialog. </div> <div class="separator" style="clear: both; text-align: left;"> A window will ask for your password. </div> <div class="separator" style="clear: both; text-align: center;"> <a href="//3.bp.blogspot.com/-Epi7rZ9Od2U/UIeLSBTVIFI/AAAAAAAACFU/fp_snMw4ZIk/s1600/Screenshot-Authenticate.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="//3.bp.blogspot.com/-Epi7rZ9Od2U/UIeLSBTVIFI/AAAAAAAACFU/fp_snMw4ZIk/s1600/Screenshot-Authenticate.png" /></a> </div> <div class="" style="clear: both; text-align: left;"> Type your password and click <b>Authenticate</b>. Some files will start to Download. </div> <div class="" style="clear: both; text-align: left;"> After the download is finished<b>&nbsp;</b>packages will be updated. Close <b>Ubuntu Software Center</b>. Open <b>Synaptic Package Manager</b>&nbsp;and search for <b>bzflag</b>&nbsp;you should see an exclamation mark on the left side of the package <b>bzflag</b>. It means an <b>upgrade</b>&nbsp;is available. Double click on the packages <b>bzflag</b>&nbsp;, <b>bzflag-data</b>&nbsp;, <b>bzflag-client</b>&nbsp;, <b>bzflag-server</b>. Then click <b>Apply</b>&nbsp;button on the top. </div> <div class="separator" style="clear: both; text-align: center;"> <a href="//3.bp.blogspot.com/-mr1dveJ_9bU/UIeND11bkGI/AAAAAAAACFc/Ja0isStxQT4/s1600/apply.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="32" src="//3.bp.blogspot.com/-mr1dveJ_9bU/UIeND11bkGI/AAAAAAAACFc/Ja0isStxQT4/s200/apply.png" width="32" /></a> </div> <div class="separator" style="clear: both; text-align: left;"> The packages you <b>double clicked </b>will be downloaded and upgraded. Enjoy <b>BzFlag</b>. </div> </div> Upload your image to the web in just a minute without registering https://subinsb.com/upload-your-image-to-the-web-in-just-a-minute-without-registering/ Mon, 22 Oct 2012 05:14:00 +0000 https://subinsb.com/upload-your-image-to-the-web-in-just-a-minute-without-registering/ <div dir="ltr" style="text-align: left;" trbidi="on"> There are many websites for uploading images for various purposes. Some of the popular services are&nbsp;<b>Picasa</b>, <b>Flickr</b>&nbsp;etc&#8230;.<br />But you need an account for using the services shown above. If you don&#8217;t want to waste any time and upload image in just a minute, then there a re some services which will upload your image in their servers. In this tutorial I will introduce to a service called&nbsp;<b><a href="http://www.postimage.org/" >Post Image</a>.</b><br />Go to <b><a href="http://www.postimage.org/" >Post Image</a>&nbsp;(</b><a href="http://www.postimage.org/">http://www.postimage.org/</a><b>)</b>.</p> <div class="separator" style="clear: both; text-align: center;"> <a href="//3.bp.blogspot.com/-qCi-UIUZk_I/UITQreZDyjI/AAAAAAAACD4/LKxxlthvBbw/s1600/postimage.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="284" src="//3.bp.blogspot.com/-qCi-UIUZk_I/UITQreZDyjI/AAAAAAAACD4/LKxxlthvBbw/s640/postimage.png" width="640" /></a> </div> <p> Choose the image file. Choose whether you want to resize your image. After completing the form. Submit it by clicking <b>Upload</b>&nbsp;<b>It</b>. </p> <div class="separator" style="clear: both; text-align: center;"> <a href="//1.bp.blogspot.com/-gWc7jf4k9L4/UITR6YlCVXI/AAAAAAAACEA/e5sXDbCu034/s1600/uploading.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="153" src="//1.bp.blogspot.com/-gWc7jf4k9L4/UITR6YlCVXI/AAAAAAAACEA/e5sXDbCu034/s400/uploading.png" width="400" /></a> </div> <p> Your image will start to upload. After uploading Copy the image URL in the <b>Direct Link</b> field. </p> <div class="separator" style="clear: both; text-align: center;"> <a href="//4.bp.blogspot.com/-PKVNF1xTlxs/UITSxn9UcPI/AAAAAAAACEI/kFC3pB5UOV0/s1600/urlpostimage.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="194" src="//4.bp.blogspot.com/-PKVNF1xTlxs/UITSxn9UcPI/AAAAAAAACEI/kFC3pB5UOV0/s640/urlpostimage.png" width="640" /></a> </div> <div class="separator" style="clear: both; text-align: left;"> That&#8217;s it. Now you got the URL of the image. You can use this URL to show the image on your website or blog using the <b>IMG</b>&nbsp;tag. </div> </div> phpMyAdmin โ€“ A software to manage MySql Database https://subinsb.com/phpmyadmin-a-software-to-manage-mysql-database/ Sun, 21 Oct 2012 17:18:00 +0000 https://subinsb.com/phpmyadmin-a-software-to-manage-mysql-database/ <div dir="ltr" style="text-align: left;" trbidi="on"> If you want to manage your <b>MySql</b>&nbsp;table you can use a software called <b>phpMyAdmin</b>. You can install <b>phpMyAdmin</b>&nbsp;in any Operating Systems. This tutorial will help you to install <b>phpMyAdmin</b>&nbsp;in Linux.</p> <div> </p> <pre><code>&lt;h2 id=&quot;require&quot; style=&quot;font-family: sans-serif; max-width: 70em;&quot;&gt; Requirements &lt;/h2&gt; &lt;ul style=&quot;font-family: sans-serif; margin: 1em; max-width: 70em;&quot;&gt; &lt;li style=&quot;margin-top: 0.5em;&quot;&gt; &lt;b&gt;PHP&lt;/b&gt; &lt;ul style=&quot;margin: 1em 1em 0px; max-width: 70em;&quot;&gt; &lt;li style=&quot;margin-top: 0.5em;&quot;&gt; You need PHP 5.2.0 or newer, with&amp;nbsp;&lt;tt&gt;session&lt;/tt&gt;&amp;nbsp;support&amp;nbsp;and the Standard PHP Library (SPL) extension. &lt;/li&gt; &lt;li style=&quot;margin-top: 0.5em;&quot;&gt; To support uploading of ZIP files, you need the PHP&amp;nbsp;&lt;tt&gt;zip&lt;/tt&gt;&amp;nbsp;extension. &lt;/li&gt; &lt;li style=&quot;margin-top: 0.5em;&quot;&gt; For proper support of multibyte strings (eg. UTF-8, which is currently default), you should install mbstring and ctype extensions. &lt;/li&gt; &lt;li style=&quot;margin-top: 0.5em;&quot;&gt; You need GD2 support in PHP to display inline thumbnails of JPEGs (&quot;image/jpeg: inline&quot;) with their original aspect ratio &lt;/li&gt; &lt;li style=&quot;margin-top: 0.5em;&quot;&gt; When using the &quot;cookie&quot;&amp;nbsp;authentication method, the&amp;nbsp;&lt;tt&gt;mcrypt&lt;/tt&gt;&amp;nbsp;extension is strongly suggested for most users and is&amp;nbsp;&lt;b&gt;required&lt;/b&gt;&amp;nbsp;for 64โ€“bit machines. Not using mcrypt will cause phpMyAdmin to load pages significantly slower. &lt;/li&gt; &lt;li style=&quot;margin-top: 0.5em;&quot;&gt; To support upload progress bars. &lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;li style=&quot;margin-top: 0.5em;&quot;&gt; &lt;b&gt;MySQL&lt;/b&gt;&amp;nbsp;5.0 or newer (details); &lt;/li&gt; &lt;li style=&quot;margin-top: 0.5em;&quot;&gt; &lt;b&gt;Web browser&lt;/b&gt;&amp;nbsp;with cookies enabled. &lt;/li&gt; &lt;/ul&gt; </code></pre> </div> <div> Press <b>ALT + CTRL + T</b>. </div> <div> You will get the <b>Terminal</b>&nbsp;window. </div> <div> Type the command shown below. </div> <blockquote class="tr_bq"> <p> sudo apt-get install phpmyadmin </p> </blockquote> <div class="separator" style="clear: both; text-align: center;"> <a href="//4.bp.blogspot.com/-MubgN7LY8_c/UIQs7l-2VUI/AAAAAAAACDw/gqoi0IcIa7U/s1600/Screenshot-simsu@simsu-veriton-series:+~.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="456" src="//4.bp.blogspot.com/-MubgN7LY8_c/UIQs7l-2VUI/AAAAAAAACDw/gqoi0IcIa7U/s640/Screenshot-simsu@simsu-veriton-series:+~.png" width="640" /></a> </div> <p> Press <b>Enter</b>&nbsp;and the installation will begin.<br />You will get a setup window during the installation. Type in the details and continue the installation.<br />One of the setup process will ask for <b>MySql</b>&nbsp;<b>Database</b>&nbsp;password and username so be careful not to type in the wrong password or username.<br />After installation go to <a href="http://localhost/phpmyadmin" style="font-weight: bold;" >localhost/phpmyadmin</a>.<br />You will get a page of a login screen. </p> <div class="separator" style="clear: both; text-align: center;"> <a href="//1.bp.blogspot.com/-dDu5swk797w/UIQr04GcSgI/AAAAAAAACDo/t8rQISvuo28/s1600/Screenshot-phpMyAdmin+-+Google+Chrome.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="338" src="//1.bp.blogspot.com/-dDu5swk797w/UIQr04GcSgI/AAAAAAAACDo/t8rQISvuo28/s640/Screenshot-phpMyAdmin+-+Google+Chrome.png" width="640" /></a> </div> <p> Type the username and password of <b>MySql Database</b>. Press <b>Go</b>&nbsp;and you will enter in to <b>phpMyAdmin</b>. That&#8217;s it.<br />In the next tutorial I will tell you how to use <b>phpMyAdmin</b>.</div> Toggle Element visibility using a little piece of code โ€“ Jquery Toggle https://subinsb.com/toggle-element-visibility-using-a-little-piece-of-code-jquery-toggle/ Sat, 20 Oct 2012 16:00:00 +0000 https://subinsb.com/toggle-element-visibility-using-a-little-piece-of-code-jquery-toggle/ <div dir="ltr" style="text-align: left;" trbidi="on"> You might wanted to <b>Show/Hide</b>&nbsp;element based on the visibility of the element. If the visibility is <b>block</b>&nbsp; ,&nbsp;<b>hide </b>the element and if visibility is <b>none</b>,&nbsp;<b>show</b> the element.<br />You can do this without the<b>&nbsp;if </b>statement. You can do this in just a line of code.<br />For example : if we want to toggle the visibility of a <b>div</b>&nbsp;with the id <b>sh</b>.</p> <blockquote class="tr_bq"> <p> $("#sh").toggle(); </p> </blockquote> <p> If the <b>div</b>&nbsp;<b>#sh</b>&nbsp;is <b>hidden</b> the code above code will make it <b>visible</b> and if it is <b>visible</b>&nbsp;the code will <b>hide</b>&nbsp;the <b>div #sh</b>.</div> 20,000 Views. Thank you. https://subinsb.com/20000-views-thank-you/ Sat, 20 Oct 2012 13:25:00 +0000 https://subinsb.com/20000-views-thank-you/ <div dir="ltr" style="text-align: left;" trbidi="on"> Hello Visitors. I am very excited to tell you that my blog has reached <b>20,000 </b>views. Thanks to everyone who visited my blog. Hope the posts helped you. Thanks for this amazing achievement. Hope my blog would get more views and someday my blog will reach <b>1,00,000 </b>views. Thank you guys. You were amazing.</p> <div class="separator" style="clear: both; text-align: center;"> <a href="//4.bp.blogspot.com/-OIyLNDxJrBY/UIKl0-2-x0I/AAAAAAAACC8/vUcBaU7XT38/s1600/20000.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="480" src="//4.bp.blogspot.com/-OIyLNDxJrBY/UIKl0-2-x0I/AAAAAAAACC8/vUcBaU7XT38/s640/20000.png" width="640" /></a> </div> <p> </div> Keypad not working in Ubuntu fix https://subinsb.com/keypad-not-working-in-ubuntu-fix/ Sat, 13 Oct 2012 13:02:00 +0000 https://subinsb.com/keypad-not-working-in-ubuntu-fix/ <div dir="ltr" style="text-align: left;" trbidi="on"> Some can&#8217;t type numbers using keypad. This because you enabled the <b>Pointer cab be controlled using keypad</b>. To disable it there are two ways.</p> <div> </div> <div> <ul style="text-align: left;"> <li> <b>By Keyboard</b> </li> </ul> <pre><code>&lt;p&gt; &lt;b&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; CTRL + SHIFT + NUM LOCK&lt;/b&gt;&lt;/div&gt; &lt;div style=&quot;text-align: left;&quot;&gt; &lt;ul style=&quot;text-align: left;&quot;&gt; &lt;li&gt; &lt;b&gt;By Terminal&lt;/b&gt; &lt;/li&gt; &lt;/ul&gt; &lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Command :- &lt;/p&gt; &lt;/div&gt; &lt;blockquote class=&quot;tr_bq&quot;&gt; &lt;p&gt; gnome-keyboard-properties &lt;/p&gt; &lt;/blockquote&gt; &lt;div style=&quot;text-align: center;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;u&gt;&lt;b&gt;OR&lt;/b&gt;&lt;/u&gt; &lt;/div&gt; &lt;div style=&quot;text-align: left;&quot;&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;go to&amp;nbsp;&lt;b style=&quot;background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20px;&quot;&gt;System โ–ธ Preferences โ–ธ Keyboard&lt;/b&gt; &lt;/div&gt; &lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;You will get a window.&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Under &lt;b&gt;Mouse Keys &lt;/b&gt;tab there is a option called&amp;nbsp;&lt;b&gt;Pointer cab be controlled using keypad&lt;/b&gt;.&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Uncheck it as shown in the image below. &lt;/p&gt; &lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt; &lt;a href=&quot;//4.bp.blogspot.com/-DAekZTlaHRA/UHll83cXVAI/AAAAAAAACAs/5l65kPO3Pxk/s1600/numpad.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;//4.bp.blogspot.com/-DAekZTlaHRA/UHll83cXVAI/AAAAAAAACAs/5l65kPO3Pxk/s1600/numpad.png&quot; /&gt;&lt;/a&gt; &lt;/div&gt;&lt;/div&gt; </code></pre> Install a RPM file in Ubuntu/Linux โ€“ Convert RPM files to DEB packages https://subinsb.com/install-a-rpm-file-in-ubuntulinux-convert-rpm-files-to-deb-packages/ Fri, 12 Oct 2012 11:57:00 +0000 https://subinsb.com/install-a-rpm-file-in-ubuntulinux-convert-rpm-files-to-deb-packages/ <div dir="ltr" style="text-align: left;" trbidi="on"> Some programs will only have an <b>RPM</b>&nbsp;file which can be downloaded and can be installed. But most of the people don&#8217;t know how to install. If you open the <b>RPM</b>&nbsp;file you will see the archive in <b>Archive Manager</b>.</p> <p> This post will help you to convert <b>RPM</b>&nbsp;files to <b>DEB</b>&nbsp;packages which we can install in <b>Linux</b>.<br />Open the terminal (<b style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20px;">Applications โ–ธ Accessories โ–ธ Terminal</b><span style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20px;">) or by pressing <b>CTRL + F2</b>.</span><br /><span style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20px;">Install <b>Alien</b>&nbsp;package to convert the <b>RPM</b>&nbsp;file by using the following command.</span> </p> <blockquote class="tr_bq"> <p> <span style="color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif;"><span style="font-size: 15px; line-height: 20px;">sudo apt-get install alien dpkg-dev debhelper build-essential</span></span> </p> </blockquote> <p> After installation we can convert the file. For that use this command. </p> <blockquote class="tr_bq"> <p> sudo alien <span style="background-color: #bf9000; color: white;">file location</span> </p> </blockquote> <p> Replace <span style="background-color: #bf9000; color: white;">file location</span><b style="color: red;">&nbsp;</b>on the above command&nbsp;with the source of your file. For Example : </p> <blockquote class="tr_bq"> <p> <b>sudo alien <span style="background-color: #bf9000;"><span style="color: white;">Downloads/wine-1.3.rpm</span></span></b> </p> </blockquote> <p> The process would take some minutes depending on the size of the <b>RPM&nbsp;</b>file.<br />After the process open the folder where your <b>RPM</b>&nbsp;file is. You would see another file with the same name with the only difference that it&#8217;s a <b>DEB</b>&nbsp;package.<br />Open the <b>DEB</b>&nbsp;package and install it using <b>GDebi Package Installer</b>. </p> <p> That&#8217;s it !! Hope this worked for you. If it didn&#8217;t worked Tell the problem in the comments and I will help you. </p> </div> How to take a screenshot in Ubuntu/Linux https://subinsb.com/how-to-take-a-screenshot-in-ubuntulinux/ Fri, 12 Oct 2012 06:56:00 +0000 https://subinsb.com/how-to-take-a-screenshot-in-ubuntulinux/ <div dir="ltr" style="text-align: left;" trbidi="on"> You can take screenshots of your desktop in <b>Linux</b>. For taking screenshots you can use <b>Take Screenshot</b>&nbsp;application.</p> <ul style="text-align: left;"> <li> <b>Use shortcut keys</b> </li> </ul> <p> To take a screenshot, use the following shortcut keys: </p> <table border="1" bordercolor="#000000" cellpadding="4" cellspacing="0" style="width: 100%px;"> <colgroup> <col width="128*"></col> <col width="128*"></col> </colgroup> <tr valign="TOP"> <td width="50%"> <b>Default Shortcut Keys</b> </td> <pre><code> &lt;td width=&quot;50%&quot;&gt; &lt;b&gt;Function&lt;/b&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr valign=&quot;TOP&quot;&gt; &lt;td width=&quot;50%&quot;&gt; Print Screen &lt;/td&gt; &lt;td width=&quot;50%&quot;&gt; Takes a screenshot of the entire screen. &lt;/td&gt; &lt;/tr&gt; &lt;tr valign=&quot;TOP&quot;&gt; &lt;td width=&quot;50%&quot;&gt; Alt+Print Screen &lt;/td&gt; &lt;td width=&quot;50%&quot;&gt; Takes a screenshot of the window which is active. &lt;/td&gt; &lt;/tr&gt; </code></pre> </table> <p> </p> <div style="text-align: left;"> </div> <ul style="text-align: left;"> <li> <b>From the Menubar</b> </li> </ul> <p> &nbsp; &nbsp; &nbsp; Choose <b>Applications โ–ธ Accessories โ–ธ Take Screenshot.</b> </p> <div style="text-align: left;"> </div> <ul style="text-align: left;"> <li> <b>From the Terminal</b> </li> </ul> <p> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; You can use the </p> <blockquote class="tr_bq"> <p> gnome-screenshot&nbsp; </p> </blockquote> <p> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; command to&nbsp;take a screenshot. The <b>gnome-screenshot</b> command takes<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; a screenshot of the entire screen, and displays the Save Screenshot<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; dialog. Use the Save Screenshot dialog to save the screenshot.<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; You can also use options on the <b>gnome-screenshot</b> command<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; as follows:<br />&nbsp; </p> <table border="1" bordercolor="#000000" cellpadding="4" cellspacing="0" style="page-break-before: always; width: 100%px;"> <colgroup> <col width="128*"></col> <col width="128*"></col> </colgroup> <tr valign="TOP"> <td width="50%"> <a href="//4.bp.blogspot.com/-3FAjC8w52XI/UHe_a7ti_sI/AAAAAAAACAk/7akxt1DdqFs/s1600/Screenshot-Take+Screenshot.png" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"><br /></a><b>Option</b> </td> <pre><code> &lt;td width=&quot;50%&quot;&gt; &lt;b&gt;Function&lt;/b&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr valign=&quot;TOP&quot;&gt; &lt;td height=&quot;6&quot; width=&quot;50%&quot;&gt; &amp;#8211;window &lt;/td&gt; &lt;td width=&quot;50%&quot;&gt; Takes a screenshot of the window that has focus. &lt;/td&gt; &lt;/tr&gt;&lt;colgroup&gt; &lt;col width=&quot;128*&quot;&gt;&lt;/col&gt; &lt;col width=&quot;128*&quot;&gt;&lt;/col&gt; &lt;/colgroup&gt; &lt;tr valign=&quot;TOP&quot;&gt; &lt;td width=&quot;50%&quot;&gt; &amp;#8211;include-border &lt;/td&gt; &lt;td width=&quot;50%&quot;&gt; Takes a screenshot after the specified number of seconds, and displays the Save Screenshot dialog. Use the Save Screenshot dialog to save the screenshot. &lt;/td&gt; &lt;/tr&gt; &lt;tr valign=&quot;TOP&quot;&gt; &lt;td width=&quot;50%&quot;&gt; &amp;#8211;delay=seconds &lt;/td&gt; &lt;td width=&quot;50%&quot;&gt; Takes a screenshot including the border of the window. &lt;/td&gt; &lt;/tr&gt; &lt;tr valign=&quot;TOP&quot;&gt; &lt;td width=&quot;50%&quot;&gt; &amp;#8211;border-effect=shadow &lt;/td&gt; &lt;td width=&quot;50%&quot;&gt; Takes a screenshot without the border of the window. &lt;/td&gt; &lt;/tr&gt; &lt;tr valign=&quot;TOP&quot;&gt; &lt;td width=&quot;50%&quot;&gt; &amp;#8211;border-effect=border &lt;/td&gt; &lt;td width=&quot;50%&quot;&gt; Takes a screenshot and adds a shadow bevel effect around it. &lt;/td&gt; &lt;/tr&gt; &lt;tr valign=&quot;TOP&quot;&gt; &lt;td width=&quot;50%&quot;&gt; &amp;#8211;interactive &lt;/td&gt; &lt;td width=&quot;50%&quot;&gt; Takes a screenshot and adds a border effect around it. &lt;/td&gt; &lt;/tr&gt; &lt;tr valign=&quot;TOP&quot;&gt; &lt;td width=&quot;50%&quot;&gt; &amp;#8211;remove-border &lt;/td&gt; &lt;td width=&quot;50%&quot;&gt; Opens a window that lets you set options before taking the screenshot. &lt;/td&gt; &lt;/tr&gt; &lt;tr valign=&quot;TOP&quot;&gt; &lt;td width=&quot;50%&quot;&gt; &amp;#8211;help &lt;/td&gt; &lt;td width=&quot;50%&quot;&gt; Displays the options for the command. &lt;/td&gt; &lt;/tr&gt; </code></pre> </table> <div class="separator" style="clear: both; text-align: center;"> <a href="//4.bp.blogspot.com/-3FAjC8w52XI/UHe_a7ti_sI/AAAAAAAACAk/7akxt1DdqFs/s1600/Screenshot-Take+Screenshot.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="283" src="//4.bp.blogspot.com/-3FAjC8w52XI/UHe_a7ti_sI/AAAAAAAACAk/7akxt1DdqFs/s320/Screenshot-Take+Screenshot.png" width="320" /></a> </div> <p> When you take a screenshot, the Save Screenshot dialog opens. To save the screenshot as an image file, enter the file name for the screenshot, choose a location from the drop-down list and click the Save button. You can also use the Copy to Clipboard button to copy the image to the clipboard or transfer it to another application by drag-and-drop. </p> </div> Know/Check Ram Type in Linux https://subinsb.com/knowcheck-ram-type-in-linux/ Thu, 11 Oct 2012 13:38:00 +0000 https://subinsb.com/knowcheck-ram-type-in-linux/ <div dir="ltr" style="text-align: left;" trbidi="on"> If you want to know what type is your RAM. This command will help you in&nbsp;<b>Linux</b>.</p> <blockquote class="tr_bq"> <p> sudo dmidecode &#8211;type 17 </p> </blockquote> <p> Type your password and press Enter. The details of your ram will be shown. </p> <div class="separator" style="clear: both; text-align: center;"> <a href="//1.bp.blogspot.com/-8EDRj6O5A_g/UHbKtcK-d0I/AAAAAAAACAc/PUtyIdkbRys/s1600/ddr.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="//1.bp.blogspot.com/-8EDRj6O5A_g/UHbKtcK-d0I/AAAAAAAACAc/PUtyIdkbRys/s1600/ddr.png" /></a> </div> <div class="separator" style="clear: both; text-align: left;"> You can now see the <b>DDR </b>of your <b>Ram</b>&nbsp;as shown in the picture above. </div> </div> Canโ€™t boot into Ubuntu after upgrading. https://subinsb.com/cant-boot-into-ubuntu-after-upgrading/ Mon, 08 Oct 2012 14:03:00 +0000 https://subinsb.com/cant-boot-into-ubuntu-after-upgrading/ <div dir="ltr" style="text-align: left;" trbidi="on"> When you upgrade to any new version of <b>Ubuntu</b>&nbsp;you will not be able to open <b>Ubuntu.</b>&nbsp;There might be a number of reasons. This post will help you to solve the problem of <b>not completing the&nbsp;</b><br /><b>installation of new packages.</b></p> <div class="separator" style="clear: both; text-align: center;"> <a href="https://2.bp.blogspot.com/-0W5ayVCROYY/Ub1bpClTFPI/AAAAAAAACuk/hx55dmbpiV0/s1600/0011.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://2.bp.blogspot.com/-0W5ayVCROYY/Ub1bpClTFPI/AAAAAAAACuk/hx55dmbpiV0/s1600/0011.jpg" /></a> </div> <p> <b><br /></b>To solve this, boot in to <b>Ubuntu. </b>You will be stuck in the <b>Ubuntu Logo.</b> </p> <p> In there press <b>ALT + CTRL + F1.</b><br />You will get a terminal.<br /><b>Login</b>&nbsp;to your account there in the terminal by typing your username first and password second.<br />Then Enter the following commands in the terminal. </p> <blockquote class="tr_bq"> <p> sudo -i </p> </blockquote> <p> <b>You will be asked for your password. </b>Then the next command. </p> <blockquote class="tr_bq"> <p> <em style="background-color: white; font-family: arial, sans-serif; font-style: normal; line-height: 16px;">sudo dpkg &#8211;configure -a</em> </p> </blockquote> <p> Wait for <b>10 Minutes or more </b>for completing it&nbsp;depending on your <b>RAM</b>.<br />After completion reboot your computer using the following command. </p> <blockquote class="tr_bq"> <p> sudo reboot&nbsp; </p> </blockquote> <p> You can now boot into <b>Ubuntu.</b> </p> </div> Removing HTML tags in an input element. https://subinsb.com/removing-html-tags-in-an-input-element/ Sun, 30 Sep 2012 05:09:00 +0000 https://subinsb.com/removing-html-tags-in-an-input-element/ <div dir="ltr" style="text-align: left;" trbidi="on"> <b>index.</b><b>html </b>(Removing HTML in INPUT element).</p> <blockquote class="tr_bq"> <p> <html><br /><head><br /><script><br />var el = document.getElementById("in"); // or just another HTML DOM element<br />var text = el.value.replace(/<[^>]+>/g, "");<br />&nbsp;document.getElementById("in").value=text;<br /></script><br /></head><br /><body><br /><input id="<span style="color: red;">in</span>" value="<span style="color: red;"><a>Subin</a></span>"><br /></body><br /></html> </p> </blockquote> <p> If the code above didn&#8217;t worked try placing the script after the <b>input element</b>.<br />This is the script </p> <blockquote class="tr_bq"> <p> &nbsp;<script><br />var el = document.getElementById("<span style="color: red;">in</span>"); // or just another HTML DOM element<br />var text = el.value.replace(/<[^>]+>/g, "");<br />&nbsp;document.getElementById("<span style="color: red;">in</span>").value=text;<br /></script> </p> </blockquote> </div> How to make a text bold in Google + post. https://subinsb.com/how-to-make-a-text-bold-in-google-post/ Sat, 29 Sep 2012 12:54:00 +0000 https://subinsb.com/how-to-make-a-text-bold-in-google-post/ <div dir="ltr" style="text-align: left;" trbidi="on"> <h2 style="text-align: left;"> <b style="background-color: white; font-family: arial, sans-serif; line-height: 18px; text-align: -webkit-auto;"><span style="font-size: large;">How to make a text bold in Google + post.</span></b> </h2> <p> <b><br style="background-color: white; font-family: arial, sans-serif; line-height: 18px; text-align: -webkit-auto;" /></b><span style="background-color: white; font-family: arial, sans-serif; line-height: 18px; text-align: -webkit-auto;">Did you ever see some post with bold text. Do you want to add this to your Google + post. Here&#8217;s How.</span><br style="background-color: white; font-family: arial, sans-serif; line-height: 18px; text-align: -webkit-auto;" /><span style="background-color: white; font-family: arial, sans-serif; line-height: 18px; text-align: -webkit-auto;">When typing a text add "*" to the starting word and ending word.</span><br style="background-color: white; font-family: arial, sans-serif; line-height: 18px; text-align: -webkit-auto;" /><span style="background-color: white; font-family: arial, sans-serif; line-height: 18px; text-align: -webkit-auto;">For example type "*Text*" without the quotations and when you post the word, "Text" will change to a bold text.</span><br /><br style="background-color: white; font-family: arial, sans-serif; line-height: 18px; text-align: -webkit-auto;" /><span style="background-color: white; font-family: arial, sans-serif; line-height: 18px; text-align: -webkit-auto;"><span style="font-size: large;"><a href="https://plus.google.com/100940821362767953768/posts/VoKr8nhQrKr" >DEMO</a></span></span></div> Block a site on all browsers in Linux https://subinsb.com/block-a-site-on-all-browsers-in-linux/ Thu, 27 Sep 2012 12:58:00 +0000 https://subinsb.com/block-a-site-on-all-browsers-in-linux/ <div dir="ltr" style="text-align: left;" trbidi="on"> This tutorial will help you to block a site in all browsers on <b>Linux</b></p> <p> Open Terminal (<b>ALT+F2</b>). </p> <div class="separator" style="clear: both; text-align: center;"> <a href="https://2.bp.blogspot.com/-VoAxWEuLVtA/UGRKbYhRgHI/AAAAAAAAB6Q/6834dirz7qU/s1600/run.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://2.bp.blogspot.com/-VoAxWEuLVtA/UGRKbYhRgHI/AAAAAAAAB6Q/6834dirz7qU/s1600/run.png" /></a> </div> <div class="separator" style="clear: both; text-align: left;"> Type <b>sudo -i</b>&nbsp;in the input field as shown in the picture above. </div> <div class="separator" style="clear: both; text-align: left;"> Check the <b>Run in terminal </b>option. </div> <div class="separator" style="clear: both; text-align: left;"> Finally click <b>Run </b>button. </div> <div class="separator" style="clear: both; text-align: left;"> </div> <div class="separator" style="clear: both; text-align: left;"> Type your password if necessary and press enter. </div> <div class="separator" style="clear: both; text-align: left;"> Then enter the following commands. </div> <blockquote class="tr_bq"> <p> gedit /etc/hosts </p> </blockquote> <p> You will get <b>Gedit Text Editor</b>&nbsp;window.<br />For Example we need to block&nbsp;<b>Facebook a</b>dd the following lines just after <b>127.0.0.1 localhost</b> </p> <blockquote class="tr_bq"> <p> 0.0.0.1 &nbsp; &nbsp; &nbsp; &nbsp; facebook.com<br />0.0.0.1 &nbsp; &nbsp; &nbsp; &nbsp; www.facebook.com </p> </blockquote> <div class="separator" style="clear: both; text-align: center;"> <a href="https://2.bp.blogspot.com/-p-iR57Twd0w/UGRMYliuZVI/AAAAAAAAB6Y/d7T1LjLxYDY/s1600/block.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://2.bp.blogspot.com/-p-iR57Twd0w/UGRMYliuZVI/AAAAAAAAB6Y/d7T1LjLxYDY/s1600/block.png" /></a> </div> <div class="separator" style="clear: both; text-align: left;"> </div> <p> &nbsp;That&#8217;s it. When you now open <b>www.facebook.com </b>or <b>facebook.com</b>&nbsp;You cannot access it. In <b>Google Chrome</b>&nbsp;you will get this page. </p> <div class="separator" style="clear: both; text-align: center;"> <a href="//1.bp.blogspot.com/-O20ixO2_ef4/UGRNAtgWr6I/AAAAAAAAB6g/wqD7Z-eETGo/s1600/blocked.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="338" src="//1.bp.blogspot.com/-O20ixO2_ef4/UGRNAtgWr6I/AAAAAAAAB6g/wqD7Z-eETGo/s640/blocked.png" width="640" /></a> </div> <div class="separator" style="clear: both; text-align: left;"> To enable back <b>Facebook </b>remove the lines we added from the file&nbsp;<b>/etc/hosts</b>. </div> <div class="separator" style="clear: both; text-align: left;"> </div> <blockquote class="tr_bq"> <p> 0.0.0.1 &nbsp; &nbsp; &nbsp; &nbsp; facebook.com<br />0.0.0.1 &nbsp; &nbsp; &nbsp; &nbsp; www.facebook.com </p> </blockquote> </div> Jquery ExtAjax Plugin : Submit forms to external files using Jquery https://subinsb.com/jquery-extajax-plugin-submit-forms-to-external-files-using-jquery/ Sun, 23 Sep 2012 15:20:00 +0000 https://subinsb.com/jquery-extajax-plugin-submit-forms-to-external-files-using-jquery/ <div dir="ltr" style="text-align: left;" trbidi="on"> Hi. You can&#8217;t submit a form to external file using <b>Jquery Ajax. </b>Finally I created a <b>Jquery Plugin</b>&nbsp;to solve this problem. I named it <b>ExtAjax</b>.<br />This&nbsp;<b>Jquery Plugin</b>&nbsp;will help you to submit a form to a external file without refreshing the page.</p> <h2 style="text-align: left;"> <b><u>Requirements</u></b> </h2> <div> <b>1) Jquery Latest Version</b> </div> <div> <b>2) extajax.js file</b> </div> <div> <b><br /></b> </div> <p> Here&#8217;s how the&nbsp;<b>HTML&nbsp;</b>file will look like: </p> <blockquote class="tr_bq"> <p> <html><br /><head><br /><script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"></script><br /><script type="text/javascript" src="extajax.js"></script><br /></head><br /><body><br /><script><br />$(document).ready(function(){<br />$("<span style="color: red;">#form</span>").submit(function(){<br />event.preventDefault();<br />$("<span style="color: red;">#form</span>").extajax();<br />});<br />});<br /></script><br /><form id="<span style="color: red;">form</span>" action="<span style="color: red;">http://yahoo.com/search</span>" method="<span style="color: red;">get</span>"><br /><input name=&#8217;q&#8217; value="Google"><input type="submit"><br /></form><br /></body><br /></html> </p> </blockquote> <p> Here is the Jquery code added in the file above. </p> <blockquote class="tr_bq"> <p> <script><br />$(document).ready(function(){<br />$("<span style="color: red;">#form</span>").submit(function(){<br />event.preventDefault();<br />$("<span style="color: red;">#form</span>").extajax();<br />});<br />});<br /></script> </p> </blockquote> <p> Replace the red colored codes above with the id or class of your form eg: <b>#form2 </b>, .<b>myform</b><br />The form : </p> <blockquote class="tr_bq"> <p> <form id="<span style="color: #0b5394;">form</span>" action="<span style="color: #38761d;">http://yahoo.com/search</span>" method="<span style="color: red;">get</span>"><br /><input name=&#8217;q&#8217; value="Google"><input type="submit"><br /></form> </p> </blockquote> <p> Replace the <span style="color: #0b5394;">blue</span> colored line with your form id. It should be same on the script too.<br />Replace the <span style="color: red;">red</span> colored line with the type of method of the post (<b>post </b>or <b>get</b>).<br />Replace the <span style="color: #38761d;">green</span> colored line with the place you want to submit the form to. </p> <h2 style="text-align: left;"> Download </h2> <div style="text-align: center;"> <embed allowfullscreen="true" allowscriptaccess="always" height="400" src="https://www.box.com/embed/y1ytji2akasouer.swf" type="application/x-shockwave-flash" width="466" wmode="opaque"> </embed> </div> </div> Canโ€™t Boot Ubuntu after installing Nvidia Driver Fix 2 https://subinsb.com/cant-boot-ubuntu-after-installing-nvidia-driver-fix-2/ Sat, 22 Sep 2012 12:50:00 +0000 https://subinsb.com/cant-boot-ubuntu-after-installing-nvidia-driver-fix-2/ <div dir="ltr" style="text-align: left;" trbidi="on"> <span style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20px;">A lot of people has trouble booting in to Ubuntu after installation of Nvidia Driver.</span><br style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20px;" /><span style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20px;">Here is the second solution if <a href="http://sag-3.blogspot.in/2012/06/cant-boot-ubuntu-after-installing.html" >first solution</a> didn&#8217;t wok.</span><br /><span style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20px;"><br /></span><span style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20px;">Since you get a terminal when you boot in to <b>Ubuntu.</b></span><br /><span style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20px;">Login to your account in the terminal</span><br /><span style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20px;"><br /></span><span style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20px;">Then run the command.</span></p> <blockquote class="tr_bq"> <p> <span style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20px;">sudo -i</span> </p> </blockquote> <p> and save a new <b>Nvidia Config File </b>by running this command. </p> <blockquote class="tr_bq"> <p> nvidia-xconfig </p> </blockquote> <p> Your new config file has been created!<br />Reboot your computer and boot in to your <b>Ubuntu </b>now.</div> Google + going to host a hangout with Steven Spielberg and Joseph Gordon-Levitt https://subinsb.com/google-going-to-host-a-hangout-with-steven-spielberg-and-joseph-gordon-levitt/ Thu, 13 Sep 2012 16:15:00 +0000 https://subinsb.com/google-going-to-host-a-hangout-with-steven-spielberg-and-joseph-gordon-levitt/ <div dir="ltr" style="text-align: left;" trbidi="on"> <h3 class="r" style="background-color: white; color: #222222; font-family: arial, sans-serif; font-size: medium; margin: 0px; overflow: hidden; padding: 0px; text-align: -webkit-auto; text-overflow: ellipsis; white-space: nowrap;"> <em style="font-style: normal; font-weight: bold;">Steven Spielberg and Joseph Gordon-Levitt </em><em style="font-style: normal; font-weight: normal;">discuss about their new film </em><em style="font-style: normal;">LINCLON.</em> </h3> <div> <em style="font-style: normal;">The hangout is&nbsp;</em><span style="background-color: white; color: #444444; font-family: arial, sans-serif; font-size: 13px; line-height: 18px; text-align: -webkit-auto; white-space: nowrap;">Tomorrow, 14 September, 04:30 GMT+05:30.</span> </div> <div> <span style="background-color: white; color: #444444; font-family: arial, sans-serif; font-size: 13px; line-height: 18px; text-align: -webkit-auto; white-space: nowrap;"><br /></span> </div> <div style="text-align: -webkit-auto;"> <span style="font-family: inherit;"><span style="background-color: white; color: #444444; line-height: 19px;">Google Play presents: Steven Spielberg and Joseph Gordon-Levitt in their first ever Hangout On Air where they will be exclusively premiering the trailer for their upcoming movie, Lincoln. If you want to be one of the lucky fans to join the hangout please:</span><br style="background-color: white; color: #444444; line-height: 19px;" /><br style="background-color: white; color: #444444; line-height: 19px;" /><span style="background-color: white; color: #444444; line-height: 19px;">-Let us know how we can contact you here&nbsp;</span><a class="ot-anchor" href="http://goo.gl/ApTvq" style="background-color: white; color: #3366cc; cursor: pointer; line-height: 19px; text-decoration: none;">http://goo.gl/ApTvq</a><span style="background-color: white; color: #444444; line-height: 19px;">.&nbsp;</span><br style="background-color: white; color: #444444; line-height: 19px;" /><span style="background-color: white; color: #444444; line-height: 19px;">-Upload a short video to your YouTube channel with the&nbsp;</span><a class="ot-hashtag" href="https://plus.google.com/s/%23lincolnhangout" style="background-color: white; color: #3366cc; cursor: pointer; line-height: 19px; text-decoration: none;">#lincolnhangout</a><span style="background-color: white; color: #444444; line-height: 19px;">&nbsp;tag explaining who you are, why you are interested in "Lincoln" and what you would like to ask Spielberg and Gordon-Levitt</span><br style="background-color: white; color: #444444; line-height: 19px;" /><span style="background-color: white; color: #444444; line-height: 19px;">-Reshare this G+ event</span><br style="background-color: white; color: #444444; line-height: 19px;" /><br style="background-color: white; color: #444444; line-height: 19px;" /><span class="proflinkWrapper" style="background-color: white; color: #444444; line-height: 19px;"><span class="proflinkPrefix" style="color: #999999;">+</span><a class="proflink" href="https://plus.google.com/106886664866983861036" oid="106886664866983861036" style="color: #3366cc; cursor: pointer; text-decoration: none;">Google Play</a></span><span style="background-color: white; color: #444444; line-height: 19px;">&nbsp;will reach out to you if youโ€™ve been selected to join.</span><a class="ot-hashtag" href="https://plus.google.com/s/%23lincolnhangout" style="background-color: white; color: #3366cc; cursor: pointer; line-height: 19px; text-decoration: none;">#lincolnhangout</a><span style="background-color: white; color: #444444; line-height: 19px;">&nbsp;.</span><br style="background-color: white; color: #444444; line-height: 19px;" /><br style="background-color: white; color: #444444; line-height: 19px;" /><span style="background-color: white; color: #444444; line-height: 19px;">ABOUT THE MOVIE:</span><br style="background-color: white; color: #444444; line-height: 19px;" /><br style="background-color: white; color: #444444; line-height: 19px;" /><span style="background-color: white; color: #444444; line-height: 19px;">Steven Spielberg directs Joseph Gordon-Levitt in &nbsp;"Lincoln," a revealing drama that focuses on the 16th Presidentโ€™s tumultuous final months in office. In a nation divided by war and the strong winds of change, Lincoln pursues a course of action designed to end the war, unite the country and abolish slavery. With the moral courage and fierce determination to succeed, his choices during this critical moment will change the fate of generations to come.</span></span> </div> </div> Get extension of a file using PHP https://subinsb.com/get-extension-of-a-file-using-php/ Tue, 04 Sep 2012 14:59:00 +0000 https://subinsb.com/get-extension-of-a-file-using-php/ <div dir="ltr" style="text-align: left;"> This function will allow you to get a <b>file&#8217;s </b>extension in <b>PHP</b>. </div> <div dir="ltr" style="text-align: left;"> <pre class="prettyprint"><code>function getExtension($fileName){ $i = strrpos($fileName, "."); if (!$i) { return ""; } $length = strlen($str) - $i; $extens = substr($str, $i+1, $length); return $extens; }</code></pre> <p> For example you need to get a extension of the file <b>photo.jpg</b>. To get the extension type this codeย in your <b>PHP</b>ย file. </p> <pre class="prettyprint"><code>&lt;span style="color: #660000;">&lt;?php&lt;/span> &lt;span style="color: #660000;">echo&lt;/span> getExtension&lt;span style="color: #660000;">(&lt;/span>'&lt;b>&lt;span style="color: #e06666;">photo.jpg&lt;/span>&lt;/b>'&lt;span style="color: #660000;">);&lt;/span> &lt;span style="color: #660000;">?&gt;&lt;/span></code></pre> <p> The above code will print out "jpg". </p> </div> How to remove an item from GRUB boot menu https://subinsb.com/how-to-remove-an-item-from-grub-boot-menu/ Mon, 03 Sep 2012 04:45:00 +0000 https://subinsb.com/how-to-remove-an-item-from-grub-boot-menu/ <div dir="ltr" style="text-align: left;" trbidi="on"> <span style="font-family: inherit;">When you upgrade from old <b>Ubuntu </b>to new <b>Ubuntu</b>. Your <b>GRUB </b>menu will contain more than one <b>Ubuntu</b>. To remove unwanted <b>Ubuntu </b>from <b>GRUB </b>you need to edit the <b>GRUB </b>configuration file.</span><br /><span style="font-family: inherit;">Follow these steps.</span><br /><span style="font-family: inherit;">Backup your <b>GRUB&nbsp;</b>configuration file which is in&nbsp;<span style="background-color: lime; color: #222222;">/boot/grub/grub.cfg</span><span style="background-color: white; color: #222222;">&nbsp;which we will need if something goes wrong</span>.</span><br /><span style="font-family: inherit;">Open <b>Terminal </b>(<b>Applications -> Accessories -> Terminal</b>). You need to be the root. For that :</span></p> <blockquote class="tr_bq"> <p> <span style="font-family: inherit;">sudo -i</span> </p> </blockquote> <p> <span style="font-family: inherit;">&nbsp;Now we want to edit the file. For that:</span> </p> <blockquote class="tr_bq"> <p> <code style="background-color: white; border: 0px; color: #222222; margin: 0px; padding: 0px; vertical-align: baseline;">&lt;span style="font-family: inherit;">gedit /boot/grub/grub.cfg&lt;/span></code> </p> </blockquote> <p> <span style="font-family: inherit;">You will get <b>GEDIT </b>window.</span><br /><span style="font-family: inherit;">Now search for&nbsp;<span style="background-color: lime;">### BEGIN /etc/grub.d/10_linux ###</span><span style="background-color: white;"><b>.</b></span></span><br /><span style="background-color: white; font-family: inherit;">After that line you will see the items of your <b>GRUB</b>.</span><br /><span style="font-family: inherit;">So if we want to remove&nbsp;<span style="background-color: lime;">Ubuntu, with Linux 2.6.32-30-generic</span><span style="background-color: white;">&nbsp;from <b>GRUB,&nbsp;</b>Remove the red highlited line in the image.</span></span> </p> <div class="separator" style="clear: both; text-align: center;"> <a href="https://2.bp.blogspot.com/-HJqIM2Gvlyw/UEQ1J6bIjjI/AAAAAAAABuo/6Ja_h0IJnnk/s1600/highlited.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><span style="font-family: inherit;"><img border="0" height="279" src="https://2.bp.blogspot.com/-HJqIM2Gvlyw/UEQ1J6bIjjI/AAAAAAAABuo/6Ja_h0IJnnk/s640/highlited.png" width="640" /></span></a> </div> <p> <span style="background-color: white; font-family: inherit;">You will now get the idea of removing items from <b>GRUB.</b></span><br /><span style="background-color: white; font-family: inherit;">Do as you like <b>but be careful not to remove other lines</b>.</span></div> How to Repair/Restore/Reinstall GRUB Using Ubuntu Live CD https://subinsb.com/how-to-repairrestorereinstall-grub-2-using-a-ubuntu-live-cd/ Sun, 02 Sep 2012 13:15:00 +0000 https://subinsb.com/how-to-repairrestorereinstall-grub-2-using-a-ubuntu-live-cd/ <p>GRUB is the default bootloader of Linux. It is installed on your Hard Disk, but it's not accessible as a drive. GRUB is installed on your Hard Disk when you install a Linux Operating System.</p> <p>Without GRUB, you can't boot in to OSs. Windows, Mac and other OS have their own bootloader. Linux too have different bootloaders. GRUB, BURG are examples.</p> <p>When you install Windows after you install Ubuntu, Windows replaces the GRUB in the Hard Disk to Windows' boot loader which won't identify Linux systems (Damn you Windows !). But, our GRUB detects every OS. So, it's better to have GRUB over Windows Boot Loader.</p> <p>You have to re install GRUB after the following scenarios :</p> <ul> <li>Changed Partitions of Hard Disk</li> <li>Installed Windows after Ubuntu</li> </ul> <p>GRUB comes with every Linux Distros. So, all you have to do is install GRUB from those distros. Luckily, Ubuntu can be booted from the Install Disk itself. Therefore you can install GRUB from the Lice CD.</p> <h2 id="boot-from-live-cd">Boot From Live CD</h2> <p>Insert the CD or Pendrive that has Ubuntu in to your computer.<img class="alignright" src="//3.bp.blogspot.com/-omlah7Nh8Ys/Ub1enzdv8eI/AAAAAAAACu8/GQ6KhdJiOvk/s320/0013.jpg" alt="" width="320" height="230" border="0" /></p> <p>Restart your computer and press <strong>F12</strong>ย repeatedly until the <strong>BIOS Boot Menu</strong>ย appears.ย You can see 2 or 3 itemsย in the menu.</p> <p>If you inserted a Ubuntuย CD then Select CD-ROM or others accordingly.</p> <p>Note : Boot menu might change according to the <strong>BIOS</strong> version.</p> <p>After selecting you will enter in to the Ubuntu Installation Process.</p> <p>After some time, Ubuntu Installation Window appears.</p> <p>Select Run Ubuntu / Try Ubuntu from the options. You will now boot in to Ubuntu.</p> <p>For more information about booting into Ubuntu from CD, see the official Ubuntu Community Pageย : <a href="https://help.ubuntu.com/community/BootFromCD">Boot From CD</a></p> <h2 id="re-install-grub">Re Install GRUB</h2> <p>When you reach the Ubuntu Desktop, open the Terminal using <code>CTRL + ALT + T</code> key combination or by the Dash menu or on Old systems by <code>Applications -&gt; Accessories -&gt; Terminal</code>.</p> <p>Mount the partition where your Ubuntu is installed. If you are not sure which it is, launch <code>gparted</code> (included in the Live CD) and find out. You can open gparted from the Terminal with the command :</p> <div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>gparted </span></span></code></pre></div><p>Linux distros use <strong>ext4</strong> partition. Locate your installed Ubuntu partition (drive) from <code>gparted</code> and note the partition (drive) letter and number (example: <code>sda5</code>).</p> <p>Now, mount the installed Ubuntu Drive. Replace <code>XY</code> with the drive letter, and partition number. Example: <code>sudo mountย /dev/sda5ย /mnt</code></p> <div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>sudo mountย /dev/sdXYย /mnt </span></span></code></pre></div><p>Then bind the directories weย need. Copy the whole command (it's separate commands wrapped into one) below and run it :</p> <div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>sudo mount --bind /dev /mnt/dev <span style="color:#f92672">&amp;&amp;</span> <span style="color:#ae81ff">\ </span></span></span><span style="display:flex;"><span><span style="color:#ae81ff"></span>sudo mount --bind /dev/pts /mnt/dev/pts <span style="color:#f92672">&amp;&amp;</span> <span style="color:#ae81ff">\ </span></span></span><span style="display:flex;"><span><span style="color:#ae81ff"></span>sudo mount --bind /proc /mnt/proc <span style="color:#f92672">&amp;&amp;</span> <span style="color:#ae81ff">\ </span></span></span><span style="display:flex;"><span><span style="color:#ae81ff"></span>sudo mount --bind /sys /mnt/sys </span></span></code></pre></div><p>If your system uses UEFI for booting, you may need to do additional steps as <a href="https://askubuntu.com/a/831241/87199">mentioned here</a>.</p> <p>Then we need to be the super use of the installed Ubuntu. For that use <strong>chroot</strong>.</p> <div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>sudo chroot /mnt </span></span></code></pre></div><p>Now install, check, and update grub. Replace <code>X</code>ย in the following command with only the drive letter (usually <strong>a</strong>). Example: <code>grub-installย /dev/sda</code></p> <div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>grub-installย /dev/sdX <span style="color:#f92672">&amp;&amp;</span> grub-install --recheckย /dev/sdX <span style="color:#f92672">&amp;&amp;</span> update-grub </span></span></code></pre></div><p>GRUB is now installed in the MBR (Master Boot Recorder).</p> <p>Now you can exit you mounted hard disk, and unmount everything we mounted</p> <div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>exit <span style="color:#f92672">&amp;&amp;</span> sudo umount /mnt/dev <span style="color:#f92672">&amp;&amp;</span> sudo umount /mnt/proc <span style="color:#f92672">&amp;&amp;</span> sudo umount /mnt </span></span></code></pre></div><p>Restartย your computer and you will get the default GRUB Boot Screen.</p> <h2 id="cant-see-windows">Can't See Windows</h2> <p>When you reboot after installing GRUB, you night not see Windows. To fix this do as below.</p> <p>Boot in to the installedย <b>Ubuntu</b>ย (not live CD) andย open Terminal.ย Then doย the following command :</p> <div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>sudo update-grub </span></span></code></pre></div><p>It will ask for your password. Type it and press enter. Reboot your computer and you will see Windows now.</p> <p>If you have any problems, comment on this post. I will help you.</p> How to Stop your Blogger Blog from Redirecting to Country Domains https://subinsb.com/how-to-stop-your-blogger-blog-from-redirecting-to-country-domains/ Thu, 30 Aug 2012 05:14:00 +0000 https://subinsb.com/how-to-stop-your-blogger-blog-from-redirecting-to-country-domains/ <div dir="ltr" style="text-align: left;" trbidi="on"> When you open your blog you will be redirected to the country based domain of your blog.<br />This will affect your blog badly. For Example:</p> <ol style="background-color: white; color: #222222; line-height: 19px; margin: 1em 0px 1.4em 24px; padding: 0px; text-align: -webkit-auto;"> <li style="margin: 0px 0px 0.5em; padding: 0px;"> <span style="font-family: inherit;">The social stats โ€“ or Facebook Likes, Google +1s and Tweet counts โ€“ for your blog stories may be diluted as the URLs for the same story become different from different visitors.</span> </li> <li style="margin: 0px 0px 0.5em; padding: 0px;"> <span style="font-family: inherit;">You will have a similar problem if you are using an external commenting platform like Disqus or Facebook Comments.</span> </li> </ol> <p> To prevent this you need to add this code to your <b>Template</b>.<br />Go to <b>Blogger -> Template -> EDIT HTML</b> </p> <p> Paste this code below <b><head> </b>tag </p> <blockquote class="tr_bq"> <p> <span style="background-color: white;"><script type="text/javascript"></span><span style="background-color: white;">var blog = document.location.hostname;</span><span style="background-color: white;">var slug = document.location.pathname;</span><span style="background-color: white;">var ctld = blog.substr(blog.lastIndexOf("."));</span><span style="background-color: white;">if (ctld != ".com") {</span><span style="background-color: white;">var ncr = "http://" + blog.substr(0, blog.indexOf("."));</span><span style="background-color: white;">ncr += ".blogspot.com/ncr" + slug;</span><span style="background-color: white;">window.location.replace(ncr);</span><span style="background-color: white;">}</span><span style="background-color: white;"></script></span> </p> </blockquote> <p> </div> How to make a transparent background/selection on an image using GIMP https://subinsb.com/how-to-make-a-transparent-backgroundselection-on-an-image-using-gimp/ Wed, 29 Aug 2012 13:10:00 +0000 https://subinsb.com/how-to-make-a-transparent-backgroundselection-on-an-image-using-gimp/ <div dir="ltr" style="text-align: left;" trbidi="on"> <div style="text-align: left;"> <span style="font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; text-align: -webkit-auto;">Open your image in <b>GIMP</b>.</span><br /><span style="font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; text-align: -webkit-auto;"><br /></span> </div> <div style="text-align: left;"> <span style="font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; text-align: -webkit-auto;">Select the area you want to make transparent.</span><span style="font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; text-align: -webkit-auto;">Select the appropriate selection tool from the Tool window or the <b>Tools &#8211; Selection Tools</b> menu on the <b>Layer window</b>.&nbsp;</span> </div> <div style="text-align: left;"> <span style="font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; text-align: -webkit-auto;">I usually use the magic wand/fuzzy select&nbsp;(Select contiguous region) tool or the Select regions by color tool.</span><br /><span style="font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; text-align: -webkit-auto;"><br /></span> </div> <div style="text-align: left;"> <span style="font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; text-align: -webkit-auto;">Click in the region you want selected.&nbsp; Use shift-click to add more regions/colors.</span> </div> <div style="text-align: left;"> <span style="font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;">Tip: It&#8217;s easier if you zoom in (View &#8211; Zoom menu) to see finer details of&nbsp;exactly what you&#8217;re selecting.</span><span style="font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; text-align: -webkit-auto;"><br /></span><span style="font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; text-align: -webkit-auto;"><br /></span> </div> <div style="text-align: left;"> <span style="font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; text-align: -webkit-auto;">In the Layer window (the one showing your image), select <b>Layer &#8211; Transparency &#8211; Add Alpha Channel</b>.&nbsp; If this is blanked out then it&#8217;s already done.&nbsp; This makes sure your image can store transparency data.</span><br /><span style="font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; text-align: -webkit-auto;">Select Edit &#8211; Clear.&nbsp; This makes the selection transparent.</span><br /><span style="font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; text-align: -webkit-auto;">Save the file.&nbsp;</span><span style="font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; text-align: -webkit-auto;">&nbsp;</span> </div> <div style="text-align: left;"> <span style="font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; text-align: -webkit-auto;"><br /></span> </div> <div style="text-align: left;"> <span style="font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; text-align: -webkit-auto;"><b>Note</b>: If you save it as a <b>PNG</b> file, be sure to select the &#8216;Save colour values from transparent pixels&#8217; option in the Save as <b>PNG</b> dialog box.</span> </div> </div> The Subins Project https://subinsb.com/the-subins-project/ Tue, 28 Aug 2012 13:39:00 +0000 https://subinsb.com/the-subins-project/ <p><a href="//3.bp.blogspot.com/-vuJXWoYeoGg/UDzDGoSOBjI/AAAAAAAABms/ASp6Tk9Douo/s1600/fdprofile.png"><img src="//3.bp.blogspot.com/-vuJXWoYeoGg/UDzDGoSOBjI/AAAAAAAABms/ASp6Tk9Douo/s640/fdprofile.png" alt=""></a></p> <p><a href="//4.bp.blogspot.com/-JGKtvKf9PsA/UDzDLZZKeoI/AAAAAAAABm0/MZLZ8b0OAy0/s1600/fdshot.png"><img src="//4.bp.blogspot.com/-JGKtvKf9PsA/UDzDLZZKeoI/AAAAAAAABm0/MZLZ8b0OAy0/s320/fdshot.png" alt=""></a></p> <p><a href="//4.bp.blogspot.com/-LDRKhSWaSMg/UDzDOR0T9hI/AAAAAAAABm8/atvhscZy7mw/s1600/services.png"><img src="//4.bp.blogspot.com/-LDRKhSWaSMg/UDzDOR0T9hI/AAAAAAAABm8/atvhscZy7mw/s320/services.png" alt=""></a></p> <p><a href="//1.bp.blogspot.com/-1R1rdS85QH8/UDzDQZO4iYI/AAAAAAAABnE/INQT_W0nGSo/s1600/subins.png"><img src="//1.bp.blogspot.com/-1R1rdS85QH8/UDzDQZO4iYI/AAAAAAAABnE/INQT_W0nGSo/s640/subins.png" alt=""></a></p> <p><a href="//3.bp.blogspot.com/-DR0tGvRYJpU/UDzDSoN2iXI/AAAAAAAABnM/zFptiZkQeRs/s1600/subinschat.png"><img src="//3.bp.blogspot.com/-DR0tGvRYJpU/UDzDSoN2iXI/AAAAAAAABnM/zFptiZkQeRs/s640/subinschat.png" alt=""></a></p> <p><a href="//1.bp.blogspot.com/-LdRhDkB_Tq8/UDzDg8LDj1I/AAAAAAAABnU/Jow91iXVtQA/s1600/subinsgames.png"><img src="//1.bp.blogspot.com/-LdRhDkB_Tq8/UDzDg8LDj1I/AAAAAAAABnU/Jow91iXVtQA/s640/subinsgames.png" alt=""></a></p> <p><a href="//1.bp.blogspot.com/-UE5OBbcpHuQ/UDzDixTKFmI/AAAAAAAABnc/44-E2Jyk9WA/s1600/subinsinstant.png"><img src="//1.bp.blogspot.com/-UE5OBbcpHuQ/UDzDixTKFmI/AAAAAAAABnc/44-E2Jyk9WA/s640/subinsinstant.png" alt=""></a></p> <p><a href="https://2.bp.blogspot.com/-LvaRQXqhiec/UDzDlSZWV2I/AAAAAAAABnk/LFhIAPjDaJg/s1600/subinslogin.png"><img src="https://2.bp.blogspot.com/-LvaRQXqhiec/UDzDlSZWV2I/AAAAAAAABnk/LFhIAPjDaJg/s640/subinslogin.png" alt=""></a></p> <p><a href="https://2.bp.blogspot.com/-sssTchInS_A/UDzDmzS6jZI/AAAAAAAABns/fTdhggSM3_0/s1600/subinslogo.png"><img src="https://2.bp.blogspot.com/-sssTchInS_A/UDzDmzS6jZI/AAAAAAAABns/fTdhggSM3_0/s320/subinslogo.png" alt=""></a></p> <p><a href="//4.bp.blogspot.com/-t-jGh6de-rE/UDzD0zyrUEI/AAAAAAAABn0/b3_VPQlzgcg/s1600/subinsmusic.png"><img src="//4.bp.blogspot.com/-t-jGh6de-rE/UDzD0zyrUEI/AAAAAAAABn0/b3_VPQlzgcg/s640/subinsmusic.png" alt=""></a></p> <p><a href="//4.bp.blogspot.com/-Nz6OFNfSFRs/UDzD4hd4qII/AAAAAAAABn8/C0u2Ssq6r7Y/s1600/subinsquiz.png"><img src="//4.bp.blogspot.com/-Nz6OFNfSFRs/UDzD4hd4qII/AAAAAAAABn8/C0u2Ssq6r7Y/s640/subinsquiz.png" alt=""></a></p> <p><a href="https://2.bp.blogspot.com/-OReAontMxLA/UDzD7-rnyAI/AAAAAAAABoE/-RqvIOqocEs/s1600/subinssignup.png"><img src="https://2.bp.blogspot.com/-OReAontMxLA/UDzD7-rnyAI/AAAAAAAABoE/-RqvIOqocEs/s640/subinssignup.png" alt=""></a></p> <p><a href="//3.bp.blogspot.com/-6AYCRjsvwxQ/UDzEDl9xFlI/AAAAAAAABoM/mflmbK6l1ck/s1600/subinswdusource.png"><img src="//3.bp.blogspot.com/-6AYCRjsvwxQ/UDzEDl9xFlI/AAAAAAAABoM/mflmbK6l1ck/s640/subinswdusource.png" alt=""></a></p> <p><a href="//4.bp.blogspot.com/-w6zeCCz_8DI/UDzEFqhvjTI/AAAAAAAABoU/RbepyIeEPJk/s1600/sugeshot.png"><img src="//4.bp.blogspot.com/-w6zeCCz_8DI/UDzEFqhvjTI/AAAAAAAABoU/RbepyIeEPJk/s320/sugeshot.png" alt=""></a></p> <h2 id="update---2019">UPDATE - 2019</h2> <p>There are <a href="https://subinsb.com/tags/subins/">some posts on Subins</a>. But, I never wrote detailed about &quot;The Subins Project&quot;. I don't know why. So I'm writing this for archival purposes.</p> <p>I lost the source code of &quot;The Subins Project&quot; because I accidentally formatted by whole drive back in 2013 during an installation of Windows XP (their installer is very bad !).</p> <p>I named it &quot;Subins&quot; seeing how Linux was named from its creator Linus. It had a</p> <ul> <li>Search engine</li> <li>Chat site (Google hangouts like)</li> <li>Social network site called <strong>Friendshood</strong> (like Facebook)</li> <li>Games site (like Chrome web store)</li> <li>Videos site (YouTube)</li> <li>Wiki site (like wikipedia)</li> <li>URL Shortener. <a href="https://github.com/subins2000/shorturl">This was my first repo in GitHub</a>, but it's not the exact site</li> <li>and some more (I don't remember)</li> </ul> <p>I didn't know GitHub back then, else would have published the source code.</p> <h3 id="tech">Tech</h3> <p>It was created entirely with <strong>PHP</strong> and had design/style inspired (and copied ?) from Google, Facebook and elsewhere. I learnt web development with this project :</p> <blockquote> <p>Starting from a google search of <code>&quot;How to create a website&quot;</code> to <code>&quot;How to host on AppFog&quot;</code>.</p> <p>I spent countless hours working on it. I think I started this in <strong>2011 November</strong> or something and it got hosted in <strong>2012 December</strong>.</p> <p>I was in <strong>7th &amp; 8th grade</strong> during the time.</p> </blockquote> <p>The project was hosted online with help of [AppFog.com] (a PaaS provider) in 2012. They gave free hosting back then. <a href="//subinsb.com/subins-project-online-thanks-to-app-fog/">I wrote a blog post on it here</a>.</p> <h4 id="the-code-was-a-disaster">The code was a disaster</h4> <ul> <li>I used <strong>mysql_query()</strong> for everything. The whole site was vulnerable to MySQL Injection and probably lots of other vulnerabilities. <ul> <li>One of my friend did point this to me and I took down the site cause all the user details was easily accessible.</li> </ul> </li> <li>The code had bad indentation and coding standards. I kinda remember it. It was very ugly. YUCK !</li> <li>Passwords weren't hashed. DISASTER ๐Ÿ’ฏ</li> </ul> <h3 id="whats-left">What's Left</h3> <p>All that's left of &quot;The Subins Project&quot; are these screenshots and the archived webpages on archive.org :</p> <ul> <li>Search Engine - subins.hp.af.cm - <a href="https://web.archive.org/web/20130101000000">https://web.archive.org/web/20130101000000</a>*/http://subins.hp.af.cm:80/</li> <li>Accounts Management Site - accounts-subins.hp.af.cm - <a href="https://web.archive.org/web/">https://web.archive.org/web/</a>*/http://accounts-subins.hp.af.cm:80</li> <li>Subins Chat - chat-subins.hp.af.cm - <a href="https://web.archive.org/web/">https://web.archive.org/web/</a>*/http://chat-subins.hp.af.cm:80</li> <li>Subins Get - get-subins.hp.af.cm - <a href="https://web.archive.org/web/">https://web.archive.org/web/</a>*/http://get-subins.hp.af.cm:80</li> <li>Friendshood - fd-subins.hp.af.cm - <a href="https://web.archive.org/web/">https://web.archive.org/web/</a>*/http://fd-subins.hp.af.cm:80</li> <li>Subins Apps - apps-subins.hp.af.cm - <a href="https://web.archive.org/web/">https://web.archive.org/web/</a>*/http://apps-subins.hp.af.cm:80</li> </ul> <h3 id="aftermath">Aftermath</h3> <ul> <li>I went on to create a better social network with <a href="https://subinsb.com/open-an-open-source-social-network-is-released/">Open</a></li> <li><a href="https://subinsb.com/search-engine-in-php-part-1/">I created a better search engine with a custom crawler</a></li> <li>I became a much better programmer !</li> </ul> <p>And looking back now :</p> <blockquote> <p>Although it was a disaster, I learnt a LOT !</p> <p>That's what matters at the end :)</p> </blockquote> Upload more than 1 MB file in PHP. https://subinsb.com/upload-more-than-1-mb-file-in-php/ Mon, 27 Aug 2012 06:43:00 +0000 https://subinsb.com/upload-more-than-1-mb-file-in-php/ <div dir="ltr" style="text-align: left;" trbidi="on"> Some may have problem with uploading file more than 1 MB or 2 MB. You can fix this by editing the configuration file of PHP. To fix this follow the steps.</p> <p> Open <b>Root Terminal </b>(Applications -> System Tools -> Root Terminal).<br />Type<b>&nbsp;</b> </p> <blockquote class="tr_bq"> <p> <b>sudo gedit /etc/php5/apache2/php.ini&nbsp;</b> </p> </blockquote> <p> and press enter key.<br />You will get gedit application with the <b>php.in </b>file. </p> <p> <span style="font-family: Arial, Helvetica, sans-serif;">Search for the words&nbsp;<span style="background-color: white; line-height: 22px; white-space: pre-wrap;"><b>post_max_size </b>&&nbsp;</span><span style="line-height: 22px; white-space: pre-wrap;"><b>upload_max_filesize</b></span><span style="background-color: white; line-height: 22px; white-space: pre-wrap;">.</span></span><br /><span style="font-family: Arial, Helvetica, sans-serif;"><span style="line-height: 22px; white-space: pre-wrap;">If you found the words you will see a <b>= </b>after the word </span><b style="line-height: 22px; white-space: pre-wrap;">post_max_size </b><span style="line-height: 22px; white-space: pre-wrap;">&&nbsp;</span><span style="line-height: 22px; white-space: pre-wrap;"><b>upload_max_filesize</b></span><span style="line-height: 22px; white-space: pre-wrap;">.</span></span><br /><span style="line-height: 22px; white-space: pre-wrap;"><span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></span><span style="line-height: 22px; white-space: pre-wrap;"><span style="font-family: Arial, Helvetica, sans-serif;"><b>Change the number as you want</b> (Default will be <b>1M </b>or <b>2M</b>).</span></span><br /><span style="line-height: 22px; white-space: pre-wrap;"><span style="font-family: Arial, Helvetica, sans-serif;">After editing save the file and restart <b>Apache Web Server </b>by opening <b>Root Terminal </b>and pasting this code</span></span> </p> <blockquote class="tr_bq"> <p> <span style="font-family: Consolas, Monaco, Courier New, Courier, monospace;"><span style="font-size: 14px; line-height: 22px; white-space: pre-wrap;">sudo /etc/init.d/apache2 reload</span></span> </p> </blockquote> <p> and press enter.<br />That&#8217;s it. Upload a file in PHP and see the magic !</div> How to create a Localhost site on Apache Server in Ubuntu Linux โ€“ Video Tutorial https://subinsb.com/how-to-create-a-localhost-site-on-apache-server-in-ubuntu-linux-video-tutorial/ Sun, 26 Aug 2012 02:31:00 +0000 https://subinsb.com/how-to-create-a-localhost-site-on-apache-server-in-ubuntu-linux-video-tutorial/ Contribute : Guest Posts https://subinsb.com/contribute-for-my-blog/ Sat, 25 Aug 2012 14:27:00 +0000 https://subinsb.com/contribute-for-my-blog/ <p>If you are a guest post writer and want to write a post for this blog, send your post to <a href="mailto:[email protected]">[email protected]</a>. If your post is great / suits to the guidelines of this blog, I will approve it and publishes it under your name.</p> <p>If you have feedbacks / suggestions please contact the administrator of this blog via <a href="mailto:[email protected]">[email protected]</a></p> Microsoftโ€™s New Logo https://subinsb.com/microsofts-new-logo/ Sat, 25 Aug 2012 14:17:00 +0000 https://subinsb.com/microsofts-new-logo/ <div dir="ltr" style="text-align: left;" trbidi="on"> Microsoft got a new Logo after 25 years. Here is the new logo.</p> <div class="separator" style="clear: both; text-align: center;"> <a href="//4.bp.blogspot.com/-UvYcV70J5YI/UDjdDjpGrKI/AAAAAAAABgQ/Ea5LC6IbcAk/s1600/mslogo_new.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="//4.bp.blogspot.com/-UvYcV70J5YI/UDjdDjpGrKI/AAAAAAAABgQ/Ea5LC6IbcAk/s1600/mslogo_new.jpg" /></a> </div> <div class="separator" style="clear: both; text-align: left;"> <span style="background-color: white; color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 21px;">This&nbsp;</span><b style="background-color: white; color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 21px;">Microsoft New logo&nbsp;</b><span style="background-color: white; color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 21px;">contains the four sqaure and the name of the company. Logo designer Sagi Haviv for the Library of Congress and Armani Exchange, thinks that the logo simply isnโ€™t distinctive enough. By opting for a simple array of four colored squares, Haviv says Microsoft missed a big opportunity.</span><span style="background-color: white; color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 21px;">It kinda looks like Google&#8217;s Logo.</span> </div> <div class="separator" style="clear: both; text-align: left;"> <span style="background-color: white; color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 21px;">Here&#8217;s a image I found in <b>Google +.</b></span> </div> <div class="separator" style="clear: both; text-align: center;"> <a href="//3.bp.blogspot.com/-y0cM4FC2Uds/UDjdvGw99LI/AAAAAAAABgY/CCdW98X2Uxg/s1600/f_00cd0b" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="//3.bp.blogspot.com/-y0cM4FC2Uds/UDjdvGw99LI/AAAAAAAABgY/CCdW98X2Uxg/s1600/f_00cd0b" /></a> </div> <div class="separator" style="clear: both; text-align: left;"> The image is right. It looks like the Nazi Symbol. But it&#8217;s a good logo. </div> <div class="separator" style="clear: both; text-align: left;"> Hoping Windows 8 would be good. </div> </div> Refresh a Div container in equal intervals of time https://subinsb.com/refresh-a-div-container-in-equal-intervals-of-time/ Fri, 17 Aug 2012 08:14:00 +0000 https://subinsb.com/refresh-a-div-container-in-equal-intervals-of-time/ <div dir="ltr" style="text-align: left;"> Hi this tutorial will help you to refresh a div every 10 seconds. You can change the seconds if you want. For this we are going to use <b>Jquery</b>.</p> <div> </div> <div> <b>The html of the div containerย </b> </div> <blockquote class="tr_bq"> <p> <div id=&#8217;refreshdiv&#8217;></div> </p> </blockquote> <p> <b>jQuery Code</b> </p> <pre class="prettyprint"><code>&lt;script src="http://code.jquery.com/jquery-latest.js"&gt;&lt;/script&gt; &lt;script&gt;setInterval(function() {$('#refreshdiv').load('divcontainer.html')}, 10000);&lt;/script&gt;</code></pre> <p> <b>divcontainer.htmlย </b> </p> <blockquote class="tr_bq"> <p> This is loading in the div #refreshdiv. </p> </blockquote> <p> This example will load <b>divcontainer.html</b> in the div <b>#refreshdiv </b>and refresh the div after 10 seconds.<br /> If you want to change the file to load replace <b>divcontainer.html </b>in the jquery codeย to the file name you want to use.<br /> If you want to change the number of seconds, replace <b>10000</b>ย with the number to refresh(Must be in milliseconds).<br /> If you want help comment on this post. </p> </div> Insert XML Data to MySQL Table Using PHP https://subinsb.com/insert-xml-file-contents-to-mysql-database-table-using-php/ Wed, 08 Aug 2012 16:46:00 +0000 https://subinsb.com/insert-xml-file-contents-to-mysql-database-table-using-php/ <div dir="ltr" style="text-align: left;"> <span style="font-family: inherit;">This tutorial will help you to insert XML file&#8217;s contents to a MySQL Database table using php.ย </span><span style="font-family: inherit;">Note- If you can&#8217;t open PHP files in browser in Ubuntu Linux See the Tutorial :ย <a href="//subinsb.com/how-to-open-php-files-in-ubuntu-instead-of-downloading">http://subinsb.com/how-to-open-php-files-in-ubuntu-instead-of-downloading</a></span><b></b></p> <div> <span style="font-family: inherit;">This is the XML data we are going to insert in to our MySQL Table.</span></p> <pre><code>&lt;pre class=&quot;prettyprint&quot;&gt;&lt;code&gt;&amp;lt;span style=&quot;font-family: inherit;&quot;&gt;&amp;lt;items&amp;gt;&amp;lt;/span&gt; </code></pre> <p>&lt;span style=&quot;font-family: inherit;&quot;&gt;ย &lt;item&gt;&lt;/span&gt; &lt;span style=&quot;font-family: inherit;&quot;&gt;ย  &lt;title&gt;Google&lt;/title&gt;&lt;/span&gt; &lt;span style=&quot;font-family: inherit;&quot;&gt;ย  &lt;url&gt;google.com&lt;/url&gt;&lt;/span&gt; &lt;span style=&quot;font-family: inherit;&quot;&gt;ย &lt;/item&gt;&lt;/span&gt; &lt;span style=&quot;font-family: inherit;&quot;&gt;ย &lt;item&gt;&lt;/span&gt; &lt;span style=&quot;font-family: inherit;&quot;&gt;ย  &lt;title&gt;Google Accounts&lt;/title&gt;&lt;/span&gt; &lt;span style=&quot;font-family: inherit;&quot;&gt;ย  &lt;url&gt;accounts.google.com&lt;/url&gt;&lt;/span&gt; &lt;span style=&quot;font-family: inherit;&quot;&gt;ย &lt;/item&gt;&lt;/span&gt; &lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;/items&gt;ย &lt;/span&gt;</code></pre></p> </div> </div> <div> <span style="font-family: inherit;">The name of the XML fileย is "items.xml ".</span> </div> <h2 id="mysql-database-table-creation">MySQL Database Table Creation</h2> <div> <span style="font-family: inherit;">This is the SQL code to create a table namedย "items" in which we will add the XML data to.</span></p> <pre class="prettyprint"><code>&lt;span style="line-height: 16px; text-align: -webkit-auto;">CREATE TABLEย &lt;/span>&lt;b style="border: 0px none; color: blue; line-height: 16px; margin: 0px; outline: 0px; padding: 0px; text-align: -webkit-auto;">items&lt;/b>&lt;span style="line-height: 16px; text-align: -webkit-auto;">(&lt;/span>&lt;span style="border: 0px none; color: #cc0000; line-height: 16px; margin: 0px; outline: 0px; padding: 0px; text-align: -webkit-auto;">id&lt;/span>&lt;span style="line-height: 16px; text-align: -webkit-auto;">ย INTย &lt;/span>&lt;span style="border: 0px none; color: blue; line-height: 16px; margin: 0px; outline: 0px; padding: 0px; text-align: -webkit-auto;">PRIMARY KEY&lt;/span>&lt;span style="line-height: 16px; text-align: -webkit-auto;">ย &lt;/span>&lt;span style="border: 0px none; color: #a64d79; line-height: 16px; margin: 0px; outline: 0px; padding: 0px; text-align: -webkit-auto;">AUTO_INCREMENT&lt;/span>&lt;span style="line-height: 16px; text-align: -webkit-auto;">, &lt;/span>&lt;span style="line-height: 16px; text-align: -webkit-auto;">&lt;span style="color: #cc0000;">title&lt;/span>ย TEXT, &lt;/span>&lt;span style="border: 0px none; color: #cc0000; line-height: 16px; margin: 0px; outline: 0px; padding: 0px; text-align: -webkit-auto;">url&lt;/span>&lt;span style="line-height: 16px; text-align: -webkit-auto;">ย TEXT&lt;/span>&lt;span style="line-height: 16px; text-align: -webkit-auto;">);&lt;/span></code></pre> <p> <span style="font-family: inherit;">Create a PHP file named "add.php"ย in the same directory where the XML fileย is.</span> <span style="font-family: inherit;">Open the <strong>add.php</strong> file<b>ย </b>in text editor and add the following code into it :</span> </p> <pre class="prettyprint"><code>$xmlDoc = new DOMDocument(); $xmlDoc-&gt;load("items.xml"); $mysql_hostname = "hostname"; // Example : localhost $mysql_user = "username"; $mysql_password = "password"; $mysql_database = "database_name"; $bd = mysql_connect($mysql_hostname, $mysql_user, $mysql_password)ย or die("Oops some thing went wrong"); mysql_select_db($mysql_database, $bd) or die("Oops some thing went wrong"); $xmlObject = $xmlDoc-&gt;getElementsByTagName('item'); $itemCount = $xmlObject-&gt;length; for ($i=0; $i &lt; $itemCount; $i++){ ย  $title = $xmlObject-&gt;item($i)-&gt;getElementsByTagName('title')-&gt;item(0)-&gt;childNodes-&gt;item(0)-&gt;nodeValue; ย  $link = $xmlObject-&gt;item($i)-&gt;getElementsByTagName('url')-&gt;item(0)-&gt;childNodes-&gt;item(0)-&gt;nodeValue; ย  $sql = "INSERT INTO `my_table_name` (title, url) VALUES ('$title', '$link')"; ย  mysql_query($sql); print "Finished Item $title n&lt;br/&gt;"; }</code></pre> <p> We&#8217;re using the depreciatedย <strong>mysql_*</strong> functions in the above code, but for a simple task like this, it can be used. If you really want the latest technology, use <strong>PDO</strong> and the code will be something like this : </p> <pre class="prettyprint"><code>$xmlDoc = new DOMDocument(); $xmlDoc-&gt;load("items.xml"); $mysql_hostname = "hostname"; // Example : localhost $mysql_user = "username"; $mysql_password = "password"; $mysql_database = "database_name"; $dbh = new PDO("mysql:dbname={$mysql_database};host={$mysql_hostname};port=3306", $mysql_user, $mysql_password); $xmlObject = $xmlDoc-&gt;getElementsByTagName('item'); $itemCount = $xmlObject-&gt;length; for ($i=0; $i &lt; $itemCount; $i++){ $title = $xmlObject-&gt;item($i)-&gt;getElementsByTagName('title')-&gt;item(0)-&gt;childNodes-&gt;item(0)-&gt;nodeValue; $link = $xmlObject-&gt;item($i)-&gt;getElementsByTagName('url')-&gt;item(0)-&gt;childNodes-&gt;item(0)-&gt;nodeValue; $sql = $dbh-&gt;prepare("INSERT INTO `my_table_name` (`title`, `url`) VALUES (?, ?)"); $sql-&gt;execute(array( $title, $link )); print "Finished Item $title n&lt;br/&gt;"; }</code></pre> <p> As you see, you have to change the variables for connecting to Database. <span style="font-family: inherit;">Open the file "add.php" in your website or in a localhost server Or Execute it via terminal with the command (Linux) :</span> </p> <pre class="prettyprint"><code>php add.php</code></pre> <p> <span style="font-family: inherit;">When it&#8217;s opened it will show a success message ofย every nodes in the items.xml file toย </span><span style="font-family: inherit;">make sure that the XML file contents are added to the MySQL Table.</span> <span style="font-family: inherit;">That&#8217;s it.</span> </p> </div> How to Empty Trash of root user in Ubuntu https://subinsb.com/how-to-empty-trash-of-root-user-in-ubuntu/ Fri, 27 Jul 2012 14:03:00 +0000 https://subinsb.com/how-to-empty-trash-of-root-user-in-ubuntu/ <div dir="ltr" style="text-align: left;"> <div dir="ltr" style="text-align: left;"> Installย <a href="http://apt.ubuntu.com/p/nautilus-gksu">nautilus-gksu</a><br /> <span style="font-size: large;"><b><span style="text-decoration: underline;">About Nautilus-gksu</span></b></span> </div> <p> Privilege granting extension for nautilus using gksu<br /> The gksu extension for nautilus allows you to open files with administration privileges using the context menu when browsing your files with nautilus. </p> <p> <b>Reboot computer after installing nautilus-gksuย </b><br /> Open your home folder.<br /> Right click on any folder and click <b>Open as administrator</b>.<br /> <a style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;" href="//1.bp.blogspot.com/-3hnvIkeW8VM/UAwgzB3SMgI/AAAAAAAABF0/oVtinZPEc78/s1600/lpane.png"><img alt="" src="//1.bp.blogspot.com/-3hnvIkeW8VM/UAwgzB3SMgI/AAAAAAAABF0/oVtinZPEc78/s1600/lpane.png" border="0" /></a>You will enter root user.<br /> On the left pane you will see root home. </p> <p> Go to <b>/root/.local/share/Trash/files</b><br /> Delete the files you don&#8217;t want.<br /> All Done !!<br /> Close the window and your root trash is emptied. </p> <p> &nbsp; </p> </div> Make a short url for Google + Profile https://subinsb.com/make-a-short-url-for-google-profile/ Mon, 16 Jul 2012 15:23:00 +0000 https://subinsb.com/make-a-short-url-for-google-profile/ <div dir="ltr" style="text-align: left;"> <span style="font-family: Arial, sans-serif; font-size: 13px; line-height: 18px; text-align: -webkit-auto;">Do You want to Make a short url for Google + Profileย </span><span style="background-color: white;">like in facebook ?</span> </div> <div class="padlinks"> <a class="demo" href="http://gplus.to/subinsiby ">Demo</a> </div> <p><span style="font-family: Arial, sans-serif; font-size: 13px; line-height: 18px; text-align: -webkit-auto;">eg: Redirect from <a href="http://gplus.to/subinsiby">http://gplus.to/subinsiby</a> toย https://plus.google.com/u/0/100940821362767953768/</span></p> <p><span style="font-family: Arial, sans-serif; font-size: 13px; line-height: 18px; text-align: -webkit-auto;">You can do this using <a href="http://gplus.to/">Google Plus Nick</a>ย </span></p> <p><span style="font-family: Arial, sans-serif; font-size: 13px; line-height: 18px; text-align: -webkit-auto;">Go to <a href="http://gplus.to/">Google Plus Nick</a>ย and follow the instructions</span></p> Custom Cursor CSS https://subinsb.com/custom-cursor-css/ Sat, 14 Jul 2012 08:50:00 +0000 https://subinsb.com/custom-cursor-css/ <div dir="ltr" style="text-align: left;" trbidi="on"> This css code will help you to add custom cursor image.</p> <p> <b><span style="font-size: large;"><a href="http://g2enjoy.blogspot.in/" >SEE DEMO</a></span></b><br /><b><br /></b>Copy this css code to your html page. </p> <blockquote class="tr_bq"> <p> <b><style></b><span style="background-color: white;"><b>body {</b></span><span style="background-color: white;"><b>cursor: url(https://lh5.googleusercontent.com/-u1rSVKP3Vpc/UAEqLZnKv0I/AAAAAAAABCQ/3alnkvGlnlQ/s32/cursor.png), url(</b></span><b>https://lh5.googleusercontent.com/-u1rSVKP3Vpc/UAEqLZnKv0I/AAAAAAAABCQ/3alnkvGlnlQ/s32/cursor.png</b><span style="background-color: white;"><b>), auto; }</b></span><span style="background-color: white;"><b></style></b></span> </p> </blockquote> <div style="text-align: center;"> <span style="font-size: large;">OR</span> </div> <div style="text-align: left;"> Copy this to your css file </div> <div style="text-align: left;"> <blockquote class="tr_bq"> <p> <span style="background-color: white;"><b>body {</b></span><span style="background-color: white;"><b>cursor: url(</b></span><b>https://lh5.googleusercontent.com/-u1rSVKP3Vpc/UAEqLZnKv0I/AAAAAAAABCQ/3alnkvGlnlQ/s32/cursor.png</b><span style="background-color: white;"><b>), url(</b></span><b>https://lh5.googleusercontent.com/-u1rSVKP3Vpc/UAEqLZnKv0I/AAAAAAAABCQ/3alnkvGlnlQ/s32/cursor.png</b><span style="background-color: white;"><b>), auto;}</b></span> </p> </blockquote> </div> </div> 10000 Views !!!! https://subinsb.com/10000-views/ Thu, 12 Jul 2012 16:16:00 +0000 https://subinsb.com/10000-views/ <div dir="ltr" style="text-align: left;"> <div class="separator" style="clear: both; text-align: center;"> <a style="margin-left: 1em; margin-right: 1em;" href="//4.bp.blogspot.com/-HgiHVTaVWPw/T_73oZ-uFfI/AAAAAAAABA4/6L9wVux_7zM/s1600/10000.png"><img alt="" src="//4.bp.blogspot.com/-HgiHVTaVWPw/T_73oZ-uFfI/AAAAAAAABA4/6L9wVux_7zM/s1600/10000.png" border="0" /></a> </div> <p> Thanking everybody who helped me to make it @ <b style="font-size: xx-large;">10000ย </b><br /> <b style="font-size: xx-large;"><br /> </b> </p> <div style="text-align: center;"> <span style="font-size: x-large;"><b>Thank You Everyone</b></span> </div> </div> DNS Changer Trogan Virus: Thousands of Computers lose internet connection today https://subinsb.com/dns-changer-trogan-virus-thousands-of-computers-lose-internet-connection-today/ Mon, 09 Jul 2012 13:28:00 +0000 https://subinsb.com/dns-changer-trogan-virus-thousands-of-computers-lose-internet-connection-today/ <div dir="ltr" style="text-align: left;" trbidi="on"> From today on wards about 3 lakh of computers will lose their internet connection. The computers will become offline. This is because of a Trogan Virus named DNS Changer.</p> <p> <span style="font-size: large;"><b>What Does DNSChanger Do to My Computer?</b></span> </p> <p> DNSChanger malware causes a computer to use rogue DNS servers in one of two ways.<br />First, it changes the computerโ€™s DNS server settings to replace the ISPโ€™s good DNS servers<br />with rogue DNS servers operated by the criminal. Second, it attempts to access devices on<br />the victimโ€™s small office/home office (SOHO) network that run a dynamic host configuration<br />protocol (DHCP) server (eg. a router or home gateway). The malware attempts to access<br />these devices using common default usernames and passwords and, if successful, changes<br />the DNS servers these devices use from the ISPโ€™s good DNS servers to rogue DNS servers<br />operated by the criminals. This is a change that may impact all computers on the SOHO<br />network, even if those computers are not infected with the malware. </p> <p> <span style="font-size: large;"><b>Am I Infected?</b></span><br />The best way to know that is by going to the website&nbsp;<span style="background-color: white; text-align: center;"><a href="http://dns-ok.us/" >DNS Changer Check-Up</a></span><br />If it shows <b>Green</b> then you have nothing to worry about. </p> <p> <span style="font-size: large;"><b>What Should I Do?</b></span><br />In addition to directing your computer to utilize rogue DNS servers, the DNSChanger<br />malware may have prevented your computer from obtaining operating system and antimalware updates, both critical to protecting your computer from online threats. This<br />behavior increases the likelihood of your computer being infected by additional malware.<br />The criminals who conspired to infect computers with this malware utilized various methods<br />to spread the infections. At this time, there is no single patch or fix that can be downloaded<br />and installed to remove this malware. Individuals who believe their computer may be<br />infected should consult a computer professional. <br />Individuals who do not have a recent back-up of their important documents, photos, music,<br />and other files should complete a back-up before attempting to clean the malware or utilize<br />the restore procedures that may have been packaged with your computer.<br />Information regarding malicious software removal can be found at the website of the United<br />States Computer Emergency Readiness Team: <a href="https://www.uscert.gov/reading_room/trojan-recovery.pdf" >Recovering from a Trogan</a>. </p> </div> How to add a header image to Blogger Dynamic Views https://subinsb.com/how-to-add-a-header-image-to-blogger-dynamic-views/ Wed, 04 Jul 2012 14:54:00 +0000 https://subinsb.com/how-to-add-a-header-image-to-blogger-dynamic-views/ <p dir="ltr" style="text-align: left;"> You must have seen some blogs like mine and Blogger Buzz which have a header image like this. These header images make the blog attractive. Do you want to add a header image to your blog like this ? Then you are in the right place.ย It is very easy to do this in your blog. You only need to add few codes to your Blogger Template. </p> <div class="separator" style="clear: both; text-align: center;"> <a style="margin-left: 1em; margin-right: 1em;" href="//1.bp.blogspot.com/-t6rqa__OHII/T_RPL32JARI/AAAAAAAAAzk/n3rHRRPiPVg/s1600/buzzheader.png"><img alt="" src="//1.bp.blogspot.com/-t6rqa__OHII/T_RPL32JARI/AAAAAAAAAzk/n3rHRRPiPVg/s1600/buzzheader.png" border="0" /></a> </div> <div class="separator" style="clear: both; text-align: center;"> </div> <div class="separator" style="clear: both; text-align: center;"> </div> <div class="separator" style="clear: both; text-align: center;"> </div> <div class="separator" style="clear: both; text-align: center;"> <a style="margin-left: 1em; margin-right: 1em;" href="//3.bp.blogspot.com/-t2nRjm7y3og/T_RWHAiVjxI/AAAAAAAAA0A/vhESdUXogdw/s1600/header-n.png"><img alt="" src="//3.bp.blogspot.com/-t2nRjm7y3og/T_RWHAiVjxI/AAAAAAAAA0A/vhESdUXogdw/s1600/header-n.png" border="0" /></a> </div> <p><strong>Note</strong>ย :- You must have enabled a Dynamic views Template on your blog to use this feature.</p> <p>Create a banner image of size (resolution)ย **ย 1200 X 65 pixels **and upload into <a href="http://picasaweb.google.com/">Picasa</a> or any other image uploading service. See this <a href="http://sag-3.blogspot.com/2012/10/upload-your-image-to-web-in-just-minute.html">tutorial</a> to see how to upload an image.</p> <p>Go to <strong><a href="http://blogger.com/">Blogger</a> -&gt; Template</strong>.ย Click on **Customiseย **<span>button.</span></p> <p><span style="background-color: white;"><a style="margin-left: 1em; margin-right: 1em; text-align: center;" href="//1.bp.blogspot.com/-6GYDqGYOJpg/T_RXipRKxzI/AAAAAAAAA0M/x3gX4j6Uo5g/s1600/cbutton.png"><img alt="" src="//1.bp.blogspot.com/-6GYDqGYOJpg/T_RXipRKxzI/AAAAAAAAA0M/x3gX4j6Uo5g/s1600/cbutton.png" border="0" /></a></span></p> <p><span style="background-color: white;">You will now enter theย <b>Template Designerย </b>of your blog.ย </span><span style="line-height: 1.5em;">Go to </span><b style="line-height: 1.5em;">Advanced -&gt; Add CSS</b> page.</p> <p>You will see a text box on the right side of the screen as show in the picture below :</p> <img style="border: 0px;" alt="" src="https://2.bp.blogspot.com/-oyEAJ1_w7io/T_RX7jxYgEI/AAAAAAAAA0U/yaAXG6pb3ZY/s1600/tdesigner.png" width="1366" height="287" border="0" /> <p>Type these text (code) in that text box :</p> <pre class="prettyprint"><code>/*Subin's Blog*/.header-bar{background-image:url('&lt;span style="color: red;">YOUR IMAGE URL&lt;/span>') !important;}</code></pre> <div class="separator" style="clear: both;"> An Example of adding the imageย <b>http://goo.gl/Xt1G1</b> as header: </div> <pre class="prettyprint"><code>/*Subin's Blog*/.header-bar{background-image:url('http://goo.gl/Xt1G1') !important;}</code></pre> <p>After doing all this click on &quot;Apply To Blog&quot;<a style="margin-left: 1em; margin-right: 1em; text-align: center;" href="//4.bp.blogspot.com/-wb0_X6ZPA8E/T_RZCJPHl9I/AAAAAAAAA0c/kwEmW3Dbw3E/s1600/ablog.png"><img alt="" src="//4.bp.blogspot.com/-wb0_X6ZPA8E/T_RZCJPHl9I/AAAAAAAAA0c/kwEmW3Dbw3E/s1600/ablog.png" border="0" /></a>ย button.</p> <p>After the changes have been saved, open your blog and your header has a background image now.</p> MAXX MX151 ARC https://subinsb.com/maxx-mx151-arc/ Mon, 02 Jul 2012 14:55:00 +0000 https://subinsb.com/maxx-mx151-arc/ <div dir="ltr" style="text-align: left;" trbidi="on"> I just bought a MAXX MX151. It&#8217;s a good phone. It&#8217;s like other MAXX and Karbonn type mobiles.<br />You can&#8217;t install a app on it.</p> <p> <span style="font-size: large;"><u>Features</u></span><br />Digital Camera<br />1.8&#8243;(4.6cm) TFT Display<br />Bluetooth<br />MP4 Player<br />3.5mm Audio Jack<br />LED Torch<br />Upto 4 GB&nbsp;MMC&nbsp;Support.<br />Maxx Arena<br /><span style="font-size: large;"><br /></span><br />This phone contains good apps. But the only problem is that you can&#8217;t install any new applications. </p> <p> It&#8217;s not a touch phone. But it&#8217;s a good phone at a good price. </p> <p> Even with all the awesome features you can buy this phone @ </p> <p> Rs 1537 </p> <p> $27.7512 </p> <p> It&#8217;s at the lowest price. In my opinion it&#8217;s a good phone. </p> </div> I love my MOM https://subinsb.com/i-love-my-mom/ Sat, 30 Jun 2012 03:00:00 +0000 https://subinsb.com/i-love-my-mom/ <div dir="ltr" style="text-align: left;" trbidi="on"> <div class="separator" style="clear: both; text-align: center;"> </div> <div style="margin-left: 1em; margin-right: 1em;"> <img src="https://lh4.googleusercontent.com/-HAIDhNfpA94/T-49pBHhldI/AAAAAAABppc/1wL4SFEqEtM/w497-h373/2.jpg" /> </div> <p> </div> Canโ€™t Boot Ubuntu after installing Nvidia Driver. https://subinsb.com/cant-boot-ubuntu-after-installing-nvidia-driver/ Fri, 29 Jun 2012 15:24:00 +0000 https://subinsb.com/cant-boot-ubuntu-after-installing-nvidia-driver/ <div dir="ltr" style="text-align: left;" trbidi="on"> <b><span style="color: red;">NOTE &#8211; Go to this <a href="http://sag-3.blogspot.in/2012/09/nvidia-solution-2.html" >post</a>&nbsp;to fix this problem. If that post didn&#8217;t helped you the do the steps in this post.</span></b></p> <p> A lot of people has trouble booting in to Ubuntu after installation of Nvidia Driver.<br />Finally I had found a solution to this problem. </p> <p> On the boot menu Click<br /><b>Ubuntu Recovery Mode</b><br /><b><br /></b>You will see a <b>&nbsp;Blue Screen </b>. On the options scroll down and click on <b>failsafex</b><br />You will now see a small dialog box. Click on <b>OK</b> Button<b>.&nbsp;</b><br />Press OK two or three times more.<br />You will now boot into your Ubuntu OS.<br />Connect to the internet.<br />Open <b>Hardware Drivers </b>and install(activate) a recommended Nvidia Driver. </p> <div class="separator" style="clear: both; text-align: center;"> <a href="//1.bp.blogspot.com/-4Gj8-xj5kZk/T-3IO4QGPaI/AAAAAAAAAyk/pmcXNn4KHro/s1600/hd.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="//1.bp.blogspot.com/-4Gj8-xj5kZk/T-3IO4QGPaI/AAAAAAAAAyk/pmcXNn4KHro/s1600/hd.png" /></a> </div> <p> <b>Reboot </b>and boot into Normal Ubuntu and your Ubuntu will boot just fine. If this doesn&#8217;t work ask me by commenting on this post or <a href="mailto:[email protected]" >email me</a>.</div> How to see transit of Venus using Stellarium in Ubuntu https://subinsb.com/how-to-see-transit-of-venus-using-stellarium-in-ubuntu/ Mon, 04 Jun 2012 08:39:00 +0000 https://subinsb.com/how-to-see-transit-of-venus-using-stellarium-in-ubuntu/ <div dir="ltr" style="text-align: left;" trbidi="on"> <u style="color: blue; font-size: large;">U can watch&nbsp;<b>transit of Venus&nbsp;</b>in your Computer</u></p> <div style="margin-bottom: 0cm;"> Edubuntu operating system using&nbsp;<b>Stellarium</b>.To know more click the link below </div> <div style="margin-bottom: 0cm;"> <a href="http://simmash.blogspot.com/">SIMMASH</a>&nbsp;<a href="http://efingers.blogspot.com/" >Efingers</a>&nbsp;<a href="http://www.google.co.in/search?sourceid=efingers&ie=UTF-8&q=Transit%20of%20Venus">Google</a> </div> <div style="margin-bottom: 0cm;"> <b><br /></b></p> <pre><code>&lt;p&gt; &lt;b&gt;To view in Ubuntu&amp;nbsp;&lt;/b&gt;&lt;br /&gt;Go to&lt;br /&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;b&gt;Applications &amp;#8211;&gt; Ubuntu Software Center &amp;#8211;&gt;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;and search for&amp;nbsp;&lt;b&gt;Stellarium&amp;nbsp;&lt;/b&gt;and click install button&lt;br /&gt;Then do the steps as shown below&lt;/div&gt; &lt;div style=&quot;margin-bottom: 0cm;&quot;&gt; &lt;b&gt;Steps&lt;/b&gt; &lt;/div&gt; &lt;div style=&quot;margin-bottom: 0cm;&quot;&gt; ***** &lt;/div&gt; &lt;div style=&quot;margin-bottom: 0cm;&quot;&gt; &lt;b&gt;&lt;span style=&quot;color: blue;&quot;&gt;Applications&amp;#8212;&gt;Science&amp;#8212;-&gt;Stellarium&lt;/span&gt;&lt;/b&gt; &lt;/div&gt; &lt;div style=&quot;margin-bottom: 0cm;&quot;&gt; &lt;/div&gt; &lt;div style=&quot;margin-bottom: 0cm;&quot;&gt; in tool bar select&amp;nbsp;&lt;b&gt;&lt;span style=&quot;color: blue;&quot;&gt;location window&lt;/span&gt;&lt;/b&gt;&amp;nbsp;, then select country name the location u need &lt;/div&gt; &lt;div style=&quot;margin-bottom: 0cm;&quot;&gt; here we type India country name and location kunnamkulam &lt;/div&gt; &lt;div style=&quot;margin-bottom: 0cm;&quot;&gt; &amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212; &lt;/div&gt; &lt;div style=&quot;margin-bottom: 0cm;&quot;&gt; in tool bar select&lt;span style=&quot;color: blue;&quot;&gt;&amp;nbsp;&lt;b&gt;Search window&lt;/b&gt;&lt;/span&gt; &lt;/div&gt; &lt;div style=&quot;margin-bottom: 0cm;&quot;&gt; &lt;span style=&quot;color: blue;&quot;&gt;find objec&lt;/span&gt;t position &lt;/div&gt; &lt;div style=&quot;margin-bottom: 0cm;&quot;&gt; in here we type&amp;nbsp;&lt;b&gt;venus&amp;nbsp;&lt;/b&gt;on the search box &lt;/div&gt; &lt;div style=&quot;margin-bottom: 0cm;&quot;&gt; by scrolling mouse you can zoom the selected object &lt;/div&gt; &lt;div style=&quot;margin-bottom: 0cm;&quot;&gt; &amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;- &lt;/div&gt; &lt;div style=&quot;margin-bottom: 0cm;&quot;&gt; in tool bar select&amp;nbsp;&lt;b&gt;&lt;span style=&quot;color: blue;&quot;&gt;Date And Time&lt;/span&gt;&lt;/b&gt; &lt;/div&gt; &lt;div style=&quot;margin-bottom: 0cm;&quot;&gt; adjust the date&amp;nbsp;&lt;b&gt;2012/6/6&amp;nbsp;&lt;/b&gt;and time&amp;nbsp;&lt;b&gt;1:00:00&lt;/b&gt; &lt;/div&gt; &lt;div style=&quot;margin-bottom: 0cm;&quot;&gt; in status bar selec&lt;span style=&quot;color: blue;&quot;&gt;t&amp;nbsp;&lt;b&gt;inceasing and decreasing the time&lt;/b&gt;&lt;/span&gt; &lt;/div&gt; &lt;div style=&quot;margin-bottom: 0cm;&quot;&gt; using the keyes&amp;nbsp;&lt;b&gt;L&lt;/b&gt;&amp;nbsp;and&lt;b&gt;&amp;nbsp;J&amp;nbsp;&lt;/b&gt;on key- board &lt;/div&gt; &lt;div style=&quot;margin-bottom: 0cm;&quot;&gt; The transit also between the time&amp;nbsp;&lt;b&gt;6:00 to 10:15 in kunnamkulam&lt;/b&gt;&lt;br /&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt; &lt;/div&gt; &lt;div style=&quot;margin-bottom: 0cm;&quot;&gt; &lt;/div&gt;&lt;/div&gt; </code></pre> Thankyou https://subinsb.com/thankyou/ Sat, 05 May 2012 07:05:00 +0000 https://subinsb.com/thankyou/ <div dir="ltr" style="text-align: left;" trbidi="on"> <div class="separator" style="clear: both; text-align: center;"> <a href="https://2.bp.blogspot.com/-NdwEwWW8U5g/T6TQKHOoNSI/AAAAAAAAAvw/7Tz3uC5CIjs/s1600/stats.png" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em; text-align: center;"><img border="0" src="https://2.bp.blogspot.com/-NdwEwWW8U5g/T6TQKHOoNSI/AAAAAAAAAvw/7Tz3uC5CIjs/s1600/stats.png" /></a> </div> <p> Yesterday(4 May 2012) I posted a post about Keith Haring because of his birthday. Google changed their homepage logo. The internet was celebrating Keith Haring&#8217;s birthday. A lot of people came to this blog yesterday. I want to thank the people who came yesterday to this blog. Thank you Visitors. </p> <p> Here are the pics of the stats yesterday.<span style="text-align: center;">About 200 people saw the post.</span> </p> <div style="text-align: center;"> </div> <div style="text-align: center;"> </div> <div style="text-align: center;"> </div> <div style="text-align: center;"> </div> <div style="text-align: center;"> <a href="//4.bp.blogspot.com/-Z4FSdFOeilU/T6TQL_8K4GI/AAAAAAAAAv4/010YD1m2gIo/s1600/stats1.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" src="//4.bp.blogspot.com/-Z4FSdFOeilU/T6TQL_8K4GI/AAAAAAAAAv4/010YD1m2gIo/s1600/stats1.png" /></a> </div> <div style="text-align: center;"> </div> <div style="text-align: center;"> </div> <p> The image shown on left side shows the number of views yesterday and today. 216 people viewed the blog yesterday and 27 people saw the blog today. </p> <p> </p> <div style="text-align: center;"> Once again I am Thanking everyone who saw this blog and made it a big success. </div> <p> </p> <div style="text-align: center;"> <span style="font-size: x-large;">Thank you</span> </div> </div> Hide or show a div using data sent to a php file https://subinsb.com/hide-or-show-a-div-using-data-sent-to-a-php-file/ Sun, 08 Apr 2012 05:13:00 +0000 https://subinsb.com/hide-or-show-a-div-using-data-sent-to-a-php-file/ <div dir="ltr" style="text-align: left;" trbidi="on"> This tutorial will help you to send data to a php file to hide a div ie sending a string to a php file to hide a div.Follow these steps.</p> <div> </div> <div> 1 : Open the php file which contains the div to hide.&nbsp; </div> <div> &nbsp; &nbsp; &nbsp;Paste this code above the <b></head></b>&nbsp;tag</p> <pre><code>&lt;blockquote class=&quot;tr_bq&quot;&gt; &lt;p&gt; &lt;b&gt;&lt;style type=&quot;text/css&quot;&gt;&lt;/b&gt;&lt;b&gt;&lt;span style=&quot;font-family: Times, 'Times New Roman', serif;&quot;&gt;#&lt;?php echo $_GET[&amp;#8216;div&amp;#8217;]; ?&gt;{&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style=&quot;font-family: Times, 'Times New Roman', serif;&quot;&gt;&lt;span style=&quot;color: red;&quot;&gt;display:none;&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style=&quot;font-family: Times, 'Times New Roman', serif;&quot;&gt;}&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style=&quot;font-family: Times, 'Times New Roman', serif;&quot;&gt;&lt;/style&gt;&lt;/span&gt;&lt;/b&gt; &lt;/p&gt; &lt;/blockquote&gt; </code></pre> </div> <p> <span style="color: red;">If you want to show a div change the line "display:none;" to "display:block;"</span> </p> <div> <span style="font-family: Times, 'Times New Roman', serif;">2 : Paste th</span><span style="font-family: Times, 'Times New Roman', serif;">e div code </span><b style="font-family: Times, 'Times New Roman', serif;">with an id </b><span style="font-family: Times, 'Times New Roman', serif;">on the php file.&nbsp;</span> </div> <div> <div class="code"> <blockquote class="tr_bq"> <p> <span style="font-family: Times, 'Times New Roman', serif;">&nbsp; &nbsp; &nbsp;<b><div id="hide">Hello World</div></b></span> </p> </blockquote> </div> <pre><code>&lt;p&gt; &lt;span style=&quot;font-family: Times, 'Times New Roman', serif;&quot;&gt;3 : If the name of the file you just typed is &quot;&lt;b&gt;main&quot; &lt;/b&gt;and the url of the file is &lt;b&gt;&quot;http://example.com/main&quot; &lt;/b&gt;then if you want to hide you have to type the url like this. &lt;b&gt;&quot;http://example.com/main?div=hide&quot; &lt;/b&gt;. After going to this url the div id &lt;b&gt;&quot;hide&quot;&lt;/b&gt;&lt;/span&gt;&lt;b style=&quot;font-family: Times, 'Times New Roman', serif;&quot;&gt;&amp;nbsp;&lt;/b&gt;&lt;span style=&quot;font-family: Times, 'Times New Roman', serif;&quot;&gt;will be hidden.&lt;/span&gt;&lt;/div&gt; &lt;/div&gt; </code></pre> How to open PHP files in Ubuntu instead of downloading. https://subinsb.com/how-to-open-php-files-in-ubuntu-instead-of-downloading/ Sat, 07 Apr 2012 15:15:00 +0000 https://subinsb.com/how-to-open-php-files-in-ubuntu-instead-of-downloading/ <p dir="ltr" style="text-align: left;"> No one can open <b>PHP</b> files in web browsers without a server. Page types such as <b>HTML</b>, <b>Javascript</b> and <b>CSS</b> can be understand by the browsers. But browsers can&#8217;t understand<b> PHP</b>. So the file will download.<span style="font-family: inherit;"><br /> There are two types of file that will run : <b>Client-side</b> and <b>Server-side</b></span><br /> <span style="font-family: inherit;"><br /> <b>Client Side </b>: The program runs in browser itself. The client can easily access the code. The browser can understand the language in which the client program is written.</span><br /> <span style="font-family: inherit;">examples : HTML, CSS, JavaScript, jQuery, AngularJS</span><br /> <span style="font-family: inherit;"><br /> <b>Server Side</b> : The program runs in server and the finished page is sent to the client&#8217;s browser. The returned page won&#8217;t contain any source code of the language ie the client won&#8217;t see the code in page source unlike in <b>Client</b> <b>Side</b>. The returned page won&#8217;t contain any server language at all.</span><br /> <span style="font-family: inherit;"><br /> So now you got the reason why the <b>PHP</b> file won&#8217;t open in web browsers.ย </span><span style="line-height: 1.5em;">You can only open </span><b style="line-height: 1.5em;">PHP</b><span style="line-height: 1.5em;"> file with a server that supports </span><b style="line-height: 1.5em;">PHP</b><span style="line-height: 1.5em;"> language.ย </span><span style="line-height: 1.5em;">So here&#8217;s how to install Apache server and configure the server in </span><b style="line-height: 1.5em;">Ubuntu</b> </p> <p dir="ltr" style="text-align: left;"> <span style="font-family: inherit;"><br /> Openย <b>Terminal [CTRL + ALT + T]</b></span> </p> <h1 dir="ltr" style="text-align: left;"> <b>Install Apache</b> </h1> <p>Type</p> <blockquote class="tr_bq"> <p> sudo apt-get install apache2 </p> </blockquote> <p>in terminal. You will be asked for your password. Type your password and press enter key.</p> <h1 id="restart-server">Restart Server</h1> <p>Type</p> <pre class="prettyprint"><code>sudo /etc/init.d/apache2 restart</code></pre> <p>in terminal and press Enter Key.</p> <p>To check whether you installed <strong>Apache</strong> correctly open your web browser and go toย <a href="http://localhost/">http://localhost/</a></p> <p>If the browser doesnโ€™t say &quot;<strong>This webpage is not available</strong>&quot;, You installed Apache correctly.</p> <h1 id="span-stylefont-family-inheritinstall-phpspan"><span style="font-family: inherit;">Install PHP</span></h1> <p>Type</p> <pre class="prettyprint"><code>sudo apt-get installย libapache2-mod-php5</code></pre> <p><span style="background-color: white;"><span style="text-align: -webkit-auto; white-space: pre-wrap;">and press Enter Key.</span></span></p> <p><span style="background-color: white;"><span style="text-align: -webkit-auto; white-space: pre-wrap;">Enable this module by doing the command :</span></span></p> <pre class="prettyprint"><code>sudo a2enmod php5</code></pre> <p><span style="text-align: -webkit-auto; white-space: pre-wrap;">and relaunch Apache by entering the command:</span></p> <pre class="prettyprint"><code>sudo service apache2 restart</code></pre> <p>To Open theย <strong>PHP</strong> files now, copy the files and paste it onย <strong>/var/www</strong> folder. The go to <strong>http://localhost/file-name.php</strong> to see your PHP file in action.ย <span style="background-color: white; text-align: -webkit-auto;"><span style="background-color: white; text-align: -webkit-auto;">See this <a href="http://sag-3.blogspot.in/2012/04/how-to-create-localhost-site-in-ubuntu.html">tutorial</a> to see how to create a localhost website.</span></span></p> How To Create A Localhost Web Site In Linux Using Apache Web Server https://subinsb.com/linux-apache-localhost/ Sat, 07 Apr 2012 13:44:00 +0000 https://subinsb.com/linux-apache-localhost/ <div dir="ltr" style="text-align: left;"> <p> <span style="font-family: inherit;"><strong>Localhost</strong> is a hosting place in your own computer. There are a vast number ofย <strong>Localhost</strong> servers you can use. The most used and popular of them isย <strong>Apache</strong>. Localhost enables you to test your work on your computer itself, instead of testing on a live server on the web. If you are creating a project, Localhost is the best place to test that project.ย In this tutorial I will show you how to create a localhost site running onย <b>Apache Server</b>ย in anyย <strong>Linux Distribution</strong>.<br /> </span> </p> <p> This tutorial is for Ubuntu versionsย <strong>10.10</strong> and below. The latest versions fromย <strong>11.04</strong> should see <a href="//subinsb.com/ubuntu-linux-create-localhost-website">this tutorial.</a> </p> <h2> Apache Server Installation </h2> <p> <span style="font-family: inherit;">We need to install Apache server first.ย <span style="background-color: white; text-align: justify;">To install Apache Web Server openย <strong>Terminal</strong>ย and do the following command :</span></span> </p> <pre class="prettyprint"><code>sudo apt-get install apache2</code></pre> <p> <span style="font-family: inherit;"><span style="background-color: white; text-align: justify;">The <strong>Apache Server</strong>ย will be downloaded and installed automatically. After installation continue to the next part of this tutorial.</span></span> </p> <h2> Site Creation </h2> <div> <span style="background-color: white; font-family: inherit; text-align: -webkit-auto;">Open the Terminal <b>CTRL + ALTย </b>+ <strong>T</strong>.<b>ย </b>Make a copy of <b>/etc/apache2/sites-available/default</b>, let&#8217;s make the copy nameย <strong>mysite</strong>. (Name depends on the site you wish to create). The following command wil copy the file and name the new file asย <strong>mysite</strong>.</span> </div> <div> <pre class="prettyprint"><code>sudo cp /etc/apache2/sites-available/default /etc/apache2/sites-available/&lt;span style="color: red;">mysite&lt;/span></code></pre> </div> </div> <p>Now edit the new file to configure :</p> <pre class="prettyprint"><code>sudo gedit /etc/apache2/sites-available/&lt;span style="color: #ff0000;">mysite&lt;/span></code></pre> <div> Then, Add the following contents in the file usingย <strong>gedit</strong> we just opened. Please read theย <strong>3</strong> conditions below and then paste the content. </div> <div> <ol> <li> <span style="color: #ff6600;"><b>You will need to change the codes &#8216;username&#8217; shown below to your home folder name.</b></span> </li> <li> <span style="color: #ff6600;"><b style="color: red;"><span style="font-family: inherit;">You will need to change the names &#8216;mysite&#8217; shown below to your desired site name.</span></b></span> </li> <li> <span style="color: #ff6600;"><b>You can also change the web address of your site by renaming "mysite.com" to the site address you want.</b></span> </li> </ol> </div> <div> <p> Content that should be added to the file : </p> <pre class="prettyprint"><code>&lt;span style="font-family: inherit;">&lt;span class="tag">&lt;VirtualHost&lt;/span>&lt;span class="pln"> *:80&lt;/span>&lt;span class="tag">&gt;&lt;/span>&lt;/span> &lt;span class="pln">ย ServerAdmin webmaster@localhost&lt;/span> &lt;span class="pln">ย ServerName &lt;/span>&lt;span style="color: red;">&lt;span class="pln">mysite.com&lt;/span>&lt;/span> &lt;span class="pln">ย DocumentRoot &lt;span style="color: red;">/home/username/mysite&lt;/span>&lt;/span> &lt;span class="pln">ย &lt;/span>&lt;span class="tag">&lt;Directoryย &lt;/span>&lt;span style="color: red;">&lt;span class="pun">/&lt;/span>&lt;span class="atn">home&lt;/span>&lt;span class="pun">/&lt;/span>&lt;span class="atn">username&lt;/span>&lt;span class="pun">/&lt;/span>&lt;span class="atn">mysite&lt;/span>&lt;/span>&lt;span class="tag">/&gt;&lt;/span> &lt;span class="pln">ย  Options Indexes FollowSymLinks MultiViews&lt;/span> &lt;span class="pln">ย  AllowOverride All&lt;/span> &lt;span class="pln">ย  Order allow,deny&lt;/span> &lt;span class="pln">ย  allow from all&lt;/span> &lt;span class="pln">ย &lt;/span>&lt;span class="tag">&lt;/Directory&gt;&lt;/span> &lt;span class="pln">ย ErrorLog /var/log/apache2/&lt;/span>&lt;span style="color: red;">&lt;span class="pln">mysite&lt;/span>&lt;/span>&lt;span class="pln">/error.log&lt;/span> &lt;span class="pln">ย # Possible values include: debug, info, notice, warn, error, crit,&lt;/span> &lt;span class="pln">ย # alert, emerg.&lt;/span> &lt;span class="pln">ย LogLevel warn&lt;/span> &lt;span class="pln">ย CustomLog /var/log/apache2/&lt;/span>&lt;span style="color: red;">&lt;span class="pln">mysite&lt;/span>&lt;/span>&lt;span class="pln">/access.log combined&lt;/span> &lt;span class="tag">&lt;/VirtualHost&gt;&lt;/span></code></pre> </div> <p><span style="font-family: inherit;"><span style="background-color: white; font-family: inherit; text-align: -webkit-auto;">Once youโ€™ve saved these changes, youโ€™ll need to enable the site.</span>ย (ย <b style="color: red;">You will need to change the name โ€˜mysiteโ€™ shown below to the name of the file you create at &quot;</b><b>/etc/apache2/sites-available/</b><b style="color: red;">&quot;ย </b><span style="color: #000000;">).</span></span></p> <pre class="prettyprint"><code>cd /etc/apache2/sites-available && sudo a2ensite &lt;span style="color: red;">mysite&lt;/span></code></pre> <p><span style="font-family: inherit;">We specified a separate directory for storing log files, so weโ€™ll need to create that log directory.(ย </span><span style="font-family: inherit;"><b style="color: red; text-align: left;">You have to change the name โ€˜mysiteโ€™ shown below to the name you given in the configuration file on &quot;</b><b>/etc/apache2/sites-available/</b><b style="color: red; text-align: left;">&quot;ย </b><span style="color: #000000;">).</span></span></p> <pre class="prettyprint"><code>sudo mkdir /var/log/apache2/&lt;span style="color: red;">mysite&lt;/span></code></pre> <p><span style="font-family: inherit;"><span style="background-color: white; font-family: inherit; text-align: -webkit-auto;">Finally, we need to point the site address to localhost in your hosts file. For that, Edit <b>/etc/hosts</b>ย :</span></span></p> <pre class="prettyprint"><code>sudo gedit /etc/hosts</code></pre> <p>and add the following at the end of the file. (ย <span style="font-family: inherit;"><span style="color: red;"><b>You need to change the web address &quot;mysite.com&quot; shown below to your address given on the file in </b>sites-availableย <b>folder </b><span style="color: #000000;">).</span></span></span></p> <pre class="prettyprint"><code>127.0.0.1 &lt;span style="color: red;">mysite.com&lt;/span></code></pre> <p><span style="font-family: inherit;"><span style="background-color: white; font-family: inherit; text-align: -webkit-auto;">Now we restart Apache Server using Terminal to apply all the changes we made.</span></span></p> <pre class="prettyprint"><code>sudo /etc/init.d/apache2 restart</code></pre> <p><span style="background-color: white; font-family: inherit; text-align: -webkit-auto;">You can now store all your work in /home/<span style="color: red;">you home name</span>/<span style="color: red;">site name</span> and navigate to it by pointing your browser to the address you gave.</span></p> Tonight Venus passes directly between Earth and an elusive cluster of stars known as the Pleiades. https://subinsb.com/tonight-venus-passes-directly-between-earth-and-an-elusive-cluster-of-stars-known-as-the-pleiades/ Wed, 04 Apr 2012 06:38:00 +0000 https://subinsb.com/tonight-venus-passes-directly-between-earth-and-an-elusive-cluster-of-stars-known-as-the-pleiades/ <div dir="ltr" style="text-align: left;" trbidi="on"> Once every eight years, a luminous Venus passes directly between Earth and an elusive cluster of stars known as the Pleiades. Tonight, you&#8217;ll have a chance to witness this event with your own eyes.</p> <div style="background-color: white; font-family: Georgia, Times, 'Liberation Serif', serif; font-size: 15px; line-height: 22px; text-align: -webkit-auto;"> The photo up top was taken a few days ago on the evening of March 31st, and showcases the two astronomical entities that you&#8217;ll be looking for. Obvious-as-ever is Venus, the brightest object in the night sky save for the Moon, beaming on the right. Less dazzling, but conspicuous in its own right, is the cluster of blue stars gathered on the left. These are the Pleiades.</p> <pre><code>&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt; &lt;a href=&quot;//1.bp.blogspot.com/-GmPjyMmbt8c/Ub1kZlLqhcI/AAAAAAAACvo/zRI0aTWhrtA/s1600/0016.jpg&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;//1.bp.blogspot.com/-GmPjyMmbt8c/Ub1kZlLqhcI/AAAAAAAACvo/zRI0aTWhrtA/s1600/0016.jpg&quot; /&gt;&lt;/a&gt; &lt;/div&gt; </code></pre> </div> <div style="background-color: white; font-family: Georgia, Times, 'Liberation Serif', serif; font-size: 15px; line-height: 22px; text-align: -webkit-auto;"> Also known as Messier object 45 (M45) or the "Seven Sisters," the young star cluster is thought to have formed less than 100 million years ago, which helps explain&nbsp;the blue-white hue of its largest members. At just 400 light years away, the Pleiades are still visible with the naked eye, but they&#8217;re usually easier to spot with a pair of binoculars or a small telescope. Tonight, however, you should be able to spot them due to their proximity to Venus. According to NASA, the planet will join the Pleiades in the night sky beginning just after sunset, making it "look like a supernova has gone off inside the cluster." </div> <div style="background-color: white; clear: both; color: #222222; font-family: Georgia, Times, 'Liberation Serif', serif; font-size: 15px; line-height: 22px; text-align: -webkit-auto;"> </div> <div style="background-color: white; font-family: Georgia, Times, 'Liberation Serif', serif; font-size: 15px; line-height: 22px; text-align: -webkit-auto;"> The cosmic conjunction began last night, and will remain visible through Wednesday, when Venus finishes passing across the face of the cluster. Tonight, however, promises to provide the most spellbinding view. Look west as soon as the Sun dips below the horizon, and remember to look for the light of Venus โ€” you&#8217;ll find it resting in the company of the Seven Sisters. (Also: be sure to check out&nbsp;this breathtaking photo of the Pleiades posing with Ecuador&#8217;s active Tungurahua volcano.) </div> <div style="background-color: white; font-family: Georgia, Times, 'Liberation Serif', serif; font-size: 15px; line-height: 22px; text-align: -webkit-auto;"> </div> <div style="background-color: white; font-family: Georgia, Times, 'Liberation Serif', serif; font-size: 15px; line-height: 22px; text-align: -webkit-auto;"> Here&#8217;s another picture </div> <div style="background-color: white; font-family: Georgia, Times, 'Liberation Serif', serif; font-size: 15px; line-height: 22px; text-align: -webkit-auto;"> </div> <div class="separator" style="clear: both; text-align: center;"> <a href="//3.bp.blogspot.com/-tG5DPXPeKgE/T3vsGOqcrtI/AAAAAAAAAmw/qeF-7nhlHWg/s1600/venus+show.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="//3.bp.blogspot.com/-tG5DPXPeKgE/T3vsGOqcrtI/AAAAAAAAAmw/qeF-7nhlHWg/s1600/venus+show.png" /></a> </div> <div class="separator" style="clear: both; text-align: center;"> </div> <div class="separator" style="clear: both; text-align: center;"> <a href="//1.bp.blogspot.com/-yy4pjees9oc/T3vs7aKB75I/AAAAAAAAAm4/2VAocAH3NtA/s1600/venus-show.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="//1.bp.blogspot.com/-yy4pjees9oc/T3vs7aKB75I/AAAAAAAAAm4/2VAocAH3NtA/s1600/venus-show.png" /></a> </div> </div> Tutorial : Write a file using php https://subinsb.com/tutorial-write-a-file-using-php/ Sat, 31 Mar 2012 15:39:00 +0000 https://subinsb.com/tutorial-write-a-file-using-php/ <div dir="ltr" style="text-align: left;" trbidi="on"> Hi. You must have heard of writing file using PHP. You want to know how to do this. I&#8217;ll tell you. Please follow these steps.<br />1 &#8211; Open your php file in text editor. Paste this code in it.</p> <div class="code"> <blockquote class="tr_bq"> <p> <?php<br />&nbsp; &nbsp; $myFile = "file.html";<br />&nbsp; &nbsp; $fh = fopen($myFile, &#8216;a+&#8217; );<br />&nbsp; &nbsp; $stringData = ("Hello");<br /> &nbsp; &nbsp; fwrite($fh, $stringData);<br />&nbsp; &nbsp; fclose($fh);<br />?> </p> </blockquote> </div> <p> This will write Hello to a file named file.html. Enjoy!!! </p> </div> Tutorial : How to add date and time using php https://subinsb.com/tutorial-how-to-add-date-and-time-using-php/ Sat, 31 Mar 2012 15:17:00 +0000 https://subinsb.com/tutorial-how-to-add-date-and-time-using-php/ <div dir="ltr" style="text-align: left;" trbidi="on"> You might want to add date and time using php in your php files. I will tell you how to do it.</p> <p> 1 &#8211; Go to your PHP page. Paste this code where you want to add date and time<br />&nbsp; &nbsp; </p> <div class="code"> &nbsp; &nbsp; &nbsp; &nbsp;date("J-F- Y&#8211;H:I A") </div> <p> This code will Show date and time in Date-Month-Year &#8211;Hour:Minute:AM/PM<br />If you want to change the type of showing date and time just change the position of the letters.<br />Here is a list of dates you can use in PHP </p> <table border="1" bordercolor="#000000" cellpadding="4" cellspacing="0"> <colgroup> <col width="128*"></col> <col width="128*"></col> </colgroup> <tr valign="TOP"> <td width="50%"> Functions </td> <pre><code> &lt;td width=&quot;50%&quot;&gt; Date types &lt;/td&gt; &lt;/tr&gt; &lt;tr valign=&quot;TOP&quot;&gt; &lt;td height=&quot;114&quot; width=&quot;50%&quot;&gt; J&lt;br /&gt;F&lt;br /&gt;Y&lt;br /&gt;H&lt;br /&gt;I&lt;br /&gt;S&lt;br /&gt;A &lt;/td&gt; &lt;td width=&quot;50%&quot;&gt; Date&lt;br /&gt;Month&lt;br /&gt;Year&lt;br /&gt;Hour&lt;br /&gt;Minutes&lt;br /&gt;Seconds&lt;br /&gt;AM/PM &lt;/td&gt; &lt;/tr&gt; </code></pre> </table> <p> &nbsp; &nbsp; &nbsp; &nbsp; </p> </div> Next Tutorial please. https://subinsb.com/next-tutorial-please/ Fri, 30 Mar 2012 17:24:00 +0000 https://subinsb.com/next-tutorial-please/ <div dir="ltr" style="text-align: left;" trbidi="on"> What do you want to know. Tell me what do you want to know. Ask me by commenting. </div> Add Facebook and Blogger Comments As Tabs In Blogger https://subinsb.com/facebook-and-blogger-comments-tabs/ Mon, 19 Mar 2012 16:45:00 +0000 https://subinsb.com/facebook-and-blogger-comments-tabs/ <p>Having multiple comments box on your posts make more comments. The most popular of Comments are Facebook. Why not add Facebook comments with Blogger comments on your blog. This can be easily done if you follow this tutorial carefully.</p> <div class="padlinks"> <a class="demo" href="http://subin-demos.blogspot.in/2012/04/facebook-and-blogger-comments-in-tabs.html" target="_blank">Demo</a> </div> <p>Go to <strong>Blogger -&gt; Template -&gt; Edit HTML</strong>.</p> <p>Paste the following code below &quot;<head>&quot; tag :</p> <pre class="prettyprint"><code>&lt;script src='http://connect.facebook.net/en_US/all.js#xfbml=1'&gt;&lt;/script&gt; &lt;script src='http://code.jquery.com/jquery-latest.js'/&gt; &lt;script type='text/javascript'&gt; function commentToggle(selectTab) { $(&quot;.comments-tab&quot;).addClass(&quot;inactive-select-tab&quot;); $(selectTab).removeClass(&quot;inactive-select-tab&quot;); $(&quot;.comments-page&quot;).hide(); $(selectTab + &quot;-page&quot;).show(); } &lt;/script&gt;</code></pre> <p>Search forย <strong>&lt;html</strong> and replace it with the following code :</p> <pre class="prettyprint"><code>&lt;htmlย xmlns:fb='http://ogp.me/ns/fb#' </code></pre> <p>Add the following HTML code above &quot;</head>&quot; :</p> <pre class="prettyprint"><code>&lt;style&gt; /*--- Tabbed Facebook Comments By subinsb.com ----*/ .comments-page { background-color: #f2f2f2; width:450px; } #blogger-comments-page { padding: 0px 5px; display: none; } .comments-tab { float: left; padding: 5px; margin-right: 3px; cursor: pointer; background-color: #f2f2f2; } .comments-tab-icon { height: 14px; display: inline-block; vertical-align: top; margin-right: 3px; } .comments-tab:hover { background-color: #eeeeee; } .inactive-select-tab{ background-color: #d1d1d1; } &lt;/style&gt;</code></pre> <p>By using the Blogger shortcut keyย **CTRL + Fย **find this code :</p> <pre class="prettyprint"><code>&lt;div class='comments' id='comments'&gt;</code></pre> <p><strong>Note : If you found two codes like above, you have to paste the code shown below after the two codes you found.</strong></p> <div style="text-align: left;"> <pre class="prettyprint"><code>&lt;center&gt; &lt;table&gt; &lt;tbody&gt; &lt;tr&gt; &lt;td&gt; &lt;div class='comments-tab' id='fb-comments' onclick='javascript:commentToggle(&quot;#fb-comments&quot;);' style='float:left;' title='Facebook Comments'&gt; &lt;img class='comments-tab-icon' src='https://2.bp.blogspot.com/-rae4j6NaLkY/T1JrjUEIkkI/AAAAAAAAGBc/PzwMIo1g1Is/s400/fbcomment.png'/&gt; &lt;fb:comments-count expr:href='data:post.url'/&gt; Comments &lt;/div&gt; &lt;/td&gt; &lt;td&gt; &lt;div class='comments-tab inactive-select-tab' id='blogger-comments' onclick='javascript:commentToggle(&apos;#blogger-comments&apos;);' title='Blogger Comments'&gt; &lt;img class='comments-tab-icon' src='http://www.blogger.com/img/icon_logo32.gif'/&gt; &lt;data:post.numComments/&gt; Blogger Comments &lt;/div&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/tbody&gt; &lt;/table&gt; &lt;div class='comments-page' id='fb-comments-page'&gt; &lt;b:if cond='data:blog.pageType == &quot;item&quot;'&gt; &lt;div id='fb-root'&gt;&lt;/div&gt; &lt;script&gt; (function(d){ var js, id = &#39;facebook-jssdk&#39;; if (d.getElementById(id)){return;} js = d.createElement(&#39;script&#39;); js.id = id; js.async = true; js.src = &quot;//connect.facebook.net/en_US/all.js#xfbml=1&quot;; d.getElementsByTagName(&#39;head&#39;)[0].appendChild(js); }(document)); &lt;/script&gt; &lt;fb:comments colorscheme='light' expr:href='data:post.url' expr:title='data:post.title' expr:xid='data:post.id' width='450'/&gt; &lt;/b:if&gt; &lt;/div&gt; &lt;div class='comments comments-page' id='blogger-comments-page' style='display:none;'&gt;</code></pre> <p> Save the template. You will get an error. Blogger will automatically highlight a code (</b:includable>). Paste the following code above the code Blogger highlighted : </p> <pre class="prettyprint"><code>&lt;/center&gt;&lt;/div&gt;</code></pre> <p> Save the Template and check out a post on your blog. Every post on your blog will now have a Facebook & Blogger Comments tabbed. If you want help, post a comment. </p> </div> Disable Right Click On Blogger Blog https://subinsb.com/disable-right-click-blogger-blog/ Sat, 17 Mar 2012 04:46:00 +0000 https://subinsb.com/disable-right-click-blogger-blog/ <p>For preventing copying of your content by visitors, you can disable the use of Right Click on your blog. Some websites and blogs prevent the right click for preventing copiers. You can also prevent the copiers by disabling the right click.</p> <div class="padlinks"> <a class="demo" href="http://subin-demos.blogspot.in/2012/04/disable-right-click-demo.html" target="_blank">Demo</a> </div> <p><span>Go to Dashboard -&gt; Layout -&gt; Add Gadget -&gt; HTML / JavaScript</span><figure id="attachment_2477" class="wp-caption aligncenter"></p> <p><a href="//lab.subinsb.com/projects/blog/uploads/2014/02/0102.png"><img class="size-full wp-image-2477" alt="Add HTML/Javascript Widget In Blogger" src="//lab.subinsb.com/projects/blog/uploads/2014/02/0102.png" width="1049" height="244" /></a><figcaption class="wp-caption-text">Add HTML/JavaScript Widget In Blogger</figcaption></figure></p> <p>Copy the following code and paste it in the Widget text area :</p> <pre class="prettyprint"><code>&lt;script&gt; var message="Not Allowed"; var shouldAlert=1; document.oncontextmenu=function(){ if(shouldAlert==1){ alert(message); } return false; }; &lt;/script&gt;</code></pre> <p>Save the &quot;HTML/JavaScript&quot; widget.</p> <p>If you want to change the message, edit the contents of the variable &quot;message&quot;.</p> <p>Now, go to your blog and try right clicking. You will get a message saying &quot;Not Allowed&quot;.</p> <p>Whenever the user right clicks, the message will be displayed. It can be quite annoying to the visitors. So, if you donโ€™t want the message to appear, change the &quot;shouldAlert&quot; value to &quot;0&quot; instead of &quot;1&quot;.</p> Get a work email on Blogger https://subinsb.com/get-a-work-email-on-blogger/ Fri, 09 Mar 2012 15:04:00 +0000 https://subinsb.com/get-a-work-email-on-blogger/ <div dir="ltr" style="text-align: left;" trbidi="on"> You must have heard of work email.<br />Do you want a work email for your blog without creating an another gmail account???<br />If you want then follow these steps.</p> <p> 1st step : Go to your <b>Blogger -> Settings -> Mobile and email&nbsp;</b><br /><b><br /></b> </p> <div class="separator" style="clear: both; text-align: center;"> </div> <p> You will see a box like this<br /><a href="//1.bp.blogspot.com/-2dxOwrTBKJ8/T1oYqqwuC9I/AAAAAAAAAlM/ya8WdTW8k6I/s1600/Screenshot-6.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em; text-align: center;"><img border="0" src="//1.bp.blogspot.com/-2dxOwrTBKJ8/T1oYqqwuC9I/AAAAAAAAAlM/ya8WdTW8k6I/s1600/Screenshot-6.png" /></a><br /><b>Type the word you want on the text box.</b><br /><b>Then click on the radio button on the left side of "<span style="background-color: #fff9e7; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: 13px; text-align: -webkit-auto;">Save emails as draft post</span><span style="background-color: #fff9e7; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: 13px; text-align: -webkit-auto;">&nbsp;"</span></b> </p> <div class="separator" style="clear: both; text-align: center;"> </div> <div style="text-align: -webkit-auto;"> <span style="color: #222222; font-family: Arial, Helvetica, sans-serif;">After this click on&nbsp;</span><a href="//4.bp.blogspot.com/-3D9C-9KMWDY/T1obA7vJUwI/AAAAAAAAAlU/mUDaGAM7XQw/s1600/Screenshot-7.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em; text-align: center;"><img border="0" src="//4.bp.blogspot.com/-3D9C-9KMWDY/T1obA7vJUwI/AAAAAAAAAlU/mUDaGAM7XQw/s1600/Screenshot-7.png" /></a>&nbsp;button </div> <div style="text-align: -webkit-auto;"> </div> <div style="text-align: -webkit-auto;"> Finished !!!!&nbsp; </div> <div style="text-align: -webkit-auto;"> <b>All the mails sent to the mail id you created will be on the "drafts" option in "Posts" menu</b> </div> </div> Jupiter and Venus near the moon today!! https://subinsb.com/jupiter-and-venus-near-the-moon-today/ Sun, 26 Feb 2012 13:43:00 +0000 https://subinsb.com/jupiter-and-venus-near-the-moon-today/ <div dir="ltr" style="text-align: left;" trbidi="on"> Today 26 February the Jupiter and Venus are near the moon. you can see the two planets near the moon.</p> <div class="separator" style="clear: both; text-align: center;"> <a href="//3.bp.blogspot.com/-OeLd7mJUq94/T0o2XAElDTI/AAAAAAAAAh0/0cDu-zg7ALU/s1600/Screenshot-3.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="//3.bp.blogspot.com/-OeLd7mJUq94/T0o2XAElDTI/AAAAAAAAAh0/0cDu-zg7ALU/s1600/Screenshot-3.png" /></a> </div> <div class="separator" style="clear: both; text-align: center;"> </div> <div class="separator" style="clear: both; text-align: center;"> See the sky and find the moon. You can see two bright stars. One is Jupiter and other one is Venus.&nbsp; </div> <div class="separator" style="clear: both; text-align: center;"> Enjoy!!!!! </div> <div class="separator" style="clear: both; text-align: center;"> </div> <div class="separator" style="clear: both; text-align: center;"> Here is a picture of the moon and the planets seen in the west side of the sky </div> <div class="separator" style="clear: both; text-align: center;"> <a href="//1.bp.blogspot.com/-FdKqOGbVLwg/T0uOAch8IUI/AAAAAAAAAiA/Sb5DlSMokZE/s1600/Screenshot-4.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="//1.bp.blogspot.com/-FdKqOGbVLwg/T0uOAch8IUI/AAAAAAAAAiA/Sb5DlSMokZE/s1600/Screenshot-4.png" /></a> </div> <div class="separator" style="clear: both; text-align: center;"> </div> <p> </div> How to Add a Fixed Header to Blogger Blog https://subinsb.com/how-to-add-a-fixed-header-to-blogger-blog/ Wed, 15 Feb 2012 15:44:00 +0000 https://subinsb.com/how-to-add-a-fixed-header-to-blogger-blog/ <p>A fixed header is a header that is in a fixed position. It will be seen in your blog wherever you are in your blog. See an example <a href="http://subin-demos.blogspot.in/2012/04/blogger-fixed-header-demo.html">here</a>.</p> <p>To add this follow these steps</p> <p>1st Step : Go to <strong>Blogger -&gt; Template -&gt; Edit Html<img class="alignright" src="//4.bp.blogspot.com/-qIrpm3u0MsA/TzvOcNDo9FI/AAAAAAAAAgQ/kG76N_6CE-o/s200/fb4.png" alt="" width="100" height="60" border="0" /></strong></p> <p>Copy and pate these lines before the <strong></head></strong> tag :</p> <pre><code>&lt;style type=&quot;text/css&quot;&gt; /* Subin's Blog - http://subinsb.com */ .fixed-header{ overflow: hidden; position: fixed; z-index: 999999; top: 0px; left: 0px; right: 0px; height: &lt;span style=&quot;color: red;&quot;&gt;76&lt;/span&gt;px; background: &lt;span style=&quot;color: red;&quot;&gt;#EEE&lt;/span&gt;; }&lt;/style&gt; </code></pre> <p>2nd Step : Go to **Blogger -&gt; Layout ย **and click onย <a style="font-family: 'Times New Roman'; line-height: normal; margin-left: 1em; margin-right: 1em; text-align: center;" href="https://2.bp.blogspot.com/-N_WqfH_GbMU/TzvQ2yjVUtI/AAAAAAAAAgc/wlk6pwY2ktY/s1600/fb6.png"><img src="https://2.bp.blogspot.com/-N_WqfH_GbMU/TzvQ2yjVUtI/AAAAAAAAAgc/wlk6pwY2ktY/s200/fb6.png" alt="" width="200" height="32" border="0" /></a>ย button.</p> <p>Then Click onย <a style="font-family: 'Times New Roman'; line-height: normal; margin-left: 1em; margin-right: 1em; text-align: center;" href="//1.bp.blogspot.com/-AsdUESbUyBY/TzvRPEkugmI/AAAAAAAAAgk/cPBSB6ld5Qw/s1600/fb7.png"><img src="//1.bp.blogspot.com/-AsdUESbUyBY/TzvRPEkugmI/AAAAAAAAAgk/cPBSB6ld5Qw/s200/fb7.png" alt="" width="200" height="46" border="0" /></a>ย button and type these in the content area</p> <pre><code>&lt;div class=&quot;fixed-header&quot; &gt; &lt;center&gt;&lt;h1&gt;Type Your Blog Name Here&lt;/h1&gt;&lt;/center&gt; &lt;/div&gt; </code></pre> <p>After typing Click on &quot;<strong>SAVE</strong>&quot; button. Thatโ€™s it. You should now see a fixed-header in your blog.</p> NFS Most Wanted cover https://subinsb.com/nfs-most-wanted-cover/ Wed, 15 Feb 2012 15:12:00 +0000 https://subinsb.com/nfs-most-wanted-cover/ <div dir="ltr" style="text-align: left;" trbidi="on"> <div class="separator" style="clear: both; text-align: center;"> <a href="//3.bp.blogspot.com/-A9_R8OfqqwA/TzvLDdODn6I/AAAAAAAAAgE/apz4ZGLMVfU/s1600/AutoRun.bmp" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="640" src="//3.bp.blogspot.com/-A9_R8OfqqwA/TzvLDdODn6I/AAAAAAAAAgE/apz4ZGLMVfU/s640/AutoRun.bmp" width="419" /></a> </div> <p> </div> Call of Duty 2 Cover https://subinsb.com/call-of-duty-2-cover/ Wed, 15 Feb 2012 15:09:00 +0000 https://subinsb.com/call-of-duty-2-cover/ <div dir="ltr" style="text-align: left;" trbidi="on"> <div class="separator" style="clear: both; text-align: center;"> <a href="//1.bp.blogspot.com/-_0JI6lUNBFU/TzvKRF4zacI/AAAAAAAAAf8/xYuUqKQWFEE/s1600/cod.bmp" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="//1.bp.blogspot.com/-_0JI6lUNBFU/TzvKRF4zacI/AAAAAAAAAf8/xYuUqKQWFEE/s1600/cod.bmp" /></a> </div> <p> </div> Tutorial : Add Sharing buttons to your blog https://subinsb.com/tutorial-add-sharing-buttons-to-your-blog/ Mon, 13 Feb 2012 06:21:00 +0000 https://subinsb.com/tutorial-add-sharing-buttons-to-your-blog/ <div dir="ltr" style="text-align: left;" trbidi="on"> Sharing buttons are used on blogger to increase its popularity and stats. You can also add this share buttons to your blog. To add sharing buttons Click this button.</p> <div style="text-align: center;"> </div> </div> Tutorial : How to add floating share box in your blog https://subinsb.com/tutorial-how-to-add-floating-share-box-in-your-blog/ Fri, 10 Feb 2012 04:43:00 +0000 https://subinsb.com/tutorial-how-to-add-floating-share-box-in-your-blog/ <div dir="ltr" style="text-align: left;" trbidi="on"> <span style="font-family: inherit;">Today we see some blogs have a floating share box. You can also have this share box.</span><br /><span style="font-family: inherit;">See a demo of floating share box <a href="http://pfogb.blogspot.in/" >here</a></span><br /><span style="font-family: inherit;">1st step : go to <b>Blogger >&nbsp;</b><strong style="background-color: white; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 14px; line-height: 19px; text-align: -webkit-auto;">Template</strong><span class="Apple-style-span" style="background-color: white; color: #333333; line-height: 19px;">/</span><strong style="background-color: white; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 14px; line-height: 19px; text-align: -webkit-auto;">Design</strong><span class="Apple-style-span" style="background-color: white; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 14px; line-height: 19px; text-align: -webkit-auto;">&nbsp;>&nbsp;</span><strong style="background-color: white; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 14px; line-height: 19px; text-align: -webkit-auto;">Edit HTML</strong><strong style="background-color: white; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 14px; line-height: 19px; text-align: -webkit-auto;">&nbsp; &nbsp; &nbsp;&nbsp;</strong></span><br /><strong style="background-color: white; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 14px; line-height: 19px; text-align: -webkit-auto;"><span style="font-family: inherit;"><br /></span></strong></p> <div style="text-align: -webkit-auto;"> <span class="Apple-style-span" style="color: #333333;"><span class="Apple-style-span" style="font-family: inherit; line-height: 19px;">Before <b></head></b>&nbsp;paste this code&nbsp;</span></span> </div> <blockquote class="tr_bq"> <div style="text-align: left;"> <b style="color: #333333; font-family: inherit; line-height: 19px;"><style type="text/css"></b> </div> <pre><code>&lt;div style=&quot;text-align: left;&quot;&gt; &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #333333; font-family: inherit;&quot;&gt;&lt;b style=&quot;font-family: inherit;&quot;&gt;#leftsidebar {&lt;/b&gt;&lt;/span&gt; &lt;/div&gt; &lt;p&gt; &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #333333; font-family: inherit;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #333333; font-family: inherit;&quot;&gt;&lt;/span&gt; &lt;/p&gt; &lt;div style=&quot;text-align: left;&quot;&gt; &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #333333; font-family: inherit;&quot;&gt;&lt;b style=&quot;font-family: inherit;&quot;&gt;position:fixed;&amp;nbsp;&lt;/b&gt;&lt;/span&gt; &lt;/div&gt; &lt;p&gt; &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #333333; font-family: inherit;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;/span&gt; &lt;/p&gt; &lt;div style=&quot;text-align: left;&quot;&gt; &lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #333333; font-family: inherit;&quot;&gt;&lt;b&gt;float:left;&lt;/b&gt;&lt;/span&gt;&lt;b style=&quot;color: #333333; font-family: inherit;&quot;&gt;}&lt;/b&gt;&lt;/span&gt; &lt;/div&gt; &lt;p&gt; &lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;/p&gt; &lt;div style=&quot;text-align: left;&quot;&gt; &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #333333; font-family: inherit;&quot;&gt;&lt;b&gt;#pageshare {position:fixed; bottom:10%; left:60px; float:left; border: 1px solid black; border-radius:5px;-moz-border-radius:5px;-webkit-border-radius:5px;background-color:#eff3fa;padding:0 0 2px &lt;/b&gt;&lt;/span&gt;&lt;b style=&quot;color: #333333; font-family: inherit;&quot;&gt;0;z-index:10; width:70px;}&lt;/b&gt; &lt;/div&gt; &lt;p&gt; &lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #333333; font-family: inherit;&quot;&gt;&lt;/p&gt; &lt;div style=&quot;text-align: left;&quot;&gt; &lt;b style=&quot;font-family: inherit;&quot;&gt;#pageshare .sbutton {float:left;clear:both;margin:5px 5px 0 5px;}&lt;/b&gt; &lt;/div&gt; &lt;p&gt; &lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #333333; font-family: inherit;&quot;&gt;&lt;/p&gt; &lt;div style=&quot;text-align: left;&quot;&gt; &lt;b style=&quot;font-family: inherit;&quot;&gt;.fb_share_count_top {width:48px !important;}&lt;/b&gt; &lt;/div&gt; &lt;p&gt; &lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #333333; font-family: inherit;&quot;&gt;&lt;/p&gt; &lt;div style=&quot;text-align: left;&quot;&gt; &lt;b style=&quot;font-family: inherit;&quot;&gt;.fb_share_count_top, .fb_share_count_inner {-moz-border-radius:3px;-webkit-border-radius:3px;}&lt;/b&gt; &lt;/div&gt; &lt;p&gt; &lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #333333; font-family: inherit;&quot;&gt;&lt;/p&gt; &lt;div style=&quot;text-align: left;&quot;&gt; &lt;b style=&quot;font-family: inherit;&quot;&gt;.FBConnectButton_Small, .FBConnectButton_RTL_Small {width:49px !important; -moz-border-radius:3px;-webkit-border-radius:3px;}&lt;/b&gt; &lt;/div&gt; &lt;p&gt; &lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #333333; font-family: inherit;&quot;&gt;&lt;/p&gt; &lt;div style=&quot;text-align: left;&quot;&gt; &lt;b style=&quot;font-family: inherit;&quot;&gt;.FBConnectButton_Small .FBConnectButton_Text {padding:2px 2px 3px !important;-moz-border-radius:3px;-webkit-border-radius:3px;font-size:8px;}&lt;/b&gt; &lt;/div&gt; &lt;p&gt; &lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #333333; font-family: inherit;&quot;&gt;&lt;/p&gt; &lt;div style=&quot;text-align: left;&quot;&gt; &lt;b style=&quot;font-family: inherit;&quot;&gt;&lt;/style&gt;&lt;/b&gt; &lt;/div&gt; &lt;p&gt; &lt;/span&gt; &lt;/p&gt;&lt;/blockquote&gt; &lt;div style=&quot;text-align: left;&quot;&gt; &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #333333; font-family: inherit;&quot;&gt;2nd step : Go to &lt;b&gt;Blogger &gt;&amp;nbsp;Layout&amp;nbsp;&lt;/b&gt;&lt;/span&gt; &lt;/div&gt; &lt;div style=&quot;text-align: left;&quot;&gt; &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #333333; font-family: inherit;&quot;&gt;&lt;br /&gt;&lt;/span&gt; &lt;/div&gt; &lt;div style=&quot;text-align: left;&quot;&gt; &lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #333333;&quot;&gt;Click on&amp;nbsp;&lt;/span&gt;&lt;a href=&quot;https://2.bp.blogspot.com/-p_-U_7RM8q0/TzScYbr-bUI/AAAAAAAAAd0/nz4OjMco1JI/s1600/fb6.png&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://2.bp.blogspot.com/-p_-U_7RM8q0/TzScYbr-bUI/AAAAAAAAAd0/nz4OjMco1JI/s1600/fb6.png&quot; /&gt;&lt;/a&gt;&amp;nbsp;button.&lt;/span&gt; &lt;/div&gt; &lt;div style=&quot;text-align: left;&quot;&gt; &lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;&lt;/span&gt; &lt;/div&gt; &lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt; &lt;span style=&quot;font-family: inherit;&quot;&gt;Then click on&amp;nbsp;&lt;a href=&quot;//1.bp.blogspot.com/-s8ay-Gy2O48/TzSctzVZjuI/AAAAAAAAAd8/JIXE39AMwh8/s1600/fb7.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;75&quot; src=&quot;//1.bp.blogspot.com/-s8ay-Gy2O48/TzSctzVZjuI/AAAAAAAAAd8/JIXE39AMwh8/s320/fb7.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&amp;nbsp;option.&lt;/span&gt; &lt;/div&gt; &lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt; &lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;&lt;/span&gt; &lt;/div&gt; &lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt; &lt;span style=&quot;font-family: inherit;&quot;&gt;Type this in the &quot;&lt;b&gt;Content Area&quot;&amp;nbsp;&lt;/b&gt;&lt;/span&gt; &lt;/div&gt; &lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt; &lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;b&gt;&lt;/b&gt;&lt;/span&gt; &lt;/div&gt; &lt;blockquote class=&quot;tr_bq&quot;&gt; &lt;p&gt; &lt;b&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;div id=&quot;fb-root&quot;&gt;&lt;/div&gt;&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;script&gt;(function(d, s, id) {&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;&amp;nbsp; var js, fjs = d.getElementsByTagName(s)[0];&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;&amp;nbsp; if (d.getElementById(id)) return;&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;&amp;nbsp; js = d.createElement(s); js.id = id;&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;&amp;nbsp; js.src = &quot;//connect.facebook.net/en_US/all.js#xfbml=1&amp;appId=&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;&lt;i&gt;&lt;u&gt;Your facebook App Id&lt;/u&gt;&lt;/i&gt;&lt;/span&gt;&quot;;&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;&amp;nbsp; fjs.parentNode.insertBefore(js, fjs);&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;}(document, &amp;#8216;script&amp;#8217;, &amp;#8216;facebook-jssdk&amp;#8217;));&lt;/script&gt;&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;div id=&amp;#8217;pageshare&amp;#8217; title=&quot;Share This With Your Friends&quot;&gt;&lt;/span&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;div class=&amp;#8217;sbutton&amp;#8217; id=&amp;#8217;gb&amp;#8217;&gt;&lt;script src=&quot;http://connect.facebook.net/en_US/all.js#xfbml=1&amp;appId=&lt;/span&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;&lt;i&gt;&lt;u&gt;Your facebook App Id&lt;/u&gt;&lt;/i&gt;&lt;/span&gt;&lt;/b&gt;&quot;&gt;&lt;b&gt;&lt;/script&gt;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;b&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;fb:like href=&quot;&lt;span style=&quot;color: red;&quot;&gt;&lt;i&gt;&lt;u&gt;Your Blog Url&lt;/u&gt;&lt;/i&gt;&lt;/span&gt;&quot; send=&quot;true&quot; layout=&quot;box_count&quot; width=&quot;50&amp;#8243; show_faces=&quot;true&quot; font=&quot;arial&quot;&gt;&lt;/fb:like&gt;&lt;/div&gt;&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;div class=&amp;#8217;sbutton&amp;#8217; id=&amp;#8217;rt&amp;#8217;&gt;&lt;a href=&quot;http://twitter.com/share&quot; class=&quot;twitter-share-button&quot; data-count=&quot;vertical&quot; &gt;Tweet&lt;/a&gt;&lt;script src=&amp;#8217;http://platform.twitter.com/widgets.js&amp;#8217; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;&lt;/div&gt;&lt;/span&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;div class=&amp;#8217;sbutton&amp;#8217; id=&amp;#8217;gplusone&amp;#8217;&gt;&lt;script type=&quot;text/javascript&quot; src=&quot;https://apis.google.com/js/plusone.js&quot;&gt;&lt;/script&gt;&lt;g:plusone size=&quot;tall&quot;&gt;&lt;/g:plusone&gt;&lt;/div&gt;&lt;/span&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;div class=&amp;#8217;sbutton&amp;#8217; id=&amp;#8217;su&amp;#8217;&gt;&lt;script src=&quot;http://www.stumbleupon.com/hostedbadge.php?s=5&amp;#8243;&gt;&lt;/script&gt;&lt;/div&gt;&lt;/span&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;div class=&amp;#8217;sbutton&amp;#8217; id=&amp;#8217;digg&amp;#8217; style=&amp;#8217;margin-left:3px;width:48px&amp;#8217;&gt;&lt;script src=&amp;#8217;http://widgets.digg.com/buttons.js&amp;#8217; type=&amp;#8217;text/javascript&amp;#8217;&gt;&lt;/script&gt;&lt;a class=&quot;DiggThisButton DiggMedium&quot;&gt;&lt;/a&gt;&lt;/div&gt;&lt;/span&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;div class=&amp;#8217;sbutton&amp;#8217; id=&amp;#8217;fb&amp;#8217;&gt;&lt;a name=&quot;fb_share&quot; type=&quot;box_count&quot; href=&quot;http://www.facebook.com/sharer.php&quot;&gt;Share&lt;/a&gt;&lt;script src=&quot;http://static.ak.fbcdn.net/connect.php/js/FB.Share&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;&lt;/div&gt;&lt;/span&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;div class=&amp;#8217;sbutton&amp;#8217;&gt;&lt;/span&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;a class=&amp;#8217;addthis_button_more at300b&amp;#8217; href=&amp;#8217;#&amp;#8217; title=&amp;#8217;view more services&amp;#8217;&gt;&lt;center&gt;&lt;h4&gt;&lt;b&gt;More&lt;/b&gt;&lt;/h4&gt;&lt;/center&gt;&lt;/a&gt;&lt;/span&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;/div&gt;&lt;/span&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;script src=&amp;#8217;http://s7.addthis.com/js/250/addthis_widget.js&amp;#8217; type=&amp;#8217;text/javascript&amp;#8217;/&gt;&lt;/span&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;/div&gt;&lt;/span&gt; &lt;/p&gt; &lt;/blockquote&gt; &lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt; &lt;/div&gt; &lt;div class=&quot;separator&quot; style=&quot;clear: both; display: inline !important;&quot;&gt; &lt;/div&gt; &lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt; &lt;span style=&quot;font-family: inherit;&quot;&gt;Then Click on &quot;Save&quot; button.&lt;/span&gt; &lt;/div&gt; &lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt; &lt;span style=&quot;font-family: inherit;&quot;&gt;Your result will be like this.&lt;/span&gt; &lt;/div&gt; &lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt; &lt;a href=&quot;//1.bp.blogspot.com/-ksF2mK4sGjA/TzSfDoDnnzI/AAAAAAAAAeI/tK2QoBRVpWk/s1600/share.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;200&quot; src=&quot;//1.bp.blogspot.com/-ksF2mK4sGjA/TzSfDoDnnzI/AAAAAAAAAeI/tK2QoBRVpWk/s200/share.png&quot; width=&quot;34&quot; /&gt;&lt;/span&gt;&lt;/a&gt; &lt;/div&gt; &lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt; &lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;&lt;/span&gt; &lt;/div&gt; &lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt; &lt;span style=&quot;font-family: inherit;&quot;&gt;Note : This share Box contains facebook Like button. if you dont want facebook like button remove these line from the &quot;&lt;b&gt;Content Area&quot;&amp;nbsp;&lt;/b&gt;&lt;/span&gt; &lt;/div&gt; &lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt; &lt;/div&gt; &lt;blockquote class=&quot;tr_bq&quot;&gt; &lt;p&gt; &lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;div id=&quot;fb-root&quot;&gt;&lt;/div&gt;&lt;/span&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;script&gt;(function(d, s, id) {&lt;/span&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;&amp;nbsp; var js, fjs = d.getElementsByTagName(s)[0];&lt;/span&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;&amp;nbsp; if (d.getElementById(id)) return;&lt;/span&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;&amp;nbsp; js = d.createElement(s); js.id = id;&lt;/span&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;&amp;nbsp; js.src = &quot;//connect.facebook.net/en_US/all.js#xfbml=1&amp;appId=&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;&lt;i&gt;&lt;u&gt;Your facebook App Id&lt;/u&gt;&lt;/i&gt;&lt;/span&gt;&quot;;&lt;/span&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;&amp;nbsp; fjs.parentNode.insertBefore(js, fjs);&lt;/span&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;}(document, &amp;#8216;script&amp;#8217;, &amp;#8216;facebook-jssdk&amp;#8217;));&lt;/script&gt;&lt;/span&gt; &lt;/p&gt; &lt;/blockquote&gt; &lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt; &lt;span style=&quot;font-family: inherit;&quot;&gt;and this line too&lt;/span&gt; &lt;/div&gt; &lt;blockquote class=&quot;tr_bq&quot;&gt; &lt;p&gt; &lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-weight: bold;&quot;&gt;&lt;div class=&amp;#8217;sbutton&amp;#8217; id=&amp;#8217;gb&amp;#8217;&gt;&lt;script src=&quot;http://connect.facebook.net/en_US/all.js#xfbml=1&amp;appId=&lt;/span&gt;&lt;/span&gt;&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red; font-family: inherit;&quot;&gt;&lt;i&gt;&lt;u&gt;Your facebook App Id&lt;/u&gt;&lt;/i&gt;&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;font-family: inherit; font-weight: bold;&quot;&gt;&quot;&gt;&lt;/script&gt;&lt;fb:like href=&quot;http://pfogb.blogspot.com&quot; send=&quot;true&quot; layout=&quot;box_count&quot; width=&quot;50&amp;#8243; show_faces=&quot;true&quot; font=&quot;arial&quot;&gt;&lt;/fb:like&gt;&lt;/div&gt;&lt;/span&gt; &lt;/p&gt; &lt;/blockquote&gt;&lt;/div&gt; </code></pre> How To Create A Facebook App https://subinsb.com/tutorial-how-to-create-a-facebook-app/ Tue, 07 Feb 2012 15:34:00 +0000 https://subinsb.com/tutorial-how-to-create-a-facebook-app/ <p style="margin-bottom: 0cm;" align="LEFT"> <span style="color: black;"><span style="font-family: 'Times New Roman';">Facebook App is something every site or app wants. A Facebook App can be used for so many purposes like <strong>Login With Facebook</strong> feature ,for a game on <strong>Facebook</strong> and so many others. Since there are so many Facebook users, it&#8217;s necessary to have a Facebook App for your site. In this post I &#8216;m going to tell you how to create a <strong>Facebook</strong> App.</span></span> </p> <p style="margin-bottom: 0cm;" align="LEFT"> <span style="color: black;"><span style="font-family: 'Times New Roman';">Go toย </span></span><a href="https://developers.facebook.com/apps" target="_blank">https://developers.facebook.com/apps</a><span style="color: black;"><span style="font-family: 'Times New Roman';">ย and click the "Create New App" button from the "Apps" menu on the top :</span></span> </p> <p style="margin-bottom: 0cm;" align="LEFT"> <a href="//lab.subinsb.com/projects/blog/uploads/2012/02/0082.png"><img class="aligncenter size-medium wp-image-2366" alt="0082" src="//lab.subinsb.com/projects/blog/uploads/2012/02/0082-300x79.png" width="300" height="79" /></a> </p> <p style="margin-bottom: 0cm;" align="LEFT"> <p style="margin-bottom: 0cm;" align="LEFT"> The App ย Creation dialog will be opened : </p> <p style="margin-bottom: 0cm; text-align: center;" align="LEFT"> <a href="//lab.subinsb.com/projects/blog/uploads/2012/02/0083.png"><img class="aligncenter size-medium wp-image-2367" alt="0083" src="//lab.subinsb.com/projects/blog/uploads/2012/02/0083-300x156.png" width="300" height="156" /></a> </p> <p style="margin-bottom: 0cm; text-align: center;" align="LEFT"> <p style="margin-bottom: 0cm;" align="LEFT"> <p style="margin-bottom: 0cm;" align="LEFT"> <p style="margin-bottom: 0cm;"> <p style="margin-bottom: 0cm;"> <p style="margin-bottom: 0cm;"> <p style="margin-bottom: 0cm;"> <p style="margin-bottom: 0cm;"> <p style="margin-bottom: 0cm;"> <p> <span style="color: black;"><span style="font-family: 'Times New Roman';">Type your App name in "Display Name".</span></span> </p> <pre><code> &lt;p&gt; &lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: 'Times New Roman';&quot;&gt;It&amp;#8217;s not required to type anything on &quot;App Namespace&quot;. If you are creating a canvas app (App On Facebook), then you should fill this with a name. This make your app accessible on :&lt;/span&gt;&lt;/span&gt; &lt;/p&gt; &lt;pre class=&quot;prettyprint&quot;&gt;&lt;code&gt;https://apps.facebook.com/{namespace}&lt;/code&gt;&lt;/pre&gt; &lt;p&gt; &lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: 'Times New Roman';&quot;&gt;&lt;/span&gt;&lt;/span&gt; &lt;/p&gt; &lt;p&gt; &lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: 'Times New Roman';&quot;&gt;By submitting, you are agreeing to the Facebook Platform Policies.Clickย &lt;strong&gt;Continue&lt;/strong&gt; button.&lt;/span&gt;&lt;/span&gt; &lt;/p&gt; &lt;p style=&quot;margin-bottom: 0cm;&quot;&gt; &lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: 'Times New Roman';&quot;&gt;Your app is being created. After creating, you will be redirected to your app page :&lt;/span&gt;&lt;/span&gt; &lt;/p&gt; &lt;p style=&quot;margin-bottom: 0cm;&quot;&gt; &lt;a href=&quot;//lab.subinsb.com/projects/blog/uploads/2012/02/0084.png&quot;&gt;&lt;img class=&quot;aligncenter size-medium wp-image-2368&quot; alt=&quot;0084&quot; src=&quot;//lab.subinsb.com/projects/blog/uploads/2012/02/0084-300x185.png&quot; width=&quot;300&quot; height=&quot;185&quot; /&gt;&lt;/a&gt; &lt;/p&gt; &lt;p style=&quot;margin-bottom: 0cm;&quot;&gt; &lt;p style=&quot;margin-bottom: 0cm;&quot;&gt; If you want to change settings like adding an image to your app, go to the &quot;Settings&quot; page which you can see on the left side of your app page. &lt;/p&gt; &lt;p&gt; From your main app page you can obtain the Applicationย &lt;strong&gt;IDย &lt;/strong&gt;andย &lt;strong&gt;Applicationย &lt;/strong&gt;&lt;strong&gt;Secretย &lt;/strong&gt;values. You may need to enter your password if you want to see the &quot;App Secret&quot; value. To see it, click on the &quot;Show&quot; button near the &quot;App Secret&quot; input. &lt;/p&gt; </code></pre> How to add Facebook log in button to blogger blog https://subinsb.com/how-to-add-facebook-log-in-button-to-blogger-blog/ Tue, 07 Feb 2012 14:52:00 +0000 https://subinsb.com/how-to-add-facebook-log-in-button-to-blogger-blog/ <div dir="ltr" style="text-align: left;" trbidi="on"> <span style="font-family: inherit;">Now you can see a lot of blog has a <b>Facebook login button</b>.</span><br /><span style="font-family: inherit;">You can also add this to your blog.</span><br /><span style="font-family: inherit;">See an example <a href="http://accounts-subins.hp.af.cm/login.php" >here</a> under <b>Social Login </b>tab.</span><br /><span style="font-family: inherit;"><br /></span><span style="font-family: inherit;">1st step : go to <a href="https://developers.facebook.com/apps" >https://developers.facebook.com/apps</a> and create a new app.</span></p> <div class="separator" style="clear: both;"> <span style="font-family: inherit;"><a href="https://2.bp.blogspot.com/-LiURNxniv_Y/TzEmozSvKZI/AAAAAAAAAZA/urQTL3UoAPs/s1600/fb-1.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://2.bp.blogspot.com/-LiURNxniv_Y/TzEmozSvKZI/AAAAAAAAAZA/urQTL3UoAPs/s1600/fb-1.png" /></a></span> </div> <div class="separator" style="clear: both;"> <span style="font-family: inherit;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span> </div> <div class="separator" style="clear: both; text-align: left;"> <span style="font-family: inherit;">Type your &nbsp;App name in <b>App Display Name</b>. You don&#8217;t need to type anything on <b>App Namespace.</b></span> </div> <div class="separator" style="clear: both; text-align: left;"> </div> <div style="text-align: left;"> <span style="font-family: inherit;">After typing your app name and after clicked on "<span class="Apple-style-span" style="background-color: white; color: #666666; font-size: 11px; font-weight: bold; line-height: 14px;">I agree to the&nbsp;</span><a href="https://developers.facebook.com/policy" style="background-color: white; color: #3b5998; cursor: pointer; font-size: 11px; font-weight: bold; line-height: 14px; text-align: left; text-decoration: none;" >Facebook Platform Policies.</a>" &nbsp;click <b>Continue</b> button.</span> </div> <div> <span style="font-family: inherit;"><br /></span> </div> <div> <span style="font-family: inherit;">Now you should see a new page like this.</span> </div> <div class="separator" style="clear: both;"> <span style="font-family: inherit;"><a href="//4.bp.blogspot.com/-d3c-24Qm8L8/TzErEFQs4CI/AAAAAAAAAZY/jBU0l4KDoD0/s1600/fb2.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="//4.bp.blogspot.com/-d3c-24Qm8L8/TzErEFQs4CI/AAAAAAAAAZY/jBU0l4KDoD0/s1600/fb2.png" /></a></span> </div> <div class="separator" style="clear: both;"> <span style="font-family: inherit;"><br /></span> </div> <div class="separator" style="clear: both;"> <span style="font-family: inherit;">Type the required information and click on <img border="0" src="//3.bp.blogspot.com/-ULMIe2OzLm4/TzErcv_ZtgI/AAAAAAAAAZg/Gs8k64IhV3w/s1600/fb3.png" style="width:200px !important;" height="26" width="200" />&nbsp;button</span> </div> <div class="separator" style="clear: both;"> <span style="font-family: inherit;"><br /></span> </div> <div class="separator" style="clear: both;"> <span style="font-family: inherit;"><br /></span> </div> <div class="" style="clear: both;"> <span style="font-family: inherit;">2nd step :&nbsp;<span class="Apple-style-span" style="background-color: white; color: #333333; font-size: 14px; line-height: 19px;">Go to&nbsp;</span><b style="background-color: white; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 14px; line-height: 19px; text-align: -webkit-auto;">Template</b><span class="Apple-style-span" style="background-color: white; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 14px; line-height: 19px; text-align: -webkit-auto;">/</span><b style="background-color: white; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 14px; line-height: 19px; text-align: -webkit-auto;">Design</b><span class="Apple-style-span" style="background-color: white; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 14px; line-height: 19px; text-align: -webkit-auto;">&nbsp;>&nbsp;</span><b style="background-color: white; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 14px; line-height: 19px; text-align: -webkit-auto;">Edit HTML</b><a href="//3.bp.blogspot.com/-nOZNaCL7tLs/TzEsuTdDPNI/AAAAAAAAAZs/MgoINsJjYEk/s1600/fb4.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em; text-align: center;"><img border="0" src="//3.bp.blogspot.com/-nOZNaCL7tLs/TzEsuTdDPNI/AAAAAAAAAZs/MgoINsJjYEk/s1600/fb4.png" height="18" width="93" /></a></span> </div> <div class="" style="clear: both;"> <span style="font-family: inherit;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span> </div> <div class="separator" style="clear: both;"> <span style="font-family: inherit;">Paste this code below <b><html</b> text:</span> </div> <div> <blockquote class="tr_bq"> <p> <span style="font-family: inherit;">xmlns:fb="http://ogp.me/ns/fb#"</span> </p> </blockquote> <pre><code>&lt;p&gt; &lt;span style=&quot;font-family: inherit;&quot;&gt;Example:&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt; &lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt; &lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;a href=&quot;https://2.bp.blogspot.com/-z5_XrYguhlE/TzExTRIgWGI/AAAAAAAAAac/v0t_0Qc2p_M/s1600/fb9.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://2.bp.blogspot.com/-z5_XrYguhlE/TzExTRIgWGI/AAAAAAAAAac/v0t_0Qc2p_M/s1600/fb9.png&quot; /&gt;&lt;/a&gt;&lt;/span&gt; &lt;/div&gt; &lt;div&gt; &lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;&lt;/span&gt; &lt;/div&gt; &lt;div&gt; &lt;span style=&quot;font-family: inherit;&quot;&gt;3rd step : Go to &lt;b style=&quot;background-color: white; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 14px; line-height: 19px; text-align: -webkit-auto;&quot;&gt;Blogger &gt; Layout&lt;/b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;background-color: white; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 14px; line-height: 19px; text-align: -webkit-auto;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt; &lt;/div&gt; &lt;div&gt; &lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;background-color: white; color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 14px; line-height: 19px; text-align: -webkit-auto;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt; &lt;/div&gt; &lt;p&gt; &lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;background-color: white; color: #333333; font-size: 14px; line-height: 19px;&quot;&gt;Click on&lt;/span&gt;&lt;a href=&quot;//3.bp.blogspot.com/-dgJ1CCw0N3I/TzEvAoOnHGI/AAAAAAAAAaA/4AWaRv9zNwI/s1600/fb6.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;//3.bp.blogspot.com/-dgJ1CCw0N3I/TzEvAoOnHGI/AAAAAAAAAaA/4AWaRv9zNwI/s1600/fb6.png&quot; height=&quot;29&quot; width=&quot;230&quot; /&gt;&lt;/a&gt;button.&lt;/span&gt; &lt;/p&gt; &lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt; &lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;&lt;/span&gt; &lt;/div&gt; &lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt; &lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;/span&gt; &lt;/div&gt; &lt;p&gt; &lt;span style=&quot;font-family: inherit;&quot;&gt;Select &amp;nbsp;HTML/JavaScript:&lt;/span&gt; &lt;/p&gt; &lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt; &lt;a href=&quot;//3.bp.blogspot.com/-_gbP2lRSQAU/TzEvXRJvIxI/AAAAAAAAAaI/6OYFfBP_WKI/s1600/fb7.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;//3.bp.blogspot.com/-_gbP2lRSQAU/TzEvXRJvIxI/AAAAAAAAAaI/6OYFfBP_WKI/s1600/fb7.png&quot; height=&quot;102&quot; width=&quot;436&quot; /&gt;&lt;/a&gt; &lt;/div&gt; &lt;div class=&quot;&quot; style=&quot;clear: both;&quot;&gt; &lt;span style=&quot;font-family: inherit;&quot;&gt;Paste this in the &lt;b&gt;content&lt;/b&gt; area:&lt;/span&gt; &lt;/div&gt; &lt;blockquote class=&quot;tr_bq&quot;&gt; &lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt; &lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;script&gt;(function(d, s, id) {&lt;/span&gt; &lt;/div&gt; &lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt; &lt;span style=&quot;font-family: inherit;&quot;&gt;&amp;nbsp; var js, fjs = d.getElementsByTagName(s)[0];&lt;/span&gt; &lt;/div&gt; &lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt; &lt;span style=&quot;font-family: inherit;&quot;&gt;&amp;nbsp; if (d.getElementById(id)) return;&lt;/span&gt; &lt;/div&gt; &lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt; &lt;span style=&quot;font-family: inherit;&quot;&gt;&amp;nbsp; js = d.createElement(s); js.id = id;&lt;/span&gt; &lt;/div&gt; &lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt; &lt;span style=&quot;font-family: inherit;&quot;&gt;&amp;nbsp; js.src = &amp;#8216;http://connect.facebook.net/en_US/all.js?xfbml=1&amp;appId=&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;&lt;b&gt;&lt;i&gt;&lt;u&gt;YOUR APP ID&lt;/u&gt;&lt;/i&gt;&lt;/b&gt;&lt;/span&gt;&amp;nbsp;&amp;quot;&amp;#39&amp;#8242;;&lt;/span&gt; &lt;/div&gt; &lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt; &lt;span style=&quot;font-family: inherit;&quot;&gt;&amp;nbsp; fjs.parentNode.insertBefore(js, fjs);&lt;/span&gt; &lt;/div&gt; &lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt; &lt;span style=&quot;font-family: inherit;&quot;&gt;}(document, &amp;#39;script&amp;#39;, &amp;#39;facebook-jssdk&amp;#39;));&lt;/script&gt;&lt;/span&gt; &lt;/div&gt; &lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt; &lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;div class=&quot;fb-login-button&quot; data-show-faces=&quot;true&quot; data-width=&quot;200&amp;#8243; data-max-rows=&quot;1&amp;#8243;&gt;&lt;/div&gt;&lt;/span&gt; &lt;/div&gt; &lt;/blockquote&gt; &lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt; &lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;&lt;/span&gt; &lt;/div&gt; &lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt; &lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;a href=&quot;//4.bp.blogspot.com/-pccHyyinKZU/TzE9Gq9DHhI/AAAAAAAAAao/xYZ1vmXgPKU/s1600/fb9.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;//4.bp.blogspot.com/-pccHyyinKZU/TzE9Gq9DHhI/AAAAAAAAAao/xYZ1vmXgPKU/s1600/fb9.png&quot; /&gt;&lt;/a&gt;&lt;/span&gt; &lt;/div&gt; &lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt; &lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;&lt;/span&gt; &lt;/div&gt; &lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt; &lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;&lt;/span&gt; &lt;/div&gt; &lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt; &lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;Now it&amp;#8217;s finished you will see your Facebook log in button in your blog&lt;/span&gt;.&lt;/span&gt; &lt;/div&gt;&lt;/div&gt; </code></pre> Tutorials https://subinsb.com/tutorials/ Tue, 07 Feb 2012 13:21:00 +0000 https://subinsb.com/tutorials/ <div dir="ltr" style="text-align: left;" trbidi="on"> From now on I will tell tutorials to help you.&nbsp; </div> Friendshood https://subinsb.com/friendshood/ Sat, 14 Jan 2012 15:10:00 +0000 https://subinsb.com/friendshood/ <div dir="ltr" style="text-align: left;" trbidi="on"> Friendshood is here!!!<br />A place to share links, thoughts, ideas etc..<br />Go to http://www.friendshood.blogspot.com </div> India vs Australia https://subinsb.com/india-vs-australia/ Wed, 28 Dec 2011 04:36:00 +0000 https://subinsb.com/india-vs-australia/ <div dir="ltr" style="text-align: left;" trbidi="on"> <div style="text-align: center;"> <span class="Apple-style-span" style="font-size: x-large;"><u>2nd Innings</u></span> </div> <div style="text-align: left;"> Australia : 72/4 (22.4 Over) </div> <div style="text-align: left;"> <span class="Apple-style-span" style="-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: #bee9f8; color: #5c6467; font-family: Arial, Helvetica, sans-serif; font-size: x-small; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 11px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;"><span class="Apple-style-span" style="color: #000099; font-weight: bold; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">Over 22.4</span>&nbsp;<span style="color: #0033cc; font-size: 11px; font-weight: bold; line-height: 11px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">Z Khan</span>&nbsp;to&nbsp;<span style="color: #339900; font-size: 11px; font-weight: bold; line-height: 11px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">MEK Hussey</span>, no runs<span style="font-size: 11px; font-weight: normal; line-height: 11px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"></span>,&nbsp;</span><span class="Apple-style-span" style="-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: #bee9f8; color: #5c6467; font-family: Arial, Helvetica, sans-serif; font-size: x-small; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 11px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;">gets forward and drags his cover drive towards mid on.</span> </div> </div> FriendsHood https://subinsb.com/friendshood-2/ Wed, 28 Dec 2011 03:53:00 +0000 https://subinsb.com/friendshood-2/ <div dir="ltr" style="text-align: left;" trbidi="on"> I created a blog to share links,thoughts,Ideas etc&#8230;. You can see that blog Just go to this <a href="http://www.friendshood.blogspot.com/" >link</a></p> <p> </div> Virender Sehwag 219 (149 balls) vs West Indies https://subinsb.com/virender-sehwag-219-149-balls-vs-west-indies/ Tue, 13 Dec 2011 04:20:00 +0000 https://subinsb.com/virender-sehwag-219-149-balls-vs-west-indies/ <div dir="ltr" style="text-align: left;" trbidi="on"> Indian Cricket Player Virender Sehwag scored 219 in just 149 balls vs West Indies</p> <div> Here is the highlights </div> <div class="separator" style="clear: both; text-align: center;"> </div> <div> <span class="Apple-style-span" style="color: #333333; font-family: arial, sans-serif; font-size: 13px; line-height: 18px;">Here are some Records By Viru ๐Ÿ™‚ ๐Ÿ™‚</span><br style="color: #333333; font-family: arial, sans-serif; font-size: 13px; line-height: 18px;" /><br style="color: #333333; font-family: arial, sans-serif; font-size: 13px; line-height: 18px;" /><span class="Apple-style-span" style="color: #333333; font-family: arial, sans-serif; font-size: 13px; line-height: 18px;">*Highest score in ODI&#8217;s&nbsp;</span><br style="color: #333333; font-family: arial, sans-serif; font-size: 13px; line-height: 18px;" /><br style="color: #333333; font-family: arial, sans-serif; font-size: 13px; line-height: 18px;" /><span class="Apple-style-span" style="color: #333333; font-family: arial, sans-serif; font-size: 13px; line-height: 18px;">*Fastest 200 in ODI&#8217;s&nbsp;</span><br style="color: #333333; font-family: arial, sans-serif; font-size: 13px; line-height: 18px;" /><br style="color: #333333; font-family: arial, sans-serif; font-size: 13px; line-height: 18px;" /><span class="Apple-style-span" style="color: #333333; font-family: arial, sans-serif; font-size: 13px; line-height: 18px;">*Fastest ODI century by any Indian (60 balls)</span><br style="color: #333333; font-family: arial, sans-serif; font-size: 13px; line-height: 18px;" /><br style="color: #333333; font-family: arial, sans-serif; font-size: 13px; line-height: 18px;" /><span class="Apple-style-span" style="color: #333333; font-family: arial, sans-serif; font-size: 13px; line-height: 18px;">*Virender Sehwag is the first ODI batsman in Cricket History to score two 170+ in a calender year&#8230;.</span><br style="color: #333333; font-family: arial, sans-serif; font-size: 13px; line-height: 18px;" /><br style="color: #333333; font-family: arial, sans-serif; font-size: 13px; line-height: 18px;" /><span class="Apple-style-span" style="color: #333333; font-family: arial, sans-serif; font-size: 13px; line-height: 18px;">*Fastest ever triple hundred by any batsman in test cricket history (278 balls)</span><br style="color: #333333; font-family: arial, sans-serif; font-size: 13px; line-height: 18px;" /><br style="color: #333333; font-family: arial, sans-serif; font-size: 13px; line-height: 18px;" /><span class="Apple-style-span" style="color: #333333; font-family: arial, sans-serif; font-size: 13px; line-height: 18px;">*Second fastest double century in test cricket by any player (168 balls)</span><br style="color: #333333; font-family: arial, sans-serif; font-size: 13px; line-height: 18px;" /><br style="color: #333333; font-family: arial, sans-serif; font-size: 13px; line-height: 18px;" /><span class="Apple-style-span" style="color: #333333; font-family: arial, sans-serif; font-size: 13px; line-height: 18px;">*Highest number of double century scores by any Indian (6)</span><br style="color: #333333; font-family: arial, sans-serif; font-size: 13px; line-height: 18px;" /><br style="color: #333333; font-family: arial, sans-serif; font-size: 13px; line-height: 18px;" /><span class="Apple-style-span" style="color: #333333; font-family: arial, sans-serif; font-size: 13px; line-height: 18px;">*1 out of only 3 players in test cricket history to score 2 triple centuries in career (309 and 319)</span><br style="color: #333333; font-family: arial, sans-serif; font-size: 13px; line-height: 18px;" /><br style="color: #333333; font-family: arial, sans-serif; font-size: 13px; line-height: 18px;" /><span class="Apple-style-span" style="color: #333333; font-family: arial, sans-serif; font-size: 13px; line-height: 18px;">*Highest batting strike rate by an Indian player in odi cricket (103.6)</span><br style="color: #333333; font-family: arial, sans-serif; font-size: 13px; line-height: 18px;" /><br style="color: #333333; font-family: arial, sans-serif; font-size: 13px; line-height: 18px;" /><br style="color: #333333; font-family: arial, sans-serif; font-size: 13px; line-height: 18px;" /><span class="Apple-style-span" style="color: #333333; font-family: arial, sans-serif; font-size: 13px; line-height: 18px;">VIRENDER SEHWAG &#8211; You are the man !! ๐Ÿ™‚</span><br style="color: #333333; font-family: arial, sans-serif; font-size: 13px; line-height: 18px;" /><br style="color: #333333; font-family: arial, sans-serif; font-size: 13px; line-height: 18px;" /><span class="Apple-style-span" style="color: #333333; font-family: arial, sans-serif; font-size: 13px; line-height: 18px;">India scored 400+ runs in ODI&#8217;s for 4 times&#8230;.</span><br style="color: #333333; font-family: arial, sans-serif; font-size: 13px; line-height: 18px;" /><br style="color: #333333; font-family: arial, sans-serif; font-size: 13px; line-height: 18px;" /><span class="Apple-style-span" style="color: #333333; font-family: arial, sans-serif; font-size: 13px; line-height: 18px;">1) 413/5 against Bermuda in 2007- Sehwag scored 115</span><br style="color: #333333; font-family: arial, sans-serif; font-size: 13px; line-height: 18px;" /><br style="color: #333333; font-family: arial, sans-serif; font-size: 13px; line-height: 18px;" /><span class="Apple-style-span" style="color: #333333; font-family: arial, sans-serif; font-size: 13px; line-height: 18px;">2) 414/7 against Srilanka in 2009 &#8211; Sehwag scored 146</span><br style="color: #333333; font-family: arial, sans-serif; font-size: 13px; line-height: 18px;" /><br style="color: #333333; font-family: arial, sans-serif; font-size: 13px; line-height: 18px;" /><span class="Apple-style-span" style="color: #333333; font-family: arial, sans-serif; font-size: 13px; line-height: 18px;">3) 401/3 against SA in 2010 &#8211; Sehwag scored 9</span><br style="color: #333333; font-family: arial, sans-serif; font-size: 13px; line-height: 18px;" /><br style="color: #333333; font-family: arial, sans-serif; font-size: 13px; line-height: 18px;" /><span class="Apple-style-span" style="color: #333333; font-family: arial, sans-serif; font-size: 13px; line-height: 18px;">3) 418/5 against WI in 2011- Sehwag scored 219&#8230; This is Sehwag !!</span> </div> </div> Play free Online Games https://subinsb.com/play-free-online-games/ Wed, 23 Nov 2011 12:27:00 +0000 https://subinsb.com/play-free-online-games/ <div dir="ltr" style="text-align: left;" trbidi="on"> HI Everybody Like 2 play Games???? If U want 2 play Go to this blog I created&nbsp;<a href="http://www.freeonlinegamesinblog.blogspot.com/">http://www.freeonlinegamesinblog.blogspot.com/</a>&nbsp;Enjoy&#8230;&#8230;.. </div> See our blog in Mobile https://subinsb.com/see-our-blog-in-mobile/ Sun, 13 Nov 2011 09:51:00 +0000 https://subinsb.com/see-our-blog-in-mobile/ <p>Our Blog is fully integrated with Mobile. You can see this blog in your Mobile. Simply go the address <a href="https://www.sag-3.blogspot.com">www.sag-3.blogspot.com</a> The blog will be in suitable for your mobile. Try it.</p> Please see my other blogs and youTube channel https://subinsb.com/please-see-my-other-blogs-and-youtube-channel/ Sun, 13 Nov 2011 04:37:00 +0000 https://subinsb.com/please-see-my-other-blogs-and-youtube-channel/ <p>Donโ€™t forget to check my other blogs and my YouTube Channel<br> <a href="https://www.simsuteam.blogspot.com">www.simsuteam.blogspot.com</a><br> <a href="https://www.subinpictures.blogspot.com">www.subinpictures.blogspot.com</a> ย  ย  ย  ย  ย  ย  ย  ย  ย  ย  ย  ย  ย www.youtube.com/subins2000<br> <a href="https://www.gadgetsandtechnology1.blogspot.com">www.gadgetsandtechnology1.blogspot.com</a></p> TOM AND JERRY IN LOVE STORY-SUBIN SIBY https://subinsb.com/tom-and-jerry-in-love-story-subin-siby/ Sun, 10 Jul 2011 10:07:00 +0000 https://subinsb.com/tom-and-jerry-in-love-story-subin-siby/ <div dir="ltr" style="text-align: left;" trbidi="on"> <div class="separator" style="clear: both; text-align: center;"> </div> </div> Taste Testing Without Smell https://subinsb.com/taste-testing-without-smell/ Fri, 22 Apr 2011 13:56:00 +0000 https://subinsb.com/taste-testing-without-smell/ <div dir="ltr" style="text-align: left;" trbidi="on"> <span class="Apple-style-span" style="color: #444444; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18px;"></span></p> <h3 class="post-title entry-title" style="color: #444444; font: normal normal bold 22px/normal Arial, Tahoma, Helvetica, FreeSans, sans-serif; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; position: relative;"> Taste Testing Without Smell </h3> <div class="post-header" style="line-height: 1.6; margin-bottom: 1em; margin-left: 0px; margin-right: 0px; margin-top: 0px;"> <div class="post-header-line-1"> </div> </div> <div class="post-body entry-content" id="post-body-2764652920138868021" style="line-height: 1.4; position: relative; width: 326px;"> <div dir="ltr" style="text-align: left;" trbidi="on"> <div align="center" style="text-align: center;"> <span class="style3style23"><b><span style="font-family: Arial;">Taste Testing Without Smell</span></b></span><b><span style="font-family: Arial;"></span></b> </div> <pre><code> &lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt; &lt;/div&gt; &lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt; We all know that some foods taste better than others but what gives us the ability to experience all these unique flavours? This simple experiment shows that there&amp;#8217;s a lot more to taste than you might have first thought. &lt;/div&gt; &lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt; &lt;strong&gt;What you&amp;#8217;ll need:&lt;/strong&gt; &lt;/div&gt; &lt;ul style=&quot;line-height: 1.4; list-style-image: initial; list-style-position: initial; list-style-type: disc; margin-bottom: 0.5em; margin-left: 0px; margin-right: 0px; margin-top: 0.5em; padding-bottom: 0px; padding-left: 2.5em; padding-right: 2.5em; padding-top: 0px;&quot; type=&quot;disc&quot;&gt; &lt;li class=&quot;MsoNormal&quot; style=&quot;border-bottom-color: transparent; border-bottom-style: none; border-bottom-width: 1px; border-color: initial; border-left-style: none; border-right-style: none; border-top-color: initial; border-top-style: none; border-top-width: initial; border-width: initial; color: #444444; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in; padding-bottom: 0.25em; padding-left: 0px; padding-right: 0px; padding-top: 0.25em; text-indent: 0px;&quot;&gt; &lt;span style=&quot;font-family: Arial; font-size: 10pt;&quot;&gt;A small piece of peeled potato&lt;/span&gt; &lt;/li&gt; &lt;li class=&quot;MsoNormal&quot; style=&quot;border-bottom-color: transparent; border-bottom-style: none; border-bottom-width: 1px; border-color: initial; border-left-style: none; border-right-style: none; border-top-color: rgb(238, 238, 238); border-top-style: none; border-top-width: 1px; border-width: initial; color: #444444; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in; padding-bottom: 0.25em; padding-left: 0px; padding-right: 0px; padding-top: 0.25em; text-indent: 0px;&quot;&gt; A small piece of peeled apple (same shape as the potato so you can&amp;#8217;t tell the difference) &lt;/li&gt; &lt;li class=&quot;MsoNormal&quot; style=&quot;border-bottom-color: initial; border-bottom-style: none; border-bottom-width: initial; border-color: initial; border-left-style: none; border-right-style: none; border-top-color: rgb(238, 238, 238); border-top-style: none; border-top-width: 1px; border-width: initial; color: #444444; margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in; padding-bottom: 0.25em; padding-left: 0px; padding-right: 0px; padding-top: 0.25em; text-indent: 0px;&quot;&gt; &amp;nbsp;&lt;strong&gt;Instructions:&lt;/strong&gt; &lt;/li&gt; &lt;/ul&gt; &lt;ol type=&quot;1&quot;&gt; &lt;li class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-indent: 0px;&quot;&gt; Close your eyes and mix up the piece of potato and the piece of apple so you don&amp;#8217;t know which is which. &lt;/li&gt; &lt;li class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-indent: 0px;&quot;&gt; &lt;shapetype coordsize=&quot;21600,21600&quot; filled=&quot;f&quot; id=&quot;_x0000_t75&quot; o:preferrelative=&quot;t&quot; o:spt=&quot;75&quot; path=&quot;m@4@5l@4@11@9@11@9@5xe&quot; stroked=&quot;f&quot;&gt;&lt;stroke joinstyle=&quot;miter&quot;&gt;&lt;/stroke&gt;&lt;formulas&gt;&lt;f eqn=&quot;if lineDrawn pixelLineWidth 0&quot;&gt;&lt;/f&gt;&lt;f eqn=&quot;sum @0 1 0&quot;&gt;&lt;/f&gt;&lt;f eqn=&quot;sum 0 0 @1&quot;&gt;&lt;/f&gt;&lt;f eqn=&quot;prod @2 1 2&quot;&gt;&lt;/f&gt;&lt;f eqn=&quot;prod @3 21600 pixelWidth&quot;&gt;&lt;/f&gt;&lt;f eqn=&quot;prod @3 21600 pixelHeight&quot;&gt;&lt;/f&gt;&lt;f eqn=&quot;sum @0 0 1&quot;&gt;&lt;/f&gt;&lt;f eqn=&quot;prod @6 1 2&quot;&gt;&lt;/f&gt;&lt;f eqn=&quot;prod @7 21600 pixelWidth&quot;&gt;&lt;/f&gt;&lt;f eqn=&quot;sum @8 21600 0&quot;&gt;&lt;/f&gt;&lt;f eqn=&quot;prod @7 21600 pixelHeight&quot;&gt;&lt;/f&gt;&lt;f eqn=&quot;sum @10 21600 0&quot;&gt;&lt;/f&gt;&lt;/formulas&gt;&lt;path gradientshapeok=&quot;t&quot; o:connecttype=&quot;rect&quot; o:extrusionok=&quot;f&quot;&gt;&lt;/path&gt;&lt;lock aspectratio=&quot;t&quot; v:ext=&quot;edit&quot;&gt;&lt;/lock&gt;&lt;/shapetype&gt;&lt;shape alt=&quot;Does this apple taste like a potato?&quot; id=&quot;_x0000_s1026&quot; o:allowoverlap=&quot;f&quot; style=&quot;height: 115.5pt; left: 0px; margin-left: -9pt; margin-top: 21.55pt; position: absolute; text-align: left; width: 111.6pt; z-index: 1;&quot; type=&quot;#_x0000_t75&quot;&gt;&lt;imagedata o:title=&quot;apple (230 x 238)&quot; src=&quot;file:///C:/DOCUME~1/sim/LOCALS~1/Temp/msoclip1/01/clip_image001.jpg&quot;&gt;&lt;/imagedata&gt;&lt;wrap type=&quot;square&quot;&gt;&lt;/wrap&gt;&lt;/shape&gt;Hold your nose and eat each piece, can you tell the difference? &lt;/li&gt; &lt;/ol&gt; &lt;div class=&quot;style24style1style23&quot; style=&quot;margin-bottom: auto; margin-left: 0in; margin-right: 0in; margin-top: auto;&quot;&gt; &amp;nbsp;&lt;strong&gt;What&amp;#8217;s happening?&lt;/strong&gt; &lt;/div&gt; &lt;div class=&quot;style1style26&quot; style=&quot;margin-bottom: auto; margin-left: 0in; margin-right: 0in; margin-top: auto;&quot;&gt; Holding your nose while tasting the potato and apple makes it hard to tell the difference between the two. Your nose and mouth are connected through the same airway which means that you taste and smell foods at the same time. Your sense of taste can recognize salty, sweet, bitter and sour but when you combine this with your sense of smell you can recognize many other individual &amp;#8216;tastes&amp;#8217;. Take away your smell (and sight) and you limit your brains ability to tell the difference between certain foods. &lt;/div&gt; &lt;div&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> </div> </div> Resume https://subinsb.com/resume/ Mon, 01 Jan 0001 00:00:00 +0000 https://subinsb.com/resume/