Skip to content

Instantly share code, notes, and snippets.

View NewAlexandria's full-sized avatar
🍄
My responses are limited; you must ask the right questions.

NewAlexandria

🍄
My responses are limited; you must ask the right questions.
View GitHub Profile
@NewAlexandria
NewAlexandria / chord.rb
Created January 1, 2016 07:02 — forked from DataKinds/chord.rb
circle modular multiplication chord renderer
# with reference to rendered output but the OP
# https://www.reddit.com/r/mathpics/comments/3yzu77/heres_an_animated_version_of_that_circular/
# and a video guide
# https://www.youtube.com/watch?v=qhbuKbxJsk8
require "rmagick"
RESOLUTION = 800
def localToGlobalCoords(n)
@NewAlexandria
NewAlexandria / brew_inventory.rb
Created October 19, 2015 04:28
A quickie copypasta for getting your main brew packages
#!/usr/bin/env ruby
bl = `brew list`.split ;1
bdl = bl.reduce({}) {|h, pkg| h.merge({pkg => `brew deps #{pkg}`.split }) } ;1
bi = bl - bdl.values.flatten.sort
File.open('apps_brew.txt', 'w') {|f| f.write bi.join("\n") }
File.open(".vimrc","a") do |f|
f.write File.readlines('.gitmodules')
.map(&:strip)
# remove extras
.reject do |l|
l.scan('[').any? || # submodule defs
l.scan(/^path/).any? || # submodules paths
l.empty? # blank lines
end
# remap URLs to user/repo names
@NewAlexandria
NewAlexandria / recent_papers_we_love.js
Created June 8, 2015 04:39
A list of the 10 most-recent submissions to papers we love
if (!window.jQuery) { document.write('<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"><\/script>') };
var recent_papers = [];
var commits = {};
var base_commit = '';
while (recent_papers.length < 10) {
commits_url = "https://api.github.com/repos/papers-we-love/papers-we-love/commits?sha="+base_commit;
$.ajax({
url: commits_url,
success: function(data) {
$(data).each( function(idx) {
@NewAlexandria
NewAlexandria / letter permutation
Created April 9, 2015 13:30
Outputs string combinatorics
r = ('a'..'z')
r.map{|l| r.map{|w| r.map{|q| q+w+l} } }.flatten
r.map{|l| r.map{|w| r.map{|q| r.map{|t| q+w+l+t } }} }.flatten.size
# add exclusions
# add recursion
@NewAlexandria
NewAlexandria / lucidchart.js
Created November 26, 2014 15:16
The unminified source of Lucidcharts, as of 2014-11-26
This file has been truncated, but you can view the full file.
(function() {
var h, ba = ba || {},
ca = this;
function da(a) {
return void 0 !== a
}
function ha(a) {
a = a.split(".");
// Processing motion blur
// 'time' runs from 0 to 1
// ignore everything above the /////////
// by Dave @ beesandbombs
int[][] result;
float time;
void setup() {
setup_();
@NewAlexandria
NewAlexandria / selfie.rb
Created August 14, 2013 22:41
A file that reads from and writes to itself
#!/usr/bin/ruby
lines = IO.readlines($0) << (DATA.readlines << ARGV[0])
File.open($0, 'w') { |file| file.puts lines }
__END__
@NewAlexandria
NewAlexandria / index.html
Created March 25, 2013 21:29 — forked from anonymous/index.html
Fork of AnonPen cloth demo in JS
<canvas id = "c" > </canvas>
<p>
Tear the cloth with your mouse.<br><br>
Right click and drag to cut the cloth.<br><br>
Reduce physics_accuracy if it's laggy, increase it for a better effect.
</p>
@NewAlexandria
NewAlexandria / svn_mass_conversion.rb
Created March 24, 2013 20:18
And then there was this time I had to mass-convert svn repos..
#!/usr/bin/env ruby
require 'fileutils'
path_base = ARGV[0] || '~/Sources'
server_path = ARGV[1]
repo_list = ARGV[2] || 'svn_repo_list'
svn_dir = File.expand_path File.join(path_base,'/svn')
git_dir = File.expand_path File.join(path_base,'/git')
unless File.exists? auth_file