Skip to content

Instantly share code, notes, and snippets.

View schettino's full-sized avatar

Matheus Schettino schettino

View GitHub Profile
@tirumaraiselvan
tirumaraiselvan / shim.js
Last active July 31, 2023 17:05
Mount Hasura on Apollo federated gateway
const { ApolloServer } = require("apollo-server");
const gql = require("graphql-tag");
const fetch = require("node-fetch");
const {
introspectionQuery,
buildClientSchema,
printSchema
} = require("graphql");
const typeDefs = gql`
@ngryman
ngryman / example.ts
Created June 29, 2019 17:24
Updating cached data from multiple parameterized queries after a mutation (hacky solution)
addTask({
variables: { input },
optimisticResponse: {
addTask: {
__typename: 'Task',
id,
...input
}
},
update: (proxy: any, { data: { addTask } }: any) => {
// handy method to create a Higher Order Component out of a
// Render Prop Component (like a Context.Consumer).
// handles, statics, displayName, refs, and value forwarding
function createHOCFromRenderProp({prop, Consumer}) {
return Component => {
function Wrapper(props, ref) {
return (
<Consumer>
{value => <Component {...{...props, [prop]: value, ref}} />}
@blankg
blankg / WebViewBridge.js
Last active July 12, 2022 06:53
For RN >= 0.57 please look at https://github.com/blankg/rn-webview-bridge-sample-new/blob/master/resources/index.html. Provides a sample implementation for sending and receiving messages to and from the React-Native WebView (using postMessage/onMessage WebView API).
/**
* Created by Guy Blank on 3/9/17.
*
* This is a sample provides an API to send & receive messages to and from the React-Native WebView (using postMessage/onMessage WebView API).
* A sample project that uses the bridge is available here https://github.com/blankg/rn-webview-bridge-sample
*
* webViewBridge.send('functionToInvoke', {mydata: 'test'}, function(){console.log('success')},function(){console.log('error')});
*
* The API is designed to be similar to the Cordova exec API so migration to it should be almost seamless.
* The API also provides solution to a React-Native WebView bug in iOS which causes sending consecutive postMessage calls to override each other.
@Philmod
Philmod / gcb-kubernetes.yaml
Last active July 25, 2021 05:34
Deploy a new image from Google Cloud Container Builder to Kubernetes, by storing GKE credentials in GCS.
steps:
- name: 'gcr.io/cloud-builders/npm'
args: ['install']
- name: 'gcr.io/cloud-builders/npm'
args: ['test']
- name: 'gcr.io/cloud-builders/docker'
args: ["build", "-t", "gcr.io/$PROJECT_ID/frontend:$REVISION_ID", "."]
- name: 'gcr.io/cloud-builders/docker'
args: ["push", "gcr.io/$PROJECT_ID/frontend:$REVISION_ID"]
- name: 'gcr.io/cloud-builders/gcloud'
@eduncan911
eduncan911 / go-build-all
Last active April 11, 2024 07:14
Go Cross-Compile Script
#!/bin/bash
#
# GoLang cross-compile snippet for Go 1.6+ based loosely on Dave Chaney's cross-compile script:
# http://dave.cheney.net/2012/09/08/an-introduction-to-cross-compilation-with-go
#
# To use:
#
# $ cd ~/path-to/my-awesome-project
# $ go-build-all
#
@harlow
harlow / golang_job_queue.md
Last active April 24, 2024 10:21
Job queues in Golang
@egerlach
egerlach / update-dokku-stack.sh
Last active December 22, 2022 03:24
Update stack underlying apps running on dokku
#!/bin/bash
# before you can use this, you need to run (as root):
# git clone https://github.com/tt/stack-images.git /root/stack-images
# git clone https://github.com/gliderlabs/herokuish.git /root/herokuish
# First, we need to get our base ubuntu images up to date
docker pull ubuntu-debootstrap:14.04
docker pull ubuntu:trusty # for postgresql
@calebwoods
calebwoods / nginx.conf
Created May 10, 2014 20:18
Sample Nginx config for deployment of Angular.js app
server { listen 80;
server_name example.com;
access_log /var/log/example.com/nginx.access.log;
error_log /var/log/example.com/nginx.error.log;
root /var/www/apps/example.com/public;
charset utf-8;
location / {
rewrite ^ https://$host$request_uri? permanent;
}
@alanhamlett
alanhamlett / api.py
Last active January 24, 2023 21:03
Serialize SQLAlchemy Model to dictionary (for JSON output) and update Model from dictionary attributes.
import uuid
import wtforms_json
from sqlalchemy import not_
from sqlalchemy.dialects.postgresql import UUID
from wtforms import Form
from wtforms.fields import FormField, FieldList
from wtforms.validators import Length
from flask import current_app as app
from flask import request, json, jsonify, abort