Skip to content

Instantly share code, notes, and snippets.

View abfo's full-sized avatar
☁️
Working on an LLM experiment called https://shopstories.us/

Robert Ellison abfo

☁️
Working on an LLM experiment called https://shopstories.us/
View GitHub Profile
@abfo
abfo / Code.gs
Created September 15, 2018 19:08
// add your Google API Project OAuth client ID and client secret here
var ClientID = '';
var ClientSecret = '';
function onOpen() {
var ui = SpreadsheetApp.getUi();
ui.createMenu('Google Fit')
.addItem('Authorize if needed (does nothing if already authorized)', 'showSidebar')
.addItem('Get Steps for Yesterday', 'getSteps')
.addItem('Get Steps for past 30 days', 'getHistory')
// load word2vec model
_vocabulary = new Word2VecBinaryReader().Read(HostingEnvironment.MapPath("~/App_Data/GoogleNews-vectors-negative300-SLIM.bin"));
// ... collect all words in post (words is List<string>, not included as implementation specific) ...
double[] vector = new double[_vocabulary.VectorDimensionsCount];
// add all words that exist in the vocabulary
int inVocabularyCount = 0;
foreach(string word in words)
<CustomAction Id='InstallSS'
Directory='SystemFolder'
ExeCommand='rundll32.exe desk.cpl,InstallScreenSaver the.scr'
Return='asyncNoWait'/>
<Custom Action="InstallSS" After="InstallFinalize"><![CDATA[NOT Installed]]></Custom>
@abfo
abfo / Blend.cs
Created September 30, 2018 00:51
private static void SimpleBlend(string image1path, string image2path, byte alpha)
{
using (Bitmap image1 = (Bitmap)Bitmap.FromFile(image1path))
{
using (Bitmap image2 = (Bitmap)Bitmap.FromFile(image2path))
{
// update the alpha for each pixel of image 2
for (int x = 0; x < image2.Width; x++)
{
for (int y = 0; y < image2.Height; y++)
public static string OAuthUrlEncode(string s)
{
if (string.IsNullOrEmpty(s))
{
return string.Empty;
}
else
{
StringBuilder sb = new StringBuilder(s.Length);
private const string NoEncodeChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_.~";
App.Current.DispatcherUnhandledException +=
new DispatcherUnhandledExceptionEventHandler(Current_DispatcherUnhandledException);
AppDomain.CurrentDomain.UnhandledException +=
new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
void someEvent_Handler(object sender, SomeEventEventArgs e)
{
if (this.Dispatcher.CheckAccess())
{
// do work on UI thread
}
else
{
// or BeginInvoke()
this.Dispatcher.Invoke(new Action(someEvent_Handler),