Skip to content

Instantly share code, notes, and snippets.

View gartmeier's full-sized avatar

Joshua Gartmeier gartmeier

  • Pitcher AG
  • Switzerland
View GitHub Profile
@gartmeier
gartmeier / cloudwatch_ecs_container.py
Last active January 5, 2019 12:29
CloudWatch metric for AWS ECS container storage
#!/usr/bin/python
import subprocess
import boto3
cw = boto3.client('cloudwatch', region_name='eu-west-1')
ctn_ip = subprocess.check_output('curl --silent ifconfig.co', shell=True).strip()
stats_lines = subprocess.check_output([
'/usr/bin/docker',
'stats',
Vue.component('chapters', {
template: `<div v-if="chapters.length > 0" class="field">
<h2 class="ui header">Rearrange Chapters</h2>
<p><i class="arrows alternate icon"></i> Tap on chapter to start moving</p>
<div class="ui grid">
<div v-for="c in chapters" class="four wide column">
<div class="ui grid">
<div class="chapter" :class="{ 'twelve wide column': moving, 'sixteen wide column': !moving }">
<div class="ui card" @click="startMoving(c)">
<div class="image">
function addHook(hook, eventName) {
let event = window[eventName];
window[eventName] = function() {
setTimeout(() => {
try {
hook.apply(null, arguments);
} catch (e) {
console.error(e);
}
@gartmeier
gartmeier / event.js
Last active November 23, 2018 09:58
$(function() {
$.fireEvent = function(name, data) {
var deferred = $.Deferred(),
callback = 'cb' + Math.random().toString(36).substring(7);
if (data) {
data.callBackFunc = callback;
data.callBack = callback;
data.source = $.fireEvent.defaults.source;
}
@gartmeier
gartmeier / pwd.py
Created May 31, 2018 18:19
Generate passwords
import string
import random
for x in range(1000):
print(''.join(random.choices(string.ascii_lowercase + string.ascii_uppercase + string.digits, k=10)))
@gartmeier
gartmeier / disclosures.js
Last active May 31, 2018 17:10
Adds disclosure slides to custom decks
(function ($) {
var prefix = 'System:ds:';
function uniqueArray(ar) {
var j = {};
ar.forEach(function (v) {
j[v + '::' + typeof v] = v;
});
@gartmeier
gartmeier / wp-compensated-links-snippet.php
Created March 9, 2018 06:39
Wordpress Snippet to show compensated links information
(function ($) {
var isWin = typeof Ti.App.Platform !== 'undefined'
&& Ti.App.Platform === 'Win';
var currentResourceId = 0,
deferredMap = {};
$.query = function (query, db) {
var id = nextQueryId(),
d = deferredMap[id] = $.Deferred(),
@gartmeier
gartmeier / pin.php
Last active October 2, 2017 16:48
generates a pin code with numbers next to each other
<?php
$num = [
1 => [2, 4],
2 => [1, 3, 5],
3 => [2, 6],
4 => [1 ,5 ,7],
5 => [2, 4, 6, 8],
6 => [3, 5, 9],
7 => [4, 8],
@gartmeier
gartmeier / openurl.sh
Last active August 29, 2015 14:04
Shell script to open the folder of a file url
#!/bin/bash
# installation:
# ~$: mv openurl.sh /usr/local/bin/openurl
# ~$: chmod +x /usr/local/bin/openurl
#
# usage: openurl file:///Users/user01/Documents/Workspace/project%201/index.html
#
# credits: urlencode and urldecode copied from https://gist.github.com/cdown/1163649