Skip to content

Instantly share code, notes, and snippets.

View level09's full-sized avatar
🌴
Always on vacation

Nidal Alhariri level09

🌴
Always on vacation
View GitHub Profile
@timhughes
timhughes / fastapi_websocket_redis_pubsub.py
Last active April 29, 2024 08:00
FastAPI Websocket Bidirectional Redis PubSub
"""
Usage:
Make sure that redis is running on localhost (or adjust the url)
Install uvicorn or some other asgi server https://asgi.readthedocs.io/en/latest/implementations.html
pip install -u uvicorn
Install dependencies
@royalgarter
royalgarter / setup_btc_prune_node_ubuntu18_do.sh
Last active September 13, 2021 02:38
Setup Bitcoin Prune Node & LND on DigitalOcean Ubuntu 18.04 LTS
#!/bin/bash
# Prerequisites:
# 1/ ZeroMQ (for LN): https://gist.github.com/royalgarter/71abc75e1214bb39a1ef14a64639c17d
# Test after install bitcoin: btc getzmqnotifications
echo "########### This script was tested with DigitalOcean Ubuntu 18.04 LTS"
echo "########### The server will reboot when the script is complete"
echo "########### Changing to home dir"
cd ~
@aramalipoor
aramalipoor / Dockerfile
Last active November 23, 2023 14:05
Docker + Alpine + Newrelic + PHP (Kubernetes / AbarCloud)
# Prepare required directories for Newrelic installation
RUN mkdir -p /var/log/newrelic /var/run/newrelic && \
touch /var/log/newrelic/php_agent.log /var/log/newrelic/newrelic-daemon.log && \
chmod -R g+ws /tmp /var/log/newrelic/ /var/run/newrelic/ && \
chown -R 1001:0 /tmp /var/log/newrelic/ /var/run/newrelic/ && \
# Download and install Newrelic binary
export NEWRELIC_VERSION=$(curl -sS https://download.newrelic.com/php_agent/release/ | sed -n 's/.*>\(.*linux-musl\).tar.gz<.*/\1/p') && \
cd /tmp && curl -sS "https://download.newrelic.com/php_agent/release/${NEWRELIC_VERSION}.tar.gz" | gzip -dc | tar xf - && \
cd "${NEWRELIC_VERSION}" && \
@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
//
@Xion
Xion / requestcontexttask.py
Created November 4, 2015 06:39
Base class for Celery tasks running inside Flask request context
from celery import Task
from flask import has_request_context, make_response, request
from myapp import app
__all__ = ['RequestContextTask']
class RequestContextTask(Task):
@rkuykendall
rkuykendall / undirected_graph.py
Created May 9, 2014 00:09
Undirected Graph: Many-to-Many, Reflexive, Non-Directional Relationships in SQLAlchemy
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
from sqlalchemy.ext.declarative import declarative_base
engine = create_engine('sqlite://', echo=False)
session = sessionmaker(engine)()
Base = declarative_base()
"""An undirected graph example Modified from SQLAlchemy directed
graph example."""
@desandro
desandro / require-js-discussion.md
Created January 31, 2013 20:26
Can you help me understand the benefit of require.js?

I'm having trouble understanding the benefit of require.js. Can you help me out? I imagine other developers have a similar interest.

From Require.js - Why AMD:

The AMD format comes from wanting a module format that was better than today's "write a bunch of script tags with implicit dependencies that you have to manually order"

I don't quite understand why this methodology is so bad. The difficult part is that you have to manually order dependencies. But the benefit is that you don't have an additional layer of abstraction.


@codeinthehole
codeinthehole / run.py
Created November 21, 2012 13:46
Sample Celery chain usage for processing pipeline
from celery import chain
from django.core.management.base import BaseCommand
from . import tasks
class Command(BaseCommand):
def handle(self, *args, **kwargs):
@crh
crh / backbone-tutorial.md
Created October 8, 2012 12:16
Backbone & Yeoman

Backbone.js and yeoman

description

this is a list tutorials for building web application using backbone.js and yeoman. We are building a Photo Gallery JS App from Backbone Fundamentals

Requirements

@level09
level09 / pyxmlrpc
Created December 23, 2011 16:01
Create Drupal Node with python thorough XMLRPC Service
#! /usr/bin/python
import xmlrpclib, pprint
class DrupalNode:
def __init__(self, title, body, ntype='article', uid=1, username ='admin'):
self.title = title
self.body = body
self.type = ntype