Skip to content

Instantly share code, notes, and snippets.

View Firehed's full-sized avatar
🐰

Eric Stern Firehed

🐰
View GitHub Profile
@Firehed
Firehed / Bcrypt.php
Created February 13, 2012 00:30
Simple PHP 5.3+ Bcrypt class and functions
<?php
/*
By Marco Arment <[email protected]>.
This code is released in the public domain.
THERE IS ABSOLUTELY NO WARRANTY.
Usage example:
// In a registration or password-change form:
@Firehed
Firehed / benchmark.php
Created May 23, 2012 20:44
Dead-simple benchmarking tool
<?php
function benchmark($i, $function) {
if (!is_callable($function)) {
return false;
}
$st = microtime(1);
while ($i--) {
$function();
}
return microtime(1) - $st;
@Firehed
Firehed / lif
Created December 18, 2012 05:58
lif: get the specified line of a file, optionally surrounded by lines of context copy to a directory in your $PATH (I'd suggest ~/bin), chmod +x, and have fun `lif -h` for help
#!/bin/bash
context=0
usage() {
cat <<EOF
lif: Line in File
Usage:
lif [-c context] line [file]
@Firehed
Firehed / gist:5639541
Created May 23, 2013 21:24
triggers E_ERROR: "Cannot call overloaded function for non-object" on line 13
<?php
private function getKey() {
if ($this->foo) {
$config = get_config();
if (!isset($config['func']) || !is_callable($config['func'])) {
throw new Exception("Function missing")
}
$func = $config['func'];
}
else {
@Firehed
Firehed / con.php
Created July 3, 2013 07:00
Print a filtered list of PHP constants. Usage: php con.php [-k keyfilter] [-v valuefilter]
<?
$x = get_defined_constants();
list($kf,$vf) = array_values(getopt('k:v:'));
foreach ($x as $k =>$v) {
if ($kf !== null && 0 !== stripos($k, $kf)) continue;
if ($vf === null || $v == $vf) echo "$k:$v\n";
}
@Firehed
Firehed / jenkins-post.php
Last active December 20, 2015 09:49
Jenkins/Phabricator integration scripts
#!/usr/bin/php
<?php
$url = $_ENV['BUILD_URL'];
$res= json_decode(file_get_contents($url . 'api/json'));
$silent = false;
$message = '';
$action = 'reject'; // default no
switch ($res->result) {
case 'SUCCESS':
$message = 'Build ok!';
@Firehed
Firehed / mysqlchk
Created April 2, 2014 01:04
MySQL/Galera Health Check for haproxy
#!/bin/bash
#
# This script checks if a mysql server is healthy running on localhost. It will
# return:
# "HTTP/1.x 200 OK\r" (if mysql is running smoothly)
# - OR -
# "HTTP/1.x 500 Internal Server Error\r" (else)
#
# The purpose of this script is make haproxy capable of monitoring mysql properly
#

Keybase proof

I hereby claim:

  • I am firehed on github.
  • I am firehed (https://keybase.io/firehed) on keybase.
  • I have a public key whose fingerprint is D20D 54D3 80A8 F0CE 3AC3 87D6 DD4D EF36 33E5 5C75

To claim this, I am signing this object:

diff --git a/autoload/ale/engine.vim b/autoload/ale/engine.vim
index f7c25b0..f541878 100644
--- a/autoload/ale/engine.vim
+++ b/autoload/ale/engine.vim
@@ -195,6 +195,19 @@ function! s:HandleExit(job_id, exit_code) abort
endfunction
function! s:HandleLSPResponse(response) abort
+ let l:is_diag_response = get(a:response, 'method', '') ==# 'textDocument/publishDiagnostics'
+
@Firehed
Firehed / wifi.h
Last active January 27, 2018 21:49
Wifi Example
const char* ssid = "yourssid";
const char* password = "yourpassword";
const char* deviceName = "ghsw8181";