Skip to content

Instantly share code, notes, and snippets.

View sovietspy2's full-sized avatar
💩
will code for food

Barney Dono sovietspy2

💩
will code for food
View GitHub Profile
@sovietspy2
sovietspy2 / valid
Last active January 4, 2018 07:50
egy iylen szerkezetu kod addig fut amig egyszer validalni tudja a szoveget
main() {
szoveg = scanf
while (!validate(szoveg)) {
szoveg = scanf
}
}
// do stuff
@sovietspy2
sovietspy2 / python3 python rss
Last active August 18, 2018 12:31
python3 RSS weatcherforcast example
import feedparser
url = "http://cdn.koponyeg.hu/img/rss/idojaras_rss_regio_4.xml"
def get_actual_weather():
try:
feed = feedparser.parse(url)
# aktualis
telepules = feed['items'][0]['koponyeg_jelenido']['allomas']
@sovietspy2
sovietspy2 / python3 python api
Created August 18, 2018 13:21
Python3 chuck norris joke api (simple)
import requests
url = "http://api.icndb.com/jokes/random"
def get_chuck_norris_joke():
response = requests.get(url)
joke = dict(response.json())
return joke['value']['joke']
@sovietspy2
sovietspy2 / python3
Created August 18, 2018 14:03
Python3 global weather forecast example
#python3 -m pip install pyowm
#
import pyowm
# I changed one character :D have fun finding it
api_key = "fd64c4e513be8dfaee03be4e9a04948"
def get_forcast_for_city(city):
owm = pyowm.OWM(api_key) # You MUST provide a valid API key
@sovietspy2
sovietspy2 / bitcoinShellTicker.py
Created August 18, 2018 14:47 — forked from mattvukas/bitcoinShellTicker.py
A simple Python script that queries the Bitstamp API every 5 seconds and prints the last USD/Bitcoin price to the shell. Requires the Python Requests library.
import requests, json
from time import sleep
def getBitcoinPrice():
URL = 'https://www.bitstamp.net/api/ticker/'
try:
r = requests.get(URL)
priceFloat = float(json.loads(r.text)['last'])
return priceFloat
except requests.ConnectionError:
@sovietspy2
sovietspy2 / wordpress footer
Created November 1, 2018 16:24
wordpress footer
@sovietspy2
sovietspy2 / githook.service
Created November 24, 2018 18:13
linux systemd daemon example with autorestart
[Unit]
Description=Git hook service
[Service]
Type=simple
Restart=always
ExecStart=/usr/bin/python3 /home/sovietspy2/www/Phaser3GamePublisher/api.py
[Install]
WantedBy=multi-user.target
@sovietspy2
sovietspy2 / validateEmails.js
Created December 3, 2018 12:21
email validator es6
// emails should be an array of strings
export default function validateEmails(emails) {
const regex = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
const validAll = cleanedEmails.every( x => regex.test(x));
return validAll;
}
@sovietspy2
sovietspy2 / javascript
Created December 14, 2018 20:08
plugins
// https://labs.phaser.io/edit.html?src=src\plugins\add%20scene%20plugin%20in%20config.js
var config = {
type: Phaser.AUTO,
parent: 'phaser-example',
width: 800,
height: 600,
scene: {
preload: preload,
create: create,
@sovietspy2
sovietspy2 / csvtojson.js
Created December 29, 2018 13:17
This is a simple converter
//usage: node csvtojson.js <filename.csv>
//output: <filename>.json
const fs = require('fs');
const originalFileName = process.argv[2];
const newFileName = originalFileName.split(".")[0] + ".json";
console.log("new file name is :",newFileName);