Skip to content

Instantly share code, notes, and snippets.

View sasikanth513's full-sized avatar
👨‍💻
Coding

Sasikanth sasikanth513

👨‍💻
Coding
View GitHub Profile
[
{
"Author": "stackoverflow",
"url": "https://stackoverflow.com",
"format": "html",
"tips": [
{
"title": "What does the "yield" keyword do?",
"body": "<p>To understand what <code>yield</code> does, you must understand what <em>generators</em> are. And before generators come <em>iterables</em>.</p>\n\n<h2>Iterables</h2>\n\n<p>When you create a list, you can read its items one by one. Reading its items one by one is called iteration:</p>\n\n<pre><code>&gt;&gt;&gt; mylist = [1, 2, 3]\n&gt;&gt;&gt; for i in mylist:\n... print(i)\n1\n2\n3\n</code></pre>\n\n<p><code>mylist</code> is an <em>iterable</em>. When you use a list comprehension, you create a list, and so an iterable:</p>\n\n<pre><code>&gt;&gt;&gt; mylist = [x*x for x in range(3)]\n&gt;&gt;&gt; for i in mylist:\n... print(i)\n0\n1\n4\n</code></pre>\n\n<p>Everything you can use \"<code>for... in...</code>\" on is an iterable; <code>lists</code>, <code>strings</code>, files...</p>\n\n<p>These iterables
[
{
"Author": "stackoverflow",
"url": "https://stackoverflow.com",
"format": "html",
"tips": [
{
"title": "What is the difference between &quot;px&quot;, &quot;dip&quot;, &quot;dp&quot; and &quot;sp&quot;?",
"body": "<p>From the <a href=\"http://developer.android.com/guide/topics/resources/more-resources.html#Dimension\" rel=\"noreferrer\">Android Developer Documentation</a>:</p>\n\n<ol>\n<li><blockquote>\n <p><strong>px</strong><br>\n Pixels - corresponds to actual pixels on the screen.</p>\n</blockquote></li>\n<li><blockquote>\n <p><strong>in</strong><br>\n Inches - based on the physical size of the screen.<br>\n 1 Inch = 2.54 centimeters</p>\n</blockquote></li>\n<li><blockquote>\n <p><strong>mm</strong><br>\n Millimeters - based on the physical size of the screen.</p>\n</blockquote></li>\n<li><blockquote>\n <p><strong>pt</strong><br>\n Points - 1/72 of an inch based on the physical size of the screen.</p>\n</blockquote></li>\n<li><blockquote>\n <p><strong>d
[
{
"Author": "stackoverflow",
"url": "https://stackoverflow.com",
"format": "html",
"tips": [
{
"title": "Getting the source directory of a Bash script from within",
"body": "<pre><code>DIR=\"$( cd \"$( dirname \"${BASH_SOURCE[0]}\" )\" &amp;&amp; pwd )\"\n</code></pre>\n\n<p>is a useful one-liner which will give you the full directory name of the script no matter where it is being called from.</p>\n\n<p>It will work as long as the last component of the path used to find the script is not a symlink (directory links are OK). If you also want to resolve any links to the script itself, you need a multi-line solution:</p>\n\n<pre><code>SOURCE=\"${BASH_SOURCE[0]}\"\nwhile [ -h \"$SOURCE\" ]; do # resolve $SOURCE until the file is no longer a symlink\n DIR=\"$( cd -P \"$( dirname \"$SOURCE\" )\" &amp;&amp; pwd )\"\n SOURCE=\"$(readlink \"$SOURCE\")\"\n [[ $SOURCE != /* ]] &amp;&amp; SOURCE=\"$DIR/$SOURCE\" # if $SOURCE was a relative symlink, we need to resolve it relati
[
{
"Author": "stackoverflow",
"url": "https://stackoverflow.com",
"format": "html",
"tips": [
{
"title": "How do JavaScript closures work?",
"body": "<h1>JavaScript closures for beginners</h1>\n\n<blockquote>Submitted by Morris on Tue, 2006-02-21 10:19. Community-edited since.</blockquote>\n\n<h2>Closures are not magic</h2>\n\n<p>This page explains closures so that a programmer can understand them &mdash; using working JavaScript code. It is not for gurus or functional programmers.</p>\n\n<p>Closures are <em>not hard</em> to understand once the core concept is grokked. However, they are impossible to understand by reading any academic papers or academically oriented information about them!</p>\n\n<p>This article is intended for programmers with some programming experience in a mainstream language, and who can read the following JavaScript function:</p>\n\n<p><div class=\"snippet\" data-lang=\"js\" data-hide=\"false\" data-console=\"true\" data-babel=\"false\">\r\n<di
[
{
"Author": "stackoverflow",
"url": "https://stackoverflow.com",
"format": "html",
"tips": [
{
"title": "How to disable text selection highlighting?",
"body": "<p><strong>UPDATE January, 2017:</strong></p>\n\n<p>According to <a href=\"http://caniuse.com/#feat=user-select-none\" rel=\"noreferrer\">Can I use</a>, the <code>user-select</code> is currently supported in all browsers except Internet&nbsp;Explorer 9 and earlier versions (but sadly <em>still</em> needs a vendor prefix).</p>\n\n<hr>\n\n<p>All of the correct CSS variations are:</p>\n\n<p><div class=\"snippet\" data-lang=\"js\" data-hide=\"false\" data-console=\"false\" data-babel=\"false\">\r\n<div class=\"snippet-code\">\r\n<pre class=\"snippet-code-css lang-css prettyprint-override\"><code>.noselect {\r\n -webkit-touch-callout: none; /* iOS Safari */\r\n -webkit-user-select: none; /* Safari */\r\n -khtml-user-select: none; /* Konqueror HTML */\r\n -moz-user-select: none; /* Firefox */\r\n
@sasikanth513
sasikanth513 / git-tips.js
Last active June 16, 2023 13:53
Git Tips
[
{
"Author": "stackoverflow",
"url": "https://stackoverflow.com",
"format": "html",
"tips": [
{
"title": "How to undo the most recent commits in Git?",
"body": "<h3>Undo a commit and redo</h3>\n\n<pre class=\"lang-sh prettyprint-override\"><code>$ git commit -m \"Something terribly misguided\" (1)\n$ git reset HEAD~ (2)\n&lt;&lt; edit files as necessary &gt;&gt; (3)\n$ git add ... (4)\n$ git commit -c ORIG_HEAD (5)\n</code></pre>\n\n<ol>\n<li>This is what you want to undo</li>\n<li>This leaves your working tree (the state of your files on disk) unchanged but undoes the commit and leaves the changes you committed unstaged (so they'll appear as \"Changes not staged for commit\" in <code>git status</code>, and you'll need to add them again before committing). If you <em>only</em> want to <em>add</em> more chan
AllCourses = [
{
url: "devops",
title: 'DEVOPS',
duartion: '(45 hours - 45 days)',
courseHighlights: [
"Ideal for those who are working on build and release system administration and data centers.",
"Laser focused classroom realtime trainings.",
"Placement services."
],
@sasikanth513
sasikanth513 / Javascript ISO country code to country name conversion
Created September 9, 2016 13:35 — forked from maephisto/Javascript ISO country code to country name conversion
ISO 3166-1 alpha-2 country code to country name conversion with a simple Javascript implementation, an array and a function.
var isoCountries = {
'AF' : 'Afghanistan',
'AX' : 'Aland Islands',
'AL' : 'Albania',
'DZ' : 'Algeria',
'AS' : 'American Samoa',
'AD' : 'Andorra',
'AO' : 'Angola',
'AI' : 'Anguilla',
'AQ' : 'Antarctica',