This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
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)] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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])); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val xmlSerializer = Xml.newSerializer() | |
val writer = StringWriter() | |
xmlSerializer.setOutput(writer) | |
xmlSerializer.startDocument("UTF-8", false) | |
xmlSerializer.startTag("", "Movies") | |
xmlSerializer.startTag("", "row") | |
xmlSerializer.attribute("", "no", "1") | |
xmlSerializer.startTag("", "FL") | |
xmlSerializer.attribute("", "val", "TicketId") | |
xmlSerializer.text("6000000066015") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val xmlSerializer = Xml.newSerializer() | |
val xmlString = xmlSerializer.document { | |
element("Movies") { | |
element("row") { | |
attribute("no", "1") | |
element("FL", "6000000066015") { | |
attribute("val", "TicketId") | |
} | |
element("FL", "Dunkirk") { | |
attribute("val", "MovieName") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<Movies> | |
<row no="1"> | |
<FL val="TicketId">6000000066015</FL> | |
<FL val="MovieName">Dunkirk</FL> | |
<FL val="TimeLog"> | |
<row no="1"> | |
<FL val="date">23/01/2018</FL> | |
<FL val="startTime">08:00</FL> | |
</row> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun Context.isNetworkConnected(): Boolean { | |
val connectivityManager = getSystemService(Context.CONNECTIVITY_SERVICE) as? ConnectivityManager | |
return connectivityManager?.getNetworkInfo(ConnectivityManager.TYPE_WIFI)?.isConnected!! || | |
connectivityManager.getNetworkInfo(ConnectivityManager.TYPE_MOBILE)?.isConnected!! | |
} |