Skip to content

Instantly share code, notes, and snippets.

@CharlyWargnier
CharlyWargnier / GTP3_script_for_sheets.txt
Created January 15, 2023 15:00
A script to integrate GTP3 in Google Sheets
const OPENAI_API_KEY = ""; // <- PASTE YOUR SECRET KEY HERE
const OPENAI_API_URL = "https://api.openai.com/v1/completions";
/**
* Submits a prompt to GPT-3 and returns the completion
*
* @param {string} prompt Prompt to submit to GPT-3
* @param {float} temperature Model temperature (0-1)
* @param {string} model Model name (e.g. text-davinci-002)
@svpino
svpino / neural-network-from-scratch.py
Last active July 25, 2023 18:04
An implementation of a neural network from scratch
import numpy as np
def sigmoid(x):
return 1 / (1 + np.exp(-x))
def neural_network(X, y):
learning_rate = 0.1
W1 = np.random.rand(2, 4)
W2 = np.random.rand(4, 1)
@SeppPenner
SeppPenner / Installing Python 3.7.4 on Raspbian.rst
Last active January 8, 2024 12:33
Installing Python 3.7.4 on Raspbian

Installing Python 3.7.4 on Raspbian =================================

As of July 2018, Raspbian does not yet include the latest Python release, Python 3.7.4. This means we will have to build it ourselves, and here is how to do it.

  1. Install the required build-tools (some might already be installed on your system).

@ipmb
ipmb / settings.py
Last active November 24, 2023 20:25
Django logging example
import logging.config
import os
from django.utils.log import DEFAULT_LOGGING
# Disable Django's logging setup
LOGGING_CONFIG = None
LOGLEVEL = os.environ.get('LOGLEVEL', 'info').upper()
logging.config.dictConfig({
@james2doyle
james2doyle / simple-json-reponse.php
Last active March 7, 2024 06:02
A simple JSON response function for PHP. Used in various PhileCMS plugins.
<?php
function json_response($code = 200, $message = null)
{
// clear the old headers
header_remove();
// set the actual code
http_response_code($code);
// set the header to make sure cache is forced
header("Cache-Control: no-transform,public,max-age=300,s-maxage=900");
@jonlabelle
jonlabelle / m3u.py
Last active December 17, 2022 17:34
Generate an mp3 playlist file (.m3u), sorted by album track number.
#!/usr/bin/env python
import os
import sys
import glob
from mutagen.mp3 import MP3
from mutagen.easyid3 import EasyID3
#
# MP3 playlist generator
@naiquevin
naiquevin / thankyou.py
Last active September 16, 2020 16:09
Python script to thank people who sent birthday wishes on facebook
import sys
from urllib import urlencode
import requests
from urlparse import urlparse, parse_qs
from random import choice
import re
self_id = None # your facebook id here
utc_bday = None # utc timestamp of your birthday
// Includes functions for exporting active sheet or all sheets as JSON object (also Python object syntax compatible).
// Tweak the makePrettyJSON_ function to customize what kind of JSON to export.
var FORMAT_ONELINE = 'One-line';
var FORMAT_MULTILINE = 'Multi-line';
var FORMAT_PRETTY = 'Pretty';
var LANGUAGE_JS = 'JavaScript';
var LANGUAGE_PYTHON = 'Python';