Skip to content

Instantly share code, notes, and snippets.

View halhenke's full-sized avatar
:octocat:
Segge Fallt

Hal Henke halhenke

:octocat:
Segge Fallt
View GitHub Profile
@sabetAI
sabetAI / codex_answers.py
Created August 16, 2021 15:52
Example Prompt for Codex /answers
import openai
openai.api_key = os.getenv("OPENAI_API_KEY")
openai.Answer.create(
search_model="cushman-codex",
model="davinci-codex",
question="Where is the React component FloatingMenu defined?",
examples_context='''public shouldShow: Exclude<FloatingMenuPluginProps['shouldShow'], null> = ({ state }) => {
const { selection } = state
const { $anchor, empty } = selection
@sabetAI
sabetAI / codex_scrape.py
Created August 16, 2021 15:46
Scraping Files for Upload to Codex
import os
from argparse import ArgumentParser
import openai
import jsonlines
openai.api_key = os.environ['OPENAI_API_KEY']
# read all typescript files in all subdirectories
def get_all_files(dir, ext):
all_files = []
@Skinner927
Skinner927 / classproperty.py
Last active October 12, 2020 23:01
Properties for Python Classes. Supports get and set.
"""
To use simply copy ClassPropertyMeta and classproperty into your project
"""
class ClassPropertyMeta(type):
def __setattr__(self, key, value):
obj = self.__dict__.get(key, None)
if type(obj) is classproperty:
return obj.__set__(self, value)
@i-am-tom
i-am-tom / FizzBuzz.hs
Last active June 26, 2023 16:35
Arguably the fastest implementation of FizzBuzz ever written.
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE UndecidableInstances #-}
{-# LANGUAGE UnsaturatedTypeFamilies #-}
import GHC.TypeLits
import Prelude hiding (Functor, Semigroup)
type Main = (Fizz <> Buzz) <$> (0 `To` 100)

Nix Flake MVP

Goals

  • To provide Nix repositories with an easy and standard way to reference other Nix repositories.

  • To allow such references to be queried and updated automatically.

  • To provide a replacement for nix-channel, NIX_PATH and Hydra

@teamdandelion
teamdandelion / labels_1024.tsv
Last active February 6, 2024 08:33
TensorBoard: TF Dev Summit Tutorial
We can make this file beautiful and searchable if this error is corrected: No tabs found in this TSV file in line 0.
7
2
1
0
4
1
4
9
5
9
@dfrib
dfrib / DictionaryKeyPath.swift
Last active April 14, 2023 12:45
Swift: Reading and writing to (possible) nested dictionaries for a given key path, using a recursive approach
// For details, see
// http://stackoverflow.com/questions/40261857/remove-nested-key-from-dictionary
import Foundation
extension Dictionary {
subscript(keyPath keyPath: String) -> Any? {
get {
guard let keyPath = Dictionary.keyPathKeys(forKeyPath: keyPath)
else { return nil }
return getValue(forKeyPath: keyPath)
{
"Imei": "354678050021708",
"Timestamp": 1477343460116,
"Priority": 0,
"Gps": {
"Longitude": 1508431968,
"Latitude": -323215269,
"Altitude": 135,
"Angle": 82,
"Satellites": 8,

This document has moved!

It's now here, in The Programmer's Compendium. The content is the same as before, but being part of the compendium means that it's actively maintained.

@fchollet
fchollet / classifier_from_little_data_script_2.py
Last active September 13, 2023 03:34
Updated to the Keras 2.0 API.
'''This script goes along the blog post
"Building powerful image classification models using very little data"
from blog.keras.io.
It uses data that can be downloaded at:
https://www.kaggle.com/c/dogs-vs-cats/data
In our setup, we:
- created a data/ folder
- created train/ and validation/ subfolders inside data/
- created cats/ and dogs/ subfolders inside train/ and validation/
- put the cat pictures index 0-999 in data/train/cats