Skip to content

Instantly share code, notes, and snippets.

View lewis-carson's full-sized avatar

Lewis Carson lewis-carson

  • 03:26 (UTC +01:00)
View GitHub Profile
@lewis-carson
lewis-carson / crawler.py
Created November 6, 2017 17:16
lightweight web crawler
from bs4 import BeautifulSoup
import random
import requests
import re
class crawler():
def findurls(self, limit, seed):
cache = seed
history = []
for idx, currenturl in enumerate(cache):
@lewis-carson
lewis-carson / alice.py
Last active December 10, 2017 09:34
A lightweight music player that runs in the console. Use the mode as 's' for shuffle or 'p' for normal play. Add 'r' to the end of the mode to make it repeat. Ctrl + C brings you to the start.
import winsound
import os
import random
from colorama import Fore, Back, Style
def printc(text):
print(Fore.RED + text)
print(Fore.WHITE)
def shuffledir(dir, repeat):
#shuffle
$(document).delegate('#textbox', 'keydown', function(e) {
var keyCode = e.keyCode || e.which;
if (keyCode == 9) {
e.preventDefault();
var start = this.selectionStart;
var end = this.selectionEnd;
// set textarea value to: text before caret + tab + text after caret
$(this).val($(this).val().substring(0, start) +
@lewis-carson
lewis-carson / r0b0t.ahk
Last active January 18, 2018 21:05
My custom AHK script. remember to change the paths at the end if you want the shortcuts for sublime, hyper, and chrome. To use install autohotkey and place this script in your startup folder. **disclaimer: i didnt make most of this script. It is just hacked togetehr from throughout the web**
#Persistent
#SingleInstance force
;; tiling window manager for windows 7-10 designed for 1 or 2 monitors arranging
;; windows in the following pattern with configurable window sizes and borders:
;; _________ _________
;; | | | | |___| <- primary monitor
;; | | | | | |
;; '---i-----' '-----i---'
class world:
def turn(self):
print('this is the world\'s turn')
class prompt:
def handle(self, command):
w.turn() #Calls worlds turn
def turn(self):
command = input('# ') #This is where the users command is prompted
p.handle(command) #calling this as a seperate function to process the input from the prompt
with open('out.py', 'w') as f:
f.write('')
def write(text, indent):
with open('out.py', 'a') as f:
f.write((indent * ' ') + text + '\n')
return
with open('in.txt') as f:
lines = f.readlines()
util = require('util');
require('util.promisify').shim();
exec = util.promisify(require('child_process').exec);
atom.commands.add 'atom-text-editor', 'blog:publish', ->
editor = atom.workspace.getActivePaneItem()
file = editor?.buffer.file.path.split('\\')
file.splice(-1,1)
{ stdout, stderr } = exec("cd #{file.join('\\')} && git add * && git commit * -m \"Updated blog\" && git push");
import os
import csv
import re
tot = ''
for i in os.listdir('csv'):
with open('csv/' + i) as f:
tot += f.read().replace(',\n', '\n')
print(f.read())