Skip to content

Instantly share code, notes, and snippets.

View NISH1001's full-sized avatar
💭
Staring into the abyss...

Nish NISH1001

💭
Staring into the abyss...
View GitHub Profile
@evildmp
evildmp / gist:3094281
Last active June 30, 2023 10:55
Set up Django, nginx and uwsgi

This document has now been incorporated into the uWSGI documentation:

http://uwsgi-docs.readthedocs.org/en/latest/tutorials/Django_and_nginx.html

Set up Django, nginx and uwsgi

Steps with explanations to set up a server using:

@telekineticyeti
telekineticyeti / py_lftp.py
Created September 5, 2012 18:57
Python shell script that utilizes the excellent LFTP to create a mirror between a local directory and a remote ftp site.
#!/usr/bin/python
'''
©2012 Paul Castle
Very crude but functional early edition, will expand in the future.
I run this script on a 3 day cron to keep my personal wiki backed up to my
local development server. LFTP is very good at retaining permissions between
mirrors.
User/pass variables require base64 encoded attributes to avoid shoulder-surfers.
@AlexandreAbraham
AlexandreAbraham / unsupervised_alt.py
Last active July 31, 2024 03:42
These are two implementations of the silhouette score. They are compatible with the scikit learn implementation but offers different drawbacks in term of complexity and memory usage. The slow version needs no memory but is painfully slow and should, I think, not be used. The second one is based on a block strategy: distance between samples and c…
""" Unsupervised evaluation metrics. """
# License: BSD Style.
from itertools import combinations
import numpy as np
from sklearn.utils import check_random_state
from sklearn.metrics.pairwise import distance_metrics
from sklearn.metrics.pairwise import pairwise_distances
@aras-p
aras-p / preprocessor_fun.h
Last active May 3, 2025 13:47
Things to commit just before leaving your job
// Just before switching jobs:
// Add one of these.
// Preferably into the same commit where you do a large merge.
//
// This started as a tweet with a joke of "C++ pro-tip: #define private public",
// and then it quickly escalated into more and more evil suggestions.
// I've tried to capture interesting suggestions here.
//
// Contributors: @r2d2rigo, @joeldevahl, @msinilo, @_Humus_,
// @YuriyODonnell, @rygorous, @cmuratori, @mike_acton, @grumpygiant,
@robertparker
robertparker / swimming-in-my-head.md
Last active June 18, 2020 07:45
writing ideas.

#Things Swimming in My Head

Like Homo Economicus Scorned

Over Labor Day Weekend, Twitter user @VXDS flew off his handle (so sorry) and made history. British Airways had lost his bag amd had been negligent in responding. Without the following to start a viral outcry over poor customer service, @XVDS did what any rational person would: he bought a promoted tweet and lamabasted the company for customer services.

The incident brings to mind a famous study in behavioral economics. In an experiment published in the Journal of Psychology, researchers gave people the chance to penalize teammates in a game for ruining the chance for the team to make money. Invariably, they did. The research flies in the face of classical economic assumption about Homo Economicus, ie the purely self-interested man. People are willing to spend their own capital in order to enforce social norms.

Is Software Eating Cities?

One prerequisite for a healthy city neighborhood, writes Jane Jacobs, is the presence of public spaces

@sloria
sloria / bobp-python.md
Last active April 27, 2025 07:06
A "Best of the Best Practices" (BOBP) guide to developing in Python.

The Best of the Best Practices (BOBP) Guide for Python

A "Best of the Best Practices" (BOBP) guide to developing in Python.

In General

Values

  • "Build tools for others that you want to be built for you." - Kenneth Reitz
  • "Simplicity is alway better than functionality." - Pieter Hintjens
@mikofski
mikofski / metapoop.py
Last active October 22, 2022 12:21
Another Python metaclass primer
#! /usr/bin/env python
"""
Python metaclasses
==================
A metaclass is a class factory; metaclasses serve two purposes:
1. replace ``type`` as the base class metatype for classes with the
``__metaclass__`` attribute
@grantslatton
grantslatton / hngen.py
Last active September 27, 2021 11:07
A program that uses Markov chains to generate probabilistic Hacker News titles.
import urllib2
import re
import sys
from collections import defaultdict
from random import random
"""
PLEASE DO NOT RUN THIS QUOTED CODE FOR THE SAKE OF daemonology's SERVER, IT IS
NOT MY SERVER AND I FEEL BAD FOR ABUSING IT. JUST GET THE RESULTS OF THE
CRAWL HERE: http://pastebin.com/raw.php?i=nqpsnTtW AND SAVE THEM TO "archive.txt"
@pv
pv / colorized_voronoi.py
Last active March 10, 2025 01:15
Colorized Voronoi diagram with Scipy, in 2D, including infinite regions
import numpy as np
import matplotlib.pyplot as plt
from scipy.spatial import Voronoi
def voronoi_finite_polygons_2d(vor, radius=None):
"""
Reconstruct infinite voronoi regions in a 2D diagram to finite
regions.
Parameters
@mabdrabo
mabdrabo / sound_recorder.py
Created January 28, 2014 23:05
Simple script to record sound from the microphone, dependencies: easy_install pyaudio
import pyaudio
import wave
FORMAT = pyaudio.paInt16
CHANNELS = 2
RATE = 44100
CHUNK = 1024
RECORD_SECONDS = 5
WAVE_OUTPUT_FILENAME = "file.wav"