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 class MyAsyncTaskName extends AsyncTask<String, Integer, String> { | |
// String: The first string is the parameter, this is what is passed to doInBackground() | |
// Integer: The first, and only, Integer type is used for progress updates, this is what is passed to onProgressUpdate() | |
// String: The second String is for what is returned by doInBackground() and what is passed to onPostExecution(); | |
@Override | |
protected void onPreExecute() { | |
// Handles what happens before the AsyncTask fully executes. | |
// Here you can do things like add a progress bar, loading animation, etc. |
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
$age = floor((time() - strtotime($data_of_birth)) / 31556926); |
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
Element.prototype.fadeIn = function(callback) { | |
var ele = this, | |
opacity = ele.style.opacity = Number(ele.style.opacity) || 0.0, | |
fadeInLoop = null, | |
intervalTime = 10, | |
opacityAmount = 0.05; | |
ele.style.display = 'block'; | |
// If the opacity is already greater than or equal to zero then there is nothing |
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 sys | |
def generate_csv_data_from_html_table(html): | |
csv_header = "" | |
csv_rows = [] | |
rows = create_rows_from_trs(remove_tab_and_newline(html)) | |
for row in rows: | |
if not row.find("<th>") == -1: | |
csv_header = row.replace("<th>", "").replace("</th>", ",") | |
elif not row.find("<td>") == -1: |
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
function redirectWithGetDataChange(key, value) { | |
var getData = window.location.search.substr(1).split("&"), | |
getKeyValue = null, | |
getKeyChanged = false; | |
for (var i=0; i<getData.length; i++) { | |
getKeyValue = getData[i].split("="); | |
if (getKeyValue[0] == key) { | |
getData[i] = key + "=" + value; |
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Example for traverseToAncestor</title> | |
</head> | |
<body> | |
<div class="top-ancestor"> | |
<div class="grandparent"> | |
<div class="parent"> | |
<div class="child"></div> |
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
#NoEnv | |
#NoTrayIcon | |
#IfWinActive ahk_class WorkerW | |
^Right::^#Right | |
^Left::^#Left |
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
# To the not-so-mathematically-inclined, this function may look like pure witch- | |
# craft. That's why I shall describe how it works. | |
# | |
# Let's say we start with an initial number of `13`, we expect an output of `31`, | |
# right? Let's see: | |
# | |
# reverse_number(13) | |
# | |
# num = 13 | |
# reversed_num = 0 |
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
from random import randint, random | |
from math import floor | |
def fisher_yates_shuffle(the_list): | |
list_range = range(0, len(the_list)) | |
for i in list_range: | |
j = randint(list_range[0], list_range[-1]) | |
the_list[i], the_list[j] = the_list[j], the_list[i] | |
return the_list |
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
from collections import OrderedDict | |
from datetime import datetime | |
def sort_dict_by_date(the_dict, date_format): | |
# Python dicts do not hold their ordering so we need to make it an | |
# ordered dict, after sorting. | |
return OrderedDict(reversed(sorted( | |
the_dict.items(), | |
key=lambda x: datetime.strptime(x[0], date_format) |
OlderNewer