Skip to content

Instantly share code, notes, and snippets.

View infusion's full-sized avatar

Robert Eisele infusion

View GitHub Profile
@infusion
infusion / import-tar-gz.sh
Last active May 4, 2023 06:00
Import a tar.gz file to MySQL
tar xOf dump.sql.tar.gz | mysql -u $user -p $database
@infusion
infusion / git-restore-file.sh
Created May 22, 2016 22:23
Find and restore a deleted file in a Git
# Find last commit for the deleted file
git rev-list -n 1 HEAD -- $path
# Checkout the commit before the the delete happened
git checkout $commit^ -- $path
@infusion
infusion / create-mediawiki.sql
Created June 20, 2016 12:26
Mediawiki MySQL Table layout
-- SQL to create the initial tables for the MediaWiki database.
-- This is read and executed by the install script; you should
-- not have to run it by itself unless doing a manual install.
-- This is a shared schema file used for both MySQL and SQLite installs.
--
-- For more documentation on the database schema, see
-- https://www.mediawiki.org/wiki/Manual:Database_layout
--
-- notes:
@infusion
infusion / fork-and-write-pid.sh
Created August 16, 2015 01:45
Fork a command and write the pid file on Bash
((/usr/local/php/bin/php -f /var/www/queue.php) & echo $! > /var/run/queue.pid &)
@infusion
infusion / up.sh
Last active February 28, 2020 11:09
Update all OSX deps
#!/bin/sh
set -e
set -x
brew update && brew upgrade
npm -g update
for package in $(npm -g outdated --parseable --depth=0 | cut -d: -f3)
@infusion
infusion / recursive-primitive.js
Last active February 2, 2020 22:10
An implementation of primitive operations like addition, multiplication and so on - recursively!
/**
* @license Recursive-Primitive.js
*
* Copyright (c) 2014, Robert Eisele (robert@xarg.org)
* Dual licensed under the MIT or GPL Version 2 licenses.
**/
const add = (a, b) => b === 0 ? a : add(a + 1, b - 1);
const sub = (a, b) => b === 0 ? a : sub(a - 1, b - 1);
const mul = (a, b) => b === 1 ? a : add(mul(a, b - 1), a);
@infusion
infusion / lighttpd-image.lua
Last active December 17, 2018 08:49
Some old lighttpd lua files
-- jpeg quality
quality = "85"
-- docroot of the images
docroot = "/var/www"
-- list of all sizes used
map_sizes = "sml"
-- map of prefixes : sizes to width/height - if the size doesn't exist, an error will thrown
@infusion
infusion / rational-pow.py
Last active November 25, 2018 14:10
Calculates the rational power using newton method
# Copyright Robert Eisele https://www.xarg.org/
from fractions import Fraction
import math
# Calculates (a/b)^(c/d) if solution is rational
def pow(a, b, c, d):
xn = Fraction(int(math.pow(a, c / float(d))), int(math.pow(b, c / float(d))))
abc = Fraction(a, b)**c
@infusion
infusion / drawAtLineIntersection.m
Last active October 8, 2016 22:28
Matlab Drawing Helper
% Draws a point at the intersection of two lines
% L1 = V1 + s * W1
% L2 = V2 + t * W2
function drawAtLineIntersection(V1, W1, V2, W2)
if isequal(V1, V2) && isequal(W1, W2)
c = V1; % could be any point on the line
else
i = [W1, -W2] \ (V2 - V1);
@infusion
infusion / daily-reporting.sh
Last active July 6, 2016 22:12
Some curl snippets
#!/bin/bash
echo "What have you done today?"
read msg
echo "For how long have wo worked today?"
read hours
user="Robert"
pass="secret"