Skip to content

Instantly share code, notes, and snippets.

View machuga's full-sized avatar

Matt Machuga machuga

View GitHub Profile
@DarrylDias
DarrylDias / neovim-test.vim
Created April 26, 2014 16:06
Neovim job control demo Original file: http://pastebin.com/hpiCP9Ae
:let srv1_id = jobstart('netcat-server-1', 'nc', ['-l', '9991'])
:let srv2_id = jobstart('netcat-server-2', 'nc', ['-l', '9991'])
function JobEvent()
" v:job_data[0] = the job id
" v:job_data[1] = the event type, one of "stdout", "stderr" or "exit"
" v:job_data[2] = data read from stdout or stderr
if v:job_data[1] == 'stdout'
let str = 'Message from job '.v:job_data[0].': '.v:job_data[2]
elseif v:job_data[1] == 'stderr'
@jah2488
jah2488 / fast_spec_helpers.rb
Last active August 29, 2015 13:57
Speed up test db transactions with optimized-ish SQL queries!
def clean!(*classes)
execute!(classes.map { |klass| "DELETE FROM #{klass.table_name}" }.join('; '))
end
def create!(klass, keys, values)
query = make_mass_query(klass, keys, values)
execute!(query).map { |row| klass.new(row) }
end
private
module Primes where
open import Level using (_⊔_)
open import Coinduction
open import Function
open import Data.Empty
open import Data.Unit
open import Data.Nat
open import Data.Nat.Properties
open import Data.Nat.Divisibility
@evancz
evancz / Ports.js
Last active March 21, 2019 17:37
Example usage of Elm "ports" that uses signals, non-signals, records, and tuples. Build the Elm code with "elm --only-js Shanghai.elm" and include all of the JS in the HTML document.
// initialize the Shanghai component which keeps track of
// shipping data in and out of the Port of Shanghai.
var shanghai = Elm.worker(Elm.Shanghai, {
coordinates:[0,0],
incomingShip: { name:"", capacity:0 },
outgoingShip: ""
});
function logger(x) { console.log(x) }
@evancz
evancz / Main.html
Last active October 22, 2020 10:46
Embed an Elm module in HTML. Compile with `elm-make Stamper.elm` or just generate the HTML automatically by specifying an HTML output file with `elm-make Stamper.elm --output=Main.html`
<html>
<head>
<title>Embedding Elm in HTML!</title>
<script type="text/javascript" src="elm.js"></script>
</head>
<body>
<h1>Stamper</h1>
<div id="stamper" style="width:50%; height:400px;"></div>
@machuga
machuga / rules.md
Last active September 22, 2023 19:45 — forked from radar/rules.md
#laravel rules

Asking for help in #laravel on Freenode

Please behave in a polite, considerate, and inclusive manner in the channel at all times. People volunteer their time in the channel to help people like you with your Laravel problems and some respect (in both directions) will go an extremely long way.

When asking questions in the #laravel channel, please follow these 12 simple rules.

  1. Do your research before hand. Your question may be answerable with a quick Google search or by simply experimenting. If it's a concept you're confused about, first check out our Official Documentation. If you're using a method in Laravel, you can look it up in the API Docs.
  2. If you've tried Googling, explain what terms you've tried to use so people can better help you.
  3. Clearly explain what is happening and create a Paste (http://laravel.io/bin), (http://kopy.io), or (http://gist.github.com) to better explain yourself
  4. **Do not use any paste service that is no
@fideloper
fideloper / install.sh
Last active October 30, 2023 20:03
Vagrant Provisioning Script for PHP applications. This installs a LAMP stack.
#!/usr/bin/env bash
echo ">>> Starting Install Script"
# Update
sudo apt-get update
# Install MySQL without prompt
sudo debconf-set-selections <<< 'mysql-server mysql-server/root_password password root'
sudo debconf-set-selections <<< 'mysql-server mysql-server/root_password_again password root'
@phaedryx
phaedryx / summary
Last active December 3, 2022 19:27
Loyalty and Layoffs by David Brady
Original text here: https://whydavewhy.com/2013/08/16/loyalty-and-layoffs/
@jed
jed / how-to-set-up-stress-free-ssl-on-os-x.md
Last active February 25, 2024 17:35
How to set up stress-free SSL on an OS X development machine

How to set up stress-free SSL on an OS X development machine

One of the best ways to reduce complexity (read: stress) in web development is to minimize the differences between your development and production environments. After being frustrated by attempts to unify the approach to SSL on my local machine and in production, I searched for a workflow that would make the protocol invisible to me between all environments.

Most workflows make the following compromises:

  • Use HTTPS in production but HTTP locally. This is annoying because it makes the environments inconsistent, and the protocol choices leak up into the stack. For example, your web application needs to understand the underlying protocol when using the secure flag for cookies. If you don't get this right, your HTTP development server won't be able to read the cookies it writes, or worse, your HTTPS production server could pass sensitive cookies over an insecure connection.

  • Use production SSL certificates locally. This is annoying

@dustin
dustin / progress.go
Last active December 19, 2015 16:18
Uploading a ton of stuff to S3, I decided I wanted something that would take this boring *os.File and give me a progress indicator. Here's the thing I threw together. Sends this sort of thing to stdout ('\r'ing over itself every second): 10MB/72MB (14.6%)
package main
import (
"fmt"
"io"
"os"
"time"
"github.com/dustin/go-humanize"
)