Skip to content

Instantly share code, notes, and snippets.

View mscharl's full-sized avatar

Michael Scharl mscharl

View GitHub Profile
@mscharl
mscharl / ip-logger.sh
Last active May 2, 2018 06:03
Script to fetch the external ip and write it to a file
export IP=$(curl --silent https://httpbin.org/ip 2>&1 | grep -Eo "([0-9]{1,3}.){3}[0-9]{1,3}")
export DATE=$(date +"%Y-%m-%d %H:%M")
echo "$DATE: $IP" >> ip.log
@mscharl
mscharl / Swift Events
Created November 1, 2016 10:36 — forked from ColinEberhardt/Swift Events
An eventing mechanism for Swift
/// An object that has some tear-down logic
public protocol Disposable {
func dispose()
}
/// An event provides a mechanism for raising notifications, together with some
/// associated data. Multiple function handlers can be added, with each being invoked,
/// with the event data, when the event is raised.
public class Event<T> {
@mscharl
mscharl / keybase.md
Last active November 30, 2017 21:49

Keybase proof

I hereby claim:

  • I am mscharl on github.
  • I am mscharl (https://keybase.io/mscharl) on keybase.
  • I have a public key whose fingerprint is 7E0C 1162 C231 77DD CCE5 BED6 D02E CBC1 E96C A2AD

To claim this, I am signing this object:

<!doctype html>
<html>
<head>
<!-- Run in full-screen mode. -->
<meta name="apple-mobile-web-app-capable" content="yes">
<!-- Make the status bar black with white text. -->
<meta name="apple-mobile-web-app-status-bar-style" content="black">
@mscharl
mscharl / functions.php
Last active December 22, 2015 02:08
Wordpress Dynamic Sidebar
<?php
if(function_exists('register_sidebar')) {
register_sidebar(array(
'before_widget' => '<div id="%1$s" class="block %2$s">',
'after_widget' => '</div>',
'before_title' => '<h3>',
'after_title' => '</h3>',
));
}
?>
@mscharl
mscharl / SharePopup.js
Created August 29, 2013 10:52
jQuery plugin for links to open in a popup (built for share links)
// the semi-colon before function invocation is a safety net against concatenated
// scripts and/or other plugins which may not be closed properly.
;(function ( $, window, document, undefined ) {
// undefined is used here as the undefined global variable in ECMAScript 3 is
// mutable (ie. it can be changed by someone else). undefined isn't really being
// passed in so we can ensure the value of it is truly undefined. In ES5, undefined
// can no longer be modified.
// window and document are passed through as local variable rather than global
@mscharl
mscharl / gist:4352571
Last active December 10, 2015 00:38
Stoping all ajax request
$.xhrPool = [];
$.xhrPool.abortAll = function() {
$(this).each(function(idx, jqXHR) {
jqXHR.abort();
});
$.xhrPool.length = 0
};
$.ajaxSetup({
beforeSend: function(jqXHR) {
@mscharl
mscharl / lessc.php
Created August 16, 2012 15:48
My on the fly less compiler
<?php
header('Content-Type: text/css');
require_once('lessc.inc.php');
$files = explode(',', $_GET['f']);
foreach($files as $f) _compile($f);