Skip to content

Instantly share code, notes, and snippets.

View kdabir's full-sized avatar
👨‍💻
go git it

Kunal Dabir kdabir

👨‍💻
go git it
View GitHub Profile
@kdabir
kdabir / ClassBasedComponent.js
Last active August 4, 2016 03:44
Creating React Components. Three flavours. Stateless component with only one expression, with multiline expression and with complete class
import React from 'react';
export default class ClassBasedComponent extends React.Component {
constructor(props) {
super(props);
// do something useful
}
componentWillMount() {
import groovy.json.JsonSlurper
def json = new JsonSlurper().parseText("""
{
inline: "json"
}
""")
@kdabir
kdabir / parse_xml.groovy
Created August 2, 2016 16:48
Parse XML
def xml = new XmlSlurper().parseText(xmlText)
@kdabir
kdabir / build.gradle
Last active August 2, 2016 13:55
Glide with idea
plugins {
id "com.appspot.glide-gae" version "0.9.3"
id 'idea'
}
idea {
module {
sourceDirs += file('app')
}
}
@kdabir
kdabir / build.gradle
Created August 2, 2016 13:08
Android enable code coverage
android {
buildTypes {
debug {
testCoverageEnabled = true
}
}
}
@kdabir
kdabir / build.gradle
Created August 2, 2016 13:07
Minimal Android Library (with unit testing support)
apply plugin: 'com.android.library'
android {
compileSdkVersion 22
buildToolsVersion '23.0.2'
}
dependencies {
testCompile 'junit:junit:4.12'
testCompile 'org.mockito:mockito-core:1.10.19'
@kdabir
kdabir / AndroidManifest.xml
Created August 2, 2016 13:06
Minimal Andorid Manifest for Libraries (put it in module/src/main)
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.foo"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="14" />
<application/>
@kdabir
kdabir / jacoco.gradle
Created August 2, 2016 13:04
Enable Code Coverage
apply plugin: 'jacoco'
jacoco {
toolVersion = "0.7.7.201606060606"
reportsDir = file("$buildDir/coverage")
}
jacocoTestReport {
reports {
csv.enabled false
@kdabir
kdabir / pit.gradle
Created August 2, 2016 13:03
Enable mutation testing in java projects
// ** Mutation Testing **
buildscript {
repositories { mavenCentral() }
dependencies { classpath 'info.solidsoft.gradle.pitest:gradle-pitest-plugin:1.1.9' }
}
apply plugin: "info.solidsoft.pitest"
@kdabir
kdabir / es6_semicolon_or_return.js
Last active August 19, 2016 08:03
Use at least one of following - a semicolon to terminate expression or an explicit return keyword.
// In a function foo be careful when you have something like following:
// Doesn't Work - implicit return and no semicolon
const myStr = "hello-world".split('-').join('_')
`${myStr}/`
// Works
const myStr = "hello-world".split('-').join('_');
return `${myStr}/`;