Skip to content

Instantly share code, notes, and snippets.

View k4ml's full-sized avatar
🏠
Working from home

Kamal Mustafa k4ml

🏠
Working from home
View GitHub Profile
@k4ml
k4ml / messaging.py
Created January 29, 2014 23:26
POPO - Plain Old Python Object
class Messaging(object):
def __init__(self, user, sender, receiver, message):
self.user = user
self.sender = sender
self.receiver = receiver
self.message = message
def send(self):
required_points = self.get_required_points()
if required_points > self.user.points:
@k4ml
k4ml / LLM.md
Created April 17, 2023 23:51 — forked from rain-1/LLM.md
LLM Introduction: Learn Language Models

Purpose

Bootstrap knowledge of LLMs ASAP. With a bias/focus to GPT.

Avoid being a link dump. Try to provide only valuable well tuned information.

Prelude

Neural network links before starting with transformers.

@k4ml
k4ml / docs.txt
Last active April 12, 2023 20:21
Python client for Webfaction API
# API Reference¶
The WebFaction [XML-RPC](http://en.wikipedia.org/wiki/XML-RPC) API provides
methods to make many account tasks scriptable. This documentation is a
complete reference to all of the possible API methods.
Please note that XML-RPC parameters are positional (order matters), and many
parameters are required. Parameters may only be omitted if omitted parameters
have default values and follow all other parameters to which you have supplied
a value.
@k4ml
k4ml / syspkg.py
Created November 15, 2012 18:55
Copy system packages into virtualenv
import os
import sys
import shutil
pkgname = sys.argv[1]
venv = sys.argv[2]
pyversion = '%s.%s' % (sys.version_info[0], sys.version_info[1])
try:
pkgobj = __import__(pkgname)
@k4ml
k4ml / admin.py
Last active October 6, 2021 07:25
Le-Wagon Workshop
from django.contrib import admin
from mysite.models import Survey, Question, Choice
class QuestionInline(admin.TabularInline):
model = Question
show_change_link = True
class ChoiceInline(admin.TabularInline):
model = Choice
@k4ml
k4ml / app.py
Last active April 29, 2021 15:27
Example of Bottle app with Django style request object as first parameter to request function handler and login_required decorator.
"""
Bottle (and also Flask) seem to favor global request object that when called within
a request function handler, will return request data that specific to the current request.
This is convenience since it free you from having to pass request object from function to
function as you would have in Django. Maybe I'm too used with Django approach but having request
object explicitly passed to your function allow me to correctly think how to structure my app.
It's not just one time when designing a solution, I come to dead end because I try to access request
data not from request context. It easy to fall into that because the request object available in the
global namespace.
@k4ml
k4ml / slacktg_bridge.py
Last active March 22, 2020 22:36
2 way bridge between Slack and Telegram.
"""
Copyright 2017 k4ml@twitter.com.
Permission to use, copy, modify, and/or distribute this software
for any purpose with or without fee is hereby granted, provided
that the above copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE
@k4ml
k4ml / main.go
Last active October 14, 2018 05:37
Reading input from console in Go
// https://tutorialedge.net/golang/reading-console-input-golang/
package main
import (
"bufio"
"fmt"
"os"
"strings"
)
@k4ml
k4ml / _webfaction_setup.rst
Created September 17, 2012 02:58 — forked from ptone/_webfaction_setup.rst
setting up a stack on webfaction

Setting up Webfaction for modern Python deployment

last updated: 4/5/2011

note that this stuff is always a moving target, much of this has been cribbed and combined from various blog posts. Much of the information was out of date from those, and if it is more than a couple months after the last updated date above, consider some of this likely to now be out of date.

@k4ml
k4ml / tgbot-ws.lua
Created July 15, 2015 04:38
telegram-bot webscript.io
local tg_token = 'your token'
if request.query['admin_command'] == 'setURL' and request.query['pass'] == 'xxx' then
local response = http.request {
url = 'https://api.telegram.org/bot' .. tg_token .. '/setWebhook',
params = {
url='https://demo-xxxx.webscript.io/script'
},
method='post',
}