Skip to content

Instantly share code, notes, and snippets.

View Bengt's full-sized avatar

Bengt Lüers Bengt

View GitHub Profile
@Bengt
Bengt / Windows Setup.md
Last active March 15, 2023 14:33
This is how I setup Windows ... More or less.

Operating System

  • Download the media creation tool
  • Use it to downgrade Windows 11 to Windows 10

Note: You do not need an USB drive for this.

Updates

  • Run Check for Updates and install all updates.
import sys, marshal, functools, subprocess
child_script = """
import marshal, sys, types;
fn, args, kwargs = marshal.load(sys.stdin)
marshal.dump(
types.FunctionType(fn, globals())(*args, **kwargs),
sys.stdout)
"""
@macournoyer
macournoyer / Output
Last active January 9, 2023 15:12
A Neural Network framework in 25 LOC
$ python xor.py
Training:
Epoch 0 MSE: 1.765
Epoch 100 MSE: 0.015
Epoch 200 MSE: 0.005
* Target MSE reached *
Evaluating:
1 XOR 0 = 1 ( 0.904) Error: 0.096
0 XOR 1 = 1 ( 0.908) Error: 0.092
1 XOR 1 = 0 (-0.008) Error: 0.008
@letmaik
letmaik / voronoi_polygons.py
Last active June 9, 2022 22:16
Creates a Voronoi diagram with cell polygons using scipy's Delaunay triangulation (scipy >= 0.9)
from __future__ import division
import collections
import numpy as np
import matplotlib
import matplotlib.pyplot as plt
from scipy.spatial import Delaunay, KDTree
# an adaptation of https://stackoverflow.com/a/15783581/60982
# using ideas from https://stackoverflow.com/a/9471601/60982
@dnmellen
dnmellen / colors.py
Created May 15, 2013 13:32
Auxiliary Python module to get styled terminal outputs in a pythonic way
# encoding: utf-8
# Copyright 2013 Diego Navarro Mellén. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification, are
# permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice, this list of
# conditions and the following disclaimer.
#
class APIWrapper:
#snippet...
def poll_api(self, tries, initial_delay, delay, backoff, success_list, apifunction, *args):
time.sleep(initial_delay)
for n in range(tries):
try:
status = self.get_status()
if status not in success_list:
@ChickenProp
ChickenProp / gist:3183960
Created July 26, 2012 19:21
Expanding the Raspberry Pi's GPIO capabilities with the MCP23017

Introduction

The MCP23017 is an I/O expander chip. It has 16 GPIO pins which you can control using an I2C interface using two pins from a Raspberry Pi, plus a power source and sink (which can also come from the Pi). It's not quite as simple as directly controlling the Pi's GPIO pins, but it's not complicated, either.

You need to install i2c-tools, which is probably in your distribution's package manager. You also need a kernel with I2C support; you might need to modprobe i2c-dev. It would presumably be possible to do without either of these things, and bitbang the I2C protocol over GPIO, but I don't understand the protocol well enough to try.

On pin numbering: if you like, you can refer to the datasheet for the MCP23017. There's a small dot in one corner of the chip, with a semi-circular cut-out at that end. The pin near

FedoraSetup

This installation guide documents my standard procedure of a system setup with Fedora. Naturally, everyone will not agree at some point on my way of doing this. Please take this with a grain of salt and use it as a guide to avoid forgetting things, as I do myself.

Rationale

I use my computer all day everyday. After a while I used every application I will ever use and configured upon first usage. The configuration disrupts but the workflow leading to using the application first. To avoid configuration induced disruptions, the configuration could be done upfront. This is a collection of configurations and other steps involved in setting up a new system with Fedora.

Problem Statement

@defnull
defnull / gist:1224387
Created September 17, 2011 21:22
Deploy a Bottle app on Heroku
mkdir heroku
cd heroku/
virtualenv --no-site-packages env
source env/bin/activate
pip install bottle gevent
pip freeze > requirements.txt
cat >app.py <<EOF
import bottle
import os
@tinogomes
tinogomes / start_stop_memcached_script.sh
Created June 21, 2010 17:34
Script sample to start/stop for linux with nohup
#!/bin/bash
#
BASE=/tmp
PID=$BASE/app.pid
LOG=$BASE/app.log
ERROR=$BASE/app-error.log
PORT=11211
LISTEN_IP='0.0.0.0'
MEM_SIZE=4