Skip to content

Instantly share code, notes, and snippets.

hdf

Block or report user

Report or block hdf

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@hdf
hdf / dir.py
Last active May 4, 2019
Generate html file with foldable recursive directory listing. (For directories with no auto indexing.)
View dir.py
import os, sys
from datetime import datetime
dir = '.'
out = 'dir.html'
if len(sys.argv) > 1:
dir = sys.argv[1]
if len(sys.argv) > 2:
out = sys.argv[2]
@hdf
hdf / fourier.js
Last active Apr 17, 2019
Discrete Fourier transformation
View fourier.js
// Coding Challenge 130.3: Drawing with Fourier Transform and Epicycles
// Daniel Shiffman
// https://thecodingtrain.com/CodingChallenges/130.1-fourier-transform-drawing.html
// https://thecodingtrain.com/CodingChallenges/130.2-fourier-transform-drawing.html
// https://thecodingtrain.com/CodingChallenges/130.3-fourier-transform-drawing.html
// https://youtu.be/7_vKzcgpfvU
// https://editor.p5js.org/codingtrain/sketches/ldBlISrsQ
class Complex {
constructor(a, b) {
@hdf
hdf / animate.py
Last active Jun 2, 2019
Comb particle evolution data from multiple files in to one moment to moment, system state based file. Also visualize the data using matplotlib.
View animate.py
# From: https://gist.github.com/hdf/42f0895a091b4a6a6d5d9eeb5cca8edf
import time, sys, os#, arrow
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.animation as animation
import matplotlib.colors as colors
import matplotlib.ticker as ticker
# Usage: animate.py [input_file [output_file]] [save] [nocb] [ann] [nofo] [keep [max]] [ne] [mirror_left] [mirror_right] [mirror_top] [mirror_bottom]
@hdf
hdf / BigO.js
Created Dec 23, 2018
Based on the array in question, and the counter value (you have to put the code for that in the function in question yourself), this function will tell us the time complexity of the function.
View BigO.js
function BigO(arr, arr3) { // Second array is optional
this.accumulator = 0; // Can be set here, or when calling ClosestMatch
/* function factorial(n, i) {
if (n > 171) // Overflow prevention
return Infinity;
if (typeof i == 'undefined')
i = 1;
if (n < i)
return 1;
if (n === i)
@hdf
hdf / index.html
Last active Nov 29, 2018
Google Drive Demo
View index.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>Google Drive Demo</title>
</head>
<body>
<div style="position: absolute; top: 40%; left: 50%; transform: translate(-50%, -40%); text-align: center;">
<a href="https://drive.google.com/open?id=1v1-ApluL9dCGx4znKVSXGKnBf4dFVGuv">Letöltés</a><br><br>
@hdf
hdf / NthClosest.js
Last active Dec 22, 2018
Interview stuff?
View NthClosest.js
// Inspired by:
// https://interviewing.io/recordings/Go-Microsoft-1
function NthClosest(points, match, n) {
if (n < 1 || n > points.length || points[0].length != match.length)
return false;
function distance(p1, p2) { // Works in any dimensions.
let out = 0, d = 0, len = p1.length;
for (let i3 = 0; i3 < len; i3++) {
@hdf
hdf / programozz.txt
Last active Sep 19, 2018
Előadás terv javaslat
View programozz.txt
Mi a programozás?
Megmondani a gépnek hogy mit csináljon. Nagyon szájbarágósan. (Angol tudás elengedhetetlen.)
Számomra a programozás olyan mint a legózás, csak olcsóbb, nem megy tönkre a kezed tőle és sose fogysz ki a darabokból.
Engem azért vonzott a programozás, mert olyan volt mint a varázslás. Mintha pár varázs szó beírásával életet lehelnél az élettelenbe. Viselkedést adhatsz egy tárgynak. És érdekelt, hogy a játékok, meg egyéb programok, amiket használtam hogyan működnek. Illetve az automatizáció is mindig vonzott, mert olyan mint a csalás. Ráveszed a világot, hogy dolgozzon helyetted.
Mihez van szükség hozzá?
Kell egy feladat.
A feladat határozza meg, hogy melyik a megfelelő eszköz (program nyelv) hozzá.
Számítógép internet eléréssel, Google, program nyelv dokumentáció/referencia, fejlesztői környezet: Visual Studio (Code) / Notepad++, idő, érdeklődés.
View bubbleSort.js
function bubbleSort(arr, cmp) {
var len = arr.length, tmp, n;
if (typeof cmp !== 'function')
cmp = function(a, b) {
return a > b;
};
do {
n = 0;
for (var i = 1; i < len; i++) {
if (cmp(arr[i], arr[i-1])) continue;
View plot.html
This file has been truncated, but you can view the full file.
<!DOCTYPE HTML>
<html>
<head>
<meta charset="UTF-8">
<title>vis.js Plot</title>
<style>
body {font: 10pt arial;}
#mygraph>div {border: 1px solid black;}
#mygraph,#controlls {display: inline-block; vertical-align: top;}
View pick.py
import sys
if len(sys.argv) < 2:
print("""Usage:
pick.py data.txt [lines_to_skip = 0] [first_line = 0]""")
sys.exit(0)
file = sys.argv[1]
skip = int(sys.argv[2]) + 1 if len(sys.argv) > 2 else 1
start = int(sys.argv[3]) if len(sys.argv) > 3 else 0
You can’t perform that action at this time.