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 / get_github_log
Created September 8, 2023 09:16
Github log pretty print with stats and formatting
# --since='last month'
echo "commit id|author|date|comment|changed files|lines added|lines deleted" > github_log.csv
git log --after='2022-1-1' --date=local --all --pretty=format:'@%h|%an|%ad|%s|' --shortstat --no-merges | tr "\n" " " | tr "@" "\n" >> github_log.csv
sed -i 's/ files changed,/|/g' github_log.csv
sed -i 's/ file changed,/|/g' github_log.csv
sed -i 's/ insertions(+),/|/g' github_log.csv
sed -i 's/ insertion(+),/|/g' github_log.csv
sed -i 's/ insertions(+)/|0/g' github_log.csv
sed -i 's/ insertion(+)/|0/g' github_log.csv
sed -i 's/ deletions(-)//g' github_log.csv
@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: