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 encode(text): | |
if not text: | |
return "" | |
else: | |
last_char = text[0] | |
max_index = len(text) | |
i = 1 | |
while i < max_index and last_char == text[i]: | |
i += 1 | |
return last_char + str(i) + encode(text[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
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
#include <lua.h> | |
#include <lauxlib.h> | |
#include <lualib.h> | |
int main (int argc, char *argv[]) { | |
if (argc < 3) { | |
fprintf(stderr, "Missing arguments. Use it like ./program <a> <b>\n"); |
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 ast | |
code = """ | |
import foo | |
a = 1 + 2 | |
b = "a" + "b" * 3 |
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
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
#include <unistd.h> | |
#include <errno.h> | |
#include "ae.h" | |
#include "anet.h" | |
#include "cdredis.h" |
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 scrape_listing(): | |
for link in get_links(LISTING_URL): | |
scrape_link(link) | |
def scrape_link(url): | |
resp = requests.get(url) | |
info = get_link_info(resp.content) | |
save('link', info) |
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
schedule('scrape_link', 'http://example.com', seconds=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
for _ in range(10): | |
schedule('scrape_link', link, seconds=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
@starting_task | |
def scrape_listing(): | |
for link in get_links(LISTING_URL): | |
schedule('scrape_link', link, seconds=0) | |
@subtask | |
def scrape_link(url): | |
resp = requests.get(url) | |
info = get_link_info(resp.content) |
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
# REPL | |
# read, eval, print, loop program | |
import os | |
import subprocess | |
import shlex | |
import sys | |
last_returncode = 0 | |
try: |
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 boto | |
ec2 = boto.connect_ec2() | |
groups = ec2.get_all_security_groups() | |
def get_groups_that_have_ingress_rules_to(groups, group_id): | |
result = [] | |
for group in groups: | |
for rule in group.rules: | |
for grant in rule.grants: |
NewerOlder