Skip to content

Instantly share code, notes, and snippets.

@TurRil
TurRil / main.py
Created April 29, 2024 09:13 — forked from mberman84/main.py
OpenChat Code
import requests
import json
import gradio as gr
url = "http://localhost:11434/api/generate"
headers = {
'Content-Type': 'application/json',
}
@TurRil
TurRil / links.md
Created October 13, 2023 09:26 — forked from tockards/links.md
PyConZA 2023
@TurRil
TurRil / multiple_ssh_setting.md
Created May 15, 2023 15:31 — forked from jexchan/multiple_ssh_setting.md
Multiple SSH keys for different github accounts

Multiple SSH Keys settings for different github account

create different public key

create different ssh key according the article Mac Set-Up Git

$ ssh-keygen -t rsa -C "[email protected]"
my_kmeans <- function(data, k, n_iterations) {
# Helper function for euclidean distance
euclidean_distance <- function(p1, p2) {
dist <- sqrt(sum((p1-p2)^2))
return(dist)
}
# Initialize centers randomly
centers <- df[sample(nrow(df), k, replace = FALSE), ]
# Perform n iterations
@TurRil
TurRil / stripdict.py
Created December 12, 2022 08:00 — forked from palewire/stripdict.py
Strip leading and trailing whitespaces in dictionary keys and values
def strip_dict(d):
"""
Strip all leading and trailing whitespace in dictionary keys and values.
"""
return dict((k.strip(), v.strip()) for k, v in d.items())
@TurRil
TurRil / githash.py
Created November 24, 2022 08:51 — forked from msabramo/githash.py
Python code to generate git SHA-1 hashes
#!/usr/bin/env python
from sys import argv
from hashlib import sha1
from cStringIO import StringIO
class githash(object):
def __init__(self):
self.buf = StringIO()
@TurRil
TurRil / README.md
Created September 23, 2022 10:06 — forked from jesslilly/README.md
Deluxe Cron Job Wrapper

Cron Job Wrapper Wish List

I want a script that will give me:

  1. Logging
  2. Log purging!
  3. Email errors!
  4. Prevent duplicate processes! (flock)
  5. Source an environment file!
  6. Anything else?
@TurRil
TurRil / README.md
Created June 18, 2021 12:15 — forked from genomics-geek/README.md
Setting up a Dockerized web application with Django REST APIs, ReactJS with Redux pattern, and Webpack Hot Reloading! Mouthful.

Guide on how to create and set up a Dockerized web app using Django REST APIs and ReactJS

Hopefully this will answer "How do I setup or start a Django project using REST Framework and ReactJS?"

This is a guide to show you step by step how this can be setup. If you just want to get started, use the cookiecuter I set up cookiecutter-django-reactjs. It basically is a fork of pydanny's cookiecutter, just added the front-end stuff :).

I created this because it was SUCH a pain in the ass setting up a project using all the latest technologies. After some research, I figured it out and have it working. The repo that implements this is located here. Feel free to use it as a boilerplate ;)

Main features:

  • Django REST APIs
@TurRil
TurRil / canvas.js
Created November 20, 2020 10:24 — forked from cam-gists/canvas.js
JavaScript: Canvas Resize (Maintain Proportion)
/*==RESIZE CANVAS TO MAINTAIN PROPORTION ==*/
var fixDimensions = function(){
//Get the image dimensions:
var image = {
width: $("canvas").width(),
height: $("canvas").height()
};
//Get the page dimensions:
@TurRil
TurRil / formatBytes.js
Created October 7, 2020 14:38 — forked from zentala/formatBytes.js
Convert size in bytes to human readable format (JavaScript)
function formatBytes(bytes,decimals) {
if(bytes == 0) return '0 Bytes';
var k = 1024,
dm = decimals || 2,
sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'],
i = Math.floor(Math.log(bytes) / Math.log(k));
return parseFloat((bytes / Math.pow(k, i)).toFixed(dm)) + ' ' + sizes[i];
}
// Usage: