Skip to content

Instantly share code, notes, and snippets.

@watson
watson / install-elasticsearch.ps1
Last active January 13, 2020 17:39
Install and run Elasticsearch in Windows PowerShell
Write-Host "Preparing to download and install Elasticsearch..." -ForegroundColor Cyan
$esVersion = "6.1.2"
$downloadUrl = "https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-$($esVersion).zip"
$zipPath = "$($env:USERPROFILE)\elasticsearch-$esVersion.zip"
$extractRoot = "$env:SYSTEMDRIVE\Elasticsearch"
$esRoot = "$extractRoot\elasticsearch-$esVersion"
Write-Host "Downloading Elasticsearch..."
(New-Object Net.WebClient).DownloadFile($downloadUrl, $zipPath)
7z x $zipPath -y -o"$extractRoot" | Out-Null
@josemcunha
josemcunha / README-Template.md
Last active December 19, 2020 11:06 — forked from PurpleBooth/README-Template.md
A template to make good README.md

Project Title

One Paragraph of project description goes here. Don't forget to link back to the tutorial.

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Prerequisites

@tkuther
tkuther / kubernetes-filebeat.yaml
Created July 12, 2018 12:33
Filebeat kubernetes config with nginx module for ingress-nginx
apiVersion: extensions/v1beta1
kind: DaemonSet
metadata:
name: filebeat
namespace: kube-system
labels:
k8s-app: filebeat
spec:
template:
metadata:
@betweenbrain
betweenbrain / life.md
Created February 27, 2016 16:34
Slim 3 Middleware Execution Order Example (last in, first executed)
<?php

require 'vendor/autoload.php';

$app = new \Slim\App();

// Executed last as it's first in (FILE)
$app->add(function ($request, $response, $next) {
	// Execute the routes first
@owenallenaz
owenallenaz / caught.js
Last active March 5, 2022 15:30
Showing that nodeJS domains do not catch synchronous errors. Hence the common practice is to enclose them in process.nextTick()
var domain = require("domain");
var d = domain.create();
d.on("error", function() {
console.log("domain caught");
});
try {
d.run(function() {
process.nextTick(function() {
@paul-appsinyourpants
paul-appsinyourpants / Console color in ruby
Created February 18, 2011 22:49
Add color to console logging easily in ruby
COLOR_ESCAPES = {
:none => 0,
:bright => 1,
:black => 30,
:red => 31,
:green => 32,
:yellow => 33,
:blue => 34,
:magenta => 35,
:cyan => 36,
@DavidWells
DavidWells / aws-lambda-redirect.js
Created June 28, 2018 20:48
How to do a 301 redirect from an AWS lambda function
exports.handler = (event, context, callback) => {
const response = {
statusCode: 301,
headers: {
Location: 'https://google.com',
}
};
return callback(null, response);
}
@dleske
dleske / k8s-update-secret.md
Last active January 29, 2024 17:12
k8s: Updating a Secret

Hopefully helped another k8s newbie with the following. The question was, how do you update a single key in a secret in k8s? I don't know anything about secrets but I will probably want to know this in the future, so here we go.

First, to create a dummy secret:

apiVersion: v1
kind: Secret
metadata:
  name: test-secret
data:
@zoellner
zoellner / utf16test.js
Created May 28, 2020 20:37
write utf-16 encoded files in node.js (both utf16be and utf16le)
const fs = require('fs');
// our demo string is in 'default' utf8 with emoji character assuming you are using an editor that supports those.
// if not, you can test this gist by setting utf8string to the equivalent '->\ud83d\ude03\ud83e\uddd2\ud83c\udffc\u00fc\u010d\u0113<-'
// gist doesn't support all ZWJ sequences, so can't show this here but it works with those as well, e.g. '\ud83d\udc68\ud83c\udffc\u200d\ud83d\udcbb'
const utf8string = '->😃🧒🏼üčē<-';
// this is what you'd usually do to write to a utf-8 encoded file
fs.writeFileSync('test-utf8.txt', utf8string);
@O-I
O-I / weighted_random_sampling.md
Last active February 21, 2024 19:02
[TIx 8] Weighted Random Sampling in Ruby

One of the many reasons I love working with Ruby is it has a rich vocabulary that allows you to accomplish your goals with a minimal amount of code. If there isn't a method that does exactly what you want, it's usually possible to build an elegant solution yourself.

Let's take the example of simulating the rolling of a die.

We can represent a die as an array of its faces.

die = [*?⚀..?⚅]
# => ["⚀", "⚁", "⚂", "⚃", "⚄", "⚅"]