Skip to content

Instantly share code, notes, and snippets.

View claytongulick's full-sized avatar

Clayton Gulick claytongulick

View GitHub Profile
@claytongulick
claytongulick / javascript.json
Last active August 25, 2023 19:22
VSCode snippet to create a skeleton Web Component using lit-html for rendering
{
"Create lit-html Web Component Skeleton": {
"prefix": "webc",
"body": [
"import {html, render} from 'lit-html';",
"",
"export default class ${1:AppComponent} extends HTMLElement {",
" constructor() {",
" super();",
" }",
@claytongulick
claytongulick / delete_slack.js
Last active May 24, 2018 06:18
Delete all messages from a specific user on a slack channel
//this grabs 1000 messages at a time from the history of a specific channel
//it spins through each message and compares it with the user id
//if it matches, it'll delete the message.
//there's a throttle of 1 delete per second so you don't bump against rate limits
let Slack = require('slack');
let API_KEY =''; //your API key - get it here: https://api.slack.com/custom-integrations/legacy-tokens
let CHANNEL_ID =''; //the channel id you want to delete from. This can be found in the url
let USER_ID = ''; //the user id for the user you want to delete. Easiest way to get this is to go to your profile and look in the url. Can also grab it from network traffic in debugger
@claytongulick
claytongulick / template.js
Last active June 25, 2022 23:32
if statement inside string template literals and lit-html.
//a quick example of how to use actual 'if' statements inside template literals,
//without using ternary operator. Sometimes this is cleaner if you have complex conditionals or nested conditionals.
//data param is passed in via render(template(data), this) - if not using lit-html, could be any function
template = (data) => html`
<div id="job_edit" class="modal">
<div class="modal-content">
${
//we're just going to wrap an anonymous inline function here and then call it with some data
(job => { //job here, is just an example, it could be anything, it's passed in below in (data.job)
if(job)
@claytongulick
claytongulick / Zen of Javascript
Last active September 14, 2022 16:55
Zen Of Javascript
Zen Of Javascript
Build functionality, not architecture.
Build small things that work
and glue them together to make big things.
Clear is better than clever,
but graceful beats both.
Comments are good, even if you're Dutch.
Asychronous is better than synchronous
except for when it isn't