Skip to content

Instantly share code, notes, and snippets.

View msmorgan's full-sized avatar

Michael Morgan msmorgan

View GitHub Profile
@msmorgan
msmorgan / .profile
Created September 26, 2010 16:05
My settings for the Bourne shell.
#!/bin/sh
#######
# 2010 Michael Morgan
#
# .profile
# Startup script for sh.
#
# I aim to keep the instructions in this file is compatible with the
# original Bourne shell.

Agility

Legion

[ ] Night Hound ()
[/] Swiftblade ()
[ ] Moon Queen ()
[ ] Wildsoul ()
[ ] Zephyr ()

//Which is more understandable, assuming you're not familiar with any JavaScript APIs?
//jQuery
$("<li/>").text("hello, world").appendTo($("<ul/>")).parent().appendTo(document.body);
//plain old JavaScript
var li = document.createElement("li");
li.appendChild(document.createTextNode("hello, world"));
var ul = document.createElement("ul");
ul.appendChild(li);
w=t>>9,
k=32,
m=2048,
a=1-t/m%1,
d=(14*t*t^t)%m*a,
y=[3,3,4.7,2][p=w/k&3]*t/4,
h="IQNNNN!!]]!Q!IW]WQNN??!!W]WQNNN?".charCodeAt(w/2&15|p/3<<4)/33*t-t,
s=y*.98%80+y%80+
(w>>7&&a*((5*t%m*a&128)*(0x53232323>>w/4&1)+(d&127)*(0xa444c444>>w/4&1)*1.5+(d*w&1)+(h%k+h*1.99%k+h*.49%k+h*.97%k-64)*(4-a-a))),
s*s>>14?127:s
@msmorgan
msmorgan / gist:2511337
Created April 27, 2012 17:58 — forked from richardsondx/view
This is what I've done
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function(){
var micropostIds = [<%= @microposts.map {|micropost| micropost.id }.join(',') %>];
$.each(micropostIds, function (index, value) {
$(".slidingDiv" + value).hide();
$(".show_hide" + value).show().click(function () {
$(".slidingDiv" + value).slideToggle();
});
});
def int_to_tuple(num, base=4):
result = ((),) * (num % base)
if num >= base:
result = (int_to_tuple(num // base, base),) + result
return result
def tuple_to_int(tup, base=4):
if len(tup) == 0:
return 0
return tuple_to_int(tup[0], base)*base + tup.count(())
arrays = arrays.map(sort); // sort each sub-array
arrays = arrays.sort(function (ary) { return ary.length; }); // sort arrays by length, shortest will be first
var indexes = [];
for (i = 0; i < arrays.length; i++) {
indexes[i] = 0;
}
var result = [];
@msmorgan
msmorgan / CalculatedProperties.cs
Created February 24, 2017 02:03
API demonstration of Calculated Properties proposal
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
namespace CalculatedProperties
@msmorgan
msmorgan / search_bug.txt
Created August 29, 2017 22:01
Searching for the exact apparent type of `replace` yields no results
Idris> :consolewidth infinite
Idris> :type replace
replace : {a : Type} -> {x : a} -> {y : a} -> {P : a -> Type} -> ((=) {A = a} {B = a} x y) -> P x -> P y
Idris> :type ({a : Type} -> {x, y : a} -> {P : a -> Type} -> x = y -> P x -> P y)
{a : Type} -> {x : a} -> {y : a} -> {P : a -> Type} -> ((=) {A = a} {B = a} x y) -> P x -> P y : Type
Idris> :search ({a : Type} -> {x, y : a} -> {P : a -> Type} -> x = y -> P x -> P y)
No results found
Idris>
module Triv
import Data.Vect
%default total
triv : {x : a} -> a
triv {x} = x
oneTwoThree : (n ** Vect n Nat)