Skip to content

Instantly share code, notes, and snippets.

View ossareh's full-sized avatar

P. Michael Ossareh ossareh

View GitHub Profile
@ossareh
ossareh / CMakeLists.txt
Created July 21, 2020 16:29 — forked from hovren/CMakeLists.txt
pybind11 with CMake and setup.py
# Build a Python extension module using pybind11
# pybindings_add_module(<module>)
# Here <module> should be the fully qualified name for the module,
# e.g. pybindings_add_module(foo.bar._baz)
# <module> becomes the target name in case you wish to do something to it later
# The source for the binding *must* be placed in src/pybindings/{relpath}/py{name}.cc
# E.g. for module=foo.bar._baz -> src/pybindings/bar/py_baz.cc
function(pybindings_add_module module)
set(target_name ${module})
string(REPLACE "." "/" modpath ${module})

In github we can add editable todo lists:

  • here is an unchecked element
  • here is a checked one
@ossareh
ossareh / async.js
Last active August 20, 2018 01:10
wut?
#!/usr/bin/env node
const inputs = [false, false, false, true, false, false];
const fast = (i, d) => {
console.log(`run ${d}`);
return i;
};
const slow = async (i) => {
return new Promise((resolve, reject) => {

Keybase proof

I hereby claim:

  • I am ossareh on github.
  • I am ossareh (https://keybase.io/ossareh) on keybase.
  • I have a public key ASCDpytm2j9S46-A1Wg1i514M_kbo8sjnskIFi4zNfTG_Ao

To claim this, I am signing this object:

$ cat echo.c
#include <stdio.h>
int main() {
int c;
while ((c = getchar()) != EOF) {
putchar(c);
}
@ossareh
ossareh / gist:2154684
Created March 22, 2012 00:40
devise flay
$ find . -type f -name '*.rb' | xargs flay
parse error on value "table_name" (tIDENTIFIER)
skipping ./lib/generators/active_record/templates/migration.rb
parse error on value "table_name" (tIDENTIFIER)
skipping ./lib/generators/active_record/templates/migration_existing.rb
Total score (lower is better) = 6797
1) Similar code found in :iter (mass = 306)
./test/routes_test.rb:162
@ossareh
ossareh / gist:2154670
Created March 22, 2012 00:39
devise flog
$ find . -type f -name '*.rb' | xargs flog
#<Racc::ParseError:
parse error on value "table_name" (tIDENTIFIER)> at /usr/share/ruby-rvm/rubies/ree-1.8.7-2011.03/lib/ruby/1.8/racc/parser.rb:350:in `on_error', /usr/share/ruby-rvm/rubies/ree-1.8.7-2011.03/lib/ruby/1.8/racc/parser.rb:99:in `_racc_do_parse_c', /usr/share/ruby-rvm/rubies/ree-1.8.7-2011.03/lib/ruby/1.8/racc/parser.rb:99:in `__send__', /usr/share/ruby-rvm/rubies/ree-1.8.7-2011.03/lib/ruby/1.8/racc/parser.rb:99:in `do_parse', /usr/share/ruby-rvm/gems/ree-1.8.7-2011.03@jtv_rails3/gems/ruby_parser-2.3.1/lib/ruby_parser_extras.rb:750:in `process'
...stupid lemmings and their bad erb templates... skipping
#<Racc::ParseError:
parse error on value "table_name" (tIDENTIFIER)> at /usr/share/ruby-rvm/rubies/ree-1.8.7-2011.03/lib/ruby/1.8/racc/parser.rb:350:in `on_error', /usr/share/ruby-rvm/rubies/ree-1.8.7-2011.03/lib/ruby/1.8/racc/parser.rb:99:in `_racc_do_parse_c', /usr/share/ruby-rvm/rubies/ree-1.8.7-2011.03/lib/ruby/1.8/racc/parser.rb:99:in `__send__',
riak_search> name:gran and name:"tur*"
{<<"games">>,<<"Gran%20Trak%2010">>,[{p,[0]},{score,0.0645806583071036}]}
{<<"games">>,<<"Gran%20Turismo">>,[{p,[0]},{score,0.0645806583071036}]}
{<<"games">>,<<"Gran%20Turismo%202">>,[{p,[0]},{score,0.0645806583071036}]}
{<<"games">>,<<"Gran%20Turismo%203%20A-Spec">>,
[{p,[0]},{score,0.0645806583071036}]}
{<<"games">>,<<"Gran%20Turismo%204">>,[{p,[0]},{score,0.0645806583071036}]}
{<<"games">>,<<"Gran%20Turismo%204%3A%20Prologue">>,
[{p,[0]},{score,0.0645806583071036}]}
{<<"games">>,<<"Gran%20Turismo%205">>,[{p,[0]},{score,0.0645806583071036}]}
@ossareh
ossareh / exception
Created March 23, 2011 20:22
trace from riak logs when parsing string with \r\n in it
=ERROR REPORT==== 23-Mar-2011::13:20:53 ===
** State machine <0.1359.255> terminating
** Last event in was {mapexec_error,
{362449,'riak@127.0.0.1'},
{error,
[{<<"lineno">>,483},
{<<"message">>,<<"JSON.parse">>},
{<<"source">>,<<"unknown">>}]}}
** When State == executing
** Data == {state,0,riak_kv_map_phase,
@ossareh
ossareh / why_clojure_rawks.clj
Created January 5, 2011 23:16
transform ratios to map and back again
(defmulti transform-ratio
"Transforms Ratios to and from maps. Passes other values through without changing them unless they are of type clojure.lang.Ratio or clojure.lang.PersistenArrayMap. In the case of a map they must be annotated with :t \"ratio\" otherwise they'll get passed through too"
class)
(defmethod transform-ratio :default [v] v)
(defmethod transform-ratio clojure.lang.Ratio [value]
{:n (numerator value)
:d (denominator value)