Skip to content

Instantly share code, notes, and snippets.

View Audhil's full-sized avatar
🎯
Focusing

Mohammed Audhil Audhil

🎯
Focusing
View GitHub Profile
@Audhil
Audhil / msg_labels_file.txt
Last active November 21, 2017 10:22
Gist to copy data from csv to .txt
"""
It read files from csv file and separates "labels" and "texts" from it.
"""
import pandas as pd
import os
import numpy as np
import string
def run():
# development way
if __name__ == '__main__':
app.run()
## server on http://127.0.0.1:5000/
## (invisible across the network) won't work on other device, other than development machine
# suggested way
if __name__ == '__main__':
app.run(host='0.0.0.0', port=5000)
@Audhil
Audhil / app(build.gradle)
Created November 26, 2017 17:09
Dependencies of DL4J & ND4J for Android App
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 26
buildToolsVersion '26.0.2'
@Audhil
Audhil / rnn.py
Created December 5, 2017 07:33
RNN_Basic_Demo - counts number of 1's in the binary input
"""
Attempt to understand RNN
url : http://monik.in/a-noobs-guide-to-implementing-rnn-lstm-using-tensorflow/
"""
import numpy as np
from random import shuffle
import tensorflow as tf
# makes 20 digits binary values
train_input = ['{0:020b}'.format(i) for i in range(2 ** 20)]
@Audhil
Audhil / algos
Last active December 7, 2017 18:31
Attempt to learn algorithms in a month
import java.util.Arrays;
// tutorial @ https://www.youtube.com/watch?v=JUOyKSZScW0&index=2&list=PLGLfVvz_LVvReUrWr94U-ZMgjYTQ538nT (bubble sort, binary search)
public class SortingAlgo {
private int[] arrayVals = {10, 9, 8, 7, 6, 5, 4, 3, 2, 1};
// print an array
private void printArray() {
System.out.println("---printing arrays");
for (int i = 0; i < arrayVals.length; i++) {
System.out.println(String.format("---value in array at index %d is %d", i, arrayVals[i]));
@Audhil
Audhil / gist:9dd57bd89cd7879c2df0db4f66739fd7
Created December 9, 2017 13:22
Gist to send email programmatically in Android
Intent iTent = new Intent(Intent.ACTION_VIEW);
StringBuilder subjectStringBuilder = new StringBuilder();
String appVersionName = "1";
try {
appVersionName = getPackageManager().getPackageInfo(getPackageName(), 0).versionName;
} catch (PackageManager.NameNotFoundException e) {
e.printStackTrace();
}
String deviceName = android.os.Build.MANUFACTURER + Constants.BLANK_SPACE + android.os.Build.MODEL;
String androidVersion = "Android " + android.os.Build.VERSION.RELEASE;
@Audhil
Audhil / GeneticAlgo.png
Last active June 29, 2025 08:42
Attempt to understand Genetic algorithm - Guess the password
GeneticAlgo.png
@Audhil
Audhil / gist:dcfa785985c1d93b440c8ba74e5f3330
Created December 18, 2017 18:10
How to fake a network response with Retrofit2?
// step 1 - make a fake response interceptor
class FakeResponseInterceptor : Interceptor {
@Throws(IOException::class)
override fun intercept(chain: Interceptor.Chain): Response? {
val responseString = "{\n" +
"\t\"name\": \"audhil\",\n" +
"\t\"occupation\": \"android developer\"\n" +
"}"
var response: Response? = null
@Audhil
Audhil / gist:2b8256788b5ac1dc135c54ccd718f360
Created December 24, 2017 18:55
SwipeToDelete in RecyclerView - (Android)
private fun initSwipeToDelete() {
ItemTouchHelper(object : ItemTouchHelper.Callback() {
// enable the items to swipe to the left or right
override fun getMovementFlags(recyclerView: RecyclerView,
viewHolder: RecyclerView.ViewHolder): Int =
makeMovementFlags(0, ItemTouchHelper.LEFT or ItemTouchHelper.RIGHT)
override fun onMove(recyclerView: RecyclerView, viewHolder: RecyclerView.ViewHolder,
target: RecyclerView.ViewHolder): Boolean = false
@Audhil
Audhil / AppExtensionFuncs.kt
Last active January 27, 2024 09:48
XML generation with Kotlin extension functions
// XML generation by code
// based on https://www.schibsted.pl/blog/back-end/readable-xml-kotlin-extensions/
fun XmlSerializer.document(docName: String = "UTF-8",
xmlStringWriter: StringWriter = StringWriter(),
init: XmlSerializer.() -> Unit): String {
startDocument(docName, true)
xmlStringWriter.buffer.setLength(0) // refreshing string writer due to reuse
setOutput(xmlStringWriter)
init()
endDocument()