Skip to content

Instantly share code, notes, and snippets.

View mooreryan's full-sized avatar

Ryan Moore mooreryan

View GitHub Profile
@CarlSmotricz
CarlSmotricz / nanocad.clj
Created July 22, 2015 00:51
A tiny CAD-like program in Clojure. Uses SeeSaw for the GUI.
; a tiny, simple CAD program prototype in Clojure.
; Carl Smotricz, 2015-07-22
(ns nanocad.core
(:use [seesaw core graphics])
(:require [seesaw.mouse :refer [location]])
(:import [javax.swing AbstractAction]))
(def CANVAS-WIDTH 400)
Notice how each number appears only once.
The order is still scrambled, but we don't care about the order.
Arg = 1
Arg = 4
Arg = 2
Arg = 6
Arg = 3
Arg = 7
@depp
depp / info.txt
Created April 30, 2015 20:56
Race condition example
This is what happens when I run the program. Note that 2 and 4 appear twice, but 0 and 1 never appear. The output is non-deterministic, because there is a race condition, the output could be almost anything.
Arg = 2
Arg = 4
Arg = 3
Arg = 5
Arg = 6
Arg = 2
Arg = 7
Arg = 8
@O-I
O-I / weighted_random_sampling.md
Last active February 21, 2024 19:02
[TIx 8] Weighted Random Sampling in Ruby

One of the many reasons I love working with Ruby is it has a rich vocabulary that allows you to accomplish your goals with a minimal amount of code. If there isn't a method that does exactly what you want, it's usually possible to build an elegant solution yourself.

Let's take the example of simulating the rolling of a die.

We can represent a die as an array of its faces.

die = [*?⚀..?⚅]
# => ["⚀", "⚁", "⚂", "⚃", "⚄", "⚅"]
@alimuldal
alimuldal / test_numpy.py
Last active April 5, 2020 10:25
test script for numpy BLAS linkage
#!/usr/bin/env python
import numpy
from numpy.distutils.system_info import get_info
import sys
import timeit
print("version: %s" % numpy.__version__)
print("maxint: %i\n" % sys.maxsize)
info = get_info('blas_opt')
@markheckmann
markheckmann / hcl_color_wheels
Last active March 1, 2018 21:16
Color wheels using colorspace::hcl by luminance
library(colorspace)
polar2cart <- function(r, theta) # polar to cartesian coords
{
rad <- theta * pi /180
cbind(x = r*cos(rad),
y = r*sin(rad))
}
h <- seq(0, 360, len=150) # hue values
@myusuf3
myusuf3 / delete_git_submodule.md
Created November 3, 2014 17:36
How effectively delete a git submodule.

To remove a submodule you need to:

  • Delete the relevant section from the .gitmodules file.
  • Stage the .gitmodules changes git add .gitmodules
  • Delete the relevant section from .git/config.
  • Run git rm --cached path_to_submodule (no trailing slash).
  • Run rm -rf .git/modules/path_to_submodule (no trailing slash).
  • Commit git commit -m "Removed submodule "
  • Delete the now untracked submodule files rm -rf path_to_submodule
(require '[clojure.core.async :as a])
(def xform (comp (map inc)
(filter even?)
(dedupe)
(flatmap range)
(partition-all 3)
(partition-by #(< (apply + %) 7))
(flatmap flatten)
(random-sample 1.0)
@Chaser324
Chaser324 / GitHub-Forking.md
Last active May 13, 2024 11:18
GitHub Standard Fork & Pull Request Workflow

Whether you're trying to give back to the open source community or collaborating on your own projects, knowing how to properly fork and generate pull requests is essential. Unfortunately, it's quite easy to make mistakes or not know what you should do when you're initially learning the process. I know that I certainly had considerable initial trouble with it, and I found a lot of the information on GitHub and around the internet to be rather piecemeal and incomplete - part of the process described here, another there, common hangups in a different place, and so on.

In an attempt to coallate this information for myself and others, this short tutorial is what I've found to be fairly standard procedure for creating a fork, doing your work, issuing a pull request, and merging that pull request back into the original project.

Creating a Fork

Just head over to the GitHub page and click the "Fork" button. It's just that simple. Once you've done that, you can use your favorite git client to clone your repo or j

@ericminikel
ericminikel / exampleRScript1.r
Created January 14, 2014 23:53
An example of how to use Rscript and optparse to run R in batch mode with command line args.
#!/broad/software/free/Linux/redhat_5_x86_64/pkgs/r_3.0.2/bin/Rscript
# Eric Vallabh Minikel
# CureFFI.org
# 2014-01-14
# example of how to use optparse in R scripts
# usage: ./exampleRScript1.r -a thisisa -b hiagain
# ./exampleRScript1.r --avar thisisa --bvar hiagain