Skip to content

Instantly share code, notes, and snippets.

View panique's full-sized avatar
🍒
Jetset lifestyle

Chris panique

🍒
Jetset lifestyle
  • Kyiv (Ukraine)
View GitHub Profile
# This is a work in progress. There are still bugs. Once it is production-ready this will become a full repo.
import os
def count_tokens(text, model_name="gpt-3.5-turbo", debug=False):
"""
Count the number of tokens in a given text string without using the OpenAI API.
This function tries three methods in the following order:
1. tiktoken (preferred): Accurate token counting similar to the OpenAI API.
2. nltk: Token counting using the Natural Language Toolkit library.
<?
# MIT license, do whatever you want with it
#
# This is my invoice.php page which I use to make invoices that customers want,
# with their address on it and which are easily printable. I love Stripe but
# their invoices and receipts were too wild for my customers on Remote OK
#
require_once(__DIR__.'/../vendor/autoload.php');
// Modified from @mutsuda's https://medium.com/@mutsuda/create-an-ios-widget-showing-google-spreadsheets-data-856767a9447e
// by @levelsio
// HOW TO
// 1) Make a Google Sheet, we'll pull the first cell e.g. A1
// 2) Publish your Google Sheet, File -> Publish To Web
// 3) Copy the SHEET_ID in the URL, put it in here below:
const endpoint = "https://spreadsheets.google.com/feeds/cells/SHEET_ID/1/public/full?alt=json"
// 4) Install Scriptable @ https://apps.apple.com/us/app/scriptable/id1405459188
// 5) Copy this entire script in to Scriptable (tip: you can send it to your iPhone via Whatsapp/Messenger/Telegram etc)
@patricknelson
patricknelson / - Using Xdebug in Docker.md
Last active October 15, 2023 19:59
Using Xdebug in Docker (works with PhpStorm)

Using Xdebug in Docker

Getting setup and running with Xdebug in a docker container these days is now fairly simple and is composed of two main steps:

  1. Ensure you've got XDebug installed and enabled in your PHP docker image, for example:
    # Installing Xdebug with PHP 7.3 images:
    RUN pecl install xdebug \
      && docker-php-ext-enable xdebug
@levelsio
levelsio / Is it now Ramadan.php
Last active June 6, 2018 01:58
"Is it now Ramadan?" function in PHP
# by @levelsio
#
# MIT licensed
#
# make sure you enable php_intl on PHP
# you can do by uncommenting ;extension=intl or ;extension=php_intl
# and installing php-intl, e.g. sudo apt-get install php-intl
#
# made for Nomad List to give people a notice if they go to a place
# where it is currently Ramadan
@nickrouty
nickrouty / rd-class-text-extraction.php
Created May 9, 2018 04:14
Class for extraction the text from doc, docx, xlsx, pptx and wrapper for 3rd party pdf to text library.
<?php
/**
* Class RD_Text_Extraction
*
* Example usage:
*
* $response = RD_Text_Extraction::convert_to_text($path_to_valid_file);
*
* For PDF text extraction, this class requires the Smalot\PdfParser\Parser class.
@levelsio
levelsio / btc-eth-dca-buy.php
Last active January 6, 2023 22:04
This script runs daily and "Dollar Cost Average"-buys $40 BTC and $10 ETH per day
<?
//
// [ BUY BTC & ETH DAILY ON BITSTAMP ]
// by @levelsio
//
// 2017-08-23
//
// 1) buy $40/day BTC
// 2) buy $10/day ETH
//
@iamarcel
iamarcel / Rental Scam - Overview.md
Last active October 23, 2023 22:31
How we almost got scammed finding a place to stay

My sister was looking for a place to stay in Oslo because she's doing an Erasmus there and due to some miscommunications, the school hadn't provided housing for her. We almost fell victim to a sophisticated scam where our correspondent placed an attractive offer online and impersonated TripAdvisor in order to collect a "booking fee".

The Intro

After contacting the "owner", we got this response:

On 21 Jul 2017, at 15:58, Rosado Gomez <rosadogomez58@gmail.com> wrote:
@nikhita
nikhita / update-golang.md
Last active April 26, 2024 04:46
How to update the Go version

How to update the Go version

System: Debian/Ubuntu/Fedora. Might work for others as well.

1. Uninstall the exisiting version

As mentioned here, to update a go version you will first need to uninstall the original version.

To uninstall, delete the /usr/local/go directory by:

#
# Building an MVP?
# Need a quick database you can set up in seconds?
# What about JSON?
#
# by @levelsio (with help from @marckohlbrugge, @oskarth, @maxdeviant and @kumailht)
# JS
db=[]
fs=require('fs')