Skip to content

Instantly share code, notes, and snippets.

@kalinchernev
kalinchernev / countries
Created October 6, 2014 09:42
Plain text list of countries
Afghanistan
Albania
Algeria
Andorra
Angola
Antigua & Deps
Argentina
Armenia
Australia
Austria
@gauravtiwari
gauravtiwari / window-auth-popup.es6.js
Last active April 12, 2024 00:56
Promise based popup window for server oAuth
/* global window */
const popup = (url) => {
const windowArea = {
width: Math.floor(window.outerWidth * 0.8),
height: Math.floor(window.outerHeight * 0.5),
};
if (windowArea.width < 1000) { windowArea.width = 1000; }
if (windowArea.height < 630) { windowArea.height = 630; }
@DarrenN
DarrenN / get-npm-package-version
Last active March 28, 2024 06:59 — forked from yvele/get-npm-package-version.sh
Extract version from package.json (NPM) using bash / shell
# Version key/value should be on his own line
PACKAGE_VERSION=$(cat package.json \
| grep version \
| head -1 \
| awk -F: '{ print $2 }' \
| sed 's/[",]//g')
echo $PACKAGE_VERSION
@discordier
discordier / gist:ed4b9cba14652e7212f5
Created December 4, 2014 06:23
options for phpStorm @noinspection annotation
javascript
ES6ValidationInspection
JSAccessibilityCheckInspection
JSBitwiseOperatorUsageInspection
JSCheckFunctionSignaturesInspection
JSClosureCompilerSyntaxInspection
JSCommentMatchesSignatureInspection
JSComparisonWithNaNInspection
JSConsecutiveCommasInArrayLiteralInspection
@bradrydzewski
bradrydzewski / generate_docker_cert.sh
Last active March 12, 2024 17:00
Generate trusted CA certificates for running Docker with HTTPS
#!/bin/bash
#
# Generates client and server certificates used to enable HTTPS
# remote authentication to a Docker daemon.
#
# See http://docs.docker.com/articles/https/
#
# To start the Docker Daemon:
#
# sudo docker -d \
@pauloricardomg
pauloricardomg / cors.nginxconf
Last active March 8, 2024 18:31
Nginx configuration for CORS-enabled HTTPS proxy with origin white-list defined by a simple regex
#
# Acts as a nginx HTTPS proxy server
# enabling CORS only to domains matched by regex
# /https?://.*\.mckinsey\.com(:[0-9]+)?)/
#
# Based on:
# * http://blog.themillhousegroup.com/2013/05/nginx-as-cors-enabled-https-proxy.html
# * http://enable-cors.org/server_nginx.html
#
server {
@brunogaspar
brunogaspar / macro.md
Last active March 7, 2024 16:26
Recursive Laravel Collection Macros

What?

If a nested array is passed into a Laravel Collection, by default these will be threaded as normal arrays.

However, that's not always the ideal case and it would be nice if we could have nested collections in a cleaner way.

This is where this macro comes in handy.

Setup

@croxton
croxton / SSL-certs-OSX.md
Last active March 3, 2024 18:58 — forked from leevigraham/Generate ssl certificates with Subject Alt Names on OSX.md
Generate ssl certificates with Subject Alt Names

Generate ssl certificates with Subject Alt Names on OSX

Open ssl.conf in a text editor.

Edit the domain(s) listed under the [alt_names] section so that they match the local domain name you want to use for your project, e.g.

DNS.1   = my-project.dev

Additional FQDNs can be added if required:

@odewahn
odewahn / error-handling-with-fetch.md
Last active February 27, 2024 09:56
Processing errors with Fetch API

I really liked @tjvantoll article Handling Failed HTTP Responses With fetch(). The one thing I found annoying with it, though, is that response.statusText always returns the generic error message associated with the error code. Most APIs, however, will generally return some kind of useful, more human friendly message in the body.

Here's a modification that will capture this message. The key is that rather than throwing an error, you just throw the response and then process it in the catch block to extract the message in the body:

fetch("/api/foo")
  .then( response => {
    if (!response.ok) { throw response }
    return response.json()  //we only get here if there is no error
 })
@hamakn
hamakn / codes.md
Created March 15, 2019 11:00
gRPC Code and HTTP Status Code