Skip to content

Instantly share code, notes, and snippets.

Avatar

Pablo Armentano pabliqe

View GitHub Profile
@mayneyao
mayneyao / notion2blog.js
Last active Jan 14, 2022
Notion.so > Personal Blog | custom domain + disqus comment
View notion2blog.js
const MY_DOMAIN = "agodrich.com"
const START_PAGE = "https://www.notion.so/gatsby-starter-notion-2c5e3d685aa341088d4cd8daca52fcc2"
const DISQUS_SHORTNAME = "agodrich"
addEventListener('fetch', event => {
event.respondWith(fetchAndApply(event.request))
})
const corsHeaders = {
"Access-Control-Allow-Origin": "*",
@yidas
yidas / js-nl2br-br2nl.md
Last active Jan 20, 2022
JavaScript nl2br & br2nl functions
View js-nl2br-br2nl.md

JavaScript nl2br & br2nl functions

The exchange of new line & br HTML tag could refer to PHP - nl2br() function, which uses to inserts HTML line breaks before all newlines in a string.

These JavaScript functions consider whether to use insert or replace to handle the swap.

nl2br

@aleclarson
aleclarson / README.md
Last active Sep 21, 2020
node-gyp build.js
View README.md

Build the native binding of a NodeJS library for multiple platforms/versions.

With no arguments, this script use the nearest node-gyp installation to build binding.gyp for the version of node being used. Then it looks for binding.node in the resulting build/Release directory, and copies it into the vendor directory (created on-the-fly). You will find it inside a subdirectory named ${process.platform}-${process.arch}-${moduleVersion}.

When --target or --version are undefined, this script resolves their values for you.

NOTE: You must specify --version if you specify --target as a version not currently used by your shell.

After building the native binding, you can npm rm bindings and use the provided binding.js module for loading your native binding with require. The binding.js module is smart enough to know which vendor subdirectory contains the appropriate binding for the current process.

View opengraph.html
<meta property="fb:app_id" content="406655189415060">
<meta property="og:site_name" content="Giphy">
<meta property="og:url" content="http://giphy.com/gifs/rhuber-test-djeEV9Xji6zjgLXBxug">
<meta property="og:title" content="Animated GIF">
<meta property="og:description" content="The best GIFs are on Giphy">
<meta property="og:type" content="video.other">
<meta property="og:image" content="http://media.giphy.com/media/djeEV9Xji6zjgLXBxug/giphy.gif">
<meta property="og:image:width" content="912">
@thomastuts
thomastuts / gulpfile.js
Created Feb 27, 2015
Splitting up Gulp tasks in separate files
View gulpfile.js
// gulpfile.js
var gulp = require('gulp');
var requireDir = require('require-dir');
var tasks = requireDir('./tasks');
gulp.task('sass', tasks.sass);
gulp.task('serve:dev', tasks.serve.dev);
gulp.task('serve:dist', tasks.serve.dist);
@DavidWells
DavidWells / reset.css
Last active Jan 19, 2022 — forked from karbassi/reset.css
CSS reset. Follow me on the twitters for more tips: https://twitter.com/davidwells
View reset.css
/* http://meyerweb.com/eric/tools/css/reset/
v2.0-modified | 20110126
License: none (public domain)
*/
html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
@sviatco
sviatco / ip.js
Last active Aug 19, 2021
Get local external ip address with nodejs
View ip.js
var
// Local ip address that we're trying to calculate
address
// Provides a few basic operating-system related utility functions (built-in)
,os = require('os')
// Network interfaces
,ifaces = os.networkInterfaces();
// Iterate over interfaces ...
@danharper
danharper / background.js
Last active Jan 20, 2022
Bare minimum Chrome extension to inject a JS file into the given page when you click on the browser action icon. The script then inserts a new div into the DOM.
View background.js
// this is the background code...
// listen for our browerAction to be clicked
chrome.browserAction.onClicked.addListener(function (tab) {
// for the current tab, inject the "inject.js" file & execute it
chrome.tabs.executeScript(tab.ib, {
file: 'inject.js'
});
});
@cobyism
cobyism / gh-pages-deploy.md
Last active Jan 19, 2022
Deploy to `gh-pages` from a `dist` folder on the master branch. Useful for use with [yeoman](http://yeoman.io).
View gh-pages-deploy.md

Deploying a subfolder to GitHub Pages

Sometimes you want to have a subdirectory on the master branch be the root directory of a repository’s gh-pages branch. This is useful for things like sites developed with Yeoman, or if you have a Jekyll site contained in the master branch alongside the rest of your code.

For the sake of this example, let’s pretend the subfolder containing your site is named dist.

Step 1

Remove the dist directory from the project’s .gitignore file (it’s ignored by default by Yeoman).