Skip to content

Instantly share code, notes, and snippets.

View gosseti's full-sized avatar

Lawrence Gosset gosseti

View GitHub Profile
@nandorojo
nandorojo / private-npm-in-gh-actions.md
Created August 3, 2021 23:52
Use private NPM packages in your GitHub actions

1 NPM_TOKEN

Add an NPM_TOKEN secret on GitHub. Get your secret key from the NPM dashboard.

2 Add a step to your action

- name: Authenticate with private NPM package
  run: echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > ~/.npmrc
// Gist for https://medium.com/@ebakhtarov/bidirectional-websockets-with-redux-saga
import { eventChannel } from "redux-saga";
import { all, call, put, take, select, race } from "redux-saga/effects";
import { actionTypes } from "./constants";
function watchMessages(socket) {
return eventChannel(emit => {
/* eslint-disable no-param-reassign */
@hubgit
hubgit / SelectField.tsx
Last active December 29, 2023 03:41
Use react-select with Formik
import { FieldProps } from 'formik'
import React from 'react'
import Select, { Option, ReactSelectProps } from 'react-select'
export const SelectField: React.SFC<ReactSelectProps & FieldProps> = ({
options,
field,
form,
}) => (
<Select
@elderbas
elderbas / class_controller.ex
Last active April 5, 2024 03:35
Elixir — Inserting Multiple Changesets Into Database - create batch
def create_batch(conn, %{"people" => people_params}) do
changesets = Enum.map(people_params, fn class ->
Person.changeset(%Person{}, person)
end)
result = changesets
|> Enum.with_index()
|> Enum.reduce(Ecto.Multi.new(), fn ({changeset, index}, multi) ->
Ecto.Multi.insert(multi, Integer.to_string(index), changeset)
end)
@lukecav
lukecav / functions.php
Created December 5, 2017 03:31
Remove add to cart buttons on shop archive page in WooCommerce
remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart', 10);
@vahidabdi
vahidabdi / arc_resolver.ex
Last active March 5, 2020 22:02
Arc Uploader resolver for Absinthe Graphql
defmodule MyApp.Schema.ArcResolver do
defmacro __using__([uploader: uploader]) do
quote do
import unquote(__MODULE__), only: [
get_file: 2
]
@__arc_upload unquote(uploader)
end
end
@mwickett
mwickett / formikApollo.js
Last active December 20, 2022 23:00
Formik + Apollo
import React from 'react'
import { withRouter, Link } from 'react-router-dom'
import { graphql, compose } from 'react-apollo'
import { Formik } from 'formik'
import Yup from 'yup'
import FormWideError from '../elements/form/FormWideError'
import TextInput from '../elements/form/TextInput'
import Button from '../elements/form/Button'
import { H2 } from '../elements/text/Headings'
@ciorici
ciorici / index.php
Created April 27, 2017 08:10
Featured Products Loop in WooCommerce 3.0
<ul class="products">
<?php
$args = array(
'post_type' => 'product',
'posts_per_page' => 12,
'tax_query' => array(
array(
'taxonomy' => 'product_visibility',
'field' => 'name',
'terms' => 'featured',
@gabelloyd
gabelloyd / archive-product.php
Created April 20, 2017 16:53
Display WooCommerce featured images on archive-product.php
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
get_header( 'shop' ); ?>
<?php
/**
* woocommerce_before_main_content hook.
*
@ericstumper
ericstumper / schema.ex
Created June 9, 2016 10:04
JWT Token creation with Absinthe and Guardian
defmodule Languafy.Schema do
use Absinthe.Schema
import_types Languafy.Schema.Types
query do
@desc "Get an App User"
field :user, type: :user do
arg :id, non_null(:id)
resolve &Languafy.Resolver.User.find/2
end