Skip to content

Instantly share code, notes, and snippets.

@rkrishnasanka
rkrishnasanka / mg.c
Last active April 6, 2018 19:50
multigrid code with annotations
/*======================================================================================
Rich Brower Sat May 28 00:23:17 EDT 2011
C program based on simple FMV code of S. F. McCormick, Multigrid Methods, Frontiers in Applied! Mathematics,
vol. 3, SIAM Books, Philadelphia, 1987.The code is intentionally put into a single file with no input parameters
to keep is concise. Of course a full code may have more traditional C structures!
We solve the 2-d Laplace problem: A phi = b
(A phi)((x,y) = [4 phi(x,y) - phi(x+1,y) - phi(x-1,y) - phi(x,y+1) -phi(x,y+1)]/a^2 + m^2 phi(x,y) = b(x,y)
/**
* READ THIS LICENSE AGREEMENT CAREFULLY BEFORE USING THIS PRODUCT. BY USING
* THIS PRODUCT YOU INDICATE YOUR ACCEPTANCE OF THE TERMS OF THE FOLLOWING
* AGREEMENT. THESE TERMS APPLY TO YOU AND ANY SUBSEQUENT LICENSEE OF THIS
* PRODUCT.
*
* License Agreement for FLUTE
*
* Copyright (c) 2004 by Dr. Chris C. N. Chu
* All rights reserved
@rkrishnasanka
rkrishnasanka / chthesis.sh
Last active February 24, 2016 22:08
Fluigi Tools
#!/bin/sh
#java -Xmx5000m -jar runFluigi.jar ../devices/chthesis/64.uf -i fluigi.ini -o eps
#java -Xmx5000m -jar runFluigi.jar ../devices_ali/xgrid_128.uf -i fluigi.ini -o eps
echo "Running Cassie's Thesis Benchmarks 2D"
for f in ../devices/chthesis/*.uf;
do
/*
* This is an basic example show the various parsing and
*/
grammar example;
//Parsing rules
//This is the statement that tells ANTLR the structure of the program.
programBlock
#-------------------------------------------------------------------------------
# PID.py
# A simple implementation of a PID controller
#-------------------------------------------------------------------------------
# Example source code for the book "Real-World Instrumentation with Python"
# by J. M. Hughes, published by O'Reilly Media, December 2010,
# ISBN 978-0-596-80956-0.
#-------------------------------------------------------------------------------
import time
import sys
import base64
import struct
key = 'ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAADQ1IiOUdFSuqJ2l0fhs= root@kali'
# get the second field from the public key file.
keydata = base64.b64decode(
key.split(None)[1])
int g1=12;
int g2=11;
int g3=10;
int g4=9;
float mi,x1,x2,pi,w1,w2;
int count1,count2;
void setup(){
Serial.begin(9600);
pi=(22.0/7.0);
//FFT.cpp
#include<iostream.h>
#include<conio.h>
#include<math.h>
#include<dos.h>
#include<complex.h>
#define pi 3.141592654
void main()
@rkrishnasanka
rkrishnasanka / pdftoimg.py
Created December 31, 2015 21:58
PDF to IMG Conversion script using imagemagick and wand
from wand.image import Image
# Converting first page into JPG
with Image(filename="/thumbnail.pdf[0]") as img:
img.save(filename="/temp.jpg")
# Resizing this image
with Image(filename="/temp.jpg") as img:
img.resize(200, 150)
img.save(filename="/thumbnail_resize.jpg")
@rkrishnasanka
rkrishnasanka / Packet.cs
Created November 21, 2014 01:59
Generic Packet Class
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Packet
{
// ----------------