Skip to content

Instantly share code, notes, and snippets.

View jonathanfann's full-sized avatar

Jonathan Fann jonathanfann

View GitHub Profile
@joewright
joewright / environment.py
Last active April 8, 2025 20:44
environment pattern
import os
class EnvironmentConfiguration():
def __init__(cls):
cls.name = os.environ.get('ENV_NAME', 'development')
cls.required_variable = os.environ.get('REQUIRED_VARIABLE')
cls.some_integer = int(os.environ.get('COOLNESS_LEVEL'))
cls.some_array = str(os.environ.get('GREAT_IDEAS')).split(',')
@joewright
joewright / delete-all-files.js
Last active December 7, 2020 22:02
Delete all files from a Slack workspace with a bot token and the Web API
const slack = require('@slack/web-api');
//@see https://api.slack.com/authentication/token-types#bot
const slackClient = new slack.WebClient('<your-bot-token>');
//start deletin'
deleteAllFiles().then(() => {
logg('All done');
}, err => {
console.error(err);
});
@gaquino
gaquino / gist:87bdf0e6e852e445c0489379d3e9732a
Last active April 21, 2025 20:35
MacOS (xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools))
If you are facing an error like that on new MacOS version.
xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
It means that you need to install XCode command line, open a Terminal and run this command:
$ xcode-select --install
Note:
If you want to download and install Command Line tools manually, it can be downloaded from: https://developer.apple.com/download/more/
@Zemnmez
Zemnmez / tweetdeck-limit-override-dm-rt-fix.js
Last active March 13, 2023 15:21
tweetdeck-limit-override.js
/*
This snippet is esssentially the same as being in the Twitter longer tweets test, for tweetdeck.
The Tweet length counter is fixed by tricking TweetDeck into counting up to 140 characters, twice, so you'll see 140
instead of 280 in the counter but going over 140 will give you another set of 140 charactrs.
*/
TD.services.TwitterClient.prototype.makeTwitterCall=function(b,e,f,g,c,d,h){c=c||function(){};d=d||function(){};b=this.request(b,{method:f,params:Object.assign(e,{weighted_character_count:!0}),processor:g,feedType:h});return b.addCallbacks(function(a){c(a.data)},function(a){d(a.req,"",a.msg,a.req.errors)}),b};
twttrTxt=Object.assign({},twttr.txt,{isInvalidTweet:function(){return!1},getTweetLength:function(x){return x=twttr.txt.getTweetLength.apply(this,arguments),x<140||x/140>2?x:x%140}});
@joewright
joewright / query-selector-logger.js
Last active February 20, 2018 15:23
log a unique jQuery selector for every element clicked on a page
// requires jQuery https://code.jquery.com/jquery-1.11.3.js
window.events = [];
$('body').click(function(event) {
//use event.target with firefox
var selector = fromHTMLElement(event.toElement || event.target);
window.events.push(selector);
console.log(selector, $(selector));
});
function fromHTMLElement(srcElement) {
@raewrites
raewrites / backend-code-global-options.php
Last active December 19, 2019 23:27
Backend Code for Global Options
/*===================================================================================
* Add global options
* =================================================================================*/
/**
*
* The page content surrounding the settings fields. Usually you use this to instruct non-techy people what to do.
*
*/
function theme_settings_page(){
@joewright
joewright / serve_it_up.js
Last active December 19, 2018 19:08
Stream mongo query through an express server
var express = require('express');
var mongoose = require('mongoose');
// connect to local db
mongoose.connect('mongodb://127.0.0.1:27017/swag', function(error) {
if (error) {
throw new Error(error);
}
});
// Mongoose Schema definition
@morganherlocker
morganherlocker / Effects Pedal hacking 101.md
Last active October 11, 2017 19:47
Effects Pedal hacking 101

General:

  • start simple
  • start with fuzz
  • don't even bother looking at building an analog delay pedal yet :)

All you really need to know about electrical components:

Resistors