Skip to content

Instantly share code, notes, and snippets.

View twogood's full-sized avatar

David Eriksson twogood

View GitHub Profile
@alexellis
alexellis / Dockerfile
Last active December 5, 2022 23:46
Run a one-shot job on Docker Swarm Mode
FROM golang:1.7.3
RUN mkdir -p /go/src/github.com/alexellis2/jaas
WORKDIR /go/src/github.com/alexellis2/jaas
COPY ./app.go ./
RUN go get -v -d
RUN go build
@smoser
smoser / README.md
Last active March 29, 2024 07:19
set up a ssh tunnel only user for ssh proxy jump

Set up a ssh tunnel only user

In order to give someone access to hosts that are available only by ssh "bouncing" (ProxyJump), add a user for this specific purpose.

We have an internal openstack where instances get IPs on per-tenant networks. Each tenant has a 'bastion' host that has a "public" ip (floating ip). You can access other instances by bouncing through the bastion. From time to time I want to let someone else into an instance. This could be done either with:

a.) just give them shell access to the bastion and let them hop through. Sharing an unrestricted shell account on my bastion is less than ideal. b.) assign a floating/"public" IP to the instance so they could go directly in. Floating IPs are limited, so this is less than ideal.

So instead, I have set up a single user as described here that can only be used for ProxyJump. It allows others proxied access to my instances but without granting them full shell access.

@andyvanee
andyvanee / Makefile
Created March 21, 2016 16:41
Export docker-machine environment variables in a makefile
#
# Run `make ENVIRONMENT=machinename` to override the default
#
ENVIRONMENT=default
TLS_VERIFY=$(shell docker-machine env $(ENVIRONMENT) | grep 'DOCKER_TLS_VERIFY=".*"' | cut -d\" -f2)
HOST=$(shell docker-machine env $(ENVIRONMENT) | grep 'DOCKER_HOST=".*"' | cut -d\" -f2)
CERT_PATH=$(shell docker-machine env $(ENVIRONMENT) | grep 'DOCKER_CERT_PATH=".*"' | cut -d\" -f2)
MACHINE_NAME=$(shell docker-machine env $(ENVIRONMENT) | grep 'DOCKER_MACHINE_NAME=".*"' | cut -d\" -f2)
export DOCKER_MACHINE_NAME=$(MACHINE_NAME)
@iPaulPro
iPaulPro / include_list_viewpager.xml
Last active March 7, 2024 11:13
CollapsingToolbarLayout with TabLayout
<?xml version="1.0" encoding="utf-8"?><!--
~ Copyright (C) 2015 The Android Open Source Project
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
@imjasonh
imjasonh / markdown.css
Last active May 17, 2024 07:30
Render Markdown as unrendered Markdown (see http://jsbin.com/huwosomawo)
* {
font-size: 12pt;
font-family: monospace;
font-weight: normal;
font-style: normal;
text-decoration: none;
color: black;
cursor: default;
}
@jcavar
jcavar / TimeAgo
Created May 11, 2014 15:16
DateUtils getRelativeTimeSpanString method which cares about time zone
/**
* DateUtils getRelativeTimeSpanString methods which cares about time zone
* @param date date for which you want time ago
* @param timeZone time zone in which is date
* @return time ago string
*/
public static String timeAgoFromDate(Date date, TimeZone timeZone) {
TimeZone defaultTimeZone = TimeZone.getDefault();
TimeZone.setDefault(timeZone);
@neolitec
neolitec / BasicAuthenticationFilter.java
Created February 12, 2014 11:09
HTTP Basic authentication Java filter
package com.neolitec.examples;
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.servlet.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@katowulf
katowulf / 1_using_queries.js
Last active April 24, 2023 07:14
Methods to search for user accounts by email address in Firebase
/***************************************************
* Simple and elegant, no code complexity
* Disadvantages: Requires warming all data into server memory (could take a long time for MBs of data or millions of records)
* (This disadvantage should go away as we add optimizations to the core product)
***************************************************/
var fb = firebase.database.ref();
/**
* @param {string} emailAddress
@nikmartin
nikmartin / A: Secure Sessions Howto
Last active April 28, 2024 05:17
Secure sessions with Node.js, Express.js, and NginX as an SSL Proxy
Secure sessions are easy, but not very well documented.
Here's a recipe for secure sessions in Node.js when NginX is used as an SSL proxy:
The desired configuration for using NginX as an SSL proxy is to offload SSL processing
and to put a hardened web server in front of your Node.js application, like:
[NODE.JS APP] <- HTTP -> [NginX] <- HTTPS -> [PUBLIC INTERNET] <-> [CLIENT]
Edit for express 4.X and >: Express no longer uses Connect as its middleware framework, it implements its own now.
@slightfoot
slightfoot / SearchActivity.java
Last active October 26, 2023 12:28
SearchView example
import java.util.ArrayList;
import java.util.Iterator;
import java.util.Locale;
import android.content.Context;
import android.content.Intent;
import android.database.AbstractCursor;
import android.database.Cursor;
import android.support.v4.app.FragmentActivity;
import android.text.TextUtils;