Skip to content

Instantly share code, notes, and snippets.

View johnmarinelli's full-sized avatar

John Marinelli johnmarinelli

View GitHub Profile
using String = const char*;
constexpr char a[] = "hello";
template <String S>
struct Word {
static constexpr String value = S;
};
int main(int argc, char* args[]) {
events { worker_connections 1024; }
http {
upstream roundrobin {
# roundrobin is enabled by default
server google.com;
server msn.com;
server yahoo.com;
}
events { worker_connections 1024; }
http {
#include /etc/nginx/conf.d/*.conf;
upstream roundrobin {
server localhost:8080;
server localhost:80;
}
ENV['RAILS_ENV'] ||= 'test'
require File.expand_path('../../config/environment', __FILE__)
require 'rails/test_help'
class ActiveSupport::TestCase
# Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order.
fixtures :all
include FactoryGirl::Syntax::Methods
(defn insert-page-into-db [page]
(println page) ; <-- doesn't get run
(try
(sql/insert! db-conn-vars :pages
[:title, :pageid]
[(get page "title"), (Integer. (get page "pageid"))]) (catch Exception e (println e))))
(defn insert-pages-into-db [pages]
(println pages) ; <-- gets ran
(map
2.2.1 :001 > str = "asdfasdf"
=> "asdfasdf"
2.2.1 :002 > def foo(x)
2.2.1 :003?> x = "john"
2.2.1 :004?> end
=> :foo
2.2.1 :005 > foo(str)
(.select js/d3 "#random-mean")
@johnmarinelli
johnmarinelli / julia.clj
Created July 18, 2016 19:22
why isn't `julia-subrect-opt` showing signs of a performance increase, when the its constituent function (for-each-pixel) does?
(defn for-each-pixel [constant max-itrs radius r-min x-step y-step px]
(let [[j i] px
[x y] (normalize-coords (double j) (double i) r-min x-step y-step)
z (->Complex x y)
zitrs (sq-poly-iteration z constant max-itrs radius)
idx (dec (count zitrs))]
(when (> idx @impure/max-idx)
(reset! impure/max-idx idx))
[j i idx]))
;(bench (julia/for-each-pixel (->Complex rc ic) max-itrs radius r-min x-step y-step [xt yt])))
@johnmarinelli
johnmarinelli / main.c
Created September 6, 2016 23:42
c threads
// gcc -g main.c -o a -lpthread
#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
typedef pthread_mutex_t mutex_t;
typedef struct {
int* ary;
@johnmarinelli
johnmarinelli / main.c
Created September 8, 2016 23:10
opengl/osx el capitan
//gcc -Wall main.c -o a -framework OpenGL -framework GLUT
/* Copyright (c) Mark J. Kilgard, 1994. */
/* This program is freely distributable without licensing fees
and is provided without guarantee or warrantee expressed or
implied. This program is -not- in the public domain. */
/* blender renders two spinning icosahedrons (red and green).
The blending factors for the two icosahedrons vary sinusoidally
and slightly out of phase. blender also renders two lines of