Skip to content

Instantly share code, notes, and snippets.

View shyal's full-sized avatar
🤓

Shyal Beardsley shyal

🤓
View GitHub Profile
@shyal
shyal / n_queen.py
Created January 18, 2020 13:00
n-queen algorithm animated in the terminal
from time import sleep
from os import system
"""
After spending the day trying to understand this algorithm, i decided to animated it in terminal.
Makes a lot more sense, so sharing.
"""
delay = .05
<html>
<head>
<style>
@import 'https://fonts.googleapis.com/css?family=Roboto:300,400,500';
header {
background-color: #263d36;
background-image: url("https://images.unsplash.com/photo-1511878587934-516d7ca5465b?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1689&q=80");
background-position: center top;
background-repeat: no-repeat;
@shyal
shyal / pushdpopd.sh
Last active November 7, 2018 18:10
pushd popd example
#!/bin/bash
# we are supposed to be in our home directory
cd
# we make a directory called foo
mkdir foo
# we "cd" into foo, but we remember where we came from
pushd foo
@shyal
shyal / fabfile.py
Last active November 7, 2018 18:09
import boto3
from fabric.api import sudo, task, env
import os
env.key_filename = os.path.expanduser('~/.ssh/key.pem')
env.user = 'ubuntu'
env.filter = ['running', 'stopped']
ec2 = boto3.resource('ec2')
@shyal
shyal / tether_prints.py
Created August 22, 2018 18:32
This should print out how many USDT have been printed
#########################################################
# This should print out how many USDT have been printed #
# date created: 22/08/2018 #
# date updated: 22/08/2018 #
#########################################################
import requests
import os
import json
import tempfile
from tornado import gen, web, ioloop, httpclient
import json
class MainHandler(web.RequestHandler):
@gen.coroutine
def get(self):
http_client = httpclient.AsyncHTTPClient()
time, ip, headers = yield [http_client.fetch("http://time.ioloop.io?format=json"),
http_client.fetch("http://ip.ioloop.io?format=json"),
@shyal
shyal / concurrent_tornado_fetches.py
Last active February 15, 2017 09:11
This example shows how to use the tornado AsyncHTTPClient concurrently to perform multiple gets
from tornado import gen, web, ioloop, httpclient
import json
class MainHandler(web.RequestHandler):
@gen.coroutine
def get(self):
http_client = httpclient.AsyncHTTPClient()
time, ip, headers = yield [http_client.fetch("http://time.ioloop.io?format=json"),
@shyal
shyal / test.py
Last active October 26, 2016 10:37
#!/usr/bin/env python
import requests
from argparse import ArgumentParser
import pickle
limit = 50
# getting urls and dumping them into file
def get_urls():
sites = requests.get("http://readthedocs.org/api/v1/project/?limit=%s&offset=0&format=json" % limit)
objects = sites.json()['objects']