Skip to content

Instantly share code, notes, and snippets.

@pchrysa
pchrysa / SumOfDigits.kt
Created August 2, 2017 21:29
Sum digits of a given number in Kotlin
/*
In mathematics, the digit sum of a given integer is the sum of all its digits (e.g.
the digit sum of 84001 is calculated as 8+4+0+0+1 = 13).
Write a function that will get an integer and will return the digit sum for that integer.
*/
fun main(args: Array<String>) {
sumOfDigits("84001");
}
public interface RetrofitService {
@POST("players")
Call<Profile> registerUser(@Body Registration registration);
}
public abstract class RetrofitCallback<T>
implements Callback<T> {
private static final String TAG = "RetrofitCallback";
Retrofit retrofit;
apply plugin: 'com.android.application'
apply plugin: 'android-apt'
android {
compileSdkVersion versions.compileSdk
buildToolsVersion versions.buildTools
defaultConfig {
applicationId "samples.linhtruong.com.ui_reactive_rxjava_realm"
minSdkVersion versions.minSdk
@alvinthen
alvinthen / opacity.txt
Created July 29, 2016 17:20
Convert opacity values in percentage to hexadecimal
0% - 00
1% - 03
2% - 05
3% - 08
4% - 0A
5% - 0D
6% - 0F
7% - 12
8% - 14
9% - 17
@segunfamisa
segunfamisa / app-module-build.gradle
Last active June 22, 2020 11:43
Using gradle extra properties to manage Android dependency versioning
// app module build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion rootProject.compileSdkVersion
buildToolsVersion rootProject.buildToolsVersion
defaultConfig {
applicationId "com.segunfamisa.gradleextraproperties"
minSdkVersion rootProject.minSdkVersion
targetSdkVersion rootProject.targetSdkVersion
@gauravat16
gauravat16 / ActivityName.java
Last active December 6, 2022 22:54
[Android] Add Context Menu to RecyclerView
//Import Statements
public class ActivityName extends AppCompatActivity {
private RecyclerView mRecyclerView;
private RecyclerView.Adapter mAdapter;
private RecyclerView.LayoutManager mLayoutManager;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@lidemin
lidemin / CustomRecyclerViewAdapter.java
Created July 13, 2016 04:46
AS's live template for custom recyclerview adapter.
public class $objectclass$Adapter extends RecyclerView.Adapter<$objectclass$ViewHolder>{
List<$objectclass$> objList;
private Context context;
private LayoutInflater inflater;
public $objectclass$Adapter(Context context) {
this.context = context;
inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}
@tanyagupta
tanyagupta / program.js
Created December 5, 2015 21:47
FILTERED LS (Exercise 5 of 13)
var fs = require('fs')
var path = require('path')
fs.readdir(process.argv[2], function (err, list) {
list.forEach(function (file) {
if (path.extname(file) === '.' + process.argv[3])
console.log(file)
})
})

Contributing

When contributing to this repository, please first discuss the change you wish to make via issue, email, or any other method with the owners of this repository before making a change.

Please note we have a code of conduct, please follow it in all your interactions with the project.

Pull Request Process

  1. Ensure any install or build dependencies are removed before the end of the layer when doing a