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
Calendar cal = Calendar.getInstance(); | |
Intent intent = new Intent(Intent.ACTION_EDIT); | |
intent.setType("vnd.android.cursor.item/event"); | |
intent.putExtra("beginTime", cal.getTimeInMillis()); | |
intent.putExtra("allDay", false); | |
intent.putExtra("rrule", "FREQ=DAILY"); | |
intent.putExtra("endTime", cal.getTimeInMillis()+60*60*1000); | |
intent.putExtra("title", "A Test Event from android app"); | |
startActivity(intent); |
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
// showing alert dialog | |
private void showAlertDialog(int pos, String optionTxt) { | |
final EditText edittext = new EditText(getApplicationContext()); | |
final AlertDialog dialog = new AlertDialog.Builder(this) | |
.setTitle(getString(R.string.optionSpace) + (pos + 1)) | |
.setPositiveButton("Ok", new DialogInterface.OnClickListener() { | |
@Override | |
public void onClick(DialogInterface dialog, int which) { | |
System.out.println("ding! Ok clicked!"); | |
} |
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
// copying | |
public static Object copy(Object orig) { | |
Object obj = null; | |
try { | |
// Write the object out to a byte array | |
ByteArrayOutputStream bos = new ByteArrayOutputStream(); | |
ObjectOutputStream out = new ObjectOutputStream(bos); | |
out.writeObject(orig); | |
out.flush(); | |
out.close(); |
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 generateRandomPassword(): String { | |
val chars = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" | |
var passWord = "" | |
for (i in 0..31) { | |
passWord += chars[Math.floor(Math.random() * chars.length).toInt()] | |
} | |
return passWord | |
} |
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
print ('top level in one.py') | |
def matter(): | |
print ('this is matter() in one.py') | |
if __name__ == '__main__': | |
print("one.py is being run directly and __name__ is : ", __name__) | |
matter() |
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
// Java code | |
BufferedReader br = null; | |
br = new BufferedReader(new InputStreamReader(assetManager.open(actualFilename))); | |
String line; | |
ArrayList<String> labels = new ArrayList<String>(); | |
while ((line = br.readLine()) != null) { | |
labels.add(line); | |
} | |
br.close(); |
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
Hands dirty with Python Numpy arrays |
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
# 't' is [[[1, 1, 1], [2, 2, 2]], [[3, 3, 3], [4, 4, 4]]] | |
shape(t) ==> [2, 2, 3] | |
# 't' is [[[1, 1, 1], [2, 2, 2]], [[3, 3, 3], [4, 4, 4]]]] | |
size(t) ==> 12 | |
# 't' is [[[1, 1, 1], [2, 2, 2]], [[3, 3, 3], [4, 4, 4]]] | |
# shape of tensor 't' is [2, 2, 3] | |
rank(t) ==> 3 | |
Note: The rank of a tensor is not the same as the rank of a matrix. |
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
##Big O notations - of algorithms | |
Big O describes the worst case scenario, can be used to define execution time or space used (e.g. in memory or on disk) by an algorithm. | |
//////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
O(1) | |
executes in same time or space regardless of size of the input data | |
vals = [None,'jack','and','jill'] |
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
package com.example.demo | |
import android.support.v7.app.AppCompatActivity | |
import android.os.Bundle | |
import kotlinx.coroutines.experimental.* | |
class MainActivity : AppCompatActivity() { | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) |
OlderNewer