Skip to content

Instantly share code, notes, and snippets.

View silentworks's full-sized avatar

Andrew Smith silentworks

View GitHub Profile
@dabit3
dabit3 / schema.graphql
Created March 9, 2020 14:47
Fine grained access control
type Post @model
@auth(rules: [
# Owner can create, update, delete
{ allow: owner },
# Authorize group-based access control
{ allow: groups, groups: ["Admin"] }
]) {
id: ID!
title: String!
content: String
@tlakomy
tlakomy / Notes.md
Last active January 13, 2020 21:40
Notes from Build an App with React Suspense, Hooks, and Context Workshop Setup with Michael Chan

Egghead Workshop Notes

Notes from Build an App with React Suspense, Hooks, and Context Workshop Setup with Michael Chan

  • Write a detailed README with contact info, info about the workshop itself, license etc
  • Create a folder for each lesson so folks won’t have to struggle with switching git branches every 15 minutes
  • Give everyone a minute to process what they’ve learned and to figure out whether they have questions
  • Reference the docs so once the workshop concludes everyone knows where to find the resources to refresh what they’ve learned
  • As with egghead lessons, guide their eyes - if you’re explaining something, then select it in your IDE (at least hover over it)
  • Take a minute to go over the questions from the chat, read the question out loud
  • Don’t be afraid to experiment when there’s an interesting question, we’re all nerds here who love to try out new stuff
@johanalkstal
johanalkstal / example.js
Last active April 29, 2024 03:12
Basic Svelte Store Routing
/**
* Basic example of routerless store based routing.
* To understand what is going on check out
* https://svelte.dev/tutorial/writable-stores
* https://www.npmjs.com/package/feather-route-matcher
*/
// stores.js
@silentworks
silentworks / php-pdo-mysql-crud.md
Created January 8, 2019 11:33 — forked from taniarascia/php-pdo-mysql-crud.md
Basic CRUD operations with PDO and MySQL

Basic CRUD operations with PDO

CRUD = Create, Read, Update, Delete

Open a database connection

$host = '127.0.0.1';
$dbname = 'test';
$username = 'root';
(function($, window, undefined) {
var InfiniteScroll = function() {
this.initialize = function() {
this.setupEvents();
};
this.setupEvents = function() {
$(window).on(
'scroll',
this.handleScroll.bind(this)
const webpack = require('webpack');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const config = require('sapper/webpack/config.js');
const { svelteMinifyHtml, sveltePostcss } = require('./utils.js');
const mode = process.env.NODE_ENV;
const isDev = mode === 'development';
module.exports = {
entry: config.client.entry(),
if (typeof window!=='undefined' && navigator.serviceWorker && navigator.serviceWorker.controller) {
let reloadOnNext = false;
let pushState = history.pushState;
history.pushState = function(state, title, url) {
pushState.call(this, state, title, url);
if (reloadOnNext===true) location.reload(true);
};
navigator.serviceWorker.controller.addEventListener('statechange', e => {
@joshuataylor
joshuataylor / app.js
Created October 23, 2017 12:31
Preact component to notify user when a change has been made, and on route change reload the page.
import { h, Component } from 'preact';
import { Router } from 'preact-router';
import Header from './header';
import Home from '../routes/home';
import Profile from '../routes/profile';
import NotifyChange from "./NotifyChange/index";
// import Home from 'async!../routes/home';
// import Profile from 'async!../routes/profile';

procedural mesh generation

Generates an algorithmic 3D OBJ file with ThreeJS and Node.js.

# print to stdout
node generate-mesh.js > test.obj

# write to file
node generate-mesh.js test.obj
anonymous
anonymous / App.html
Created August 23, 2017 21:56
Svelte component
<label>
<input type='checkbox' bind:checked='visible'> visible
</label>
{{#if visible}}
<div transition:scale></div>
{{/if}}
<style>
div {