Skip to content

Instantly share code, notes, and snippets.

View thomasfr's full-sized avatar

Thomas Fritz thomasfr

View GitHub Profile
@thomasfr
thomasfr / newUserAndDatabase.sql
Last active August 29, 2015 14:06
Create Mysql user, password and grant rights on database
/** GRANT [type of permission] ON [database name].[table name] TO ‘[username]’@'localhost’ IDENTIFIED BY 'some_pass' WITH GRANT OPTION; **/
GRANT ALL PRIVILEGES ON DATABASE.* TO 'newuser'@'localhost' IDENTIFIED BY 'some_pass';
FLUSH PRIVILEGES;
/** BACKUP USER **/
GRANT SELECT,LOCK TABLES ON *.* TO 'backup'@'localhost' IDENTIFIED BY 'PASS';
@thomasfr
thomasfr / mysqld.service
Created July 23, 2014 17:43
mysqld.service file for systemd
[Unit]
Description=MySQL Server
After=syslog.target
After=network.target
[Service]
Type=simple
PermissionsStartOnly=true
ExecStartPre=/bin/mkdir -p /var/run/mysqld
ExecStartPre=/bin/chown mysql:mysql -R /var/run/mysqld
var MagentoAPI = require('magento');
var util = require('util');
var magento = new MagentoAPI({
host: 'wunderl.sernji.com',
port: 80,
path: '/api/xmlrpc/',
login: 'user',
pass: 'password'
});
@thomasfr
thomasfr / Example-POST-orders.md
Last active August 29, 2015 14:03
Eversport API

Example POST Request

Full Request / Response Format and documentation can be read here: http://jsonapi.org/format/

POST https://api.eversport.at/v2/venues/1234/orders
Content-Type: application/vnd.api+json
Accept: application/vnd.api+json

{
  "links": {
@thomasfr
thomasfr / Opening_Hours_Variant_3.adoc
Last active August 29, 2015 13:57
A Neo4J GraphGist about an attempt to model Office Hours. I want to be abel to ask questions like: "What location has opened now or at a given date and time?" and "Has this location open now or at a given date and time?"
@thomasfr
thomasfr / Office_Hours_Variant_2.adoc
Last active August 29, 2015 13:57
A Neo4J GraphGist about an attempt to model Office Hours. I want to be abel to ask questions like: "What location has opened now or at a given date and time?" and "Has this location open now or at a given date and time?"
@thomasfr
thomasfr / Office_Hours_Variant_1.adoc
Last active August 29, 2015 13:57
A Neo4J GraphGist about an attempt to model Office Hours. I want to be abel to ask questions like: "What location has opened now or at a given date and time?" and "Has this location open now or at a given date and time?"
CREATE (locationA:Location{name:"location A"}),
(locationA)-[:hasOfficeHours]->(officeHours:OfficeHours),
(officeHours)-[:year]->(year:Year{value:2014}),
(year)-[:month]->(month:Month{value:3,name:"March"}),

(month)-[:day]->(day24:Day{value:24, name:"Monday"}),
(day24)-[:hasInterval]->(:Interval{from:8,to:12}),
@thomasfr
thomasfr / nginx.conf
Created March 22, 2014 22:34
Redirect all requests not matching server_name to `www.example.com`
server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
rewrite ^ http://www.example.com permanent;
}
server {
server_name www.example.com
root /usr/share/nginx/html;
index index.html;
@thomasfr
thomasfr / iptables.sh
Last active April 13, 2024 01:59
iptable rules to allow outgoing DNS lookups, outgoing icmp (ping) requests, outgoing connections to configured package servers, outgoing connections to all ips on port 22, all incoming connections to port 22, 80 and 443 and everything on localhost
#!/bin/bash
IPT="/sbin/iptables"
# Server IP
SERVER_IP="$(ip addr show eth0 | grep 'inet ' | cut -f2 | awk '{ print $2}')"
# Your DNS servers you use: cat /etc/resolv.conf
DNS_SERVER="8.8.4.4 8.8.8.8"
# Allow connections to this package servers
@thomasfr
thomasfr / autossh.service
Last active January 5, 2024 08:11
Systemd service for autossh
[Unit]
Description=Keeps a tunnel to 'remote.example.com' open
After=network.target
[Service]
User=autossh
# -p [PORT]
# -l [user]
# -M 0 --> no monitoring
# -N Just open the connection and do nothing (not interactive)