Skip to content

Instantly share code, notes, and snippets.

View nbhusare's full-sized avatar
🏠
Working from home

Neeraj Bhusare nbhusare

🏠
Working from home
View GitHub Profile
@nbhusare
nbhusare / gist:741a10b6cc6dcecc721d636baf66d55f
Created March 8, 2019 07:43
Delete all local branch which have been merged
https://stackoverflow.com/questions/6127328/how-can-i-delete-all-git-branches-which-have-been-merged
@nbhusare
nbhusare / gist:f7adca6da396634cb752aa2f096da87b
Created December 17, 2018 04:39
Display all Git aliases
[alias]
aliases = !git config --get-regexp ^alias\\. | sed -e s/^alias.// -e s/\\ /\\ $(printf \"\\043\")--\\>\\ / | column -t -s $(printf \"\\043\") | sort -k 1
$ git aliases
@nbhusare
nbhusare / ReadFilesFromBundle.java
Last active November 24, 2018 16:43
Eclipse - Reading files from a folder present in a bundle
public static List<File> getFilesFromBundle(final Bundle bundle, final String folderName) {
final List<File> files = Lists.newLinkedList();
final Enumeration<URL> findEntries = bundle.findEntries("/" + folderName, "*", false); // recursive = false
while (findEntries.hasMoreElements()) {
final URL url = findEntries.nextElement();
try {
final URL fileURL = FileLocator.toFileURL(url);
final File file = new File(fileURL.getFile());
files.add(file);
} catch (final IOException e) {
@nbhusare
nbhusare / CreateDatabase.kt
Created October 21, 2018 21:24
Android : Creating database
// Create in-memory database
Room.inMemoryDatabaseBuilder(context, ContactDb.class).build();
// Create file based database
Room.databaseBuilder(context, ContactDb.class, "contact-db").build();
public static final String SCHEME = "content";
public static final String AUTHORITY = "org.nbhusare.contacts";
public static final String CONTENT_PATH = "contacts";
new Uri.Builder().scheme(SCHEME).authority(AUTHORITY).appendPath(CONTENT_PATH).build();
Get PID using "jps -mv"
jstack -l <PID> > dump.txt
Reference - https://intellij-support.jetbrains.com/hc/en-us/articles/206544899-Getting-a-thread-dump-when-IDE-hangs-and-doesn-t-respond
String jvmVersion = System.getProperty("java.vm.specification.version");
if ("1.8".equals(jvmVersion))
/*************************GO-LICENSE-START*********************************
* Copyright 2014 ThoughtWorks, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
final List<Customer> customers = getCustomersFromDb();
IntStream.range(0, customers.size()).forEach(index -> {
print("Index " + index)
print("Customer " + customers.get(index));
}
)
EObject eObject = ieObjectDescription.getEClass().getEPackage().getEFactoryInstance().create(ieObjectDescription.getEClass());