Skip to content

Instantly share code, notes, and snippets.

@janich
janich / exportMysqlUsers.php
Created July 31, 2013 13:02
Export MySQL users and permissions
<?php
/**
* Export MySQL users and permissions
*
* This script exports raw CREATE USER and GRANT queries of a given database
* to help migrate MySQL users and permissions to a new server.
* Users will keep their passwords across the migration.
*
* Warning: The import queries expects exactly the same database structure!
*
@WickyNilliams
WickyNilliams / index.html
Last active February 22, 2023 15:07
parseTable.js - convert HTML table to array of objects. MIT licensed (https://opensource.org/licenses/MIT)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>parseTable</title>
</head>
<body>
<table>
<thead>
<tr>
@BrianWill
BrianWill / Javascript - asynchronous code.md
Last active April 26, 2024 08:11
Using asynchronous API's using callbacks and Promises

In most programming languages, most functions are synchronous: a call to the function does all of its business in the same thread of execution. For functions meant to retrieve data, this means the data can be returned by calls to the function.

For an asynchronous function, a call to the function triggers business in some other thread, and that business (usually) does not complete until after the call returns. An asynchronous function that retrieves data via another thread cannot directly return the data to the caller because the data is not necessarily ready by the time the function returns.

In a sense, asynchronous functions are infectious: if a function foo calls an asynchronous function to conclude its business, then foo itself is asynchronous. Once you rely upon an asynchronous function to do your work, you cannot somehow remove the asynchronicity.

callbacks

When the business initiated by an asynchronous function completes, we may want to run some code in response, so the code run

@zcaceres
zcaceres / Nested-Routers-Express.md
Last active September 6, 2024 16:45
Child Routers in Express

Nested Routers in Express.js

Express makes it easy to nest routes in your routers. But I always had trouble accessing the request object's .params when you had a long URI with multiple parameters and nested routes.

Let's say you're building routes for a website www.music.com. Music is organized into albums with multiple tracks. Users can click to see a track list. Then they can select a single track and see a sub-page about that specific track.

At our application level, we could first have a Router to handle any requests to our albums.

const express = require('express');
@benzkji
benzkji / index.html
Last active March 25, 2021 16:41
simple invisible recaptcha example, works with multiple forms
<script src='https://www.google.com/recaptcha/api.js?hl=de'></script>
check https://developers.google.com/recaptcha/docs/invisible
<div
id="header_recaptcha"
class="g-recaptcha"
data-sitekey="6LctdiQUAAAAAOTUOX92-PkGJXpZgGUp5hrq4l65"
data-size="invisible"
data-callback="recaptcha_submit"
@GhazanfarMir
GhazanfarMir / Instructions.sh
Last active May 14, 2024 03:26
Install PHP7.2 NGINX and PHP7.2-FPM on Ubuntu 16.04
########## Install NGINX ##############
# Install software-properties-common package to give us add-apt-repository package
sudo apt-get install -y software-properties-common
# Install latest nginx version from community maintained ppa
sudo add-apt-repository ppa:nginx/stable
# Update packages after adding ppa
@BrianWill
BrianWill / tech_writing.md
Last active October 6, 2024 06:44
Rules for technical communication

The 4 C's of good technical communication:

concise

Concision not only saves the audience time, it cuts out distracting verbiage and helps avoid burying key information in a sea of boiler plate.

Audiences very often revisit sources, and concision makes it easier to relocate particular bits of information.

Smaller pieces are easier to rearrange, and so in practice, the more concise, the more authors are likely to work out an ideal structure.

@unr
unr / nginx.local.dev
Created February 27, 2019 18:09
Example Nginx file for a Laravel/Nuxt php server locally. Production runs something similar, but more complex with load balancers.
server {
listen 80;
server_name site.com www.site.com *.site.com;
return 301 https://$host$request_uri;
}
server {
listen 443 ssl http2;
server_name site.com www.site.com *.site.com;
root /;
@meigwilym
meigwilym / index.md
Created November 28, 2019 08:52
Notes on stitcher.io's Laravel beyond CRUD

Laravel beyond CRUD

stitcher.io

A blog series for PHP developers working on larger-than-average Laravel projects

Written for projects with a development lifespan of six to twelve months, with a team of three to six developers working on them simultaneously.

Chapter 1: Domain oriented Laravel