Skip to content

Instantly share code, notes, and snippets.

@rokinmaharjan
rokinmaharjan / Revert git merge
Created December 19, 2019 11:48
Revert git merge
git revert -m 1 <merge commit hash>
@rokinmaharjan
rokinmaharjan / GIT - Delete branches not in remote
Created February 7, 2019 14:10
Delete branches not in remote
git branch --merged >/tmp/merged-branches && nano /tmp/merged-branches && xargs git branch -d </tmp/merged-branches
@rokinmaharjan
rokinmaharjan / .gitignore not working
Last active August 12, 2019 11:18
.gitignore doesn't ignore files included in it
NOTE : First commit your current changes, or you will lose them.
git rm -r --cached .
git add .
git commit -m "fixed untracked files"
@rokinmaharjan
rokinmaharjan / Creating zip using gradle
Created January 14, 2019 09:07
Creating zip using gradle
task buildZip(type: Zip) {
from compileJava
from processResources
into('lib') {
from configurations.compileClasspath
}
}
build.dependsOn buildZip
@rokinmaharjan
rokinmaharjan / dispatcher-servlet.xml
Created December 24, 2018 06:32
Dispatcher servlet config
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc.xsd
http://www.springframework.org/schema/context
@rokinmaharjan
rokinmaharjan / ResponseEntity example
Last active December 11, 2018 06:01
ResponseEntity example
# Method 1
@PostMapping("/users")
public ResponseEntity<List<String>> addUsers() throws IOException {
return ResponseEntity.ok().body(this.userService.addUsers());
}
# Method 2
@DeleteMapping()
@ResponseStatus(HttpStatus.NO_CONTENT)
@rokinmaharjan
rokinmaharjan / Updating nested document in MongoDB - Spring
Created November 28, 2018 09:06
Updating multi-level nested document in MongoDB - Spring
EXAMPLE JSON:
{
"_id": 12345,
"_class": "com.example.ProductRates",
"rates": [
{
"productId": NumberInt(1234),
"rate": 100.0,
"rateCardId": NumberInt(1),
"month": NumberInt(201801)
@rokinmaharjan
rokinmaharjan / Create virtual environment in python
Created September 17, 2018 11:39
Create, activate and deactivate virtual environment in python Raw
### Create virtual environment
python -m virtualenv evn_name
### Activate environment
source env/bin/activate
### Deactivate environment
deactivate
@rokinmaharjan
rokinmaharjan / Base image for ML
Last active October 23, 2018 06:40
Base image for ML
# Build as jupyterhub/singleuser
# Run with the DockerSpawner in JupyterHub
ARG BASE_IMAGE=fusemachinesinc/fusemachines-base-notebook
FROM $BASE_IMAGE
MAINTAINER Fusemachines <info@fusemachines.com>
ADD install_jupyterhub /tmp/install_jupyterhub
ARG JUPYTERHUB_VERSION=master
@rokinmaharjan
rokinmaharjan / Docker commands
Last active February 11, 2019 10:19
Docker commands
1. Show all images
docker images
2. Show all running containers
docker ps
3. Show all running and stopped containers
docker ps -a
4. Run an container