Skip to content

Instantly share code, notes, and snippets.

View albertms10's full-sized avatar
🏠
Working from home

Albert Mañosa albertms10

🏠
Working from home
View GitHub Profile
@Mwamitovi
Mwamitovi / config.js
Created August 6, 2020 14:25
Serve a react project on Heroku
// Step-1:
// create a script server file at the project root e.g. server.js
const path = require('path');
const express = require('express');
const app = express();
const port = process.env.PORT || 3000;
const publicPath = path.join(__dirname, 'build');
// serve the build folder
@ltOgt
ltOgt / conditional_parent_widget.dart
Created June 29, 2020 14:50
Flutter Widget to conditionally wrap a subtree with a parent without breaking the code tree
import 'package:flutter/widgets.dart';
/// Conditionally wrap a subtree with a parent widget without breaking the code tree.
///
/// [condition]: the condition depending on which the subtree [child] is wrapped with the parent.
/// [child]: The subtree that should always be build.
/// [conditionalBuilder]: builds the parent with the subtree [child].
///
/// ___________
/// Usage:
@nicholashoule
nicholashoule / gitbranches.md
Last active September 20, 2024 16:25
Git prune and delete merged local branches

Git prune and delete merged local branches

Prune
git remote prune origin --dry-run
git remote prune origin
@Potherca
Potherca / Do not commit the `phpunit.xml` file.md
Last active August 20, 2024 14:34
Do not commit the `phpunit.xml` file
@YuCJ
YuCJ / pureSplice.js
Last active April 2, 2022 02:36
A pure version of Array.prototype.splice(). It will return a new array rather than mutate the array.
/**
* A pure version of Array.prototype.splice
* It will return a new array rather than mutate the array
* See: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/splice
* @param {Array} array The target array
* @param {number} start Index at which to start changing the array
* @param {number} deleteCount An integer indicating the number of old array elements to remove
* @param {any} items The elements to add to the array, beginning at the start index
* @returns {Array}
*/
@lattner
lattner / async_swift_proposal.md
Last active October 29, 2024 18:53 — forked from oleganza/async_swift_proposal.md
Concrete proposal for async semantics in Swift

Async/Await for Swift

Introduction

Modern Cocoa development involves a lot of asynchronous programming using closures and completion handlers, but these APIs are hard to use. This gets particularly problematic when many asynchronous operations are used, error handling is required, or control flow between asynchronous calls gets complicated. This proposal describes a language extension to make this a lot more natural and less error prone.

This paper introduces a first class Coroutine model to Swift. Functions can opt into to being async, allowing the programmer to compose complex logic involving asynchronous operations, leaving the compiler in charge of producing the necessary closures and state machines to implement that logic.

@ithinkihaveacat
ithinkihaveacat / service-worker.d.ts
Last active September 30, 2024 00:18 — forked from tiernan/service-worker.d.ts
Typings for using the Service Worker API with TypeScript
/**
* Copyright (c) 2016, Tiernan Cridland
*
* Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby
* granted, provided that the above copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
* INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
@guilherme
guilherme / gist:9604324
Last active October 10, 2024 18:27
Git pre-commit hook that detects if the developer forget to remove all the javascript console.log before commit.
#!/bin/sh
# Redirect output to stderr.
exec 1>&2
# enable user input
exec < /dev/tty
consoleregexp='console.log'
# CHECK
if test $(git diff --cached | grep $consoleregexp | wc -l) != 0
then
@kosinix
kosinix / gist:8267252
Last active November 19, 2021 02:04
Prevent Access to Subdomain Folder from Main Domain. Note: Place this in your sub domain's .htaccess file (public_html/subdomain). Change subdomain to actual sub-domain and mysite.com to your main domain.
RedirectMatch ^/subdomain/(.*)$ http://subdomain.mysite.com/$1
@mobilemind
mobilemind / git-tag-delete-local-and-remote.sh
Last active November 2, 2024 08:30
how to delete a git tag locally and remote
# delete local tag '12345'
git tag -d 12345
# delete remote tag '12345' (eg, GitHub version too)
git push origin :refs/tags/12345
# alternative approach
git push --delete origin tagName
git tag -d tagName