How to use g method in fast-check-monorepo

Best JavaScript code snippet using fast-check-monorepo

slushpool.py

Source:slushpool.py Github

copy

Full Screen

1#! /usr/bin/env python32from datetime import datetime3from os.path import exists4from PIL import Image, ImageDraw, ImageColor5import json6import math7import subprocess8import sys9import time10import vicarioustext11def getaccountprofile():12 cmd = "curl --silent -H \"SlushPool-Auth-Token: " + authtoken + "\" https://slushpool.com/accounts/profile/json/btc/"13 if useTor:14 cmd = "torify " + cmd15 try:16 cmdoutput = subprocess.check_output(cmd, shell=True).decode("utf-8")17 j = json.loads(cmdoutput)18 except subprocess.CalledProcessError as e:19 cmdoutput = ""20 if len(cmdoutput) == 0:21 cmdoutput = "{\"btc\":{\"confirmed_reward\": null, \"unconfirmed_reward\": \"0.00000000\", \"estimated_reward\": \"0.00000000\", \"hash_rate_unit\": \"Gh/s\", \"hash_rate_5m\": 0.0000}}"22 j = json.loads(cmdoutput)23 return j24def getaccountrewards():25 time.sleep(6)26 cmd = "curl --silent -H \"SlushPool-Auth-Token: " + authtoken + "\" https://slushpool.com/accounts/rewards/json/btc/"27 if useTor:28 cmd = "torify " + cmd29 try:30 cmdoutput = subprocess.check_output(cmd, shell=True).decode("utf-8")31 j = json.loads(cmdoutput)32 except subprocess.CalledProcessError as e:33 cmdoutput = ""34 if len(cmdoutput) == 0:35 cmdoutput = "{\"btc\":{\"daily_rewards\":[]}}"36 j = json.loads(cmdoutput)37 return j38def getpoolstats():39 time.sleep(6)40 cmd = "curl --silent -H \"SlushPool-Auth-Token: " + authtoken + "\" https://slushpool.com/stats/json/btc/"41 if useTor:42 cmd = "torify " + cmd43 try:44 cmdoutput = subprocess.check_output(cmd, shell=True).decode("utf-8")45 j = json.loads(cmdoutput)46 except subprocess.CalledProcessError as e:47 cmdoutput = ""48 if len(cmdoutput) == 0:49 cmdoutput = "{\"btc\":{\"blocks\":{\"0\":{\"date_found\":0,\"mining_duration\":0,\"total_shares\":0,\"state\":\"confirmed\",\"confirmations_left\":0,\"value\": \"0.00000000\",\"user_reward\": \"0.00000000\",\"pool_scoring_hash_rate\": 0.000000}}}}"50 j = json.loads(cmdoutput)51 return j52def getpriceinfo():53 cmd = "curl -s " + priceUrl54 if useTor:55 cmd = "torify " + cmd56 global price_last57 global price_high58 global price_low59 try:60 cmdoutput = subprocess.check_output(cmd, shell=True).decode("utf-8")61 if len(cmdoutput) > 0:62 j = json.loads(cmdoutput)63 price_last = int(math.floor(float(j["btc_usd"]["last"])))64 price_high = int(math.floor(float(j["btc_usd"]["high"])))65 price_low = int(math.floor(float(j["btc_usd"]["low"])))66 except subprocess.CalledProcessError as e:67 cmdoutput = "{\"error\": \"dont care\" }"68 return (price_last,price_high,price_low)69def getaccounthashrate(accountprofile):70 hashrate = accountprofile["btc"]["hash_rate_5m"]71 hashdesc = accountprofile["btc"]["hash_rate_unit"]72 while (hashrate > 1000.0) and (hashdesc != "Ph/s"):73 hashrate = hashrate/1000.074 if hashdesc == "Ph/s":75 hashdesc = "Eh/s"76 if hashdesc == "Th/s":77 hashdesc = "Ph/s"78 if hashdesc == "Gh/s":79 hashdesc = "Th/s"80 if hashdesc == "Mh/s":81 hashdesc = "Gh/s"82 hashfmt = str(format(hashrate, ".2f")) + " " + hashdesc83 return hashfmt84def gethighestreward(accountrewards):85 highestreward = 0.0086 days = 087 for reward in accountrewards["btc"]["daily_rewards"]:88 days = days + 189 currenttotal = float(reward["total_reward"])90 if currenttotal > highestreward:91 highestreward = currenttotal92 return highestreward93def getlowestreward(accountrewards):94 lowestreward = 0.0095 days = 096 for reward in accountrewards["btc"]["daily_rewards"]:97 days = days + 198 currenttotal = float(reward["total_reward"])99 if days == 1:100 lowestreward = currenttotal101 else:102 if currenttotal < lowestreward:103 lowestreward = currenttotal104 return lowestreward105def createimage(accountrewards, accountprofile, poolstats, price_last, width=480, height=320):106 headerheight = 30107 footerheight = 15108 hashheight = (height - headerheight - footerheight) * .4109 rewardheight = (height - headerheight - footerheight) * .5110 im = Image.new(mode="RGB", size=(width, height), color=colorBackground)111 draw = ImageDraw.Draw(im)112 # Header113 vicarioustext.drawcenteredtext(draw, "SlushPool Mining Summary", 24, int(width/2), int(headerheight/2), colorHeader, True)114 # Hashrate115 hashrate = getaccounthashrate(accountprofile)116 vicarioustext.drawcenteredtext(draw, "Hashrate", 16, (width/4*1), (headerheight + (hashheight/2) - 24), colorTextFG)117 vicarioustext.drawcenteredtext(draw, hashrate, 24, (width/4*1), (headerheight + (hashheight/2)), colorDataValue)118 # Yesterday and Today value119 earningspad = 24120 value_last_day = "0 sats"121 value_today = "0 sats"122 if len(accountrewards["btc"]["daily_rewards"]) > 0:123 since_date = accountrewards["btc"]["daily_rewards"][0]["date"]124 sattally = 0125 for key in poolstats["btc"]["blocks"]:126 block = poolstats["btc"]["blocks"][key]127 if block["date_found"] > since_date:128 if block["user_reward"] is not None:129 sattally = sattally + int(float(block["user_reward"]) * sats_per_btc)130 else:131 break132 sattally2 = sattally133 since_date = since_date + 86400134 sattally = 0135 for key in poolstats["btc"]["blocks"]:136 block = poolstats["btc"]["blocks"][key]137 if block["date_found"] > since_date:138 if block["user_reward"] is not None:139 sattally = sattally + int(float(block["user_reward"]) * sats_per_btc)140 else:141 break142 value_last_day = str(sattally2 - sattally) + " sats"143 value_today = str(sattally) + " sats"144 vicarioustext.drawcenteredtext(draw, "Earnings Yesterday", 16, (width/4*3), (headerheight + (hashheight/2) - 22 - earningspad), colorTextFG)145 vicarioustext.drawcenteredtext(draw, value_last_day, 24, (width/4*3), (headerheight + (hashheight/2) - earningspad), colorDataValue)146 vicarioustext.drawcenteredtext(draw, "Earnings Today", 16, (width/4*3), (headerheight + (hashheight/2) - 22 + earningspad), colorTextFG)147 vicarioustext.drawcenteredtext(draw, value_today, 24, (width/4*3), (headerheight + (hashheight/2) + earningspad), colorDataValue)148 # 30 Days Rewards149 highestreward = gethighestreward(accountrewards)150 lowestreward = getlowestreward(accountrewards)151 labelwidth = math.floor(width / 5)152 graphedge = 3153 charttop = headerheight + hashheight + 32154 chartleft = labelwidth + graphedge155 chartright = width - graphedge156 chartbottom = height - footerheight - graphedge157 # - chart border158 draw.line(xy=[chartleft, charttop, chartleft, chartbottom],fill=colorGraphLineLight,width=1)159 draw.line(xy=[chartleft, chartbottom, chartright, chartbottom],fill=colorGraphLineLight,width=1)160 draw.line(xy=[chartleft, charttop, chartright, charttop],fill=colorGraphLineDark,width=1)161 draw.line(xy=[chartright, charttop, chartright, chartbottom],fill=colorGraphLineDark,width=1)162 # - dashed line background163 chart25 = int(math.floor(charttop + ((chartbottom - charttop)/4*1)))164 chart50 = int(math.floor(charttop + ((chartbottom - charttop)/4*2)))165 chart75 = int(math.floor(charttop + ((chartbottom - charttop)/4*3)))166 for i in range(chartleft, chartright, 10):167 draw.line(xy=[i,chart25,i+1,chart25],fill=colorGraphLineDark,width=1)168 draw.line(xy=[i,chart50,i+1,chart50],fill=colorGraphLineDark,width=1)169 draw.line(xy=[i,chart75,i+1,chart75],fill=colorGraphLineDark,width=1)170 # - left labels171 reward25 = int(math.floor((lowestreward + ((highestreward - lowestreward)/4*3)) * sats_per_btc))172 reward50 = int(math.floor((lowestreward + ((highestreward - lowestreward)/4*2)) * sats_per_btc))173 reward75 = int(math.floor((lowestreward + ((highestreward - lowestreward)/4*1)) * sats_per_btc))174 vicarioustext.drawrighttext(draw, str(reward25) + " sats", 12, labelwidth, chart25, colorTextFG)175 vicarioustext.drawrighttext(draw, str(reward50) + " sats", 12, labelwidth, chart50, colorTextFG)176 vicarioustext.drawrighttext(draw, str(reward75) + " sats", 12, labelwidth, chart75, colorTextFG)177 # - 30 days of bars178 totaldays = 31179 days = 0180 daystoskip = 1181 daywidth = int(math.floor((chartright - chartleft) / totaldays))182 barwidth = daywidth - 2183 overalltotal = 0184 masize = 14 # days of simple moving average.185 maoldx = -1186 maoldy = -1187 for reward in accountrewards["btc"]["daily_rewards"]:188 days = days + 1189 # skip the first day entry, something not right, and it doesnt show on slushpool.com190 if days < (daystoskip + 1):191 continue192 if days > totaldays + 1:193 break194 currenttotal = 0195 if reward["total_reward"] is not None:196 currenttotal = float(reward["total_reward"])197 overalltotal = overalltotal + currenttotal198 dayx = chartright - ((days - daystoskip) * daywidth)199 barpct = 0200 if highestreward > lowestreward:201 barpct = (currenttotal-lowestreward)/(highestreward-lowestreward)202 bartop = chartbottom - int(math.floor((chartbottom-charttop)*barpct))203 draw.rectangle(xy=[dayx,bartop,dayx+barwidth,chartbottom-1],fill=colorMiningReward)204 if reward["bos_plus_reward"] is not None:205 bosreward = float(reward["bos_plus_reward"])206 bospct = bosreward/(highestreward-lowestreward)207 bosbottom = bartop + int(math.floor((chartbottom-charttop)*bospct))208 if bosbottom > chartbottom:209 bosbottom = chartbottom210 draw.rectangle(xy=[dayx,bartop,dayx+barwidth,bosbottom],fill=colorBOSReward)211 # referral_bonus, referral_reward also available, but i dont know what they would look like yet212 # moving average line213 max = dayx + int(barwidth/2)214 matotal = 0215 for maidx in range(masize):216 marewardidx = days + maidx217 if len(accountrewards["btc"]["daily_rewards"]) > marewardidx:218 mareward = accountrewards["btc"]["daily_rewards"][marewardidx]219 marewardtotal = float(mareward["total_reward"])220 matotal = matotal + marewardtotal221 maavg = (matotal / masize)222 mapct = 0223 if highestreward > lowestreward:224 mapct = (maavg-lowestreward)/(highestreward-lowestreward)225 may = chartbottom - int(math.floor((chartbottom-charttop)*mapct))226 if maoldx != -1:227 draw.line(xy=[(max,may),(maoldx,maoldy)],fill=colorMovingAverage,width=2)228 maoldx = max229 maoldy = may230 overalltotal = overalltotal * sats_per_btc231 # Chart header232 if days > 0:233 dailyavg = (overalltotal / days)234 # Warn if missing breakeven. 235 breakevendaily = int((sats_per_btc / price_last) * (kwhUsed * 24 * kwhPrice))236 breakevencolor = colorBreakEvenGood237 if dailyavg < breakevendaily:238 breakevencolor = colorBreakEvenMiss239 vicarioustext.drawtoplefttext(draw, "Warning: Mining at a loss", 16, 0, (headerheight + hashheight + 16), breakevencolor)240 vicarioustext.drawtoplefttext(draw, "Last 30 days " + str(int(overalltotal)) + " sats", 16, 0, (headerheight + hashheight), colorTextFG)241 vicarioustext.drawtoprighttext(draw, "Daily avg " + str(int(dailyavg)) + " sats", 16, width, (headerheight + hashheight), colorTextFG)242 vicarioustext.drawtoprighttext(draw, "Break even " + str(int(breakevendaily)) + " sats", 16, width, (headerheight + hashheight + 16), breakevencolor)243 else:244 vicarioustext.drawcenteredtext(draw, "Rewards will be graphed below once earnings are recorded" , 16, int(width/2), (headerheight + hashheight))245 # Date and Time246 vicarioustext.drawbottomrighttext(draw, "as of " + vicarioustext.getdateandtime(), 12, width, height, colorTextFG)247 # Save to file248 im.save(outputFile)249if __name__ == '__main__':250 # Defaults251 configFile = "/home/bitcoin/nodeyez/config/slushpool.json"252 outputFile = "/home/bitcoin/images/slushpool.png"253 authtoken = "--put-your-auth-token-in-nodeyez/config/slushpool.json--"254 useTor=False255 priceUrl = "https://bisq.markets/bisq/api/markets/ticker"256 priceCheckInterval = 10800 # controls how often (in seconds), the market price is checked. 10800 is once every 3 hours257 kwhPrice = .12 # price per killowatt hour, in dollars258 kwhUsed = 1.100 # amount of killowatts used per hour for miners on the account259 sleepInterval = 600 # controls how often this display panel is updated. 600 is once every 10 minutes260 colorHeader=ImageColor.getrgb("#ffffff") # The header text color. Need to pass to also specify bolding261 colorMiningReward=ImageColor.getrgb("#6b50ff") # Slushpool mining rewards color262 colorBOSReward=ImageColor.getrgb("#fb82a8") # Slushpool BOS rewards color263 colorReferralReward=ImageColor.getrgb("#00bac5") # Slushpool referral rewards color264 colorGraphLineLight=ImageColor.getrgb("#a0a0a0") # Chart border left and bottom265 colorGraphLineDark=ImageColor.getrgb("#606060") # Chart border top and right266 colorMovingAverage=ImageColor.getrgb("#d69f06") # The moving average line267 colorDataValue=ImageColor.getrgb("#4040ff") # Color for hashrate, yesterday and today's earnings268 colorBreakEvenMiss=ImageColor.getrgb("#ff0000") # The break even color when the average is at or above the value269 colorBreakEvenGood=ImageColor.getrgb("#00ff00") # Break even color when average is below the value (cheaper to buy than mine)270 colorTextFG=ImageColor.getrgb("#ffffff") # General text color other than header and data values271 colorBackground=ImageColor.getrgb("#000000") # Background color272 # Inits273 sats_per_btc = 100000000 # useful constant274 price_last=1275 price_high=1276 price_low=1277 breakevendaily = 9999999 # will get calculated below278 price_countdown = 0279 # Require config280 if not exists(configFile):281 print(f"You must specify configuration including authtoken in {configFile}")282 exit(1)283 # Overide defaults284 if exists(configFile):285 with open(configFile) as f:286 config = json.load(f)287 if "slushpool" in config:288 config = config["slushpool"]289 if "authtoken" in config:290 authtoken = config["authtoken"]291 else:292 print(f"You must configure an authorization token in {configFile}")293 exit(1)294 if "outputFile" in config:295 outputFile = config["outputFile"]296 if "useTor" in config:297 useTor = config["useTor"]298 if "priceUrl" in config:299 priceUrl = config["priceUrl"]300 if "priceCheckInterval" in config:301 priceCheckInterval = int(config["priceCheckInterval"])302 if "kwhPrice" in config:303 kwhPrice = float(config["kwhPrice"])304 if "kwhUsed" in config:305 kwhUsed = float(config["kwhUsed"])306 if "sleepInterval" in config:307 sleepInterval = int(config["sleepInterval"])308 sleepInterval = 300 if sleepInterval < 300 else sleepInterval # minimum 5 minutes, access others309 if "colorHeader" in config:310 colorHeader = ImageColor.getrgb(config["colorHeader"])311 if "colorMiningReward" in config:312 colorMiningReward = ImageColor.getrgb(config["colorMiningReward"])313 if "colorBOSReward" in config:314 colorBOSReward = ImageColor.getrgb(config["colorBOSReward"])315 if "colorReferralReward" in config:316 colorReferralReward = ImageColor.getrgb(config["colorReferralReward"])317 if "colorGraphLineLight" in config:318 colorGraphLineLight = ImageColor.getrgb(config["colorGraphLineLight"])319 if "colorGraphLineDark" in config:320 colorGraphLineDark = ImageColor.getrgb(config["colorGraphLineDark"])321 if "colorMovingAverage" in config:322 colorMovingAverage = ImageColor.getrgb(config["colorMovingAverage"])323 if "colorDataValue" in config:324 colorDataValue = ImageColor.getrgb(config["colorDataValue"])325 if "colorBreakEvenMiss" in config:326 colorBreakEvenMiss = ImageColor.getrgb(config["colorBreakEvenMiss"])327 if "colorBreakEvenGood" in config:328 colorBreakEvenGood = ImageColor.getrgb(config["colorBreakEvenGood"])329 if "colorTextFG" in config:330 colorTextFG = ImageColor.getrgb(config["colorTextFG"])331 if "colorBackground" in config:332 colorBackground = ImageColor.getrgb(config["colorBackground"])333 # Check for single run334 if len(sys.argv) > 1:335 if sys.argv[1] in ['-h','--help']:336 print(f"Creates a summary image of Slushpool account with the current hashrate, and the")337 print(f"account earnings depicted for yesterday and today, and a graph of past 30 days")338 print(f"Usage:")339 print(f"1) Call without arguments to run continuously using the configuration or defaults")340 print(f"2) Pass with an argument other than -h or --help to run once and exit.")341 print(f"You must specify a custom configuration file at {configFile}")342 exit(0)343 else:344 print(f"Running once and exiting")345 # Loop346 while True:347 print("Getting account profile and rewards")348 accountprofile = getaccountprofile()349 accountrewards = getaccountrewards()350 poolstats = getpoolstats()351 if price_countdown <= 0:352 print("Getting updated prices")353 price_last, price_high, price_low = getpriceinfo()354 price_countdown = priceCheckInterval355 else:356 price_countdown = price_countdown - sleepInterval357 print("Creating image")358 createimage(accountrewards,accountprofile,poolstats,price_last)359 if len(sys.argv) > 1:360 exit(0)...

