Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View ExpHP's full-sized avatar

Michael Lamparski ExpHP

View GitHub Profile
@ExpHP
ExpHP / gist:5786458
Created June 15, 2013 01:53
AutoHotKey script to fix mouse buttons in hexagon
lb := 0
rb := 0
SetMouseDelay,0
LButton::
Click down
lb := 1
return
@ExpHP
ExpHP / old code
Last active November 30, 2015 01:26
trait bounds
src/math.rs:328:45: 328:61 error: no method named `pointwise_mul` found for type `iter::Shaped<iter::SparseMap<iter::SparseIntersection<vec::IntoSparseIter<u32>, vec::IntoSparseIter<u32>>, Box<core::ops::FnMut((u32, u32)) -> u32 + 'static>>>` in the current scope
src/math.rs:328 let a = a.clone().pointwise_mul(a.clone()).pointwise_mul(a);
^~~~~~~~~~~~~~~~
src/math.rs:328:45: 328:61 note: the method `pointwise_mul` exists but the following trait bounds were not satisfied: `iter::Shaped<iter::SparseMap<iter::SparseIntersection<vec::IntoSparseIter<u32>, vec::IntoSparseIter<u32>>, Box<core::ops::FnMut((u32, u32)) -> u32>>> : math::GetValueIter`, `iter::Shaped<iter::SparseMap<iter::SparseIntersection<vec::IntoSparseIter<u32>, vec::IntoSparseIter<u32>>, Box<core::ops::FnMut((u32, u32)) -> u32>>> : math::SparseSparseOps<_>`, `iter::Shaped<iter::SparseMap<iter::SparseIntersection<vec::IntoSparseIter<u32>, vec::IntoSparseIter<u32>>, Box<core::ops::FnMut((u32
diff --git a/f90nml/parser.py b/f90nml/parser.py
index 687de10..7fb42d7 100644
--- a/f90nml/parser.py
+++ b/f90nml/parser.py
@@ -75,25 +75,39 @@ class Parser(object):
>>> parser = Parser()
>>> data_nml = parser.read('data.nml')"""
- nml_file = open(nml_fname, 'r')
+ nml_is_file = hasattr(nml_fname, 'read')
extern crate num_integer;
extern crate num_traits;
use num_integer::Integer;
use num_traits::{PrimInt,Signed,Zero,One};
#[derive(Copy,Clone,Debug,Eq,PartialEq)]
pub struct GcdData<X> {
// greatest common divisor
pub gcd: X,
// least common multiple
@ExpHP
ExpHP / 0-link.md
Last active August 10, 2016 13:11
rust-musl-make-error
@ExpHP
ExpHP / all-flags-green
Created August 12, 2016 15:13
syntastic-rustvim-all-flags-green
:SyntasticInfo
Syntastic version: 3.7.0-180 (Vim 704, Linux)
Info for filetype: rust
Global mode: active
Passive filetypes: asm python
Filetype rust is active
The current file will be checked automatically
Available checker: rustc
Currently enabled checker: rustc
use serde;
use serde::de::Deserialize;
use serde_json as json;
use std::collections::BTreeSet;
use itertools::Itertools;
use ::util::MyIteratorExt;
use ::layers::{Layers,Layer};
use ::ruleset::traits::RuleSet;
-- | @'sieveFactor' fs n@ finds the prime factorisation of @n@ using the 'FactorSieve' @fs@.
-- For negative @n@, a factor of @-1@ is included with multiplicity @1@.
-- After stripping any present factors @2@, the remaining cofactor @c@ (if larger
-- than @1@) is factorised with @fs@. This is most efficient of course if @c@ does not
-- exceed the bound with which @fs@ was constructed. If it does, trial division is performed
-- until either the cofactor falls below the bound or the sieve is exhausted. In the latter
-- case, the elliptic curve method is used to finish the factorisation.
sieveFactor :: FactorSieve -> Integer -> [(Integer,Int)]
sieveFactor (FS bnd sve) = check
where
@ExpHP
ExpHP / factor_sieve.rs
Created August 18, 2016 15:34
segmented sieve
#![feature(step_by)]
#![feature(test)]
pub extern crate test;
use test::Bencher;
// Using a segmented sieve method for factorization.
// This has a couple of speed advantages that are not possible to offer
// currently through the abstractions present in my `factor` crate.
@ExpHP
ExpHP / a_setup-notes.md
Last active September 11, 2016 19:32
ihaskell-install-static-transcript

Notes about my setup:

  • IHaskell repo was cloned to ~/build/IHaskell
  • notebook root (and cabal.sandbox.config) is at ~/ihaskell/.
  • sandbox is at ~/ihaskell/sandbox/.cabal-sandbox. (I relocated it as part of a misguided attempt to reduce the number of instances of "an add-source dependency has updated")

As I noted in the issue:

  • The Docker image works fine.
    • But I do not use it because I want to install more packages.
  • Dynamic linking also fixes the error