Skip to content

Instantly share code, notes, and snippets.

View nrworld's full-sized avatar

Nikhil Raj nrworld

  • PA
  • 21:20 (UTC -04:00)
View GitHub Profile
@nrworld
nrworld / gist:55b70075543fc48513052d24944c1f4a
Created August 30, 2020 18:00
Install Brave in silent mode on AWS windows instance using user data
<powershell>
$LocalTempDir = $env:TEMP; $BraveInstaller = "BraveBrowserSetup.exe"; (new-object System.Net.WebClient).DownloadFile('https://brave-browser-downloads.s3.brave.com/latest/BraveBrowserSilentSetup.exe', "$LocalTempDir\$BraveInstaller"); & "$LocalTempDir\$BraveInstaller";
</powershell>
@nrworld
nrworld / Process stream in chunks
Last active January 1, 2020 14:08
Process stream in chunks
@Test
public void testStreamProcessing() {
List<Integer> finalArray = new ArrayList<>();
Spliterator<Integer> split = IntStream.rangeClosed(1, 33).spliterator();
while (true) {
List<Integer> chunk = new ArrayList<>(10);
for (int i = 0; i < 10 && split.tryAdvance(chunk::add); i++) {
}
if (chunk.isEmpty()) break;
@nrworld
nrworld / clean_code.md
Created May 20, 2019 01:28 — forked from wojteklu/clean_code.md
Summary of 'Clean code' by Robert C. Martin

Code is clean if it can be understood easily – by everyone on the team. Clean code can be read and enhanced by a developer other than its original author. With understandability comes readability, changeability, extensibility and maintainability.


General rules

  1. Follow standard conventions.
  2. Keep it simple stupid. Simpler is always better. Reduce complexity as much as possible.
  3. Boy scout rule. Leave the campground cleaner than you found it.
  4. Always find root cause. Always look for the root cause of a problem.

Design rules

@nrworld
nrworld / gist:f8875be64087c85c9718ec5bb6d34ab9
Created April 23, 2018 16:42
Cleanup old brew formula's
## Run the following on commandline and watch it clean your disk
p=`brew ls --versions | awk '{ print $1 }'`
for pack in $p
do
brew cleanup $pack
done;