Skip to content

Instantly share code, notes, and snippets.

View lmartins's full-sized avatar

Luis Martins lmartins

  • Goodwin Media, Multiweb
  • Portugal
View GitHub Profile
@kitze
kitze / conditionalwrap.js
Created October 25, 2017 16:54
one-line React component for conditionally wrapping children
import React from 'react';
const ConditionalWrap = ({condition, wrap, children}) => condition ? wrap(children) : children;
const Header = ({shouldLinkToHome}) => (
<div>
<ConditionalWrap
condition={shouldLinkToHome}
wrap={children => <a href="/">{children}</a>}
>
@ahmadawais
ahmadawais / upload-a-file.MD
Created June 18, 2017 11:07 — forked from websupporter/upload-a-file.MD
Upload a file using the WordPress REST API

Upload files

Using the REST API to upload a file to WordPress is quite simple. All you need is to send the file in a POST-Request to the wp/v2/media route.

There are two ways of sending a file. The first method simply sends the file in the body of the request. The following PHP script shows the basic principle:

@rogeliog
rogeliog / App.js
Created December 6, 2016 19:15
Composition and filters in React
/*
This is a minimal working example
*/
import React, { Component } from 'react';
import Filters from './Filters';
import InputFilter from './InputFilter';
import allMovies from './movies';
class App extends Component {
(function($) {
acf.add_action('ready', function( $el ){
//Identify the field you want to check against.
//Use a class to handle scenarios involving repeater / flexible content where multiple instances exist
var $field = $('.example input');
$field.on('change', function (evt) {
@krambertech
krambertech / Component.jsx
Created July 2, 2016 10:44
ReactJS: Input fire onChange when user stopped typing (or pressed Enter key)
import React, { Component } from 'react';
import TextField from 'components/base/TextField';
const WAIT_INTERVAL = 1000;
const ENTER_KEY = 13;
export default class TextSearch extends Component {
constructor(props) {
super();
@noelboss
noelboss / git-deployment.md
Last active April 24, 2024 03:17
Simple automated GIT Deployment using Hooks

Simple automated GIT Deployment using GIT Hooks

Here are the simple steps needed to create a deployment from your local GIT repository to a server based on this in-depth tutorial.

How it works

You are developing in a working-copy on your local machine, lets say on the master branch. Most of the time, people would push code to a remote server like github.com or gitlab.com and pull or export it to a production server. Or you use a service like deepl.io to act upon a Web-Hook that's triggered that service.

Sketch Image Compressor (Beta)

A Plugin for Sketch that compresses your bitmap assets, to keep filesize to a minimum.

Please note that the compression is lossless, so no pixels will be harmed by running this Plugin : )

Installation

  • Download Sketch Image Compressor & unzip it.
  • Double click Sketch Image Compressor.sketchplugin to install the Plugin.
@MindyPostoff
MindyPostoff / gist:c70dc98a099a9bf1c2f0
Last active June 15, 2021 21:58
Reorder Display of Fields on WooCommerce Bookings Form
/**
* A function to reorder the default display of fields on the WooCommerce Bookings form
* Put this function in your theme's functions.php file
*/
function custom_order_booking_fields ( $fields ) {
$reorder = array();
$reorder[] = $fields['wc_bookings_field_duration']; // Duration
$reorder[] = $fields['wc_bookings_field_resource']; // Resource
$reorder[] = $fields['wc_bookings_field_persons']; // Persons

Font Face

A mixin for writing @font-face rules in SASS.

Usage

Create a font face rule. Embedded OpenType, WOFF2, WOFF, TrueType, and SVG files are automatically sourced.

@include font-face(Samplino, fonts/Samplino);
anonymous
anonymous / gulpfile.js
Created December 18, 2014 15:25
var gulp = require("gulp");
var sass = require("gulp-sass");
var autoprefix = require("gulp-autoprefixer");
var filter = require('gulp-filter');
var browserSync = require('browser-sync');
var reload = browserSync.reload;
/**
* Start BrowserSync
*/