Skip to content

Instantly share code, notes, and snippets.

Avatar

Konstantin Farrell konstantinfarrell

View GitHub Profile
@konstantinfarrell
konstantinfarrell / foo.js
Last active Sep 5, 2019
Google scraper stuff
View foo.js
var scraper = require("google-play-scraper")
// get a list of apps
var apps = scraper.search({
term: "foo",
num: 100,
})
var meta = []
@konstantinfarrell
konstantinfarrell / web.html
Last active Sep 9, 2017
A neat graph/web animation using p5.js
View web.html
<!DOCTYPE html>
<html>
<head>
<title>Webs</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.5.14/p5.js"></script>
<style>
body {
margin: 0;
overflow-x: hidden;
overflow-y: hidden;
@konstantinfarrell
konstantinfarrell / fix_massive.py
Last active Mar 11, 2017
Is Massive broken because of that stupid database file? Use this. Python 3.6
View fix_massive.py
import os
def fix_massive():
user = os.getlogin()
shit = rf'C:\Users\{user}\AppData\Local\Native Instruments\Massive\NIMassiveDataBase_ul'
if os.path.exists(shit):
os.remove(shit)
@konstantinfarrell
konstantinfarrell / golevel.py
Last active Jul 7, 2016
What originally was meant to be a quick script to determine how much total XP is needed to reach a certain level turned into an exercise showing the value of knowing the summation formula rather than simply going for the brute-force method
View golevel.py
import timeit
import math
def total_xp(level):
"""
Uses a loop to compute the total amount of xp
needed to reach a certain level.
"""
total = 0
View fibonnacci.py
import os
def fibonnacci(num):
"""
Takes a number num and returns the num'th fibonnacci number.
"""
if num == 2 or num == 1:
return 1
else:
fib = fibonnacci(num-1) + fibonnacci(num-2)
@konstantinfarrell
konstantinfarrell / directory_walk.py
Last active Jul 3, 2016
Recursive directory walk function in Python.
View directory_walk.py
import os
def directory_walk(path):
for item in os.listdir(path):
if os.path.isdir(item):
directory_walk(item)
else:
print(item)
@konstantinfarrell
konstantinfarrell / fizzbuzz.py
Created Jun 28, 2016
FizzBuzz one-liner in Python 3
View fizzbuzz.py
# Using a lambda function
print(list(map(lambda i: "Fizz"*(i%3==0)+"Buzz"*(i%5==0) or str(i), range(1,101))))
# Using a for loop
for i in range(1, 101): print("Fizz"*(i%3==0)+"Buzz"*(i%5==0) or str(i))
@konstantinfarrell
konstantinfarrell / stock_request.py
Last active Jun 14, 2016
Query a stock symbol with the python requests library
View stock_request.py
import requests
API_URL="http://finance.yahoo.com/d/quotes.csv"
symbol="AMZN"
params="sopc"
querystring = API_URL + "?s=" + symbol + "&f=" + params
@konstantinfarrell
konstantinfarrell / organize_directory.py
Created May 29, 2016
Python script that cleans up my downloads folder
View organize_directory.py
import shutil
import mimetypes
from os import listdir
from os.path import isfile, join
ORIGIN = r"C:\Users\Konstantin\Downloads\\" # Change these. Unless your system
# happens to have the same configuration.
MUSIC_DESTINATION = r"C:\Users\Konstantin\Music\\"
PICTURE_DESTINATION = r"C:\Users\Konstantin\Pictures\\"
PDF_DESTINATION = r"C:\Users\Konstantin\Documents\\"
@konstantinfarrell
konstantinfarrell / cube_error.ino
Created May 14, 2016
Arduino code to translate HTTP error messages into LED patterns on a 3x3x3 LED matrix.
View cube_error.ino
// we're gonna try something new here.
int scannow=0,scandir=0;
int incoming = 0;
unsigned int table[][4]={
{0x000, 0x000, 0x000, 0x0000},
};
void setup() {
Serial.begin(9600);