Full Screen

Full Screen

mempoolblocks.py

Source:mempoolblocks.py Github

copy

Full Screen

...12def convert_size(size_bytes):13 if size_bytes == 0:14 return "0B"15 size_name = ("B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB")16 i = int(math.floor(math.log(size_bytes, 1024)))17 p = math.pow(1024, i)18 s = round(size_bytes / p, 2)19 return "%s %s" % (s, size_name[i])20def drawmempoolblock(draw,x,y,w,h,blockinfo,mpb):21 blocksize=blockinfo["blockSize"]22 blockvsize=blockinfo["blockVSize"]23 transactions=blockinfo["nTx"]24 feeranges=list(blockinfo["feeRange"])25 feelow=feeranges[0]26 feehigh=feeranges[len(feeranges)-1]27 feemedian=blockinfo["medianFee"]28 feelowint = int(math.floor(float(feelow)))29 feehighint = int(math.floor(float(feehigh)))30 feemedianint = int(math.floor(float(feemedian)))...

Full Screen

Full Screen

spcl.py

Source:spcl.py Github

copy

Full Screen

...191 redleak_returned = redleak_correct(self)192 self.spectra['corrected']=redleak_returned[0]193 self.header = redleak_returned[1]194 return195 def sigma_clipping(self, spec_id='original', name='clipped',196 sigma_high=3, iterations=3):197 spectrum, wavelengths = self._use_spectrum(spec_id)198 i=0199 while i<iterations:200 median = numpy.median(spectrum)201 stdev = numpy.std(spectrum)202 diff = abs(spectrum-median)203 if i==0:204 mask = diff<(sigma_high*stdev)205 else:206 mask = mask & (diff<(sigma_high*stdev))207 i+=1208 self.masks[name] = mask209 self.spectra[name] = [spectrum[mask], wavelengths[mask]]...

