repo_name
stringlengths
6
97
path
stringlengths
3
341
text
stringlengths
8
1.02M
Belyanova/Python_-training
test/test_phones.py
<reponame>Belyanova/Python_-training import re import pytest import allure def test_phones_on_home_page(app): with allure.step('Given a user from home and edit page'): user_from_home_page = app.user.get_user_list()[0] user_from_edit_page = app.user.get_user_info_from_edit_page(0) with allure.s...
Belyanova/Python_-training
model/configurations_login.py
<gh_stars>0 class Configurations_login: def __init__(self, username, password): self.username = username self.password = password
Belyanova/Python_-training
model/user_in_group.py
class UserGroup: def __init__(self, id=None, group_id=None,): self.group_id = group_id self.id = id
695195646/robot_eyes
untitled1/Hash_img.py
<reponame>695195646/robot_eyes<gh_stars>0 #coding-utf-8 import cv2 import numpy as np import os import shutil #存放图片目录 path = "D:\\untitled1\\photo" #用户传输原图 imgPathSrc = "\\untitled1\\photo\\p1.jpg" #相似比例值 simil = 0.85 #相似图片存入地址 saveFile = "C:\\Users\\EDZ\\Desktop\\test_consult\\" def ORBImgSimilarity...
jamiebyer/mohrs
app.py
# -*- coding: utf-8 -*- # Run this app with `python app3.py` and # visit http://127.0.0.1:8050/ in your web browser. # documentation at https://dash.plotly.com/ from flask import Flask from os import environ import dash import dash_core_components as dcc import dash_html_components as html from dash.dependencies imp...
tomasMasson/sfgv_proteomics
scripts/create_proteins_table.py
<gh_stars>0 #!/usr/bin/env python3 "Aggregates individual SfGV proteomics datasets into a summary table" import click import pandas as pd def create_proteins_table(dataset1, dataset2, dataset3, output): """ Merges the three protein tables of each replicate into a summary table. """ # Read the three...
gplssm/ding0_viz
utils/retrieve_data.py
<reponame>gplssm/ding0_viz import os from ding0.core import NetworkDing0 from utils.process_data import read_config_yaml, to_list_of_ints from egoio.tools import db from sqlalchemy.orm import sessionmaker import argparse def generate_ding0_data(grid_id, save_path): engine = db.connection(readonly=True) session = s...
gplssm/ding0_viz
utils/process_data.py
import os import requests import pandas as pd import json from geojson import Feature, MultiPolygon, FeatureCollection, Point, LineString from shapely.wkb import loads as wkb_loads from shapely.wkt import loads as wkt_loads from shapely.ops import transform import pyproj from functools import partial import argparse im...
Naighu/python-screenrecorder
resources/screencapture.py
<filename>resources/screencapture.py<gh_stars>1-10 import cv2 import numpy as np import pyautogui class WriteVideoToFile(cv2.VideoWriter): # def __init__(self, filename, fourcc, fps, framesize): # calls the super class __init__ function def __enter__(self): return self def __exit__(self, ty...
Naighu/python-screenrecorder
resources/decor.py
# decorators for functions def audio_record_thread(func): def inner(s): print("AudioCapture: Started Recording Audio") func(s) print("AudioCapture: Stopped Recording Audio") return return inner def file_saving(func): def wrap(filename): print("Saving file...") ...
Naighu/python-screenrecorder
resources/audiocapture.py
<filename>resources/audiocapture.py<gh_stars>1-10 import pyaudio import wave import cv2 # from decor import * class CaptureAudio: def __init__(self): self.FORMAT = pyaudio.paInt16 self.CHANNELS = 2 self.RATE = 44100 self.CHUNK = 1024 # if it is False then the recoding shou...
Naighu/python-screenrecorder
resources/screenrec.py
import numpy import cv2 from threading import Thread from screencapture import * from audiocapture import * import tkinter as tk from tkinter.font import Font class ScreenRecorder(object): def __init__(self): self.audio = CaptureAudio() self.video = ScreenCapture() def startRecoding(self): ...
bezyakina/my_django_blog
posts/migrations/0007_auto_20200817_1747.py
# Generated by Django 2.2.13 on 2020-08-17 17:47 from django.db import migrations class Migration(migrations.Migration): dependencies = [ ("posts", "0006_auto_20200811_1551"), ] operations = [ migrations.AlterModelOptions( name="post", options={"ordering": ("-pub...
bezyakina/my_django_blog
posts/migrations/0010_auto_20200821_1104.py
# Generated by Django 2.2.13 on 2020-08-21 11:04 from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ ("posts", "0009_comment"), ] operations = [ migrations.AlterField( model_name="post", name="pub_date", fi...
bezyakina/my_django_blog
posts/migrations/0003_post_group.py
<filename>posts/migrations/0003_post_group.py<gh_stars>0 # Generated by Django 2.2 on 2020-07-09 12:04 import django.db.models.deletion from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ ("posts", "0002_group"), ] operations = [ migrations.A...
bezyakina/my_django_blog
users/admin.py
<filename>users/admin.py from ckeditor.widgets import CKEditorWidget from django.contrib import admin from django.contrib.flatpages.admin import FlatPageAdmin from django.contrib.flatpages.models import FlatPage from django.db import models # Define a new FlatPageAdmin class FlatPageAdmin(FlatPageAdmin): formfiel...
bezyakina/my_django_blog
posts/tests.py
<reponame>bezyakina/my_django_blog from time import sleep from django.core.cache import cache from django.core.files.uploadedfile import SimpleUploadedFile from django.test import Client, TestCase from django.urls import reverse from posts.models import Follow, Group, Post, User class PostAppTest(TestCase): def...
bryanwills/netbox
netbox/ipam/tables/fhrp.py
<gh_stars>0 import django_tables2 as tables from utilities.tables import BaseTable, ButtonsColumn, MarkdownColumn, TagColumn, ToggleColumn from ipam.models import * __all__ = ( 'FHRPGroupTable', 'FHRPGroupAssignmentTable', ) IPADDRESSES = """ {% for ip in record.ip_addresses.all %} <a href="{{ ip.get_abso...
ZLLentz/pcds-envs
scripts/update_tags.py
import argparse import json import re import requests import subprocess from pathlib import Path from packaging import version CHANNELS = ['conda-forge', 'pcds-tag', 'lcls-ii'] def latest_version(package): try: info = subprocess.check_output(['conda', 'search', '--json', package], ...
ZLLentz/pcds-envs
scripts/check_master_tags.py
# Helper script to check which packages we need to tag import os import pathlib import shutil import subprocess import sys import time def get_master_tag(repo): tmp_dir = 'check_tag_tmp' shutil.rmtree(tmp_dir, ignore_errors=True) clone_tries = 10 while clone_tries > 0: try: subpro...
ZLLentz/pcds-envs
scripts/release_notes_table.py
<gh_stars>0 import dataclasses import pathlib import re import subprocess import sys import typing import prettytable # How much of a change is enough to include in the table? VER_DEPTH = { 'pcds': 3, 'slac': 3, 'lab': 3, 'community': 2, 'other': 1, } # Section headers HEADERS = { 'pcds': 'PC...
ZLLentz/pcds-envs
scripts/test_setup.py
import argparse import configparser import contextlib import json import os import requests import subprocess from pathlib import Path URL_BASE = 'https://github.com/{}.git' parser = argparse.ArgumentParser() parser.add_argument('env') parser.add_argument('--tag', action='store_true') def version_info(): conda_l...
kc611/aeppl
tests/test_transforms.py
import aesara import aesara.tensor as at import numpy as np import pytest import scipy as sp from aesara.graph.fg import FunctionGraph from numdifftools import Jacobian from aeppl.joint_logprob import joint_logprob from aeppl.transforms import ( DEFAULT_TRANSFORM, LogOddsTransform, LogTransform, RVTran...
kc611/aeppl
aeppl/transforms.py
import abc from functools import partial, singledispatch from typing import Dict, List, Optional, Type, Union import aesara.tensor as at from aesara.gradient import jacobian from aesara.graph.basic import Node, Variable from aesara.graph.features import AlreadyThere, Feature from aesara.graph.fg import FunctionGraph f...
kc611/aeppl
aeppl/mixture.py
from typing import List, Optional import aesara.tensor as at import numpy as np from aesara.compile.builders import OpFromGraph from aesara.graph.basic import Apply from aesara.graph.fg import FunctionGraph from aesara.graph.opt import local_optimizer, pre_greedy_local_optimizer from aesara.ifelse import ifelse from a...
kc611/aeppl
tests/test_joint_logprob.py
import aesara import aesara.tensor as at import numpy as np import pytest import scipy.stats.distributions as sp from aesara.graph.basic import Apply, ancestors, equal_computations from aesara.graph.op import Op from aesara.tensor.subtensor import ( AdvancedIncSubtensor, AdvancedIncSubtensor1, AdvancedSubte...
kc611/aeppl
aeppl/logprob.py
from functools import singledispatch from typing import Tuple import aesara.tensor as at import aesara.tensor.random.basic as arb import numpy as np from aesara.assert_op import Assert from aesara.graph.op import Op from aesara.tensor.slinalg import Cholesky, solve_lower_triangular from aesara.tensor.var import Tensor...
kc611/aeppl
aeppl/joint_logprob.py
<gh_stars>0 import warnings from collections import deque from typing import Dict, Optional, Union import aesara.tensor as at from aesara import config from aesara.graph.basic import graph_inputs, io_toposort from aesara.graph.fg import FunctionGraph from aesara.graph.op import compute_test_value from aesara.graph.opt...
kc611/aeppl
aeppl/abstract.py
import abc from functools import singledispatch from typing import List from aesara.graph.basic import Apply, Variable from aesara.graph.op import Op from aesara.tensor.random.op import RandomVariable class MeasurableVariable(abc.ABC): """A variable that can be assigned a measure/log-probability""" MeasurableV...
kc611/aeppl
aeppl/printing.py
import string import textwrap from collections import OrderedDict from collections.abc import Mapping, MutableMapping from copy import copy from typing import Optional, Union import aesara import aesara.tensor as at from aesara.assert_op import Assert from aesara.compile.function.types import Function from aesara.grap...
kc611/aeppl
tests/test_mixture.py
import aesara import aesara.tensor as at import numpy as np import pytest import scipy.stats.distributions as sp from aesara.graph.basic import Variable from aeppl.joint_logprob import joint_logprob from tests.utils import assert_no_rvs def test_mixture_basics(): srng = at.random.RandomStream(29833) def cre...
Sayan97/BIET---Official
app1.py
<gh_stars>0 from flask import Flask app = Flask(__name__,static_url_path="/static",static_folder="/Users/Sayan/Documents/GitHub/BIET/static") @app.route('/') def homepage(): return app.send_static_file('index.html') @app.route('/index.html') def homepage1(): return app.send_static_file('index.html') @app.ro...
danielpops/slack-starterbot
starterbot.py
import os import time import re from slackclient import SlackClient # instantiate Slack client slack_client = SlackClient(os.environ.get('SLACK_BOT_TOKEN')) # starterbot's user ID in Slack: value is assigned after the bot starts up starterbot_id = None # constants RTM_READ_DELAY = 1 # 1 second delay between reading ...
fluffynuts/scripts
audtool-play-pause.py
import subprocess import os def play_pause(): file_path = os.path.realpath(__file__) containing_dir = os.path.dirname(file_path) aud_tool = os.path.join(containing_dir, "audtool.exe") if not os.path.isfile(aud_tool): print("please copy this script into the folder containing audtool.exe") ...
fluffynuts/scripts
colors.py
<gh_stars>1-10 #!/usr/bin/python #print table header import sys colw = 10 bg_start = 40 bg_end = 48 fg_start = 30 fg_end = 38 print("Terminal color code lookup chart") print(" \033[2;37;40m* add leading '\\033' and trailing 'm' to text in desired block\033[0m") print(" \033[2;37;40m* remember to terminate with '\\...
fluffynuts/scripts
DropboxPushbulletPusher.py
#!/usr/bin/python import sys import os from pushbullet import Pushbullet import ConfigParser import dropbox class Pusher: def __init__(self): self._loadConfig() def _loadConfig(self): home = os.path.expanduser('~') self._secretsFile = os.path.join(home, 'secrets.ini') self._loadConfigFile() def...
fluffynuts/scripts
cputemp-xml.py
<filename>cputemp-xml.py #!/usr/bin/python import os import sys import xml.dom.minidom def all_numeric(s): for c in s: if "01234567890".count(c) == 0: return False return True if __name__ == "__main__": out = "" if len(sys.argv[1:]): out = sys.argv[1] doc = xml.dom.minidom.Document() docEl = doc.createEl...
fluffynuts/scripts
flatten_fs.py
<reponame>fluffynuts/scripts #!/usr/bin/python import sys import os import re class Flattener: def __init__(self, basedir = None): self.basedir = basedir self.blankstr = 75 * " " def status(self, s): if (len(s) > 72): s = s[:72] + "..." sys.stdout.write("\r%s\r%s" % (self.blankstr, s)) sys.stdout.flu...
fluffynuts/scripts
uptime.py
import sys import os from datetime import datetime class Uptime: def printUptime(self): lastbootstr = self._getLastBootStr() uptimeDelta = self._getUptimeDelta(lastbootstr) self._printUptime(uptimeDelta) def _printUptime(self, tdelta): printstring = self._getPrintString(tdelta) pri...
fluffynuts/scripts
PushbulletMessage.py
#!/usr/bin/python import sys import os from pushbullet import Pushbullet import ConfigParser import dropbox class MessagePusher: def __init__(self): self._loadConfig() def _loadConfig(self): home = os.path.expanduser('~') self._secretsFile = os.path.join(home, 'secrets.ini') self._loadConfigFile()...
fluffynuts/scripts
update-cm.py
#!/usr/bin/python import os import shutil from PushbulletMessage import MessagePusher store_path = '/mnt/dump/install-src/cm12-i9300/rom' serve_path = '/var/www/html/cm12' urlBase = 'http://192.168.1.100/cm12/' exe = 'code/xda-rom-downloader/source/xda-rom-downloader/bin/Debug/xda-rom-downloader.exe' home = os.path.ex...
fluffynuts/scripts
vacuum_ff.py
#!/usr/bin/python import os import sys import sqlite3 import ConfigParser def pad(s, w = 60): while (len(s) < w): s += " " return s def vacuum(db): sys.stdout.write(pad(" Vacuuming %s" % (os.path.basename(db)))) sys.stdout.flush() try: c = sqlite3.connect(db) c.executescript("vacuum;") sys....
fluffynuts/scripts
shuf.py
<gh_stars>1-10 #!/usr/bin/python import sys import random import os import re def main(args): last_arg = "" limit = None for arg in args: if last_arg == "-n": limit = int(arg) last_arg = "" if arg == "-n": last_arg = arg if not sys.stdin.isatty(): ...
fluffynuts/scripts
dircmp.py
<filename>dircmp.py #!/usr/bin/python # vim: expandtab shiftwidth=2 tabstop=2 import os import sys try: import psyco except: pass import time blankstr = "" ls_label = "" def ls_R(dir): ls = [dir] os.path.walk(dir, walk_cb, ls) ls = ls[1:] sys.stdout.write("\r" + blankstr + "\r") sys.stdout.flush() ls.sor...
fluffynuts/scripts
umount_v30.py
<filename>umount_v30.py #!/usr/bin/python import os import sys import pygtk pygtk.require("2.0") import pynotify import time try: import psyco psyco.full() except: pass def fix_series_similar(dir): if not os.path.isdir(dir): return False files = os.listdir(dir) pre = "" idx = 1 while True: for ...
fluffynuts/scripts
smartsaver.py
<reponame>fluffynuts/scripts #!/usr/bin/python #vim: expandtab import sys import os import glob import time class SmartSaver: def __init__(self): self.watch_cmds = ["/usr/bin/mplayer", "/usr/bin/vlc"] #self.watch_cmds = ["gmplayer"] self.interval = 15 self.proc_cache = dict() self.tmpprocs = [] ...
fluffynuts/scripts
gen_toxvid_makefile.py
<filename>gen_toxvid_makefile.py #!/usr/bin/python # purpose: to generate a makefile wrapper around the toxvid shell script that I wrote # which converts one or more video files into a single output video file with # the xvid video codec. The problem with this script is that it uses mencoder # which doesn't take ...
fluffynuts/scripts
hddtemp-xml.py
#!/usr/bin/python import os import sys import xml.dom.minidom def all_numeric(s): for c in s: if "01234567890".count(c) == 0: return False return True def get_temp(drive): cmd = "/usr/sbin/hddtemp " + drive fp = os.popen(cmd, "r") ret = "" line = fp.readline() in_temp = False idx = -1 nums = ".012345678...
fluffynuts/scripts
get-latest-chromium.py
#!/usr/bin/python # determine major version of the python engine: # this script was originall written for py 2.6 # but adapted for 3.1; I'd like both to work import sys pyver = int(sys.version.split(" ")[0].split(".")[0]) import time import urllib if pyver == 3: import urllib.request else: import urllib2 import...
fluffynuts/scripts
opts.py
#!/bin/false # CLI options helper import os import sys class Options: def __init__(self, UsageHeader = "", UnconsumedHelp = ""): self.options = dict() # put something like "MyApp V1.2.3.4" here self.UsageHeader = UsageHeader # help for trailing arguments which do not have an argument spec...
fluffynuts/scripts
flatten_once.py
<reponame>fluffynuts/scripts #!/usr/bin/python import os import sys class Flattener: def __init__(self, options = {}): self.blankstr = 75 * " " self.options = { } for opt in options: self.options[opt] = options[opt] def process(self, baseFolder): allFiles = self.ls_R(baseFolder) for ...
fluffynuts/scripts
medesync.py
<filename>medesync.py<gh_stars>1-10 #!/usr/bin/python # vim: ft=python columns=123 foldmethod=marker foldmarker=<<<,>>> expandtab shiftwidth=2 tabstop=2 softtabstop=2 # Released under the terms of the BSD license, outlined below: # Copyright (c) 2010, <NAME> # All rights reserved. # # Redistribution and use in source ...
fluffynuts/scripts
inhibit-screensaver.py
<gh_stars>1-10 #!/usr/bin/python import dbus import time bus = dbus.Bus(dbus.Bus.TYPE_SESSION) devobj = bus.get_object('org.gnome.ScreenSaver', '/org/gnome/ScreenSaver') dev = dbus.Interface(devobj, "org.gnome.ScreenSaver") cookie = dev.Inhibit('inhibit-screensaver.py', 'client request') time.sleep(0) dev.UnInhibit(co...
artful-addict/kh-squared-coming-soon
usr/libexec/fax/coverpage.py
#!/usr/bin/python # cover.py -- add an autogenerated cover page to a PDF document import sys, os, getopt, string, pwd, cgi from Quartz.CoreGraphics import * from Quartz.ImageIO import * from AppKit import * from WebKit import * from Foundation import * ## definitions subject_title = 'Subject:' from_title = 'From:' ...
artful-addict/kh-squared-coming-soon
usr/libexec/feedback/filevault.py
<gh_stars>0 #!/usr/bin/env python # -*- coding: utf-8 -*- # Imports import json import plistlib import subprocess import sys # Constants kCoreStorageLogicalVolumeConversionState = 'CoreStorageLogicalVolumeConversionState' kCoreStorageLogicalVolumeFamilyEncryptionType = 'CoreStorageLogicalVolumeFamilyEncryptionType' k...
artful-addict/kh-squared-coming-soon
usr/libexec/feedback/appearance.py
<filename>usr/libexec/feedback/appearance.py<gh_stars>0 #!/usr/bin/env python # -*- coding: utf-8 -*- import Foundation as NS import json import sys out = "" try: defaults = NS.NSUserDefaults.standardUserDefaults() globalDomain = defaults.persistentDomainForName_(NS.NSGlobalDomain) universalAccess = defau...
artful-addict/kh-squared-coming-soon
usr/bin/smtpd.py
#!/usr/bin/python -R import sys, os import glob, re partA = """\ python version %d.%d.%d can't run %s. Try the alternative(s): """ partB = """ Run "man python" for more information about multiple version support in Mac OS X. """ sys.stderr.write(partA % (sys.version_info[:3] + (sys.argv[0],))) dir, base = os.path...
thexdesk/aminator
aminator/plugins/volume/linux.py
# -*- coding: utf-8 -*- # # # Copyright 2013 Netflix, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless ...
thexdesk/aminator
aminator/plugins/distro/linux.py
<gh_stars>100-1000 # -*- coding: utf-8 -*- # # # Copyright 2013 Netflix, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-...
ilomedia/snips-skill-clock
action-heure.py
<reponame>ilomedia/snips-skill-clock<gh_stars>0 #!/usr/bin/env python3 # -*- coding: utf-8 -*- import configparser from hermes_python.hermes import Hermes from hermes_python.ontology import * from datetime import datetime from pytz import timezone import io CONFIGURATION_ENCODING_FORMAT = "utf-8" CONFIG_INI = "config...
FeliciaLeaton/Project3a
flask_wtforms_tutorial/charts.py
<reponame>FeliciaLeaton/Project3a ''' This web service extends the Alphavantage api by creating a visualization module, converting json query results retuned from the api into charts and other graphics. This is where you should add your code to function query the api ''' import requests from datetime import datetime...
SkullTech/portfolio-devclub
portfolio/projects/urls.py
<filename>portfolio/projects/urls.py from django.conf.urls import url from . import views urlpatterns = [ url(r'^$', views.projects, name='projects'), ]
SkullTech/portfolio-devclub
portfolio/blog/models.py
from django.db import models from django.utils import timezone class Tag(models.Model): name = models.CharField(max_length=50) description = models.CharField(max_length=200, null=True, blank=True, default='') def __str__(self): return self.name class Post(models.Model): author = models.Fore...
SkullTech/portfolio-devclub
portfolio/contact/admin.py
from django.contrib import admin from .models import ContactMessage admin.site.register(ContactMessage)
SkullTech/portfolio-devclub
portfolio/projects/views.py
from django.shortcuts import render from .github import repositories def projects(request): repos = repositories() return render(request, 'projects/projects.html', {'repos': repos})
SkullTech/portfolio-devclub
portfolio/contact/forms.py
from django import forms from django.urls import reverse from .models import ContactMessage from crispy_forms.helper import FormHelper from crispy_forms.layout import Submit class ContactForm(forms.ModelForm): class Meta: model = ContactMessage exclude = ['submitted_date'] def __init__(self, ...
SkullTech/portfolio-devclub
portfolio/contact/views.py
<reponame>SkullTech/portfolio-devclub from django.shortcuts import render from django.utils import timezone from .forms import ContactForm from .models import ContactMessage def contact(request): messages = ContactMessage.objects.filter(submitted_date__lte=timezone.now()).order_by('submitted_date') form = Con...
SkullTech/portfolio-devclub
portfolio/contact/migrations/0001_initial.py
<reponame>SkullTech/portfolio-devclub<filename>portfolio/contact/migrations/0001_initial.py # -*- coding: utf-8 -*- # Generated by Django 1.10.5 on 2017-03-03 15:59 from __future__ import unicode_literals from django.db import migrations, models class Migration(migrations.Migration): initial = True depende...
SkullTech/portfolio-devclub
portfolio/contact/models.py
<reponame>SkullTech/portfolio-devclub from django.db import models from django.utils import timezone class ContactMessage(models.Model): title = models.CharField(max_length=100) message = models.TextField() name = models.CharField(max_length=50) email = models.EmailField() submitted_date = models....
SkullTech/portfolio-devclub
portfolio/projects/github.py
import os from github3 import login def repositories(): github_username = os.environ.get('GITHUB_USERNAME', None) github_password = os.environ.get('GITHUB_PASSWORD', None) github = login(username=github_username, password=github_password) repos = github.iter_user_repos(github_username) return repos
RaymondKirk/cocoapi
PythonAPI/setup.py
<reponame>RaymondKirk/cocoapi from setuptools import dist, setup, Extension install_requires = [ 'setuptools>=18.0', 'cython>=0.27.3', 'matplotlib>=2.1.0', 'numpy>=1.16.2,<=1.19' ] dist.Distribution().fetch_build_eggs(install_requires) import numpy as np # To compile and install locally run "pyth...
ccha23/CS1302ICP
_build/jupyter_execute/Lecture8/Dictionaries and Sets.py
<filename>_build/jupyter_execute/Lecture8/Dictionaries and Sets.py #!/usr/bin/env python # coding: utf-8 # # Dictionaries and Sets # **CS1302 Introduction to Computer Programming** # ___ # In[1]: get_ipython().run_line_magic('reload_ext', 'mytutor') # ## Motivation for associative container # The following code...
ccha23/CS1302ICP
_build/jupyter_execute/Lecture3/Iteration.py
<filename>_build/jupyter_execute/Lecture3/Iteration.py #!/usr/bin/env python # coding: utf-8 # # Iteration # **CS1302 Introduction to Computer Programming** # ___ # In[1]: get_ipython().run_line_magic('reload_ext', 'mytutor') from ipywidgets import interact # ## Motivation # Many tasks are repetitive: # - To pr...
ccha23/CS1302ICP
_build/jupyter_execute/Lab1/Card.py
<reponame>ccha23/CS1302ICP<gh_stars>1-10 #!/usr/bin/env python # coding: utf-8 # # Card guessing game # **CS1302 Introduction to Computer Programming** # ___ # ## Rules of the game # Consider a deck of 52 cards: # <table> # <tr> # <td></td> # <th>1 (A)</th> # <th>2</th> # <th>3</...
ccha23/CS1302ICP
_build/jupyter_execute/Lecture1/Introduction to Computer Programming.py
#!/usr/bin/env python # coding: utf-8 # # Introduction to Computer Programming # **CS1302 Introduction to Computer Programming** # ___ # ## Computer # ### What is a computer? # Is computer a calculator that is bigger and more advanced? # <center><figure> # <a title="Ccha23 / CC BY-SA (https://creativecommons.org/...
ccha23/CS1302ICP
_build/jupyter_execute/Lecture6/More on Functions.py
<reponame>ccha23/CS1302ICP<gh_stars>1-10 #!/usr/bin/env python # coding: utf-8 # # More on Functions # **CS1302 Introduction to Computer Programming** # ___ # In[1]: get_ipython().run_line_magic('reload_ext', 'mytutor') # ## Recursion # Consider computing the [Fibonacci number](https://en.wikipedia.org/wiki/Fib...
ccha23/CS1302ICP
_build/jupyter_execute/Lab4/Mastermind.py
#!/usr/bin/env python # coding: utf-8 # # Mastermind # **CS1302 Introduction to Computer Programming** # ___ # In this notebook, you will write a game called [*Mastermind*](https://en.wikipedia.org/wiki/Mastermind_(board_game)). # Play the video below to learn about the rule of the game. # In[ ]: get_ipython()....
ccha23/CS1302ICP
_build/jupyter_execute/Lab7/Cybersecurity.py
<filename>_build/jupyter_execute/Lab7/Cybersecurity.py #!/usr/bin/env python # coding: utf-8 # # Cybersecurity # **CS1302 Introduction to Computer Programming** # ___ # Python is a popular tool among hackers and engineers. In this lab, you will learn Cryptology in cybersecurity, which covers # - [Cryptography](https...
ccha23/CS1302ICP
_build/jupyter_execute/Lecture7/Lists and Tuples.py
<reponame>ccha23/CS1302ICP<filename>_build/jupyter_execute/Lecture7/Lists and Tuples.py #!/usr/bin/env python # coding: utf-8 # # Lists and Tuples # **CS1302 Introduction to Computer Programming** # ___ # In[1]: get_ipython().run_line_magic('reload_ext', 'mytutor') # ## Motivation of composite data type # The f...
ccha23/CS1302ICP
_build/jupyter_execute/Review/Review Questions.py
<reponame>ccha23/CS1302ICP #!/usr/bin/env python # coding: utf-8 # # Review Questions # **CS1302 Introduction to Computer Programming** # ___ # In[1]: get_ipython().run_line_magic('reload_ext', 'mytutor') # ## Dictionaries and Sets # **Exercise (Concatenate two dictionaries with precedence)** Define a function ...
ccha23/CS1302ICP
_build/jupyter_execute/Lab3a/Improved Quadratic Equation Solver.py
#!/usr/bin/env python # coding: utf-8 # # Improved Quadratic Equation Solver # **CS1302 Introduction to Computer Programming** # ___ # In this notebook, we will improve the quadratic equation solver in the previous lab using conditional executions. # First of all, run the following to setup the environment. # In[...
ccha23/CS1302ICP
_build/jupyter_execute/Lab6/Combinatorics.py
#!/usr/bin/env python # coding: utf-8 # # Combinatorics # **CS1302 Introduction to Computer Programming** # ___ # ## Permutation using Recursion # A [$k$-permutation of $n$](https://en.wikipedia.org/wiki/Permutation#k-permutations_of_n) items $a_0,\dots,a_{n-1}$ is an ordered tuple # # $$ # (a_{i_0},\dots,a_{i_{k...
ccha23/CS1302ICP
_build/jupyter_execute/Lab2/Calculators.py
#!/usr/bin/env python # coding: utf-8 # # Calculators # **CS1302 Introduction to Computer Programming** # ___ # Run the following to load additional tools required for this lab. # In particular, the `math` library provides many useful mathematical functions and constants. # In[ ]: get_ipython().run_line_magic('...
ccha23/CS1302ICP
_build/jupyter_execute/Lecture2/Values and Variables.py
<reponame>ccha23/CS1302ICP #!/usr/bin/env python # coding: utf-8 # # Values and Variables # **CS1302 Introduction to Computer Programming** # ___ # In[1]: get_ipython().run_line_magic('reload_ext', 'mytutor') # ## Integers # **How to enter an [integer](https://docs.python.org/3/reference/lexical_analysis.html#i...
ccha23/CS1302ICP
_build/jupyter_execute/Lab9/Monte Carlo and Root Finding.py
#!/usr/bin/env python # coding: utf-8 # # Monte Carlo and Root Finding # **CS1302 Introduction to Computer Programming** # ___ # ## The Monty-Hall Game # In[ ]: get_ipython().run_cell_magic('html', '', '<iframe width="912" height="513" src="https://www.youtube.com/embed/rn1y-HrmA5c?end=23" frameborder="0" allow="...
ccha23/CS1302ICP
_build/jupyter_execute/Lecture3/Conditional Execution.py
<gh_stars>1-10 #!/usr/bin/env python # coding: utf-8 # # Conditional Execution # **CS1302 Introduction to Computer Programming** # ___ # In[1]: get_ipython().run_line_magic('reload_ext', 'mytutor') # ## Motivation # Conditional execution means running different pieces of code based on different conditions. Why?...
ccha23/CS1302ICP
_build/jupyter_execute/Lecture4/Writing Functions.py
#!/usr/bin/env python # coding: utf-8 # # Writing Function # **CS1302 Introduction to Computer Programming** # ___ # In[1]: get_ipython().run_line_magic('reload_ext', 'mytutor') # ## Function Definition # **How to write a function?** # A function is defined using the [`def` keyword](https://docs.python.org/3/r...
ccha23/CS1302ICP
_build/jupyter_execute/Lecture4/Using Functions.py
<gh_stars>1-10 #!/usr/bin/env python # coding: utf-8 # # Using Functions # **CS1302 Introduction to Computer Programming** # ___ # In[1]: get_ipython().run_line_magic('reload_ext', 'mytutor') # ## Motivation # **How to reuse code so we can write less?** # When we write a loop, the code is executed multiple tim...
ccha23/CS1302ICP
_build/jupyter_execute/Lab3b/Big Number Conversion.py
<filename>_build/jupyter_execute/Lab3b/Big Number Conversion.py #!/usr/bin/env python # coding: utf-8 # # Big Number Conversion # **CS1302 Introduction to Computer Programming** # ___ # ## Conversion to Decimal # In this notebook, we will use iterations to convert numbers with arbitrary size. # ### Binary-to-Decim...
ccha23/CS1302ICP
_build/jupyter_execute/Lecture2/Expressions and Arithmetic.py
<gh_stars>1-10 #!/usr/bin/env python # coding: utf-8 # # Expressions and Arithmetic # **CS1302 Introduction to Computer Programming** # ___ # ## Operators # The followings are common operators you can use to form an expression in Python: # | Operator | Operation | Example | # | --------: | :------------- | :...
ccha23/CS1302ICP
_build/jupyter_execute/Lecture5/Objects.py
#!/usr/bin/env python # coding: utf-8 # # Objects # **CS1302 Introduction to Computer Programming** # ___ # In[1]: get_ipython().run_line_magic('reload_ext', 'mytutor') # ## Object-Oriented Programming # **Why object-oriented programming?** # In[2]: import jupyter_manim from manimlib.imports import * # In[...
ccha23/CS1302ICP
_build/jupyter_execute/Lab5/Pandas.py
<reponame>ccha23/CS1302ICP<filename>_build/jupyter_execute/Lab5/Pandas.py #!/usr/bin/env python # coding: utf-8 # # Pandas # **CS1302 Introduction to Computer Programming** # ___ # In this lab, we will analyze COVID19 data using a powerful package called [`pandas`](https://pandas.pydata.org/docs/user_guide/index.htm...
ccha23/CS1302ICP
_build/jupyter_execute/Lecture9/Monte Carlo Simulation and Linear Algebra.py
#!/usr/bin/env python # coding: utf-8 # # Monte Carlo Simulation and Linear Algebra # **CS1302 Introduction to Computer Programming** # ___ # In[1]: get_ipython().run_line_magic('reload_ext', 'mytutor') # ## Monte Carlo simulation # **What is Monte Carlo simulation?** # > The name Monte Carlo refers to the [M...
ccha23/CS1302ICP
_build/jupyter_execute/Lab1/Setup.py
#!/usr/bin/env python # coding: utf-8 # # Setup # CS1302 Introduction to Computer Programming # ___ # ## JupyterHub # ### How to access the JupyterHub Server? # 1. Enter the url of the Jupyterhub server [ltjh.cs.cityu.edu.hk](https://ltjh.cs.cityu.edu.hk) in a web browser. # 1. Enter your [EID](https://www.cityu.ed...
ccha23/CS1302ICP
_build/jupyter_execute/Lab8/Information Theory.py
<gh_stars>1-10 #!/usr/bin/env python # coding: utf-8 # # Information Theory # **CS1302 Introduction to Computer Programming** # ___ # As mentioned in previous lectures, the following two lists `coin_flips` and `dice_rolls` simulate the random coin flips and rollings of a dice: # In[ ]: # Do NOT modify any variabl...
OmarSalah95/Lambda-Treasure-MUD-Automation
cpu.py
"""CPU functionality.""" import sys import time class CPU: """Main CPU class.""" def __init__(self): """Construct a new CPU.""" self.ram = [0] * 256 self.reg = [0] * 7 + [len(self.ram)-12] # final register reserved for SP -- grows downward, and final 11 blocks are reserved fo...
OmarSalah95/Lambda-Treasure-MUD-Automation
adv.py
<reponame>OmarSalah95/Lambda-Treasure-MUD-Automation import requests import json import random import time from player import Player from api import url, key, opposite, Queue player = Player() def get_name(name): """ Using the most recent locations of treasure, the player travels to those rooms and picks...
OmarSalah95/Lambda-Treasure-MUD-Automation
api.py
url = "https://lambda-treasure-hunt.herokuapp.com" key = open("api_key.txt", "r").read() opposite = {"n": "s", "e": "w", "s": "n", "w": "e"} class Queue(): def __init__(self): self.queue = [] def enqueue(self, value): self.queue.append(value) def dequeue(self): if self.size() > 0...
OmarSalah95/Lambda-Treasure-MUD-Automation
miner.py
from api import url, key import requests, sys, random, hashlib, json, time from uuid import uuid4 from timeit import default_timer as timer def mine(): """ Simple Proof of Work Algorithm Stringify the block and look for a proof. Loop through possibilities, checking each one against `vali...
OmarSalah95/Lambda-Treasure-MUD-Automation
player.py
from api import url, key, opposite import requests import json import time import os from miner import mine from cpu import * class Player: def __init__(self): data = self._get_status() time.sleep(data['cooldown']) self.name = data['name'] self.cooldown = data['cooldown'] s...