'recording_actor_position': lambda: choice(RECORDING_ACTOR_POSITIONS), 'editor_position': lambda: choice(EDITOR_POSITIONS), 'artist_type': lambda: choice(ARTIST_TYPES), 'using_technology': lambda: choice(USING_TECHNOLOGIES), 'duration': lambda: choice(range(MIN_DURATION_S, MAX_DURATION_S, 60)), 'estimation_time': lambda: choice(range(MIN_DURATION_S, MAX_DURATION_S, 60)), 'process_status': lambda: choice(PROCESS_STATUS), 'description': lambda: lorem.sentence(), 'insertion_location': lambda: choice(INSERTION_LOCATIONS), 'sound_type': lambda: choice(SOUND_TYPES), 'digitization_type': lambda: choice(DIGITIZATION_TYPES), 'revision_type': lambda: choice(REVISION_TYPES), 'coloring_type': lambda: choice(COLORING_TYPES), 'voice_acting_type': lambda: choice(VOICE_ACTING_TYPES), 'artifact_type': lambda: choice(ARTIFACT_TYPES), 'effect_level':
def __generate_section(self, references): paragraph = ParagraphTag(lorem.sentence()).get_formatted() a = AnchorTag(random.choice(references)).get_formatted() image = self.__get_image_tag() return SectionTag(paragraph + a + image).get_formatted()
def __get_image_tag(self): filename = StringGenerator().get_random_string( self.__IMG_FILENAME_LENGTH) + '.jpg' return ImageTag(ImageGenerator().generate(filename), lorem.sentence()).get_formatted()
def generate_textual_description(row): return lorem.sentence()
return requests.post(url.format(PORT), json=data, stream=True) def register_data(text, scores, word=False, port=PORT): rtype = 'simple' if isinstance(scores[0], (list, np.ndarray)): rtype = 'mult' if isinstance(scores, np.ndarray): scores = scores.tolist() _check_lengths(text, scores, rtype) r = post_request( { 'text': text, 'scores': scores, 'rtype': rtype, 'word': word }, port=port) return r.status_code == 200 if __name__ == '__main__': import lorem text = '\n'.join([lorem.sentence() for _ in range(10)]) print(register_data(text, np.random.randn(len(text))))
"""Some simple examples of simplerestclient.SimpleRESTClient""" __author__ = "Alan Evans <*****@*****.**>" import json import lorem from simplerestclient import SimpleRESTClient client = SimpleRESTClient( 'https://jsonplaceholder.typicode.com/', verify = True) print json.dumps(client.get('posts/1').json(), indent=4) resp = client.put('posts/%d' % 1, json={'body': lorem.paragraph()}) print 'updated post id: %d, status_code: %d, content: %s' % ( 1, resp.status_code, resp.content) post = client.post('posts', json = { 'author_id': 1, 'title': lorem.sentence(), 'body': lorem.paragraph(), } ).json() print 'created post: ', json.dumps(post, indent=4)
i = 0 while i < length_in_pixels: byte = str(bin(image[i]))[2:].zfill(8) message += byte[-nbits:] i += 1 mod = length % -nbits if mod != 0: message = message[:mod] return message print("Downloading image!") path = 'https://picsum.photos/1280/960' resp = urllib.request.urlopen(path) image = np.asarray(bytearray(resp.read()), dtype="uint8") image = cv2.imdecode(image, cv2.IMREAD_COLOR) print("Image downloaded!") shape = image.shape nbits = 1 message = lorem.sentence() secret = encode_as_binary_array(message) image = hide_message(image, secret, nbits) print('Message:', message) cv2.imwrite('ex1_encoded.png', image) message = decode_from_binary_array(reveal_message(image, nbits, len(secret))) print('Decoded:', message)
def feed(): header = """{"feed": { "author": {"name":{"label":"iTunes Store"},"uri":{"label":"http://www.apple.com/itunes/"}}, "entry": [ {"im:name":{"label":"Instagram"},"rights":{"label":"© 2015 Instagram, LLC."},"im:price":{"label":"Get","attributes":{"amount":"0.00000","currency":"USD"}},"im:image":[{"label":"http://is4.mzstatic.com/image/thumb/Purple128/v4/bb/ab/25/bbab25cd-f94b-3735-9a36-3743db54df87/Prod-1x_U007emarketing-85-220-0-5.png/53x53bb-85.png","attributes":{"height":"53"}},{"label":"http://is1.mzstatic.com/image/thumb/Purple128/v4/bb/ab/25/bbab25cd-f94b-3735-9a36-3743db54df87/Prod-1x_U007emarketing-85-220-0-5.png/75x75bb-85.png","attributes":{"height":"75"}},{"label":"http://is2.mzstatic.com/image/thumb/Purple128/v4/bb/ab/25/bbab25cd-f94b-3735-9a36-3743db54df87/Prod-1x_U007emarketing-85-220-0-5.png/100x100bb-85.png","attributes":{"height":"100"}}],"im:artist":{"label":"Instagram, Inc.","attributes":{"href":"https://itunes.apple.com/us/developer/instagram-inc/id389801255?mt=8&uo=2"}},"title":{"label":"Instagram - Instagram, Inc."},"link":{"attributes":{"rel":"alternate","type":"text/html","href":"https://itunes.apple.com/us/app/instagram/id389801252?mt=8&uo=2"}},"id":{"label":"https://itunes.apple.com/us/app/instagram/id389801252?mt=8&uo=2","attributes":{"im:id":"389801252","im:bundleId":"com.burbn.instagram"}},"im:contentType":{"attributes":{"term":"Application","label":"Application"}},"category":{"attributes":{"im:id":"6008","term":"Photo & Video","scheme":"https://itunes.apple.com/us/genre/ios-photo-video/id6008?mt=8&uo=2","label":"Photo & Video"}},"im:releaseDate":{"label":"2010-10-06T01:12:41-07:00","attributes":{"label":"October 6, 2010"}}}, """ footer = """ ], "updated": { "label": "2017-10-31T11:17:05-07:00" }, "rights": { "label": "Copyright 2008 Apple Inc." }, "title": { "label": "iTunes Store: Customer Reviews" }, "icon": { "label": "http://itunes.apple.com/favicon.ico" }, "link": [{"attributes":{"rel":"alternate","type":"text/html","href":"https://itunes.apple.com/WebObjects/MZStore.woa/wa/viewGrouping?cc=us&id=1"}},{"attributes":{"rel":"self","href":"https://itunes.apple.com/us/rss/customerreviews/id=389801252/sortby=mostrecent/json"}},{"attributes":{"rel":"first","href":"https://itunes.apple.com/us/rss/customerreviews/page=1/id=389801252/sortby=mostrecent/xml?urlDesc=/customerreviews/id=389801252/sortby=mostrecent/json"}},{"attributes":{"rel":"last","href":"https://itunes.apple.com/us/rss/customerreviews/page=10/id=389801252/sortby=mostrecent/xml?urlDesc=/customerreviews/id=389801252/sortby=mostrecent/json"}},{"attributes":{"rel":"previous","href":"https://itunes.apple.com/us/rss/customerreviews/page=1/id=389801252/sortby=mostrecent/xml?urlDesc=/customerreviews/id=389801252/sortby=mostrecent/json"}},{"attributes":{"rel":"next","href":"https://itunes.apple.com/us/rss/customerreviews/page=2/id=389801252/sortby=mostrecent/xml?urlDesc=/customerreviews/id=389801252/sortby=mostrecent/json"}}], "id": { "label": "https://itunes.apple.com/us/rss/customerreviews/id=389801252/sortby=mostrecent/json" } } } """ num_changes = random.randint(1, 3) print("Number of changes: %d" % (num_changes,)) new_reviews = [] for i in range(num_changes): action = random.choice(['insert', 'delete', 'change', 'change']) if action == 'insert': global next_review_id print("Adding #%d" % (next_review_id,)) new_reviews.append({ "rating" : random.randint(1, 5), "id" : next_review_id, "body" : lorem.paragraph(), "title" : lorem.sentence(), "author" : lorem.sentence() }) next_review_id = next_review_id + 1 elif action == 'delete': if len(new_reviews) > 0: index = random.randint(0, len(new_reviews) - 1) print("Removing at %d", index) new_reviews.pop(index) elif action == 'change': r = random.choice(review_feed) field = random.choice(['body', 'title', 'rating', 'rating']) print("Changing %s of #%d" % (field, r["id"])) if field == 'body': r["body"] = lorem.paragraph() elif field == 'title': r["title"] = lorem.sentence() elif field == 'rating': r["rating"] = random.randint(1, 5) for r in new_reviews: review_feed.insert(0, r) return header + ",".join(map(json_for_review, review_feed)) + footer
def on_sentence(self): sentence = lorem.sentence() self.sentence_edit.setText(sentence)
import requests import simplejson as json import argparse import lorem if __name__ == "__main__": description = "Given N, post N news to the API made out of lorem ipsums." parser = argparse.ArgumentParser(description=description) parser.add_argument('N', help=description) # argument parsing args = parser.parse_args() N = args.N for n in range(0, int(N)): s = lorem.sentence() # 'Eius dolorem dolorem labore neque.' p = lorem.paragraph() t = lorem.text() url = "http://localhost:5000/news" data = { "title": s, "description": p, "content": t, "link": "http://www.lavoz.com.ar/" } headers = { 'Content-type': 'application/json', 'Authorization': "bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyIjoidXNlciIsInJvbGUiOiJhZG1pbiIsImlhdCI6MTUzNDc2NTQ4OX0.PHH3IPY6hrPHo6rb8rRwadHkov90iwnmnicLSg3IpDg"
def generate_title(): return lorem.sentence()
def generate(): data = [] current_time = datetime.datetime.now() year = current_time.strftime('%Y') month = current_time.strftime('%m') dir_path = '../../' + STATIC_PATH.format(year, month) # generando cursos for pk in range(1, CURSOS_SIZE + 1): image_path = STATIC_URL.format(year, month, pk) if not os.path.exists(dir_path): os.makedirs(dir_path) urllib.request.urlretrieve(LOREM_PICSUM, '../../' + image_path) model = { 'model': 'cursos.curso', 'pk': pk, 'fields': { 'titulo': lorem.sentence(), 'descricao': lorem.paragraph(), 'imagem': image_path, 'created_at': str(current_time), 'updated_at': str(current_time), } } data.append(model) print('Gerado curso {}'.format(pk)) # gerando aulas for pk in range(1, AULAS_SIZE + 1): model = { 'model': 'cursos.aula', 'pk': pk, 'fields': { 'titulo': ' '.join(lorem.sentence().split()[:2]), 'curso': random.randint(1, CURSOS_SIZE), 'created_at': str(current_time), 'updated_at': str(current_time), } } data.append(model) print('Gerado aula {}'.format(pk)) # gerando apostilas for pk in range(1, APOSTILAS_SIZE + 1): model = { 'model': 'cursos.apostila', 'pk': pk, 'fields': { 'titulo': ' '.join(lorem.sentence().split()[:3]), 'created_at': str(current_time), 'updated_at': str(current_time), } } data.append(model) print('Gerado apostila {}'.format(pk)) # gerando pacotes for pk in range(1, PACOTES_SIZE + 1): model = { 'model': 'cursos.pacote', 'pk': pk, 'fields': { 'apostila': random.randint(1, APOSTILAS_SIZE), 'aula': random.randint(1, AULAS_SIZE), } } data.append(model) print('Gerado pacote {}'.format(pk)) with open('cursos.json', 'w') as f: json.dump(data, f, indent=4)
from datetime import date BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) sys.path.append(BASE_DIR) os.environ.setdefault("DJANGO_SETTINGS_MODULE", "documenter.settings") import django import lorem django.setup() from rate_doc.models import * from django.contrib.auth.models import User for i in range(100): report = Report( title=lorem.sentence(), section="Section", page=3, report_text_html=lorem.text(), ) report.save() for user in User.objects.all(): doc = Doc( assignedTo=user, report=report, ) doc.save()
""" Chat users """ import lorem print("register chatron2 s s") chats = 500 for i in range(chats): print("msg chatron1 "+lorem.sentence()) if i%100==0: print("follow chatron1")
def handle(obj): return {'request': obj, 'body': lorem.sentence()}
from bos_consensus.util import ( ArgumentParserShowDefaults, logger, ) from client.client import (MessageInfo, send_message) parser = ArgumentParserShowDefaults() log = None logger.set_argparse(parser) parser.add_argument( '-m', '--message', default=lorem.sentence().split()[0], help='Messages you want to send to the server', type=str, ) parser.add_argument( '-i', '--ip', default='localhost', help='Server IP you want to send the message to', type=str, ) parser.add_argument( '-p', '--port', default=5001, help='Server port you want to send the message to',