Skip to content

Instantly share code, notes, and snippets.

View Miserlou's full-sized avatar

Rich Jones Miserlou

View GitHub Profile
@Miserlou
Miserlou / light.html.heex
Created February 20, 2023 12:45
Heex Example
<h1>The light is <%= @bulb_status %>.</h1>
<button phx-click="on" disabled={!@bulb_on} >On</button>
<button phx-click="off" disabled={@bulb_on}>Off</button>
@Miserlou
Miserlou / sort_map_by_value_example.ex
Last active May 12, 2022 13:48
How to Sort a Map By Value In Elixir
# I couldn't find this easily in the documentation or on Google.
# Here's how you sort a map in Elixir.
# Maps aren't a sorted structure, so the result is a keyword list.
input = %{
player_1: %{score: 2},
player_2: %{score: 1},
player_3: %{score: 10}
player_4: %{score: 5}
}

Based on: Ultimate Full-Body Dumbbell Workout | Andy Speer

Complex 1: Power and Stretching

Perform 3 rounds, resting 60-90 sec. between rounds

  1. Dumbbell Clean: 10 reps
  2. Dumbbell Push Press: 10 reps
  3. Dumbbell Front Squat: 10 reps

Complex 2: Hypertrophy Series

Perform 3 rounds, resting 60 sec. between rounds

@Miserlou
Miserlou / bully_cop_veto.md
Created June 6, 2020 18:36
The Bully Cop Veto

The Bully Cop Veto

A simple democratic tool will give people the basic democratic dignity of getting to choose who polices their communities.

"All cops are bastards." That's not as bad as it sounds, really - lots of people are bastards. Many of my friends are bastards. I can be a bit of a bastard myself.

I'm not, however, a sadistic psychopath. Bastards, sure, but not all cops are sadistic psychopaths, either - but there are thousands of them all over the country. They sit at the very center of America's police oppression problem - the Bully Cops.

When I say the Bully Cop, you all immediately know exactly who I mean. I've met a few in my life, maybe you have too. If you haven't, consider yourself lucky, but you've certainly seen them in any of the shaky cell-phone videos showing the brutal, murderous police violence that we all know familiarly, but never get used to.

They're the particular type of people who are attracted to the job for all of the wrong reasons. They don't want to improve their commu

$ sra-stat -x --statistics ERR519500
<Run accession="ERR519500" read_length="variable" spot_count="32952112" base_count="4850189422" base_count_bio="4850189422" spot_count_mates="27576357" base_count_bio_mates="4408409901" spot_count_bad="0" base_count_bio_bad="0" spot_count_filtered="0" base_count_bio_filtered="0" cmp_base_count="35415">
<Size value="2431143551" units="bytes"/>
<Bases cs_native="false" count="4850189422">
<Base value="A" count="1369386787"/>
<Base value="C" count="1047013379"/>
<Base value="G" count="1049160006"/>
<Base value="T" count="1384472113"/>
<Base value="N" count="195382"/>
</Bases>
@Miserlou
Miserlou / knn.txt
Created February 22, 2019 04:50
Various kNNs
$ p cluster.py
Loading data..
Loading metadata..
All data loaded..
Clustering and imputing metadata field: refinebio_accession_code
Mapped strings to integers:
{2049: 'E-TABM-105-High_24h_1_H1_75-59', 2050: 'E-TABM-105-High_24h_4_E2_75-59', 2055: 'E-TABM-105-High_24h_2_G7_75-59', 2056: 'E-TABM-105-High_24h_5_D8_75-59', 2057: 'E-TABM-105-High_24h_3_G8_75-59', 2065: 'E-MEXP-818-H_GFP and BSA set1', 2066: 'E-MEXP-818-H_GFP and BSA set2', 2070: 'E-TABM-105-Ctrl_24h_2_G1_75-59', 2071: 'E-MTAB-5850-tre-sib-heart-1', 2072: 'E-MTAB-5850-tre-sib-heart-2', 2073: 'E-TABM-105-Ctrl_24h_1_F6_75-59', 2078: 'E-TABM-105-Ctrl_24h_5_H5_75-59', 2083: 'E-MTAB-2906-Zeb_Liv_Ac_Up_1', 2084: 'E-MTAB-2906-Zeb_Liv_Ac_Up_2', 2085: 'E-MTAB-2906-Zeb_Liv_Ac_Up_3', 2103: 'E-TABM-105-High_168h_1_D2_75-59', 2107: 'E-TABM-105-High_168h_4_C4_75-59', 2108: 'E-TABM-105-High_168h_2_B8_75-59', 2110: 'E-TABM-105-High_168h_3_H3_75-59', 2114: 'E-TABM-105-High_168h_5_G6_75-59', 2118: 'E-MEXP-818-H_GFP and FGF8 set1', 2119: 'E-MEXP-818-H_GFP and FGF8
@Miserlou
Miserlou / get_gene_info.R
Created February 19, 2019 19:35
Get gene info for zebrafish genes
# C.Savonen
# ALSF for CCDL
# 2019
# Purpose: Get gene info for Zebrafish/Human genes
# Replace 'Hs' with 'Dr' etc
columns(org.Hs.eg.db::org.Hs.eg.db)
# Get ensembl genes
@Miserlou
Miserlou / heatmap.py
Created February 15, 2019 19:52
Heatmaps with Dask, Holoviews and Datashader
import time
import datashader as ds
import pandas as pd
import numpy as np
import holoviews as hv
from holoviews import opts
from colorcet import fire
from datashader import transfer_functions as tf
from dask import dataframe as dd
@Miserlou
Miserlou / khan.txt
Last active October 17, 2018 16:26
khan.txt
This file has been truncated, but you can view the full file.
sample1 sample2 sample3 sample4 sample5 sample6 sample7 sample8 sample9 sample10 sample11 sample12 sample13 sample14 sample15 sample16 sample17 sample18 sample19 sample20 sample21 sample22 sample23 sample24 sample25 sample26 sample27 sample28 sample29 sample30 sample31 sample32 sample33 sample34 sample35 sample36 sample37 sample38 sample39 sample40 sample41 sample42 sample43 sample44 sample45 sample46 sample47 sample48 sample49 sample50 sample51 sample52 sample53 sample54 sample55 sample56 sample57 sample58 sample59 sample60 sample61 sample62 sample63
0.773343723 -0.078177781 -0.084469157 0.965614087 0.075663904 0.458816284 0.067097744 0.094127663 0.108316143 -0.970746918 1.163931755 0.503619724 1.187202973 0.005982072 0.996874831 0.722123289 0.614266298 0.998423561 0.856753019 0.657053573 1.285506707 0.76593285 0.8382427 0.313496007 0.73764242 1.026256627 0.215756333 -0.161930867 0.37101168 -0.031800313 0.306749135 0.432431556 0.892940218 0.108405874 0.733136829 0.239410524 1.242308511 0.620253855 1.13182137
@Miserlou
Miserlou / loop_vs_parallel.txt
Created October 5, 2018 15:39
loop_vs_parallel.txt
# via https://www.reddit.com/r/debian/comments/9ha2dj/ive_written_a_useful_system_utility_how_do_i_get/e6abuht/
$ loop 'ls' --every 10s
$ yes | parallel -N0 -j1 --delay 10s ls
$ loop 'touch $COUNT.txt' --count-by 5
$ yes | parallel -N0 -j1 echo touch '{= $_=seq()*5 =}'.txt
$ loop './get_response_code' --until-contains 200
# Only show the lines containing 200