Skip to content

Instantly share code, notes, and snippets.

@Loupax
Loupax / mailer.go
Last active September 20, 2019 08:24
package mailer
import (
"bytes"
"crypto/tls"
"encoding/base64"
"fmt"
"io"
"net/http"
"net/mail"
package redis
import (
"fmt"
"sync"
)
type MockClient struct {
lock sync.RWMutex
cache map[string]string
@Loupax
Loupax / mongodb.go
Last active August 9, 2019 07:39
Integration of newrelic for mongodb collections
package mongodb
import (
"context"
newrelic "github.com/newrelic/go-agent"
"go.mongodb.org/mongo-driver/mongo"
"go.mongodb.org/mongo-driver/mongo/options"
)
// Collection is a wrapper of the mongo.Collection type including a NewRelic Application dependency
@Loupax
Loupax / ExampleUsageController.php
Created May 1, 2019 14:21
Create service locator that gets configured using tags
<?php
declare(strict_types=1);
namespace App\Controller;
use App\Service\One;
use App\Service\Two;
use Symfony\Component\DependencyInjection\ServiceLocator;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
@Loupax
Loupax / Style Checkbox with CSS using Label.html
Last active April 30, 2018 13:42
Use a hidden checkbox, label and styles to style the checkbox. A fork (and minor clean up) of https://gist.github.com/592332
<!DOCTYPE HTML>
<html lang="en-US">
<head>
<title>Checkbox</title>
<style>
input[type=checkbox] {
display:none;
}
input[type=checkbox] + label {
We can't make this file beautiful and searchable because it's too large.
policyID,statecode,county,eq_site_limit,hu_site_limit,fl_site_limit,fr_site_limit,tiv_2011,tiv_2012,eq_site_deductible,hu_site_deductible,fl_site_deductible,fr_site_deductible,point_latitude,point_longitude,line,construction,point_granularity
119736,FL,CLAY COUNTY,498960,498960,498960,498960,498960,792148.9,0,9979.2,0,0,30.102261,-81.711777,Residential,Masonry,1
448094,FL,CLAY COUNTY,1322376.3,1322376.3,1322376.3,1322376.3,1322376.3,1438163.57,0,0,0,0,30.063936,-81.707664,Residential,Masonry,3
206893,FL,CLAY COUNTY,190724.4,190724.4,190724.4,190724.4,190724.4,192476.78,0,0,0,0,30.089579,-81.700455,Residential,Wood,1
333743,FL,CLAY COUNTY,0,79520.76,0,0,79520.76,86854.48,0,0,0,0,30.063236,-81.707703,Residential,Wood,3
172534,FL,CLAY COUNTY,0,254281.5,0,254281.5,254281.5,246144.49,0,0,0,0,30.060614,-81.702675,Residential,Wood,1
785275,FL,CLAY COUNTY,0,515035.62,0,0,515035.62,884419.17,0,0,0,0,30.063236,-81.707703,Residential,Masonry,3
995932,FL,CLAY COUNTY,0,19260000,0,0,19260000,20610000,0,0,0,0,30.102226,-81.
@Loupax
Loupax / deepClone.js
Last active February 7, 2018 14:09
Deep cloning functionality for JS
function cloneObject(input) {
if (isPrimitive(input)) {
return input;
}
if (Array.isArray(input)) {
return input.map((item)=>{return cloneObject(item);});
}
const clone = {};
This file has been truncated, but you can view the full file.
ETYMOLOGY.
(Supplied by a Late Consumptive Usher to a Grammar School)
The pale Usher--threadbare in coat, heart, body, and brain; I see him
now. He was ever dusting his old lexicons and grammars, with a queer
handkerchief, mockingly embellished with all the gay flags of all
the known nations of the world. He loved to dust his old grammars; it
somehow mildly reminded him of his mortality.
@Loupax
Loupax / Input.js
Created January 5, 2018 13:46
Input react component
import React from 'react'
/**
* Extension of the native html input element
* in order to enable the indeterminate property
* for checkboxes
*/
export default class Input extends React.Component {
componentDidMount() {
// this.el does not exist on the server (tests), so set it to an
@Loupax
Loupax / docker-compose.yml
Created December 28, 2017 12:17
Example docker-compose.yml
version: '3.2'
services:
my-db:
image: mariadb
restart: always
ports:
- 8081:3306
environment:
MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD}