Skip to content

Instantly share code, notes, and snippets.

@nipunsadvilkar
nipunsadvilkar / Different_style_guide_python.md
Created March 23, 2017 07:10
What is the standard Python docstring format?

Formats

Python docstrings can be written following several formats as the other posts showed. However the default Sphinx docstring format was not mentioned and is based on reStructuredText (reST). You can get some information about the main formats in that tuto.

Note that the reST is recommended by the PEP 287

There follows the main used formats for docstrings.

- Epytext

@ljharb
ljharb / array_iteration_thoughts.md
Last active April 29, 2024 17:13
Array iteration methods summarized

Array Iteration

https://gist.github.com/ljharb/58faf1cfcb4e6808f74aae4ef7944cff

While attempting to explain JavaScript's reduce method on arrays, conceptually, I came up with the following - hopefully it's helpful; happy to tweak it if anyone has suggestions.

Intro

JavaScript Arrays have lots of built in methods on their prototype. Some of them mutate - ie, they change the underlying array in-place. Luckily, most of them do not - they instead return an entirely distinct array. Since arrays are conceptually a contiguous list of items, it helps code clarity and maintainability a lot to be able to operate on them in a "functional" way. (I'll also insist on referring to an array as a "list" - although in some languages, List is a native data type, in JS and this post, I'm referring to the concept. Everywhere I use the word "list" you can assume I'm talking about a JS Array) This means, to perform a single operation on the list as a whole ("atomically"), and to return a new list - thus making it mu

@jmcarp
jmcarp / forceDownload.js
Created March 1, 2014 15:35
Forcing a file download in JavaScript
function forceDownload(href) {
var anchor = document.createElement('a');
anchor.href = href;
anchor.download = href;
document.body.appendChild(anchor);
anchor.click();
}
@alterakey
alterakey / ClientActivity.java
Created November 14, 2012 12:21
Android NIO experiment
package com.gmail.altakey.nio;
import android.app.Activity;
import android.os.Bundle;
import android.os.AsyncTask;
import java.nio.*;
import java.nio.channels.SocketChannel;
import java.net.InetAddress;
import java.net.InetSocketAddress;