Skip to content

Instantly share code, notes, and snippets.

View jaredonline's full-sized avatar

Jared McFarland jaredonline

View GitHub Profile
$ cpp -I. -I/Users/jmcfarland/code/php/ext/rust_fib -DPHP_ATOM_INC -I/Users/jmcfarland/code/php/ext/rust_fib/include -I/Users/jmcfarland/code/php/ext/rust_fib/main -I/Users/jmcfarland/code/php/ext/rust_fib -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -I/usr/include/php/ext/date/lib -DHAVE_CONFIG_H -g -O2 rust_fib.c
#### OUTPUT
# 1 "rust_fib.c"
# 1 "<built-in>" 1
# 1 "<built-in>" 3
# 169 "<built-in>" 3
# 1 "<command line>" 1
# 1 "<built-in>" 2
$ valgrind --leak-check=yes ./php ~/code/php/ext/rust_a_star/src/rust_a_star.php
==15950== Memcheck, a memory error detector
==15950== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
==15950== Using Valgrind-3.11.0.SVN and LibVEX; rerun with -h for copyright info
==15950== Command: ./php /Users/jmcfarland/code/php/ext/rust_a_star/src/rust_a_star.php
==15950==
--15950-- ./php:
--15950-- dSYM directory is missing; consider using --dsymutil=yes
--15950-- UNKNOWN host message [id 412, to mach_host_self(), reply 0x30f]
--15950-- UNKNOWN host message [id 222, to mach_host_self(), reply 0x30f]
@jaredonline
jaredonline / gist:1224439
Created September 17, 2011 22:19
Method deprecation helper
module MethodDeprecator
def self.included(base)
base.extend(ClassMethods)
end
module ClassMethods
def deprecate_method(method, replacement)
class_eval <<-DEPRECATE_METHOD_END
def #{method.to_s}_with_deprecation
puts "WARNING: Deprecated method #{self.class}##{method.to_s} called, use #{replacement} instead. Called from #{Kernel.caller[0]}"
@jaredonline
jaredonline / gist:1231156
Created September 21, 2011 03:22
Homeworks
/* Here's what you've got */
/*
Problem 2: You are asked to implement an automated number-to-language translation system for a phone com- pany. Write a C program that receives as an input an integer number and converts each digit of the number to an English word. The integer number can be of any length.
Sample program execution:
Please enter your phone number: 2345769854 two three four five seven six nine eight five four
*/
def percent_asset_split
plan.best_investment(risk_index).map do |symbol, percentage|
::Position.new(:symbol => symbol.to_s, :amount => percentage.to_f, :account => self.account).asset_allocation
end.sum.compress.to_percent
end
hash = { ... some stuff ... }
keys = hash.keys
random_key = keys[(rand(keys.count)]
hash[random_key]
require 'benchmark'
Benchmark.bm(30) do |x|
x.report("Test One") do
# .. code for your first version here ..
end
x.report("Test Two") do
# .. code for your second version here ..
end
@jaredonline
jaredonline / Console Output
Created November 21, 2015 13:07
Error installing Relay example
jared@Jareds-MacBook ~/code/js$ cd relay/examples/todo && npm install
> babel-relay-plugin@0.4.2 prepublish /Users/jared/code/js/relay/scripts/babel-relay-plugin
> npm run build
> babel-relay-plugin@0.4.2 build /Users/jared/code/js/relay/scripts/babel-relay-plugin
> scripts/build-lib
module.js:339