Full Screen

Full Screen

satsperusd.py

Source:satsperusd.py Github

copy

Full Screen

1#! /usr/bin/env python32from PIL import Image, ImageDraw, ImageColor3from os.path import exists4import json5import math6import subprocess7import sys8import time9import vicarioustext10def drawsatssquare(draw,dc,dr,spf,satw,bpx,bpy):11 satsleft = spf12 for y in range(10):13 for x in range(10):14 if satsleft > 0:15 tlx = (bpx + (dc*11*satw) + (x*satw))16 tly = (bpy + (dr*11*satw) + (y*satw))17 brx = tlx+satw-218 bry = tly+satw-219 if satshape == "square":20 draw.rectangle(xy=((tlx,tly),(brx,bry)),fill=colorSatShape)21 if satshape == "circle":22 draw.ellipse(xy=((tlx,tly),(brx,bry)),fill=colorSatShape)23 satsleft = satsleft - 124def createimage(width=480, height=320):25 last,high,low = getpriceinfo()26 satsperfiatunit = int(round(100000000.0 / last))27 satsperfiatunitlow = int(round(100000000.0 / low))28 satsperfiatunithigh = int(round(100000000.0 / high))29 satsleft = satsperfiatunit30 satw=int(math.floor(width/87))31 padleft=int(math.floor((width-(87*satw))/2))32 padtop=4033 im = Image.new(mode="RGBA", size=(width, height), color=colorBackground)34 draw = ImageDraw.Draw(im)35 alpha_img = Image.new(mode="RGBA", size=(width, height), color=(0,0,0,0))36 drawa = ImageDraw.Draw(alpha_img)37 if showBigText and not showBigTextOnTop:38 vicarioustext.drawcenteredtext(draw, str(satsperfiatunit), 128, int(width/2), int(height/2), colorSatAmountShadow)39 vicarioustext.drawcenteredtext(draw, str(satsperfiatunit), 128, int(width/2)-2, int(height/2)-2, colorSatAmount)40 dc = 041 dr = 042 while satsleft > 100:43 satsleft = satsleft - 10044 drawsatssquare(draw,dc,dr,100,satw,padleft,padtop)45 dc = dc + 146 if dc >= 8:47 dr = dr + 148 dc = 049 drawsatssquare(draw,dc,dr,satsleft,satw,padleft,padtop)50 if showBigText and showBigTextOnTop:51 vicarioustext.drawcenteredtext(drawa, str(satsperfiatunit), 128, int(width/2), int(height/2), colorSatAmountShadow)52 vicarioustext.drawcenteredtext(drawa, str(satsperfiatunit), 128, int(width/2)-2, int(height/2)-2, colorSatAmount)53 vicarioustext.drawcenteredtext(draw, "Sats Per USD", 24, int(width/2), int(padtop/2), colorHeader, True)54 if not showBigText:55 vicarioustext.drawcenteredtext(draw, "Last: " + str(satsperfiatunit), 20, int(width/8*4), height-padtop)56 vicarioustext.drawcenteredtext(draw, "High: " + str(satsperfiatunitlow), 20, int(width/8*7), height-padtop)57 vicarioustext.drawcenteredtext(draw, "Low: " + str(satsperfiatunithigh), 20, int(width/8*1), height-padtop)58 vicarioustext.drawbottomlefttext(draw, "Market data by bisq", 16, 0, height, colorBisq)59 vicarioustext.drawbottomrighttext(draw, "as of " + vicarioustext.getdateandtime(), 12, width, height)60 # Combine and save61 composite = Image.alpha_composite(im, alpha_img)62 print(f"Saving file to {outputFile}")63 composite.save(outputFile)64def getpriceinfo():65 print("Retrieving updated price information")66 cmd = "curl --silent " + priceurl67 if useTor:68 cmd = "torify " + cmd69 global last70 global high71 global low72 try:73 cmdoutput = subprocess.check_output(cmd, shell=True).decode("utf-8")74 if len(cmdoutput) > 0:75 j = json.loads(cmdoutput)76 last = int(math.floor(float(j["btc_usd"]["last"])))77 high = int(math.floor(float(j["btc_usd"]["high"])))78 low = int(math.floor(float(j["btc_usd"]["low"])))79 except subprocess.CalledProcessError as e:80 cmdoutput = "{\"error\": }"81 return (last,high,low)82if __name__ == '__main__':83 # Defaults84 configFile="/home/bitcoin/nodeyez/config/satsperusd.json"85 outputFile="/home/bitcoin/images/satsperusd.png"86 priceurl="https://bisq.markets/bisq/api/markets/ticker"87 useTor=False88 satshape="square" # may be one of these: ['square','circle']89 sleepInterval=360090 showBigText=True91 showBigTextOnTop=True92 colorBisq=ImageColor.getrgb("#40FF40")93 colorHeader=ImageColor.getrgb("#ffffff")94 colorSatShape=ImageColor.getrgb("#ff7f00")95 colorSatAmount=ImageColor.getrgb("#4040407f")96 colorSatAmountShadow=ImageColor.getrgb("#ffffff7f")97 colorBackground=ImageColor.getrgb("#000000")98 # Inits99 last=1100 low=1101 high=1102 # Override defaults103 if exists(configFile):104 with open(configFile) as f:105 config = json.load(f)106 if "satsperusd" in config:107 config = config["satsperusd"]108 if "outputFile" in config:109 outputFile = config["outputFile"]110 if "priceurl" in config:111 priceurl = config["priceurl"]112 if "useTor" in config:113 useTor = config["useTor"]114 if "satshape" in config:115 satshape = config["satshape"]116 if "sleepInterval" in config:117 sleepInterval = int(config["sleepInterval"])118 sleepInterval = 600 if sleepInterval < 600 else sleepInterval # minimum 10 minutes, access others119 if "showBigText" in config:120 showBigText = config["showBigText"]121 if "showBigTextOnTop" in config:122 showBigTextOnTop = config["showBigTextOnTop"]123 if "colorBisq" in config:124 colorBisq = ImageColor.getrgb(config["colorBisq"])125 if "colorHeader" in config:126 colorHeader = ImageColor.getrgb(config["colorHeader"])127 if "colorSatShape" in config:128 colorSatShape = ImageColor.getrgb(config["colorSatShape"])129 if "colorSatAmount" in config:130 colorSatAmount = ImageColor.getrgb(config["colorSatAmount"])131 if "colorSatAmountShadow" in config:132 colorSatAmountShadow = ImageColor.getrgb(config["colorSatAmountShadow"])133 if "colorBackground" in config:134 colorBackground = ImageColor.getrgb(config["colorBackground"])135 if len(sys.argv) > 1:136 if sys.argv[1] in ['-h','--help']:137 print(f"Retrieves the market rate of BTC from Bisq and renders number of Sats per dollar")138 print(f"Usage:")139 print(f"1) Call without arguments to run continuously using the configuration or defaults")140 print(f"2) Pass an argument other than -h or --help to run once and exit")141 print(f"You may specify a custom configuration file at {configFile}")142 else:143 createimage()144 exit(0)145 # Loop146 while True:147 createimage()...

