Skip to content

Instantly share code, notes, and snippets.

View gelinger777's full-sized avatar

Gelinger Media gelinger777

  • www.gelinger.at
  • Vienna
View GitHub Profile
@gelinger777
gelinger777 / nginx.conf
Created April 17, 2024 19:47 — forked from leeovery/nginx.conf
Modified Nginx configuration file for servers provisioned by Laravel Forge
# nginx Configuration File
# http://wiki.nginx.org/Configuration
# Run as a less privileged user for security reasons.
user forge;
# How many worker threads to run;
# "auto" sets it to the number of CPU cores available in the system, and
# offers the best performance. Don't set it higher than the number of CPU
# cores if changing this parameter.
@gelinger777
gelinger777 / checkeuvat.py
Created May 30, 2022 10:52 — forked from kgaughan/checkeuvat.py
Checking an EU VAT number using the VIES SOAP interface
from suds.client import Client
client = Client('http://ec.europa.eu/taxation_customs/vies/checkVatService.wsdl')
# Returns a dict-like object with the fields 'countryCode', 'vatNumber',
# 'requestDate', 'valid' (boolean), 'name', and 'address'.
result = client.service.checkVat('IE', '6390845P')
@gelinger777
gelinger777 / gasp.py
Created December 3, 2020 21:36 — forked from iUmarov/gasp.py
# This is my implmentation of calculating Global Average Symmetric Price (GASP) as it's mentioned in this video: https://www.youtube.com/watch?v=wpmTuNvGQjQ
# Presenter in the video doesn't explain briefly how to calculate the GASP, but, I kinda figured it out myself
order_book = {
'bids': [
[97, 0.1],
[96, 0.2],
[95, 6]
],
@gelinger777
gelinger777 / influx_schema.sql
Created November 8, 2020 10:28 — forked from bbc4468/influx_schema.sql
Influx DB Schema for OHLC
create database price_history_db
CREATE CONTINUOUS QUERY "cq_1m" ON "price_history_db" BEGIN SELECT MIN(price) as low, MAX(price) as high, FIRST(price) as open, LAST(price) as close, SUM(size) as volume INTO "price_1m" FROM "trade" GROUP BY time(1m), symbol END
CREATE CONTINUOUS QUERY "cq_5m" ON "price_history_db" BEGIN SELECT MIN(low) as low, MAX(high) as high, FIRST(open) as open, LAST(close) as close, SUM(volume) as volume INTO "price_5m" FROM "price_1m" GROUP BY time(5m), symbol END
CREATE CONTINUOUS QUERY "cq_15m" ON "price_history_db" BEGIN SELECT MIN(low) as low, MAX(high) as high, FIRST(open) as open, LAST(close) as close, SUM(volume) as volume INTO "price_15m" FROM "price_5m" GROUP BY time(15m), symbol END
CREATE CONTINUOUS QUERY "cq_1h" ON "price_history_db" BEGIN SELECT MIN(low) as low, MAX(high) as high, FIRST(open) as open, LAST(close) as close, SUM(volume) as volume INTO "price_1h" FROM "price_15m" GROUP BY time(1h), symbol END
CREATE CONTINUOUS QUERY "cq_6h" ON "price_history_db" BEGIN SELECT

Server side printing with Google Cloud Print API from a PHP application

It took me quite some time to figure out how to print properly from a web application. I will explain here how I did it, so you don't have to spend the same time.

Authorization

Google Cloud Print API uses OAuth 2.0 for authorization.

As explained [here][1] on the Google Developer page, the best way to use OAuth with the Google API is with a Google service account. Create a service account as explained on the Google Developer page.

To use OAuth a library is required. Google has published the [Google API PHP client library][2]. If you want to use the examples from the Developer pages, you need to use version 1 of the library. In this article I use version 2 of the library.

@gelinger777
gelinger777 / phantomjs-revealjs-slide-capture.js
Created July 1, 2017 11:00 — forked from soxofaan/phantomjs-revealjs-slide-capture.js
PhantomJS script to capture/render screenshots of the slides of a Reveal.js powered slideshow.
/**
* PhantomJS script to capture/render screenshots of the slides of a Reveal.js powered slideshow.
*/
var page = require('webpage').create();
var args = require('system').args;
// Get url to render from command line.
var url;
if (args.length < 2) {
@gelinger777
gelinger777 / xml_split.py
Created June 22, 2017 19:08 — forked from benallard/xml_split.py
Small python script to split huge XML files into parts. It takes one or two parameters. The first is always the huge XML file, and the second the size of the wished chunks in Kb (default to 1Mb) (0 spilt wherever possible) The generated files are called like the original one with an index between the filename and the extension like that: bigxml.…
#!/usr/bin/env python
import os
import xml.parsers.expat
from xml.sax.saxutils import escape
from optparse import OptionParser
from math import log10
# How much data we process at a time