Skip to content

Instantly share code, notes, and snippets.

@henno
henno / openbravo_pos_sales_clearing_script.sql
Created June 9, 2016 16:49
Delete sales from Openbravo POS
delete from ticketlines;
delete from ticketlines;
delete from tickets;
delete from taxlines;
delete from payments;
delete from stockdiary;
delete from stockcurrent;
delete from reservation_customers;
delete from reservations;
delete from receipts;
@henno
henno / projects.example.com.conf
Last active November 12, 2016 21:38
Nginx configuration for projects as subdirectories (projects.example.com/project1)
#
# cat /etc/nginx/sites-enabled/projects.example.com
#
# Define variable $topdir (top level directory name)
map $request_uri $topdir {
~(?<captured_topdir>^/[a-zA-Z0-9]+)[/] $captured_topdir;
}
server {
@henno
henno / forward_remote_server_port_to_local_port.sh
Last active November 27, 2016 12:49
Forward remote web server port 9000 to localhost using SSH for debugging code running on remote server
#!/bin/sh
# Execute this on your local development machine
ssh -R 9000:localhost:9000 virt50123@mylivesite.com
@henno
henno / import_users.ps1
Created December 22, 2016 18:23
Load users to Active Directory from CSV
$Users = Import-Csv -Delimiter ";" -Path "C:\Users\Administrator\Desktop\users.csv"
foreach ($User in $Users)
{
$Displayname = $User.'Firstname' + " " + $User.'Lastname'
$UserFirstname = $User.'Firstname'
$UserLastname = $User.'Lastname'
$OU = $User.'OU'
$SAM = $User.'SAM'
$UPN = $User.'Firstname' + "." + $User.'Lastname' + "@" + $User.'Maildomain'
$Password = $User.'Password'
http://www.catalog.update.microsoft.com/search.aspx?q=kb2952664
@henno
henno / mikrotik_base_conf.rsc .ini
Last active May 21, 2019 08:00
Mikrotik base config
# Mikrotik config derived from the default factory config
# Features:
# - Ether1 is for Internet (WAN) and has DHCP client enabled
# - Ether 2-5 and wlan1 and wlan2 are in a bridge called bridge
# - This bridge has a DHCP server activated serving IPs from $myLanSubnet.10-$myLanSubnet.254
# - Wireless is set up with $mySSID using WPA2 and Sinimustvalge
# - Custom admin user tvv with klaabu is set to protect against hacking
# - Get an email when a user breaks the Internet by connecting his router's WAN port to your LAN
#
#!/bin/sh
find . -mtime -99 -printf "%T+ %s %p\n"|sort
@henno
henno / refresh_database.bat
Last active January 12, 2020 09:57
Command Prompt (cmd.exe) version
@echo off
SET DUMP_FILE_LOCATION=doc\database.sql
SET MYSQL=c:\xampp\mysql\bin\mysql.exe
SET MYSQLDUMP=c:\xampp\mysql\bin\mysqldump.exe
IF "%1"=="" GOTO ERROR
SET DATABASE_NAME="%1"
IF "%2"=="--dump" GOTO :DUMP
@henno
henno / refresh_database.sh
Last active January 12, 2020 09:57
Bash (for example git-bash.exe) version
#!/usr/bin/env bash
# This file can do one of two things:
# - reset a MySQL database back to original state from a dump file at given location and
# - create a new dump file from the current contents of given MySQL database
#
# Usage for resetting a database from dump:
#
# refresh_database.sh yourdatabasename
#
#
@henno
henno / timetable.php
Created March 30, 2020 22:43
tahvel.edu.ee to Apple and Google calendar
<?php
// Get current timestamp
$now = date("Ymd\THis");
// Retrieve data from tahvel.edu.ee
$data = file_get_contents("https://tahvel.edu.ee/hois_back/timetableevents/timetableByTeacher/15/calendar?from=2019-09-02T00:00:00Z&lang=et&teachers=$_GET[teacher]");
// Convert JSON to PHP array
$data = (array)json_decode($data);