Skip to content

Instantly share code, notes, and snippets.

View ROBERT-MCDOWELL's full-sized avatar

ROBERT MCDOWELL ROBERT-MCDOWELL

View GitHub Profile
@Sitwon
Sitwon / wget.sh
Created January 3, 2014 19:22
A very basic replacement for wget in pure Bash.
#!/bin/bash
wget() {
local PROTO=${1%%://*}
local NOPROTO=${1#*://}
local HOST=${NOPROTO%%/*}
local PORT=${HOST#*:}
[ "${HOST}" = "${PORT}" ] && PORT=80
HOST=${HOST%:*}
local URI=${NOPROTO#*/}
@fetus-hina
fetus-hina / weeknumber2date.php
Created November 23, 2012 10:44
Calculate date by ISO-Week-Number (and wday)
<?php
function weekNumberToDate($year, $week, $wday = 1) {
// http://en.wikipedia.org/wiki/ISO_week_date#Calculating_a_date_given_the_year.2C_week_number_and_weekday
$correction = (int)gmdate('w', gmmktime(0, 0, 0, 1, 4, (int)$year)) + 3;
$yday = (int)$week * 7 + (int)$wday - $correction;
$time = gmmktime(0, 0, 0, 1, $yday, (int)$year);
return array((int)gmdate('Y', $time), (int)gmdate('n', $time), (int)gmdate('j', $time));
}
var_dump(weekNumberToDate(2008, 39, 6));
@ruzickap
ruzickap / livemedia-creator_make-pxe-live
Created July 16, 2017 07:23
Create PXE live files form Fedora 26 using lorax
# livemedia-creator --make-pxe-live --live-rootfs-keep-size --image-name=my_fedora_img --tmp=/var/tmp/a --ks fedora26-my.ks --iso=/home/ruzickap/data2/iso/Fedora-Workstation-netinst-x86_64-26-1.5.iso --resultdir=/var/tmp/a/result
/usr/lib64/python3.5/optparse.py:999: PendingDeprecationWarning: The KSOption class is deprecated and will be removed in pykickstart-3. Use the argparse module instead.
option = self.option_class(*args, **kwargs)
2017-07-16 08:12:28,922: disk_img = /var/tmp/a/result/my_fedora_img
2017-07-16 08:12:28,923: Using disk size of 6002MiB
2017-07-16 08:12:28,923: install_log = /var/tmp/lorax/virt-install.log
2017-07-16 08:12:29,161: qemu vnc=127.0.0.1:0
2017-07-16 08:12:29,161: Running qemu
2017-07-16 08:12:29,286: Processing logs from ('127.0.0.1', 52518)
2017-07-16 08:40:25,126: Installation finished without errors.
@vandot
vandot / geoipbind.py
Created March 16, 2016 00:52
Fetch geoip data and create Bind9 ACL based on continents for poor man's GSLB service
#!/usr/bin/env python
import csv
import urllib
import zipfile
import os
link = 'http://geolite.maxmind.com/download/geoip/database/GeoLite2-Country-CSV.zip'
csv1 = 'GeoLite2-Country-Blocks-IPv4.csv'
csv2 = 'GeoLite2-Country-Locations-en.csv'
@berstend
berstend / AllowFlashInChromium.md
Last active January 22, 2020 10:21
Allow flash content to run by default in Chromium by using a management policy file

Tested on Ubuntu 14.04 and Chromium 65

Steps

apt-get install chromium-browser adobe-flashplugin

mkdir -p /etc/chromium/policies/managed

vim /etc/chromium/policies/managed/foo_policy.json
@alumican
alumican / Timer.as
Created September 3, 2014 09:21
AS3 Timer based on getTimer
package util
{
import flash.display.DisplayObject;
import flash.events.Event;
import flash.events.EventDispatcher;
import flash.events.TimerEvent;
import flash.utils.getTimer;
/**
* This is the timer class based on getTimer().
@xlanor
xlanor / abrtcmd.txt
Created September 28, 2017 16:20
Fedora 26 - Disable abrt
#ABRT was spamming my fedora system with updates nonstop.
sudo systemctl -t service | grep abrt
sudo systemctl stop abrt-journal-core.service
sudo systemctl disable abrt-journal-core.service
sudo systemctl stop abrt-oops.service
sudo systemctl disable abrt-oops.service
sudo systemctl stop abrt-xorg.service
sudo systemctl disable abrt-xorg.service
sudo systemctl stop abrtd.service
@scottsb
scottsb / resetting-csync2-cluster.md
Last active October 25, 2021 20:28
Guide to Resetting a csync2 Cluster

Guide to Resetting a csync2 Cluster

Introduction

These are possible steps to reset a csync2 cluster that has been seriously fubared. This is an apocalyptic approach and should only be used when more surgical fixes (like correcting an individual conflict) aren't workable.

Use Cases

@apk
apk / websock.sh
Created April 18, 2012 15:51
A web socket server as a bash script.
#!/bin/bash
# WebSocket shell, start & browse to http://<Host>:6655/
# Requires bash 4.x, openssl.
# Author: rootshell@corelogics.de (which isn't me, apk)
coproc d { nc -l -p 6656 -q 0; }
nc -l -p 6655 -q 1 > /dev/null <<-ENDOFPAGE
HTTP/1.1 200 OK
<html><head><script language="javascript">
var url = location.hostname + ':' + (parseInt(location.port) + 1);
@tcurvelo
tcurvelo / takeout.js
Created April 18, 2018 00:46
WIP: Automating Google Takeout Download
const puppeteer = require('puppeteer');
(async () => {
const browser = await puppeteer.launch({headless: false});
const page = await browser.newPage();
await page.goto('https://takeout.google.com/');
const input = await page.evaluate(() => {
const next = document.querySelector('#identifierNext');