Skip to content

Instantly share code, notes, and snippets.

Avatar

Matthew Reishus mreishus

View GitHub Profile
@mreishus
mreishus / app.js
Last active Sep 13, 2019
First try at Phoenix LiveView Hook organization
View app.js
// 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 Sep 12, 2019 — forked from stevedomin/create_post.exs
Using UUIDs as primary key with Ecto
View create_post.exs
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 / .gitlab-ci.yml
Created Aug 19, 2019
gitlab-ci.yml for self-signed docker repositories, from debuglevel/greeting-microservice
View .gitlab-ci.yml
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 / DragScrollProvider.js
Last active Aug 10, 2018
React component to provide click-and-drag scrolling
View DragScrollProvider.js
// @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.
View gist:bfbb0a532f9ecdce536d80eb3e8897c1
☁ 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},{
View benchmark-loops.php
<?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"
View gist:acd0e70913676f84cc35
168405
_node: "A2SbQc0TQ82Jg2urmB4A4A"
_index: "ot_qa2-3"
_type: "jobs"
_id: "lZkNWotoQVKqiFbaUJqeXA"
_score: 0.28624028
fields:
association_key:
- "168405"
View gist:7475460
# =============== 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 Sep 2, 2011
git pre-commit for detecting conflicts
View pre-commit
#!/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
You can’t perform that action at this time.