Skip to content

Instantly share code, notes, and snippets.

@tpandit
tpandit / snoopy.py
Last active September 14, 2023 17:36
Crypto currency live monitor that auto updates
import curses
import time
import sys
import requests
# Constants
CURRENCY='USD'
REQUESTS_PER_MINUTE=10
REQUEST_URI='https://api.coinmarketcap.com/v1/ticker/'
@danielrw7
danielrw7 / replify
Last active October 24, 2023 12:03
replify - Create a REPL for any command
#!/bin/sh
command="${*}"
printf "Initialized REPL for `%s`\n" "$command"
printf "%s> " "$command"
read -r input
while [ "$input" != "" ];
do
eval "$command $input"
printf "%s> " "$command"

Git Cheat Sheet

Commands

Getting Started

git init

or

@jshahbazi
jshahbazi / mkl_matrix_multiply.f90
Last active January 17, 2017 03:20
Wrapper routine for using the Intel MKL xGEMM matrix multiplication routines
subroutine matrix_multiply(first_matrix, first_transposed, second_matrix, second_transposed, result_matrix)
!This subroutine multiplies two matrices using the Intel MKL xGEMM multiplication routines
!The routines can be a little tricky, so I've made it a little easier to use them consistently
!first_matrix and second_matrix are the input matrices
!first_transposed and second_transposed are integers indicating (with a 1 or 0) whether or not
!the respective matrix is transposed
!The resulting matrix is stored in result_matrix, but you'll have to allocate that outside the routine
!The sGEMM below can be changed to dGEMM for double precision without any other changes to the
!subroutine call. You'll then have to change the 'real' variables to 'double precision'.
@jshahbazi
jshahbazi / fmincg.f90
Created May 31, 2014 22:17
fmincg minimization function ported to Fortran
real function fmincg(length, nn_params, input_layer_size, hidden_layer_size, num_labels, inputdata, y, lambda)
implicit none
! Copyright (C) 2001 and 2002 by Carl Edward Rasmussen. Date 2002-02-13
! (C) Copyright 1999, 2000 & 2001, Carl Edward Rasmussen
!
! Permission is granted for anyone to copy, use, or modify these
! programs and accompanying documents for purposes of research or
! education, provided this copyright notice is retained, and note is
! made of any changes that have been made.
@jeamland
jeamland / gist:11284662
Created April 25, 2014 10:20
Bluetooth LE on OS X via Python
import select
import socket
import sys
import objc
from PyObjCTools import AppHelper
objc.loadBundle("CoreBluetooth", globals(),
bundle_path=objc.pathForFramework(u'/System/Library/Frameworks/IOBluetooth.framework/Versions/A/Frameworks/CoreBluetooth.framework'))
@jshahbazi
jshahbazi / djb_hash.f90
Last active April 3, 2020 19:27
Daniel J. Bernstein's hash algorithm written in Fortran
integer function djb_hash(str) result(hash)
implicit none
character(len=*),intent(in) :: str
integer :: hash
integer :: i
hash = 5381
do i=1,len(str)
@jshahbazi
jshahbazi / fortran_convolution.f90
Last active September 24, 2023 13:44
A simple convolution of two 1D vectors (signals) done in Fortran
function convolve(x, h)
implicit none
!x is the signal array
!h is the noise/impulse array
real, dimension(:), allocatable :: convolve, y
real, dimension(:) :: x, h
integer :: kernelsize, datasize
integer :: i,j,k