Skip to content

Instantly share code, notes, and snippets.

View themasch's full-sized avatar

Mark Schmale themasch

View GitHub Profile
@themasch
themasch / app.js
Last active September 2, 2016 14:42
serve gitlab artifacts via http
"use strict";
const express = require('express');
const gitlab = require('gitlab');
const Zip = require('jszip');
const got = require('got');
const mimeType = require('mime-types');
const glClient = gitlab({url: 'https://my.cool.gitlab.instance.io', token: 'YOUR_TOKEN_HERE'});
const app = express();
server {
listen 80;
server_name my.domain.com;
return 301 https://$server_name$request_uri;
}
@themasch
themasch / gist:8186786046bf8ced2d58
Created June 30, 2015 14:11
node-bencode benchmarks 30.06.15
node 0.10.39
decode to buffer
13,172 op/s » bencode
13,310 op/s » bencoding
16,289 op/s » dht_bencode
686 op/s » bncode
11,969 op/s » dht
encode buffer
IPT=$(which iptables)
#IPT=echo
LAN=("eth1" "eth2" "wlan0")
WAN="eth0"
$IPT -F
$IPT -t nat -F
$IPT -P INPUT ACCEPT
$IPT -P OUTPUT ACCEPT
import weechat;
def client_connected(data, signal, signal_data):
weechat.prnt("", "a client connected, new clients: %s" % weechat.info_get("relay_client_count", "connected"));
return weechat.WEECHAT_RC_OK
def client_disconnected(data, signal, signal_data):
left = weechat.info_get("relay_client_count", "connected");
weechat.prnt("", "a client disconnected, clients left: %s" % left);
if left < "1":
var Promise = require('bluebird')
var mkdirp = Promise.promisify(require('mkdirp'))
var fs = Promise.promisifyAll(require('fs'))
var request = require('request')
var resolutions = {
1: [ 1, 1 ],
2: [ 2, 2 ],
3: [ 5, 4 ],
4: [ 10, 9 ],
.flexTileContainer {
display: -webkit-box;
display: -moz-box;
display: -ms-flexbox;
display: -webkit-flex;
display: flex;
-webkit-flex-direction: row;
flex-direction: row;
-webkit-flex-wrap: wrap;
flex-wrap: wrap;
<!DOCTYPE html>
<html>
<head>
<script src="https://openui5.hana.ondemand.com/resources/sap-ui-core.js" id="sap-ui-bootstrap" data-sap-ui-theme="sap_bluecrystal" data-sap-ui-libs="sap.m"></script>
<meta charset="utf-8">
<title>JS Bin</title>
</head>
<body id="content" class="sapUiBody">
<script id="jsbin-javascript">
sap.ui.getCore().attachInit(function() {
@themasch
themasch / Scheduler.js
Last active August 29, 2015 14:05
node.js rate limite scheduler
function ms(input) {
if(typeof input === 'Number') {
return input
}
var number = parseInt(input, 10);
var unit = input.replace(number.toString(10), '').trim()
switch(unit) {
case 'd':
number *= 24
@themasch
themasch / component-preload-view-hack.js
Created July 16, 2014 10:02
inline xmlviews in ui5 component-preload.js
!(function() {
if (!sap.ui.core.mvc.View.prototype_initCompositeSupport) {
try {
sap.ui.core.mvc.View();
} catch (x) {} ;
}
var p = sap.ui.core.mvc.View.prototype, oI = p._initCompositeSupport;
p._initCompositeSupport = function(s) {
if (s.viewName) {
var vT = {"view.App": "<mvc:View xmlns=\"sap.m\" xmlns:mvc=\"sap.ui.core.mvc\" displayBlock=\"true\"> <Shell appWidthLimited=\"true\"> <App id=\"rootNav\"/> </Shell> </mvc:View>" /* ... */};