Skip to content

Instantly share code, notes, and snippets.

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

Sasikanth sasikanth513

👨‍💻
Coding
View GitHub Profile
@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',
[
{
"Author": "stackoverflow",
"url": "https://stackoverflow.com",
"format": "html",
"tips": [
{
"title": "What is the difference between "px", "dip", "dp" and "sp"?",
"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": "What does the &quot;yield&quot; 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": "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": "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 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
[
{
key: 'git',
version: 1
},
{
key: 'js',
version: 1
},
{
[
{
key: 'git',
version: 1
},
{
key: 'js',
version: 1
},
{
@sasikanth513
sasikanth513 / horizontal scroll
Created July 22, 2018 05:37
Mac os swift app to add horizontal scroll to the text view
class ViewController: NSViewController {
@IBOutlet weak var scrollView: NSScrollView!
@IBOutlet var textView: NSTextView!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
@sasikanth513
sasikanth513 / mac-screenshot.md
Created September 26, 2018 04:00
Change default screenshot folder in mac
defaults write com.apple.screencapture location .

Replace . with your path