This file contains hidden or 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 counting_sort(l, upper_bound): | |
counts = [0] * (upper_bound + 1) | |
ret = [] | |
# count how many times each number occurs | |
for i in l: | |
counts[i] += 1 | |
# fill in ret | |
for i, count in enumerate(counts): | |
for _ in range(count): | |
ret.append(i) |
This file contains hidden or 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 batch_query_set(query_set, single=False, batch_size=1000): | |
try: | |
last_id = query_set.order_by('-id')[0].id | |
first_id = query_set.order_by('id')[0].id | |
for start in range(first_id, last_id + 1, batch_size): | |
end = min(start + batch_size - 1, last_id) | |
records = query_set.filter(id__range=(start, end)).all() | |
if single: | |
for record in records: | |
yield record |
This file contains hidden or 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 scrapyz.spiders.core import GenericSpider, Target | |
class RedditSpider(GenericSpider): | |
name = "reddit" | |
start_urls = ["https://www.reddit.com/"] | |
class Meta: | |
elements = ".thing" | |
targets = [ | |
Target("rank", ".rank::text"), |
This file contains hidden or 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
if champion data base doesn't exist | |
{ | |
client.get(url, null, new JsonHttpResponseHandler() { | |
@Override | |
public void onSuccess(JSONObject response) | |
{ | |
button1.setVisibility(View.GONE); | |
button2.setVisibility(View.GONE); | |
button3.setVisibility(View.GONE); | |
progressBar.setVisibility(view.visible); |
This file contains hidden or 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
#include <stdio.h> | |
void main() | |
{ | |
char* str = "Cool Way To Loop Through An Array Of Characters\n"; | |
for(; *str; str++) | |
printf("%c", str[0]); | |
} |