Skip to content

Instantly share code, notes, and snippets.

View kevinmartinjos's full-sized avatar

Kevin Martin Jose kevinmartinjos

View GitHub Profile
function! LoadTerminal()
let bnr = bufnr('!/bin/bash')
if bnr > 0
:sbuffer !/bin/bash
else
:term
endif
endfunction
@kevinmartinjos
kevinmartinjos / pagerank.y
Created January 19, 2020 16:29
Pagerank - irdm sheet 11 problem 1
import numpy as np
def iterate(alpha, n, P, pi):
e = np.array([[1], [1], [1], [1], [1], [1]])
return (alpha * e)/n + (1-alpha) * np.matmul(np.transpose(P), pi)
if __name__ == "__main__":
P = np.array([
[0, 0.5, 0, 0.5, 0, 0],
@kevinmartinjos
kevinmartinjos / pim_polynomials.rs
Created January 21, 2019 19:01
PIM book polynomials - 1
extern crate rand;
use std::io;
use rand::Rng;
fn main() {
let mut secret_passcode_str = String::new();
println!("What's the secret passcode?");
io::stdin().read_line(&mut secret_passcode_str).expect("Failed to read line");
let secret_passcode = secret_passcode_str.trim().parse::<i32>().expect("Wanted a number");

Keybase proof

I hereby claim:

  • I am lonesword on github.
  • I am lonesword (https://keybase.io/lonesword) on keybase.
  • I have a public key ASC9kr46VgC-qjCTOgDYo7jXQ0azhN2aZpx_ncjYlc11rgo

To claim this, I am signing this object:

@kevinmartinjos
kevinmartinjos / escalate_ticket.js
Last active December 16, 2017 14:10
Google sheet script to send email
function escalate_ticket(event)
{
sheet = SpreadsheetApp.getActiveSheet()
var range = sheet.getDataRange();
var values = range.getValues();
// 0 indexed. Col 6 contains email? Enter 5 here
var email_col_num = 5
var is_tat_breached_col_num = 3
var comment_col_num = 4
@kevinmartinjos
kevinmartinjos / polywar.js
Created May 31, 2015 17:54
A quick experiment with box2d and p5.js to cook up a game based on the angle at which polygons collide. The idea seems promising
//aliases for box2d stuff. Makes life easier.
var b2Vec2 = Box2D.Common.Math.b2Vec2
, b2AABB = Box2D.Collision.b2AABB
, b2BodyDef = Box2D.Dynamics.b2BodyDef
, b2Body = Box2D.Dynamics.b2Body
, b2FixtureDef = Box2D.Dynamics.b2FixtureDef
, b2Fixture = Box2D.Dynamics.b2Fixture
, b2World = Box2D.Dynamics.b2World
, b2MassData = Box2D.Collision.Shapes.b2MassData
@kevinmartinjos
kevinmartinjos / rectangle.js
Created April 16, 2015 18:06
Draft, rectangle packing algorithm
var Globals = {
originX: 0,
originY: 0,
rectangles: []
};
function Packer(ratio, w_, h_){
this.ratio = ratio;
this.width = w_;
@kevinmartinjos
kevinmartinjos / gist:a9463090a8c69f8d4ff2
Last active August 29, 2015 14:08
Sutherland-hogson polygon clipping javascript
<!--
Sutherland-Hodgson polygon clipping algorithm using html5 canvas and javascript. Click to clip polygon sequentially
Copyright (C) 2014 Kevin Martin Jose
-->
<!--
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
@kevinmartinjos
kevinmartinjos / gist:cafc9a7aa9db3f7bfc52
Last active March 30, 2021 22:03
Cohen-Sutherland outcode algorithm
<!--
Cohen-Sutherland outcode algorithm using html5 canvas and javascript. Click to clip lines sequentially
Copyright (C) 2014 Kevin Martin Jose
-->
<!--
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
@kevinmartinjos
kevinmartinjos / aubio_mic_pitch
Created October 21, 2014 16:33
Yell at the mic, see the frequencies on the terminal
from aubio import source, pitch, freqtomidi, sink
from pysoundcard import Stream
if __name__ == '__main__':
win_s = 1024 #fft size
hop_s = 512 #hop size. Whatever that means
s = Stream(block_length = hop_s)