Skip to content

Instantly share code, notes, and snippets.

View magnusja's full-sized avatar
👨‍💻
..

magnus magnusja

👨‍💻
..
View GitHub Profile
@hannes-brt
hannes-brt / pyximport_numpy.py
Created December 28, 2010 13:08
Setup pyximport to include the numpy headers
import pyximport
import numpy as np
pyximport.install(setup_args={'include_dirs': np.get_include()})
@MohamedAlaa
MohamedAlaa / tmux-cheatsheet.markdown
Last active May 11, 2024 07:10
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@Nilzor
Nilzor / PageBase.cs
Created August 31, 2012 07:27
Page navigation helpers Metro
public class PageBase : LayoutAwarePage
{
protected override void OnNavigatedTo(Windows.UI.Xaml.Navigation.NavigationEventArgs e)
{
base.OnNavigatedTo(e);
object obj = null;
Debug.Assert(e.Parameter == null || e.Parameter is String, "Expected string as parameter");
if (e.Parameter != null) obj = SerializationHelper.DataContractDeserialize<object>((string) e.Parameter);
OnNavigatedToSmart(e, obj);
}
@bwhite
bwhite / rank_metrics.py
Created September 15, 2012 03:23
Ranking Metrics
"""Information Retrieval metrics
Useful Resources:
http://www.cs.utexas.edu/~mooney/ir-course/slides/Evaluation.ppt
http://www.nii.ac.jp/TechReports/05-014E.pdf
http://www.stanford.edu/class/cs276/handouts/EvaluationNew-handout-6-per.pdf
http://hal.archives-ouvertes.fr/docs/00/72/67/60/PDF/07-busa-fekete.pdf
Learning to Rank for Information Retrieval (Tie-Yan Liu)
"""
import numpy as np
@nikreiman
nikreiman / gist:5009156
Last active August 30, 2018 18:28
Why have a sample rate as a floating point number?
Why have a sample rate as a floating point number?
Many audio API's, such as the VST and CoreAudio SDK's, represent the sampling
rate of the audio hardware as a floating point number. This may seem rather
silly at first, given that it's impossible to have a sample rate of 44100.5.
Thus it would seem that an unsigned integer (ie, uint32_t), would be an ideal
container for sample rate.
However, there is a reason that many audio API's use float (or better yet,
double) for sample rate. The reason is because that most DSP algorithms rely on
@dodyg
dodyg / gist:5823184
Last active March 29, 2024 03:59
Kotlin Programming Language Cheat Sheet Part 1

#Intro

Kotlin is a new programming language for the JVM. It produces Java bytecode, supports Android and generates JavaScript. The latest version of the language is Kotlin M5.3

Kotlin project website is at kotlin.jetbrains.org.

All the codes here can be copied and run on Kotlin online editor.

Let's get started.

@nraychaudhuri
nraychaudhuri / gist:6026730
Created July 18, 2013 04:31
drive agnostic slick crud example
import scala.slick.lifted.MappedTypeMapper
import scala.slick.lifted.ColumnBase
import scala.slick.session.Session
import models._
import alltables._
//so that we dont depend on specific driver
import scala.slick.driver.BasicDriver.simple._
import scala.slick.lifted.Projection
//generic CRUD that can operate on any table with id column
@grenade
grenade / 01-generate-ed25519-ssh-key.sh
Last active May 2, 2024 23:15
generate ed25519 ssh and gpg/pgp keys and set file permissions for ssh keys and config
#!/bin/bash
# generate new personal ed25519 ssh key
ssh-keygen -o -a 100 -t ed25519 -f ~/.ssh/id_ed25519 -C "rob thijssen <rthijssen@gmail.com>"
# generate new host cert authority (host_ca) ed25519 ssh key
# used for signing host keys and creating host certs
ssh-keygen -t ed25519 -f manta_host_ca -C manta.network
eval "$(ssh-agent -s)"
@byaka
byaka / gpuFanControl.py
Last active May 23, 2019 08:42
Script for linux, that controls Nvidia GPU Fan. You can set curve of temperature-speed (see line :160).
#!/usr/bin/env python
"""
Script to control the fan speed of an NVidia gpu using a custom fan speed/temperature curve.
Copyright (C) 2012 Luke Frisken
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.
@sheikhwaqas
sheikhwaqas / setup-mysql.sh
Last active September 6, 2023 15:59
Install MySQL Server on Ubuntu (Non-Interactive Installation)
# Download and Install the Latest Updates for the OS
apt-get update && apt-get upgrade -y
# Set the Server Timezone to CST
echo "America/Chicago" > /etc/timezone
dpkg-reconfigure -f noninteractive tzdata
# Enable Ubuntu Firewall and allow SSH & MySQL Ports
ufw enable
ufw allow 22