Skip to content

Instantly share code, notes, and snippets.

View johnwheeler's full-sized avatar
🏠
Working from home

John Wheeler johnwheeler

🏠
Working from home
  • San Diego, California
View GitHub Profile
#!/usr/bin/env python
"""
pip install tiktoken requests
export OPENAI_API_KEY=<redact>
chmod +x prepare-commit-msg
mv prepare-commit-msg .git/hooks/
"""
import math
@LukeMathWalker
LukeMathWalker / audit.yml
Last active July 2, 2024 15:09
GitHub Actions - Rust setup
name: Security audit
on:
schedule:
- cron: '0 0 * * *'
push:
paths:
- '**/Cargo.toml'
- '**/Cargo.lock'
jobs:
security_audit:
@ctrlcctrlv
ctrlcctrlv / rust-maintainer-perfectionism.md
Last active January 4, 2024 15:42
Rust maintainer perfectionism

Rust maintainer perfectionism, or, the tragedy of Alacritty

I did not submit this to Hacker News and did not intend that this post would have high circulation but have no real problem with it being there or with it having such. I have more recent comments below. This post is from January 2020 and predates the Modular Font Editor K (MFEK) project.

I have not worked on Rust projects in quite a while, and don't know if I ever will again. I feel many crate maintainers are way too perfectionist, for example, despite all the developer hours that went into this PR, it took the effort within years to be (halfway) merged.

There's always a reason not to merge, isn't there? It would be better done with a new nightly language feature, or the function signature should have a where clause, or the documentation is not perfect. There's always a new nit to pick in the world of Ru

import time
class Bucket(object):
def __init__(self, max_amount, refill_time, refill_amount):
self.max_amount = max_amount
self.refill_time = refill_time
self.refill_amount = refill_amount
self.reset()
def _refill_count(self):
@brandondurham
brandondurham / styles.less
Last active June 24, 2024 14:48
Using Operator Mono in Atom
/**
* Using Operator Mono in Atom
*
* 1. Open up Atom Preferences.
* 2. Click the “Open Config Folder” button.
* 3. In the new window’s tree view on the left you should see a file called “styles.less”. Open that up.
* 4. Copy and paste the CSS below into that file. As long as you have Operator Mono SSm installed you should be golden!
* 5. Tweak away.
*
* Theme from the screenshot (http://cdn.typography.com/assets/images/blog/operator_ide2.png):
@brandonhuff
brandonhuff / unicodetodate.pipe.ts
Created January 3, 2016 23:08
Angular 2 Beta.0 pipe for converting ISO 8601 string dates to javascript Date type.
// https://en.wikipedia.org/wiki/ISO_8601
// Example
// Usage: {{ dateValue | unicodeToDate | date:'MM/dd/yyyy' }}
// Data: 2014-01-05T18:14:18.32
// Result: 01/05/2014
import {Pipe} from 'angular2/core';
@Pipe({name: 'unicodeToDate'})
export class UnicodeToDatePipe {
@omarstreak
omarstreak / threadDataManager.js
Created September 10, 2015 17:54
Thread Data Manager example
import Kefir from 'kefir';
class ThreadDataManager {
constructor(){
Kefir.stream(emitter => {this._emitter = emitter; return () => null});
this._threadData = {}; //map from threadID to thread data
}
setThreadData(threadID, data){
this._threadData[threadID] = data;
sdk.Lists.registerThreadRowViewHandler(function(threadRowView){
var emitter; //variable name to hoist the emitter to
var stream = Kefir.stream(function(inEmitter){
emitter = inEmitter;
return function(){}; //we need to return a function that gets called when the stream ends
});
threadRowView.addLabel(stream); //add the label passing in the stream

Angular2 + JSPM cheat sheet

First time setup

  • install jspm beta: npm install -g jspm@beta
  • set up your project: jspm init
  • install dependencies: jspm install angular2 reflect-metadata zone.js es6-shim

This will create a jspm_packages folder, and a config.js file.

Open the config.js file - this file manages options for the System.js loader - tweak it as appropriate

@omarstreak
omarstreak / background.js
Last active October 22, 2023 15:44
Chrome API Extension
//oauth2 auth
chrome.identity.getAuthToken(
{'interactive': true},
function(){
//load Google's javascript client libraries
window.gapi_onload = authorize;
loadScript('https://apis.google.com/js/client.js');
}
);