Skip to content

Instantly share code, notes, and snippets.

@dhruvr
dhruvr / File.go
Last active October 9, 2019 17:53
File type in go
// os pkg contains lot of things lets focus on the Close method
//under is File struct which has embedded *file
//From https://golang.org/src/os/types.go?s=369:411#L6
type File struct {
*file // os specific
}
//Here file implements Closer interface from https://golang.org/src/io/io.go?s=4043:4083#L88
//From https://golang.org/src/os/file_unix.go?s=7043:7071#L219
@dhruvr
dhruvr / CloserInterface.go
Created September 21, 2019 21:25
Closer interface
type Closer interface {
Close() error
}
@dhruvr
dhruvr / JavaUsingGradle.java
Last active September 4, 2019 05:52
Using gradle for dependencies
import com.google.common.base.Stopwatch;
import java.util.concurrent.TimeUnit;
public class App {
public static void main(String[] args) throws InterruptedException {
Stopwatch stopwatch = Stopwatch.createStarted();
Thread.sleep(100);
@dhruvr
dhruvr / array_iteration_thoughts.md
Created September 28, 2018 05:46 — forked from ljharb/array_iteration_thoughts.md
Array iteration methods summarized

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 much simpler to think about both the old list and the new one, what they contain, and

@dhruvr
dhruvr / redis-no-persistence.conf
Created November 16, 2017 06:36 — forked from ndelitski/redis-no-persistence.conf
redis without persistence config
# Note on units: when memory size is needed, it is possible to specify
# it in the usual form of 1k 5GB 4M and so forth:
#
# 1k => 1000 bytes
# 1kb => 1024 bytes
# 1m => 1000000 bytes
# 1mb => 1024*1024 bytes
# 1g => 1000000000 bytes
# 1gb => 1024*1024*1024 bytes
#
@dhruvr
dhruvr / redis-no-persistence.conf
Created November 16, 2017 06:36 — forked from ndelitski/redis-no-persistence.conf
redis without persistence config
# Note on units: when memory size is needed, it is possible to specify
# it in the usual form of 1k 5GB 4M and so forth:
#
# 1k => 1000 bytes
# 1kb => 1024 bytes
# 1m => 1000000 bytes
# 1mb => 1024*1024 bytes
# 1g => 1000000000 bytes
# 1gb => 1024*1024*1024 bytes
#
@dhruvr
dhruvr / redis-no-persistence.conf
Created November 16, 2017 06:36 — forked from ndelitski/redis-no-persistence.conf
redis without persistence config
# Note on units: when memory size is needed, it is possible to specify
# it in the usual form of 1k 5GB 4M and so forth:
#
# 1k => 1000 bytes
# 1kb => 1024 bytes
# 1m => 1000000 bytes
# 1mb => 1024*1024 bytes
# 1g => 1000000000 bytes
# 1gb => 1024*1024*1024 bytes
#
@dhruvr
dhruvr / gist:04f3ed4a3529a79fab5f12f2182f4695
Created July 4, 2017 14:35 — forked from Frozenfire92/gist:3627e38dc47ca581d6d024c14c1cf4a9
Install Scala and SBT using apt-get on Ubuntu 16.04 or any Debian derivative using apt-get
## Java
sudo apt-get update
sudo apt-get install default-jdk
## Scala
sudo apt-get remove scala-library scala
sudo wget http://scala-lang.org/files/archive/scala-2.12.1.deb
sudo dpkg -i scala-2.12.1.deb
sudo apt-get update
sudo apt-get install scala
@dhruvr
dhruvr / introrx.md
Created June 30, 2017 07:24 — forked from staltz/introrx.md
The introduction to Reactive Programming you've been missing
FFmpeg has been removed from Ubuntu 14.04 and was replaced by Libav. This decision has been reversed so that FFmpeg is available now in Ubuntu 15.04 again, but there is still no official package for 14.04. In this tutorial, I will show you how to install FFmpeg from mc3man ppa. Add the mc3man ppa:
sudo add-apt-repository ppa:mc3man/trusty-media
And confirm the following message by pressing <enter>:
Also note that with apt-get a sudo apt-get dist-upgrade is needed for initial setup & with some package upgrades
More info: https://launchpad.net/~mc3man/+archive/ubuntu/trusty-media
Press [ENTER] to continue or ctrl-c to cancel adding it
Update the package list.