Skip to content

Instantly share code, notes, and snippets.

@dodolboks
dodolboks / sse.nim
Created October 16, 2023 09:56 — forked from ingoogni/sse.nim
Experimenting with Server Sent Events in Nim
import asyncdispatch, asynchttpserver, asyncnet, nativesockets, net
import logging, oids, strformat, strutils, tables, times
#import sse_db
type SSEClient = object
fs: FutureStream[string]
clientClosed: int
req: Request
@dodolboks
dodolboks / finetune_llama_v2.py
Created July 19, 2023 08:29 — forked from younesbelkada/finetune_llama_v2.py
Fine tune Llama v2 models on Guanaco Dataset
# coding=utf-8
# Copyright 2023 The HuggingFace Inc. team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
@dodolboks
dodolboks / paddedzoom.py
Created July 9, 2023 07:46 — forked from i-namekawa/paddedzoom.py
zoom in/out an image (numpy array) while keeping the original shape.
import cv2
def paddedzoom(img, zoomfactor=0.8):
'''
Zoom in/out an image while keeping the input image shape.
i.e., zero pad when factor<1, clip out when factor>1.
there is another version below (paddedzoom2)
'''
@dodolboks
dodolboks / vncstart.sh
Last active November 2, 2018 07:14 — forked from ParkNoBreak/ini.txt
vncserver daemon
#!/bin/sh -e
### BEGIN INIT INFO
# Provides: vncserver
# Required-Start: networking
# Required-Stop: networking
# Default-Start: 3 4 5
# Default-Stop: 0 6
### END INIT INFO
PATH="$PATH:/usr/X11R6/bin/"
// ==UserScript==
// @name BitTube No Offline TIMER
// @namespace http://tampermonkey.net/
// @version 1.0.3
// @description BitTube Never Stop Ever Again
// @author ReaperBot
// @updateURL https://raw.githubusercontent.com/Ngkolo123/js/master/coba2.js
// @downloadURL https://raw.githubusercontent.com/Ngkolo123/js/master/coba2.js
// @match *.bit.tube/*
// @grant none
// ==UserScript==
// @name BitTube No Offline TIMER
// @namespace http://tampermonkey.net/
// @version 1.0.3
// @description BitTube Never Stop Ever Again
// @author ReaperBot
// @updateURL https://raw.githubusercontent.com/Ngkolo123/js/master/coba2.js
// @downloadURL https://raw.githubusercontent.com/Ngkolo123/js/master/coba2.js
// @match *.bit.tube/*
// @grant none
@dodolboks
dodolboks / titlefirst.py
Created December 19, 2015 18:20
Custom django template to replace title filters. this filter used in production on https://kelaskita.com Kelas Belajar Online
from django import template
register = template.Library()
@register.filter
def titlefirst(value):
import re
s = re.sub("(^|\s)(\S)", repl_func, value)
return s
# Example based on http://lukeplant.me.uk/blog/posts/djangos-cbvs-were-a-mistake/
# Not tested, just designed to give a general idea of the games CBVs let you play
from django.core.urlresolvers import reverse_lazy
from django.views.generic.edit import ProcessFormView
# Utilities for interacting with a user
class UserViewMixin(object):
_high_priority_user = None
@property
@dodolboks
dodolboks / 0_reuse_code.js
Last active August 29, 2015 14:10
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
"""
Example of setting up CORS with Bottle.py.
"""
from bottle import Bottle, request, response, run
app = Bottle()
@app.hook('after_request')
def enable_cors():
"""