Full Screen

Full Screen

tools.py

Source:tools.py Github

copy

Full Screen

...27 Spec.mask_wl(numpy.array(([line[0],line[1]])),line_id,spec_id)28 Spec.mask_wl(numpy.array(([line[0], line[2]-(line[3]/2)],29 [line[2]+(line[3]/2),line[1]])), 30 line_id+' continuum',spec_id)31 Spec.sigma_clipping(line_id+' continuum', name=line_id+' clipped',32 sigma_high=2, iterations=10)33 poly = fit_continuum(Spec, line_id+' clipped', order=1)34 lineprofile = Spec.spectra[line_id][0] - \35 poly(Spec.spectra[line_id][1])36 fit = optimize.leastsq(profiles.errfunc, [line[2],line[3],1],37 args=(Spec.spectra[line_id][1],38 lineprofile, profdict[profile]))39 if plt==True:40 wls = numpy.arange(Spec.spectra[line_id][1][0],41 Spec.spectra[line_id][1][-1], 0.001)42 plot(wls, profdict[profile](fit[0],wls)+poly(wls))43 if keep_changes==False:44 del Spec.spectra[line_id]45 del Spec.spectra[line_id+' continuum']...

Full Screen

Full Screen

ipaddress.py

Source:ipaddress.py Github

