Skip to content

Instantly share code, notes, and snippets.

@AlexDiru
AlexDiru / fftimage.py
Created May 12, 2018 20:06
Working FFT of an image in Python
# Original author https://stackoverflow.com/a/38507628
# I've only done minor changes to make it work
from PIL import Image
import numpy as np
import scipy.fftpack as fp
## Functions to go from image to frequency-image and back
im2freq = lambda data: fp.rfft(fp.rfft(data, axis=0),
axis=1)
@AlexDiru
AlexDiru / Idiotize.cpp
Created July 11, 2017 14:35
TyPe LiKe ThIs
#include <iostream>
#include <string>
#include <cctype>
using namespace std;
int main(int argc, char* argv[]) {
if (argc != 2) {
cerr << "WrOnG aRgUmEnT cOuNt LoSeR" << endl;
return -1;
xrandr --newmode "1400x900_60.00" 103.50 1400 1480 1624 1848 900 903 913 934 -hsync +vsync
xrandr --addmode VGA1 1400x900_60.00
@AlexDiru
AlexDiru / gist:3959450
Created October 26, 2012 15:31
Extract mantissa and exponent from a float
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
//holds one bit
struct sbit
{
unsigned b : 1;
};
typedef struct sbit BIT;
@AlexDiru
AlexDiru / C76i.cs
Created July 15, 2012 18:45
/r/ (intermediate) Daily Programmer Challenge 76
//http://www.reddit.com/r/dailyprogrammer/comments/wk066/7132012_challenge_76_intermediate_probability/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace CodingChallenges
{
class Program
@AlexDiru
AlexDiru / C76.cs
Created July 15, 2012 18:24
/r/ (easy) Daily Programmer Challenge 76
//http://www.reddit.com/r/dailyprogrammer/comments/wjzly/7132012_challenge_76_easy_title_case/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace CodingChallenges
{
class Program
@AlexDiru
AlexDiru / Dijkstra.cs
Created July 14, 2012 15:53
Dijkstra
//Quick Dijkstra algorithm whipped up for Coursera, not very efficient though
class Node
{
List<Edge> Edges;
public int ID;
public Node(int oID) { ID = oID; Edges = new List<Edge>(); }
public void AddEdge(Edge e) { Edges.Add(e); }