Skip to content

Instantly share code, notes, and snippets.

View nickatnight's full-sized avatar

Nick nickatnight

View GitHub Profile
@leandronsp
leandronsp / 001-server.bash
Last active June 16, 2024 18:54
A complete yet simple Web server (with login & logout system) written in Shell Script
#!/bin/bash
## Create the response FIFO
rm -f response
mkfifo response
function handle_GET_home() {
RESPONSE=$(cat home.html | \
sed "s/{{$COOKIE_NAME}}/$COOKIE_VALUE/")
}
@kylemcdonald
kylemcdonald / parler-video.md
Last active July 10, 2022 04:22
How to view a video on Parler.

How to view a video on Parler

Let's say you have a video ID, like wfy02V209EwU taken from this map

The link for the video kiBnNejo0JW0 is at https://video.parler.com/ki/Bn/kiBnNejo0JW0. Notice that the link is: https://video.parler.com/ followed by the first two characters of the video ID, then /, then the next two characters, another /, and the video ID.

But if you click on this, you will get an error.

This is because the Parler video servers are still running (as of January 12) but the Domain Name System (DNS) is not running.

@sainipray
sainipray / filter.py
Created February 27, 2020 09:53
Custom Django rest framework Ordering Filter
from rest_framework.filters import OrderingFilter
class CustomOrderFilter(OrderingFilter):
allowed_custom_filters = ['user_city', 'user_country']
fields_related = {
'user_city': 'user__city__name', # ForeignKey Field lookup for ordering
'user_country': 'user__country__name'
}
def get_ordering(self, request, queryset, view):
@sbinlondon
sbinlondon / synthwaveglow.md
Last active February 22, 2024 22:40
Get the synth wave glow theme working for VS Code on Mac

Get the synth wave glow working for VS Code on Mac

These notes are pretty much the same steps as the two extensions list, it's just that I had to collate them together because neither seems to list it fully in the proper order.

  1. Install Synthwave ’84/Synthwave + Fluoromachine theme on VS Code (I used the Fluoromachine one)

  2. Install Custom CSS and JS Loader

  3. Command + Shift + P to open command palette > "Preferences: Open settings (JSON)"

@dmmeteo
dmmeteo / 1.srp.py
Last active June 7, 2024 14:11
SOLID Principles explained in Python with examples.
"""
Single Responsibility Principle
“…You had one job” — Loki to Skurge in Thor: Ragnarok
A class should have only one job.
If a class has more than one responsibility, it becomes coupled.
A change to one responsibility results to modification of the other responsibility.
"""
class Animal:
def __init__(self, name: str):
@evansde77
evansde77 / mock_requests.py
Last active May 30, 2024 10:11
Example of mocking requests calls
#!/usr/bin/env python
"""
mocking requests calls
"""
import mock
import unittest
import requests
from requests.exceptions import HTTPError
@cspanring
cspanring / pip-install-gdal.md
Last active October 18, 2023 07:56
Installing GDAL in a Python virtual environment

Installing GDAL in a Python virtual environment

Get gdal development libraries:

$ sudo apt-add-repository ppa:ubuntugis/ubuntugis-unstable
$ sudo apt-get update
$ sudo apt-get install libgdal-dev

Create and activate a virtual environment:

@domenic
domenic / promises.md
Last active June 24, 2024 03:11
You're Missing the Point of Promises

This article has been given a more permanent home on my blog. Also, since it was first written, the development of the Promises/A+ specification has made the original emphasis on Promises/A seem somewhat outdated.

You're Missing the Point of Promises

Promises are a software abstraction that makes working with asynchronous operations much more pleasant. In the most basic definition, your code will move from continuation-passing style:

getTweetsFor("domenic", function (err, results) {
 // the rest of your code goes here.