Skip to content

Instantly share code, notes, and snippets.

View nicka101's full-sized avatar

Nick Anstee nicka101

  • Anstee Development
  • Norway
View GitHub Profile
@nicka101
nicka101 / table_dependents.sql
Last active August 29, 2015 14:08
Return a list of tables which depend on the specified table
CREATE PROCEDURE table_dependents
(
IN tbl_name varchar(255)
)
BEGIN
CREATE TEMPORARY TABLE tbl_dependents_processing(
table_name varchar(255) PRIMARY KEY NOT NULL
)ENGINE=MEMORY;
INSERT INTO tbl_dependents_processing SELECT DISTINCT TABLE_NAME FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE WHERE REFERENCED_TABLE_NAME = tbl_name;
@nicka101
nicka101 / backup-orders.php
Last active September 10, 2015 09:36
Backup utilities for Magento
<?php
if(count($argv) < 4){
echo "No database credentials supplied\n";
exit(1);
}
$username = $argv[1];
$password = $argv[2];
$db = $argv[3];
@nicka101
nicka101 / nginx
Created June 16, 2015 09:24
Nginx init script
#!/bin/sh
### BEGIN INIT INFO
# Provides: nginx
# Required-Start: $local_fs $remote_fs $network $syslog $named
# Required-Stop: $local_fs $remote_fs $network $syslog $named
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: starts the nginx web server
# Description: starts nginx using start-stop-daemon
@nicka101
nicka101 / socket-constant-rebind.cpp
Last active August 29, 2015 14:23
Test ephemeral port allocation for routed connections
#include <string>
#include <iostream>
#ifdef _WIN32
#include <WS2tcpip.h>
#define LAST_ERR WSAGetLastError()
#define SOCK_INVALID(s) s == INVALID_SOCKET
#else
#define LAST_ERR errno
#define SOCK_INVALID(s) s < 0
#include <sys/socket.h>
@nicka101
nicka101 / importPriceRules.php
Created July 14, 2015 10:29
import pricerules manual
<?php
require('app/Mage.php');
Mage::app();
$ftpCred = Mage::getStoreConfig('sinchimport_root/sinch_ftp');
Mage::dispatchEvent('sinch_pricerules_import_ftp', array(
'ftp_host' => $ftpCred["ftp_server"],
'ftp_username' => $ftpCred["login"],
'ftp_password' => $ftpCred["password"]
));
@nicka101
nicka101 / prg.php
Created April 7, 2016 13:30
Fix pricerules groups not appearing properly as a customer attribute
<?php
require_once('app/Mage.php');
Mage::app();
$attrib = Mage::getSingleton('eav/config')->getAttribute('customer', 'sinch_pricerules_group');
$attrib->setData('used_in_forms', array('adminhtml_customer'));
$attrib->save();
@nicka101
nicka101 / magento-backup.sh
Created August 23, 2016 09:18
Simple Backup script for Magento, with offsite uploading to Azure (requires bash, docker, mysqldump, xz, sha256sum and tar)
#!/bin/bash
# Simple Magento backup script by Nicka101 <nicka101@cloudbro.net>
# Some configuration constants
DB_NAME="<YOUR DB NAME>"
AZURE_USERNAME="<YOUR AZURE USERNAME>"
AZURE_KEY="<YOUR AZURE KEY>"
AZURE_CONTAINER="<YOUR (EXISTING) AZURE CONTAINER>"
WEBDIR=/var/www/whatever-folder
@nicka101
nicka101 / Instructions.txt
Last active August 28, 2020 02:40
Notes on Building the Linux kernel for Orange Pi PC2 (Allwinner H5)
Get a copy of the linux kernel source you intend to build
Install u-boot-tools, gcc-aarch64-linux-gnu, g++-aarch64-linux-gnu device-tree-compiler libncurses-dev (packages names on debian-based systems)
You also need native compiler tools available, such as build-essential
Add the following to arch/arm64/boot/dts/allwinner/Makefile:
dtb-$(CONFIG_ARCH_SUNXI) += sun50i-h5-orangepi-pc2.dtb
If they allwinner folder doesn't exist, get the patches necessary to create it (and its friends) from mainline kernel, linux-sunxi, etc, etc
Add the attached dts, dtsi and defconfig files to the locations specified below:
dts & dtsi --> arch/arm64/boot/dts/allwinner/
defconfig --> arch/arm64/config/
Run the following (from the root of the kernel tree):
@nicka101
nicka101 / mytop.sh
Created December 20, 2016 03:13
A simple bash script top-like program for mysql based on mysqladmin and dialog (well stty too, but its part of coreutils)
#!/bin/bash
# Top-like script for MySQL
DELAY=2
TTY_WIDTH=$(($(stty size | awk '{print $2}')-6)) # determine terminal width
TTY_HEIGHT=$(($(stty size | awk '{print $1}')-6)) # determine terminal height
while true; do
content="Status:\n"
@nicka101
nicka101 / build_nginx.sh
Last active July 14, 2017 11:24 — forked from Belphemur/build_nginx.sh
Compiling Nginx with LibreSSL (and http2)
#!/usr/bin/env bash
# names of latest versions of each package
export NGINX_VERSION=1.13.1
export VERSION_PCRE=pcre-8.40
export VERSION_LIBRESSL=libressl-2.5.4
export VERSION_NGINX=nginx-$NGINX_VERSION
#export NPS_VERSION=1.9.32.10
#export VERSION_PAGESPEED=v${NPS_VERSION}-beta