Skip to content

Instantly share code, notes, and snippets.

View douglascayers's full-sized avatar

Doug Ayers douglascayers

View GitHub Profile
@justmoon
justmoon / custom-error.js
Last active April 22, 2024 17:19 — forked from subfuzion/error.md
Creating custom Error classes in Node.js
'use strict';
module.exports = function CustomError(message, extra) {
Error.captureStackTrace(this, this.constructor);
this.name = this.constructor.name;
this.message = message;
this.extra = extra;
};
require('util').inherits(module.exports, Error);
@MoOx
MoOx / index.js
Last active February 9, 2024 22:44
Export/import github labels
// go on you labels pages
// eg https://github.com/cssnext/cssnext/labels
// paste this script in your console
// copy the output and now you can import it using https://github.com/popomore/github-labels !
var labels = [];
[].slice.call(document.querySelectorAll(".label-link"))
.forEach(function(element) {
labels.push({
name: element.textContent.trim(),
@p3t3r67x0
p3t3r67x0 / openssl_commands.md
Last active February 3, 2024 18:53
Some list of openssl commands for check and verify your keys

openssl

Install

Install the OpenSSL on Debian based systems

sudo apt-get install openssl
@douglascayers
douglascayers / github-copy-labels.sh
Last active December 22, 2023 08:16
Export and import GitHub labels between projects by running bash script with jq and curl. Uses GitHub REST API. Requires personal access token.
# This script uses the GitHub Labels REST API
# https://developer.github.com/v3/issues/labels/
# Provide a personal access token that can
# access the source and target repositories.
# This is how you authorize with the GitHub API.
# https://help.github.com/en/articles/creating-a-personal-access-token-for-the-command-line
GH_TOKEN="YOUR_TOKEN"
# If you use GitHub Enterprise, change this to "https://<your_domain>/api/v3"
@douglascayers
douglascayers / github-export-labels.js
Last active September 14, 2023 15:30
Export and import GitHub labels between projects by running JavaScript in the browser console to automate clicks.
/**
* Inspired by @MoOx original script: https://gist.github.com/MoOx/93c2853fee760f42d97f
* Adds file download per @micalevisk https://gist.github.com/MoOx/93c2853fee760f42d97f#gistcomment-2660220
*
* Changes include:
* - Get the description from the `title` attribute instead of `aria-label` (doesn't exist anymore)
* - Use style.backgroundColor and parse the rgb(...) to hex (rather than regex parsing of 'style' string)
* - Downloads labels to a JSON file named after the webpage to know which GitHub repo they came from.
*
* Last tested 2019-July-27:
@glueckpress
glueckpress / GitHub-Desktop-Bitbucket.md
Last active June 20, 2023 08:16
[How-to] Use GitHub Desktop to clone and commit to a Bitbucket repository just as you would with any GitHub repository. (Mac)

⚠️ Note: this guide is from 2016 – a long time on the internet. Content may be outdated, check the comments for more recent info.


Clone Bitbucket Repository and Add it to GitHub Desktop App (Mac)

You can’t clone a Bitbucket repo using GithHub Desktop directly. Instead you would have to:

  1. Clone the Bitbucket repo locally via command line.
  2. Add the cloned repository to your GitHub Desktop app.
@peterknolle
peterknolle / FileController.cls
Last active January 30, 2023 20:40
Lightning File Upload Component
public class FileController {
@AuraEnabled
public static Id saveTheFile(Id parentId, String fileName, String base64Data, String contentType) {
base64Data = EncodingUtil.urlDecode(base64Data, 'UTF-8');
Attachment a = new Attachment();
a.parentId = parentId;
a.Body = EncodingUtil.base64Decode(base64Data);
@ceme
ceme / bash_curl_loop
Last active January 19, 2023 13:07
bash curl loop
while true; do sleep 1; curl http://www.google.com; echo -e '\n\n\n\n'$(date);done
@peterknolle
peterknolle / AutocompleteController.cls
Last active December 29, 2022 17:11
Lightning Autocomplete Component
public class AutocompleteController {
@AuraEnabled
public static List<sObject> getSuggestions(String sObjectType, String term, String fieldsToGet, Integer limitSize) {
// could add in logic to remove possible duplicate fields
String fields = fieldsToGet.length() > 0 ? ',' + fieldsToGet : '';
String soql =
' SELECT Name, Id ' + String.escapeSingleQuotes(fields) +
' FROM ' + String.escapeSingleQuotes(sObjectType) +
' WHERE Name Like \'' + String.escapeSingleQuotes(term) + '%\'' +
@afawcett
afawcett / AddressFinder.cmp
Last active November 25, 2022 08:58
Salesforce London World Tour 2016: Lightning Out: Components on Any Platform
<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes"
controller="AddressFinderController" access="global">
<aura:attribute name="accounts" type="Account[]"/>
<aura:attribute name="contacts" type="Contact[]"/>
<aura:registerEvent name="AddressInfo" type="c:AddressInfo"/>
<div class="slds-form--stacked">
<div class="slds-form-element">
<label class="slds-form-element__label" for="inputSample2">Account Search</label>