copy

Full Screen

1#! /usr/bin/env python32from PIL import Image, ImageDraw, ImageColor3from os.path import exists4import json5import subprocess6import sys7import time8import vicarioustext9def getcurrentip():10 cmd = "hostname -I"11 try:12 cmdoutput = subprocess.check_output(cmd, shell=True).decode("utf-8")13 iplist = cmdoutput.split()14 goodip = "IP Addresses:\n"15 for i in iplist:16 if len(i) <= 15:17 goodip = goodip + "\n" + i18 return goodip19 except subprocess.CalledProcessError as e:20 print(e)21 return "unknown"22def createimage(width=480, height=320):23 currentip = getcurrentip()24 im = Image.new(mode="RGB", size=(width, height), color=colorBackground)25 draw = ImageDraw.Draw(im)26 vicarioustext.drawcenteredtext(draw, str(currentip), 36, int(width/2), int(height/2), colorTextFG, True)27 vicarioustext.drawbottomrighttext(draw, "as of " + vicarioustext.getdateandtime(), 12, width, height, colorTextFG)28 im.save(outputFile)29if __name__ == '__main__':30 # Defaults31 configFile="/home/bitcoin/nodeyez/config/ipaddress.json"32 outputFile="/home/bitcoin/images/ipaddress.png"33 colorTextFG=ImageColor.getrgb("#ffffff")34 colorBackground=ImageColor.getrgb("#000000")35 sleepInterval=12036 # Override config37 if exists(configFile):38 with open(configFile) as f:39 config = json.load(f)40 if "ipaddress" in config:41 config = config["ipaddress"]42 if "outputFile" in config:43 outputFile = config["outputFile"]44 if "colorTextFG" in config:45 colorTextFG = ImageColor.getrgb(config["colorTextFG"])46 if "colorBackground" in config:47 colorBackground = ImageColor.getrgb(config["colorBackground"])48 if "sleepInterval" in config:49 sleepInterval = int(config["sleepInterval"])50 sleepInterval = 30 if sleepInterval < 30 else sleepInterval # minimum 30 seconds, local only51 # Check for single run52 if len(sys.argv) > 1:53 if sys.argv[1] in ['-h','--help']:54 print(f"Prepares an image with all the IP addresses used by this host")55 print(f"Usage:")56 print(f"1) Call without arguments to run continuously using the configuration or defaults")57 print(f"2) Call with an argument other then -h or --help to run once and exit")58 print(f"You may specify a custom configuration file at {configFile}")59 else:60 createimage()61 exit(0)62 # Loop63 while True:64 createimage()...

