Skip to content

Instantly share code, notes, and snippets.

View carcigenicate's full-sized avatar

Brendon Williams carcigenicate

View GitHub Profile
def fnc ():
baseurls = lst() # Added an s to the name because there's multiple
for baseurl in baseurls # Then grab each url
request = requests.get(baseurl)
response = str(request.content)
page_soup = BeautifulSoup(response, 'html.parser')
a = page_soup.findAll("div",{"class":"large-7 medium-9 columns"})
b = page_soup.findAll("div",{"body field"})
import os, subprocess
# Just stick all the lines in a single list
# This saves you from needing to type out variable names that you'll never use, and the mess that's needed to deal with dynamic variables.
vmaf_lines = ["VMAF STATISTICS for " + inp_file + ":",
"=========================",
"PSNR Average: " + str(psnr_avg) + "dB",
"PSNR Minimal: " + str(psnr_min) + "dB",
"PSNR Maximal: " + str(psnr_max) + "dB",
"=========================",
(time (doseq [n (range 5)]
(future
(Thread/sleep 2000))))
(defn process-list [list]
"Process `members of list` one by one."
(doseq [sub-lists (partition-list N-THREADS list)]
(println "SL" sub-lists)
(future (doseq [sub-list sub-lists]
(println sub-list)
(dosync (swap! element_processing_retries inc)
(map increase-element sub-list))))))
(defn main []
The problem is that `random_generator` is returning a list of numbers, but `get_guess` is returning a string.
This means that `ran[i]==guess[i]` is comparing a string (`guess[i]`) with a number (`ran[i]`), which will always be false.
Since you want to get numbers from the user, convert their input into numbers first.
Change:
guess=input()
(ns mandelbrot-redo.irrelevant.ball)
(defrecord Ball [pos-x pos-y radius vel-x vel-y])
; Making the atom hold a list to hold multiple balls
(def balls-atom (atom []))
; You should prefer "->Ball" over the "Ball." constructor. The java interop form "Ball." has a few drawbacks
; And I'm adding to the balls vector. What you had before didn't make sense.
; You put an empty map in the atom, then immedietly overwrote it with a single ball
(ns workers)
(defrecord Worker [write-f get-f])
; Just access the "workers" map by key name. (workers :worker-1)
(def workers
{:worker-1 (->Worker (fn [data file])
(fn [params]))
(defmacro trace-letfn [fnspecs & body]
(let [mod-fns (mapv #(let [[name args & body] %]
`(~name ~args (t/trace-fn-call '~name (fn ~args ~@body) ~args)))
fnspecs)]
`(letfn ~mod-fns ~@body)))
(trace-letfn [(f [n] (println "Thing" n))
(g [m] (println "Somethin else" m))]
(f 1)
(g 2))
(defn roll-for-stats []
(->> (repeatedly 7 read-line) ; Ask for input 7 times and store in a list
(map #(Long/parseLong %)) ; Parse them as numbers
(sort) ; Sort the list
(drop 1))) ; Then drop the first element, which is the smallest
(roll-for-stats) ; Type 1 2 3 4 5 6 7
=> (2 3 4 5 6 7)
; Note use of read-line instead of read-string.
import socket
import time
MESSAGE = bytes("!", "utf-8")
UDP_PORT = 443
def ping(udp_ip):
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
sock.settimeout(2)
sock.sendto(MESSAGE, (udp_ip, UDP_PORT))