Skip to content

Instantly share code, notes, and snippets.

@leuc
leuc / amdgpu_metrics.py
Last active December 10, 2023 04:19
Decode AMD GPU Metrics from SysFS
#!/usr/bin/env python3
#
# SPDX-License-Identifier: GPL-3.0-or-later
#
# amdgpu_metrics.py decode amdgpu metrics from sysfs
# Copyright (C) 2021 leuc
#
# This program is free software: you can redistribute it and/or modify it under the
# terms of the GNU Affero General Public License as published by the Free Software
# Foundation, either version 3 of the License, or (at your option) any later
@YannBerthelot
YannBerthelot / PlaneModel.py
Last active December 9, 2023 21:52
Plane Model Transition Function for RL Environment
import math
from math import cos, sin, ceil, floor
import numpy as np
from numpy import arcsin
from numpy.linalg import norm
from .graph_utils import plot_duo, plot_multiple, plot_xy
class FlightModel:
def __init__(self):
"""
@Chandler
Chandler / slack_history.py
Last active March 26, 2024 14:35
Download Slack Channel/PrivateChannel/DirectMessage History
print("UPDATE AUG 2023: this script is beyond old and broken")
print("You may find interesting and more up to date resources in the comments of the gist")
exit()
from slacker import Slacker
import json
import argparse
import os
# This script finds all channels, private channels and direct messages
@kn0ll
kn0ll / blurbcloud.py
Created September 12, 2015 07:19
super hacky script for taking a song off soundcloud and creating a new version where the computer incessantly reads user comments over the audio
import random
import urllib
import urllib2
import soundcloud
import subprocess
from pydub import AudioSegment
def get_track(client_id, sc_url):
client = soundcloud.Client(client_id=client_id)
track = client.get('/resolve', url=sc_url)
@fogus
fogus / oregon.bas
Created July 31, 2015 19:52
1975 version of Oregon Trail
8 REM MINNESOTA EDUCATIONAL COMPUTING CONSORTIUM STAFF
9 REM PROGRAMMING REVISIONS BY DON RAWITSCH - 1975
11 REM CURRENT VERSION - 3/27/75
15 REM **FOR THE MEANING OF THE VARIABLES USED, LIST LINES 4900-4960**
25 PRINT "DO YOU NEED INSTRUCTIONS (YES/NO)";
30 DIM C$[5]
35 INPUT C$
40 IF C$="NO" THEN 400
45 PRINT LIN(2)
59 REM ***INSTRUCTIONS***
@karpathy
karpathy / min-char-rnn.py
Last active June 21, 2024 13:50
Minimal character-level language model with a Vanilla Recurrent Neural Network, in Python/numpy
"""
Minimal character-level Vanilla RNN model. Written by Andrej Karpathy (@karpathy)
BSD License
"""
import numpy as np
# data I/O
data = open('input.txt', 'r').read() # should be simple plain text file
chars = list(set(data))
data_size, vocab_size = len(data), len(chars)
@kenkeiter
kenkeiter / impbcopy.m
Last active January 17, 2024 23:02
Take a selfie, archive it, and copy it to the clipboard -- all from the terminal! (bash + os x)
/////////////////////////////////////////////////////////
// Copied from http://www.alecjacobson.com/weblog/?p=3816
/////////////////////////////////////////////////////////
#import <Foundation/Foundation.h>
#import <Cocoa/Cocoa.h>
#import <unistd.h>
BOOL copy_to_clipboard(NSString *path)
{
// http://stackoverflow.com/questions/2681630/how-to-read-png-image-to-nsimage
NSImage * image;
@bdarnell
bdarnell / streaming.py
Created January 11, 2015 21:23
Demo of streaming requests with Tornado
"""Demo of streaming requests with Tornado.
This script features a client using AsyncHTTPClient's body_producer
feature to slowly produce a large request body, and two server
handlers to receive this body (one is a proxy that forwards to the
other, also using body_producer).
It also demonstrates flow control: if --client_delay is smaller than
--server_delay, the client will eventually be suspended to allow the
server to catch up. You can see this in the logs, as the "client
@kenkeiter
kenkeiter / go_marshaling_thoughts.md
Created October 5, 2014 16:41
Quick thoughts on separation of representation from implementation in Go serialization.

If your application demands marshaling to JSON or another serialiazation format using Go, it can be tempting to design your structures to be cleanly serializable – often to the detriment of the implementation.

You might find yourself exporting variables you shouldn't be exporting, or creating elaborate ways to prevent mutability of attributes you care about.

If you find yourself doing this, stop, and consider the separation of concerns. JSON is a representation of your structure, and should not be directly tied to its underlying implementation, unless it's convenient. Although it's a bit more expensive, consider creating custom marshaling functions and generating one-off structs with the exact fields you need to decouple the implementation from representation.

In the following example, you don't want to export the Value field from the Counter struct, because it exposes your value to potentially unsafe operations (two incrementations at the same time, for example):

type Counter struct {