Skip to content

Instantly share code, notes, and snippets.

@samuel-alves
samuel-alves / Web2Case.html
Created February 23, 2023 17:12 — forked from mhamzas/Web2Case.html
Salesforce Web to lead and Web to Case using Javascript [CORS Proof !]
<script type="text/javascript">
// Case Data preparation
var postData = {
oid: '00D0b000000xxxx', //Put your ORGID here
name:'John Smith',
company:'ACME',
email:'yyy@customercompany.com',
origin:'Web',
subject:'Web2Case using the custom API',
@samuel-alves
samuel-alves / 01-directory-structure.md
Created February 6, 2023 18:39 — forked from tracker1/01-directory-structure.md
Anatomy of a JavaScript/Node project.

Directory structure for JavaScript/Node Projects

While the following structure is not an absolute requirement or enforced by the tools, it is a recommendation based on what the JavaScript and in particular Node community at large have been following by convention.

Beyond a suggested structure, no tooling recommendations, or sub-module structure is outlined here.

Directories

  • lib/ is intended for code that can run as-is
  • src/ is intended for code that needs to be manipulated before it can be used

1. Clone your fork:

git clone git@github.com:YOUR-USERNAME/YOUR-FORKED-REPO.git

2. Add remote from original repository in your forked repository:

cd into/cloned/fork-repo
git remote add upstream git://github.com/ORIGINAL-DEV-USERNAME/REPO-YOU-FORKED-FROM.git
git fetch upstream
@samuel-alves
samuel-alves / delete-all-woocommerce-products-and-relations.sql
Last active March 26, 2020 15:35 — forked from pejantantangguh/delete-all-woocommerce-products.php
Remove all WooCommerce products from database via SQL
DELETE relations.*, taxes.*, terms.*
FROM wp_term_relationships AS relations
INNER JOIN wp_term_taxonomy AS taxes
ON relations.term_taxonomy_id=taxes.term_taxonomy_id
INNER JOIN wp_terms AS terms
ON taxes.term_id=terms.term_id
WHERE object_id IN (SELECT ID FROM wp_posts WHERE post_type='product');
DELETE FROM wp_postmeta WHERE post_id IN (SELECT ID FROM wp_posts WHERE post_type = 'product');
DELETE FROM wp_posts WHERE post_type = 'product';
@samuel-alves
samuel-alves / heroku_env_copy.sh
Created March 5, 2020 12:26 — forked from nabucosound/heroku_env_copy.sh
Script to copy environment variables from an existing heroku app to another one
#!/bin/bash
# Source: http://blog.nonuby.com/blog/2012/07/05/copying-env-vars-from-one-heroku-app-to-another/
set -e
sourceApp="$1"
targetApp="$2"
while read key value; do
@samuel-alves
samuel-alves / uri.js
Created April 13, 2018 10:00 — forked from jlong/uri.js
URI Parsing with Javascript
var parser = document.createElement('a');
parser.href = "http://example.com:3000/pathname/?search=test#hash";
parser.protocol; // => "http:"
parser.hostname; // => "example.com"
parser.port; // => "3000"
parser.pathname; // => "/pathname/"
parser.search; // => "?search=test"
parser.hash; // => "#hash"
parser.host; // => "example.com:3000"
@samuel-alves
samuel-alves / nodejs-custom-es6-errors.md
Created November 15, 2017 10:56 — forked from slavafomin/nodejs-custom-es6-errors.md
Custom ES6 errors in Node.js

Here's how you could create custom error classes in Node.js using latest ES6 / ES2015 syntax.

I've tried to make it as lean and unobtrusive as possible.

Defining our own base class for errors

errors/AppError.js

@samuel-alves
samuel-alves / better-nodejs-require-paths.md
Created March 7, 2017 10:23 — forked from branneman/better-nodejs-require-paths.md
Better local require() paths for Node.js

Better local require() paths for Node.js

Problem

When the directory structure of your Node.js application (not library!) has some depth, you end up with a lot of annoying relative paths in your require calls like:

var Article = require('../../../models/article');

Those suck for maintenance and they're ugly.

Possible solutions

Swipe Controls with Backbone.js

Requires

Hammer.js

@samuel-alves
samuel-alves / script-loaded.js
Created February 9, 2017 14:10 — forked from AllThingsSmitty/script-loaded.js
Check if any given script has loaded
var myScript = document.createElement('script');
myScript.src = 'http://code.jquery.com/jquery-2.1.4.min.js';
myScript.onload = function() {
console.log('jQuery loaded.');
};
document.body.appendChild(myScript);