Skip to content

Instantly share code, notes, and snippets.

View ramithuh's full-sized avatar

Ramith Hettiarachchi ramithuh

View GitHub Profile
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@ramithuh
ramithuh / jax_default_device.py
Created May 1, 2023 23:49
specify jax default device to use
import jax
import jax.numpy as jnp
jax.config.update("jax_default_device", jax.devices("cpu")[0])
#runs on cpu
long_vector = jnp.arange(int(1e7))
%timeit jnp.dot(long_vector, long_vector).block_until_ready()
jax.config.update("jax_default_device", jax.devices("gpu")[2])
@ramithuh
ramithuh / wandb_resume.py
Created February 10, 2022 21:00
resume wandb project and log data
import wandb
wandb.init(id="31cnstm6", project="test", resume="must")
wandb.log({"this was added later": 1241241})
@ramithuh
ramithuh / clipboard-compress.sh
Created May 3, 2020 16:04
Compress the screenshots saves in a folder and copy them to clipboard (macOS preview screenshots)
for f in "$@"
do
/usr/local/bin/pngquant 32 --skip-if-larger --strip --ext=.png --force "$f"
/usr/local/bin/zopflipng -y "$f" "$f"
/Users/ramith/Documents/ss/impbcopy "$f"
done
on run {input, parameters}
do shell script "open /Users/ramith/Documents/SEM4_TRONIC_ACA"
return input
end run
num=[0.9955 -1.8936 0.9955];
den=[1 -1.8936 0.9911];
zplane(num,den)
grid on;
%freqz(num,den,100);
@ramithuh
ramithuh / code3.m
Created November 10, 2018 18:05
Notch Filter
close all;
clear all;
load('noisy_ECG_sig.mat')
y=noisy_ECG_sig; %the signal loaded
L=length(y)
sampling_freq = 1000
figure; % plot the original signal
@ramithuh
ramithuh / 347.py
Created October 22, 2016 10:32
project euler 347
import math
arr=[]
#this is for prime
def isprime(k):
if(k==1 or k==0):
return 0
for i in range(2,int(k**(0.5))+1):
if(k%i==0):
@ramithuh
ramithuh / coffee vs.js
Last active September 22, 2016 08:01
Examples with coffeescript
### The implementation of binary search that is tested.
# Return the index of an element in a sorted list. (or -1, if not present)###
index = (list, target) ->
[low, high] = [0, list.length]
while low < high
mid = (low + high) >> 1
val = list[mid]
return mid if val is target
if val < target then low = mid + 1 else high = mid
@ramithuh
ramithuh / proc_edison
Created July 14, 2015 16:13
execute this sketch
import com.leapmotion.leap.*; //leap motion library
import processing.serial.*; //serial communication library
Controller leap; //define a controller
Serial port; //define a port
void setup(){
size(250,250); //sketch size
leap = new Controller(); // initialize the controller
port = new Serial(this, Serial.list()[2], 115200);//initialize the port in my case its [2]