Skip to content

Instantly share code, notes, and snippets.

@mreishus
mreishus / .gitlab-ci.yml
Created August 19, 2019 17:05
gitlab-ci.yml for self-signed docker repositories, from debuglevel/greeting-microservice
services:
- name: docker:dind
command: ["/bin/sh", "-c", "[[ -z $CERTIFICATE_URL ]] && ( echo Injecting no certificate && dockerd-entrypoint.sh || exit ) || ( echo Injecting certificate $CERTIFICATE_URL && wget $CERTIFICATE_URL -O /usr/local/share/ca-certificates/cert.crt && update-ca-certificates && dockerd-entrypoint.sh || exit )"]
variables:
## Uncomment this to inject a self-signed certificate into the docker:dind service
# CERTIFICATE_URL: http://my_server/my_corp.crt
# # disable TLS; see: https://gitlab.com/gitlab-org/gitlab-runner/issues/1350#note_199840999 and https://about.gitlab.com/2019/07/31/docker-in-docker-with-docker-19-dot-03/
# DOCKER_TLS_CERTDIR: ""
@mreishus
mreishus / symbols-outline.diff
Created January 27, 2022 16:54
diff for symbols-outline vim plugin to work with vim-pandoc handling markdown
diff --git a/lua/symbols-outline/providers/markdown.lua b/lua/symbols-outline/providers/markdown.lua
index 225dd66..c7afabd 100644
--- a/lua/symbols-outline/providers/markdown.lua
+++ b/lua/symbols-outline/providers/markdown.lua
@@ -4,7 +4,7 @@ local M = {}
-- probably change this
function M.should_use_provider(bufnr)
- return vim.api.nvim_buf_get_option(bufnr, "ft") == "markdown"
+ return vim.api.nvim_buf_get_option(bufnr, "ft") == "markdown" or vim.api.nvim_buf_get_option(bufnr, "ft") == "pandoc"
@mreishus
mreishus / app.js
Last active September 13, 2019 04:52
First try at Phoenix LiveView Hook organization
// assets/js/app.js
// We need to import the CSS so that webpack will load it.
// The MiniCssExtractPlugin is used to separate it out into
// its own CSS file.
import css from "../css/app.css"
// webpack automatically bundles all modules in your
// entry points. Those entry points can be configured
// in "webpack.config.js".
@mreishus
mreishus / create_post.exs
Created September 12, 2019 01:48 — forked from stevedomin/create_post.exs
Using UUIDs as primary key with Ecto
defmodule MyBlog.Repo.Migrations.CreatePost do
use Ecto.Migration
def change do
create table(:posts, primary_key: false) do
add :id, :uuid, primary_key: true
add :body, :string
add :word_count, :integer
timestamps
@mreishus
mreishus / DragScrollProvider.js
Last active August 10, 2018 19:57
React component to provide click-and-drag scrolling
// @flow
import * as React from "react";
// I got this from https://gist.github.com/flushentitypacket/7717cb30d1b172e633cea864eeb4d2e7
// Changes made
// 1. Added Y position
// 2. Converted from TypeScript to FlowType
// 3. Changed removeEventListeners to run off document.documentElement - they weren't working for me
// 4. Added event.preventDefault to mouse down handler - might prevent getting stuck in dragging state
// 5. Changed privateState updates to use a mutational style.
☁ word-vector-service [master] ⚡ ./test-search.sh car
{"message":"You searched for words similar to car.","result":[{"word":"vehicle","similarity":0.7821096736772518},{"word":"cars","similarity":0.7423831256488782},{"word":"suv","similarity":0.716096183913142},{"word":"minivan","similarity":0.6907036207365957},{"word":"truck","similarity":0.6735788941063529},{"word":"jeep","similarity":0.6511331376892135},{"word":"pickup_truck","similarity":0.6441437657521791},{"word":"scooter","similarity":0.6381531537921122},{"word":"sedan","similarity":0.6336699305265391},{"word":"motorcycle","similarity":0.6256056151438883},{"word":"van","similarity":0.6115673116061694},{"word":"mercedes","similarity":0.6063581532609913},{"word":"vehicles","similarity":0.5998871012894661},{"word":"motorbike","similarity":0.5921168453789547},{"word":"bike","similarity":0.5854155253215375},{"word":"automobile","similarity":0.5838368457239428},{"word":"bmw","similarity":0.5806985605377539},{"word":"driver","similarity":0.5779392938202413},{
@mreishus
mreishus / gist:7475460
Created November 14, 2013 22:30
Set::extract
# =============== CODE =========================
$data = array(
'EventPresenter' => array(
0 => 1000,
'corp_id' => 2000,
),
);
$corp_id = Set::extract($data, "/EventPresenter/corp_id");
pr(compact('corp_id'));
@mreishus
mreishus / pre-commit
Created September 2, 2011 19:51
git pre-commit for detecting conflicts
#!/bin/bash
#This goes in .git/hooks/pre-commit
git diff --cached --name-status | while read st file; do
# skip deleted files
if [ "$st" == 'D' ]; then continue; fi
if grep -q "^>>>>" "$file"; then
echo "Conflict detected in $file, aborting commit."
exit 1
<?php
/**
* Simple Benchmarker for PHP While Loops
*
* USES pcntl_fork() to split to different processes,
* so we assure RAM utilization doesn't "bleed"
*
* Usage:
* We are using php files for the large test, just to get a bunch of "random"
168405
_node: "A2SbQc0TQ82Jg2urmB4A4A"
_index: "ot_qa2-3"
_type: "jobs"
_id: "lZkNWotoQVKqiFbaUJqeXA"
_score: 0.28624028
fields:
association_key:
- "168405"