Full Screen

Full Screen

blockheight.py

Source:blockheight.py Github

copy

Full Screen

1#! /usr/bin/env python32from PIL import Image, ImageDraw, ImageColor3from os.path import exists4import json5import sys6import time7import vicariousbitcoin8import vicarioustext9def createimage(width=480, height=320):10 currentblock = vicariousbitcoin.getcurrentblock()11 im = Image.new(mode="RGB", size=(width, height), color=colorBackground)12 draw = ImageDraw.Draw(im)13 vicarioustext.drawcenteredtext(draw, str(currentblock), 96, int(width/2), int(height/2), colorTextFG)14 vicarioustext.drawbottomrighttext(draw, "as of " + vicarioustext.getdateandtime(), 12, width, height, colorTextFG)15 im.save(outputFile)16if __name__ == '__main__':17 # Defaults18 configFile="/home/bitcoin/nodeyez/config/blockheight.json"19 outputFile="/home/bitcoin/images/blockheight.png"20 colorTextFG=ImageColor.getrgb("#ffffff")21 colorBackground=ImageColor.getrgb("#000000")22 sleepInterval=12023 # Override config24 if exists(configFile):25 with open(configFile) as f:26 config = json.load(f)27 if "blockheight" in config:28 config = config["blockheight"]29 if "outputFile" in config:30 outputFile = config["outputFile"]31 if "colorTextFG" in config:32 colorTextFG = ImageColor.getrgb(config["colorTextFG"])33 if "colorBackground" in config:34 colorBackground = ImageColor.getrgb(config["colorBackground"])35 if "sleepInterval" in config:36 sleepInterval = int(config["sleepInterval"])37 sleepInterval = 30 if sleepInterval < 30 else sleepInterval # minimum 30 seconds, local only38 # Check for single run39 if len(sys.argv) > 1:40 if sys.argv[1] in ['-h','--help']:41 print(f"Generates an image based on the blockheight")42 print(f"Usage:")43 print(f"1) Call without arguments to run continuously using the configuration or defaults")44 print(f"You may specify a custom configuration file at {configFile}")45 exit(0)46 # Loop47 while True:48 createimage()...

