Skip to content

Instantly share code, notes, and snippets.

View johndatserakis's full-sized avatar

John Datserakis johndatserakis

View GitHub Profile
@pkieltyka
pkieltyka / aclmux.go
Last active December 22, 2023 22:01
wrapped chi.Router with basics for acl functionality
package aclmux
import (
"net/http"
"regexp"
"strings"
"github.com/go-chi/chi"
)
const { resolve } = require('path')
const chalk = require('chalk')
const findInFiles = require('find-in-files')
const importReg = /'(.*?)'$/
async function findVendorEntries (vendors, folder) {
const reg = `import (.*? from )?'((${vendors.join('|')})/.*?)'`
const results = await findInFiles.find(reg, folder, /\.(vue|jsx?|styl)$/)
const set = new Set(vendors)
@axle07
axle07 / cypress_xhr.js
Created March 15, 2018 18:23
Cypress.js: Assert that an XHR POST was successful.
describe('XHR form submission test', () => {
before(() => {
cy.visit('/testurl')
})
it('successfully submits an XHR on form submission', () => {
cy.get('[data-test="form"]').within(() => {
cy.get('#test-input').type('spyfu.com')
cy.route('POST', '/sumbit/here').as('postForm') // note that the route needs to match trailing slashes
cy.get('button[type="submit"]').click()
.wait('@postForm')
.some-class {
background-color: yellow;
}
using UnityEngine;
public class ThisPlatform {
// This property allows you to use ThisPlatform.IsIphoneX to determine if you should do anything special in your code when checking for iPhone X.
public static bool IsIphoneX {
get {
#if UNITY_IOS
// If testing without an iPhone X, add FORCE_IPHONEX to your Scripting Define Symbols.
@gricard
gricard / webpack4upgrade.md
Last active April 20, 2025 23:06
Just some notes about my attempt to upgrade to webpack 4

If you enjoyed reading this, I'm intending to do more blogging like this over here: https://cdgd.tech

This is not a complaint about Webpack or v4 in any way. This is just a record of my process trying it out so I could provide feedback to the webpack team

Hmm... I don't see any docs for 4.0 on https://webpack.js.org. I guess I'll just wing it. All I need to do is npm i -D webpack@next, right?

+ [email protected]
@redblobgames
redblobgames / vue-canvas.js
Last active April 11, 2023 07:31
Vue component for canvas with automatic dependency tracking
/** Canvas component
A generic canvas component that calls a draw function to draw the
contents, and automatically calls it again when anything the draw
function depends on changes. Blog entry:
http://simblob.blogspot.com/2018/03/using-vue-with-canvas.html
Example:
<a-canvas width="500" height="200"
@Lwdthe1
Lwdthe1 / usaCities.json
Last active April 24, 2025 04:51
JSON of 5797+ USA Cities and Their States - Presented by https://www.ManyStories.com
[
{ "city": "Abbeville", "state": "Louisiana" },
{ "city": "Aberdeen", "state": "Maryland" },
{ "city": "Aberdeen", "state": "Mississippi" },
{ "city": "Aberdeen", "state": "South Dakota" },
{ "city": "Aberdeen", "state": "Washington" },
{ "city": "Abilene", "state": "Texas" },
{ "city": "Abilene", "state": "Kansas" },
{ "city": "Abingdon", "state": "Virginia" },
{ "city": "Abington", "state": "Massachusetts" },
@philhawksworth
philhawksworth / _redirects
Last active December 27, 2021 21:49
Simple example of Netlify _redirects file
# Redirect with a 301
/home / 301
# Redirect with a 302
/my-redirect / 302
# Rewrite a path
/pass-through /index.html 200
@joachimesque
joachimesque / config.php
Created January 4, 2018 15:19
CSP headers with a script-src nonce directive for Kirby
<?php
/*
---------------------------------------
CSP
---------------------------------------
*/
$csp_nonce = base64_encode(random_bytes(20));
$csp_header = "Content-Security-Policy: default-src 'self'; script-src 'self' 'nonce-" . $csp_nonce . "';";
// set `csp-nonce` so it's accessable