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
// Sort Descending Date | |
tempArray = originalArray.slice(); | |
tempArray.sort(function(a,b){ | |
return new Date(b.date) - new Date(a.date); | |
}); | |
for (i = 0; i < tempArray.length; i++) { | |
console.log(`\t${i + 1}) ${tempArray[i].date} - ${tempArray[i].displayName}`); | |
} |
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
# class builder to save time during 162 toa exam | |
# no gui validation | |
import tkinter as tk | |
from tkinter import Frame, Button, Label, StringVar, messagebox | |
from tkinter.scrolledtext import ScrolledText | |
from tkinter.constants import DISABLED, NORMAL, END, WORD | |
class ClassBuilder(Frame): | |
""" ClassBuilder is a subclass of Frame class """ |
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
def valid_expression(expression: str) -> bool: | |
""" Returns True if string is valid binary expression. False otherwise. | |
- Operand is valid binary digits | |
- Operator is either '!', '&', or '|' | |
- Length of operands is more than 2 digits | |
- Both operands are same length | |
- Expression is in the format of “operand operator operand”, seperated by blanks""" | |
if len(expression.split()) == 3: | |
first, operator, second = expression.split() |
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
<html> | |
<head> | |
<title>HTA a href sub calling</title> | |
<HTA:APPLICATION | |
APPLICATIONNAME="HTA a href sub calling" | |
ID="hta_utility" | |
border = "thin" | |
borderStyle = "tool" | |
caption = "yes" | |
contextMenu = "yes" |
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
#!/usr/bin/env python | |
# Useful if hosting something through a dynamic IP address | |
import dropbox | |
import urllib | |
import re | |
from datetime import datetime | |
from time import sleep |
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
// What to retrive? | |
// | |
// All the Documents in the 'note' Collection | |
// WHERE Document _author is the current logged in user | |
// ORDERBY _creation_date descending | |
// List to hold the notes | |
List<BaasDocument> noteList = new ArrayList<BaasDocument>(); | |
// using pagination and selection |
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
BaasFile oldFile = new BaasFile(); | |
// Fetch the file from server | |
oldFile.fetch(oldFileID, new BaasHandler<BaasFile>() { | |
@Override | |
public void handle(BaasResult<BaasFile> baasResult) { // Successfully fetch file | |
if (baasResult.isSuccess()) { | |
Log.d(TAG, "Received old file"); | |
// Delete the file from server |
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
public static byte[] convertBitmapToByteArray(Bitmap bitmap){ | |
ByteArrayOutputStream stream = new ByteArrayOutputStream(); | |
bitmap.compress(Bitmap.CompressFormat.PNG, 100, stream); | |
return stream.toByteArray(); | |
} |
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
//rescale image | |
public static Bitmap scaleBitmapAndKeepRation(Bitmap TargetBmp,int reqHeightInPixels,int reqWidthInPixels) | |
{ | |
if(TargetBmp.getWidth() >= reqHeightInPixels && TargetBmp.getHeight() >= reqHeightInPixels) { | |
Matrix m = new Matrix(); | |
m.setRectToRect(new RectF(0, 0, TargetBmp.getWidth(), TargetBmp.getHeight()), new RectF(0, 0, reqWidthInPixels, reqHeightInPixels), Matrix.ScaleToFit.CENTER); | |
Bitmap scaledBitmap = Bitmap.createBitmap(TargetBmp, 0, 0, TargetBmp.getWidth(), TargetBmp.getHeight(), m, true); | |
return scaledBitmap; | |
} | |
else |
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
// Resize and Upload a Image file in byteArray to BaasBox | |
// try catch for null and IO exception. | |
try { | |
// Convert bitmap to byteArray | |
Bitmap bitmap = scaleBitmapAndKeepRation( | |
MediaStore.Images.Media.getBitmap(getApplicationContext().getContentResolver(), selectedImageUri), | |
720, | |
720); | |
byte[] byteArray = convertBitmapToByteArray(bitmap); |
NewerOlder