Full Screen

Full Screen

profiles.py

Source:profiles.py Github

copy

Full Screen

1import numpy2def errfunc(P, x, y, model): 3 return y-model(P, x) 4def gaussian(G=[0,1,1], x=1): ...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1import { g } from 'fast-check-monorepo';2console.log(g());3import { h } from 'fast-check-monorepo';4console.log(h());5import { i } from 'fast-check-monorepo';6console.log(i());7import { j } from 'fast-check-monorepo';8console.log(j());9import { k } from 'fast-check-monorepo';10console.log(k());11import { l } from 'fast-check-monorepo';12console.log(l());13import { m } from 'fast-check-monorepo';14console.log(m());15import { n } from 'fast-check-monorepo';16console.log(n());17import { o } from 'fast-check-monorepo';18console.log(o());19import { p } from 'fast-check-monorepo';20console.log(p());21import { q } from 'fast-check-monorepo';22console.log(q());23import { r } from 'fast-check-monorepo';24console.log(r());25import { s } from 'fast-check-monorepo';26console.log(s());27import { t } from 'fast-check-monorepo';28console.log(t());

Full Screen

Using AI Code Generation

copy

Full Screen

1const { g } = require('fast-check');2console.log(g);3const { g } = require('fast-check');4console.log(g);5const { g } = require('fast-check');6console.log(g);7const { g } = require('fast-check');8console.log(g);9 at Resolver.resolveModule (node_modules/jest-resolve/

Full Screen

Using AI Code Generation

copy

Full Screen

1const { g } = require('fast-check-monorepo')2g()3const { h } = require('fast-check-monorepo')4h()5const { i } = require('fast-check-monorepo')6i()7const { j } = require('fast-check-monorepo')8j()9const { k } = require('fast-check-monorepo')10k()11const { l } = require('fast-check-monorepo')12l()13const { m } = require('fast-check-monorepo')14m()15const { n } = require('fast-check-monorepo')16n()17const { o } = require('fast-check-monorepo')18o()19const { p } = require('fast-check-monorepo')20p()21const { q } = require('fast-check-monorepo')22q()23const { r } = require('fast-check-monorepo')24r()25const { s } = require('fast-check-monorepo')26s()27const { t } = require('fast-check-monorepo')28t()29const { u } = require('fast

Full Screen

Using AI Code Generation

copy

Full Screen

1const { g } = require('fast-check-monorepo');2const { g } = require('fast-check-monorepo');3const { g } = require('fast-check-monorepo');4const { g } = require('fast-check-monorepo');5const { g } = require('fast-check-monorepo');6const { g } = require('fast-check-monorepo');7const { g } = require('fast-check-monorepo');8const { g } = require('fast-check-monorepo');9const { g } = require('fast-check-monorepo');10const { g } = require('fast-check-monorepo');11const { g } = require('fast-check-monorepo');12const { g } = require('fast-check-monorepo');13const { g } = require('fast-check-monorepo');14const { g } = require('fast-check-monorepo');15const { g } = require('fast-check-monorepo');16const { g } = require('fast-check-mon

Full Screen

Using AI Code Generation

copy

Full Screen

1const fastCheck = require("fast-check");2console.log(fastCheck.g);3const fastCheck = require("fast-check");4console.log(fastCheck.g);5const fastCheck = require("fast-check");6console.log(fastCheck.g);7const fastCheck = require("fast-check");8console.log(fastCheck.g);9const fastCheck = require("fast-check");10console.log(fastCheck.g);11const fastCheck = require("fast-check");12console.log(fastCheck.g);13const fastCheck = require("fast-check");14console.log(fastCheck.g);15const fastCheck = require("fast-check");16console.log(fastCheck.g);17const fastCheck = require("fast-check");18console.log(fastCheck.g);19const fastCheck = require("fast-check");20console.log(fastCheck.g);21const fastCheck = require("fast-check");22console.log(fastCheck.g);23const fastCheck = require("fast-check");24console.log(fastCheck.g);25const fastCheck = require("fast-check");26console.log(fastCheck.g);27const fastCheck = require("fast-check");28console.log(fastCheck.g);29const fastCheck = require("fast-check");30console.log(fastCheck.g);31const fastCheck = require("fast-check");32console.log(fastCheck.g);33const fastCheck = require("fast-check");34console.log(fastCheck.g);

Full Screen

Using AI Code Generation

copy

Full Screen

1const { g } = require('fast-check-monorepo');2g();3const { g } = require('fast-check');4g();5npm ERR! 404 You should bug the author to publish it (or use the name yourself!)6const hello = async (event, context) => {7 return {8 body: JSON.stringify({9 }),10 };11};12module.exports = {13};14{15 "scripts": {

Full Screen

Using AI Code Generation

copy

Full Screen

1const { g } = require('fast-check');2const { add } = require('./add');3const test = () => {4 g.it('should add 2 numbers', () => {5 g.assert(add(1, 2) === 3);6 });7};8test();9const { g } = require('fast-check');10const { add } = require('./add');11const test = () => {12 g.it('should add 2 numbers', () => {13 g.assert(add(1, 2) === 3);14 });15};16test();17const { g } = require('fast-check');18const { add } = require('./add');19const test = () => {20 g.it('should add 2 numbers', () => {21 g.assert(add(1, 2) === 3);22 });23};24test();25const { g } = require('fast-check');26const { add } = require('./add');27const test = () => {28 g.it('should add 2 numbers', () => {29 g.assert(add(1, 2) === 3);30 });31};32test();33const { g } = require('fast-check');34const { add } = require('./add');35const test = () => {36 g.it('should add 2 numbers', () => {37 g.assert(add(1, 2) === 3);38 });39};40test();41const { g } = require('fast-check');42const { add } = require('./add');43const test = () => {44 g.it('should add 2 numbers', () => {45 g.assert(add(1, 2) === 3);46 });47};48test();49const { g } = require('fast-check');50const { add } = require('./add

Full Screen

Using AI Code Generation

copy

Full Screen

1const fc = require('fast-check');2const {g} = require('fast-check-monorepo');3const f = (x, y) => x + y;4const prop = (x, y) => {5 return f(x, y) === f(y, x);6};7fc.assert(8 fc.property(g(), g(), prop),9 {verbose: true, numRuns: 1000}10);11const fc = require('fast-check');12const {g} = require('fast-check-monorepo');13const f = (x, y) => x + y;14const prop = (x, y) => {15 return f(x, y) === f(y, x);16};17fc.assert(18 fc.property(g(), g(), prop),19 {verbose: true, numRuns: 1000}20);21const fc = require('fast-check');22const {g} = require('fast-check-monorepo');23const f = (x, y) => x + y;24const prop = (x, y) => {25 return f(x, y) === f(y, x);26};27fc.assert(28 fc.property(g(), g(), prop),29 {verbose: true, numRuns: 1000}30);31const fc = require('fast-check');32const {g} = require('fast-check-monorepo');33const f = (x, y) => x + y;34const prop = (x, y) => {35 return f(x, y) === f(y, x);36};37fc.assert(38 fc.property(g(), g(), prop),39 {verbose: true, numRuns: 1000}40);41const fc = require('fast-check

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run fast-check-monorepo automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful