Skip to content

Instantly share code, notes, and snippets.

View myw's full-sized avatar

Misha Wolfson myw

View GitHub Profile
@myw
myw / keybase.md
Created September 26, 2019 06:04
Keybase Identity Verification

Keybase proof

I hereby claim:

  • I am myw on github.
  • I am myw01 (https://keybase.io/myw01) on keybase.
  • I have a public key ASBjv1n1yy582iSZL4BAiTavpF0_gIdSrZmK_LFWVE7dego

To claim this, I am signing this object:

@myw
myw / add-dns-search-domains.sh
Last active January 10, 2017 11:08
Add DNS Search domains to the Docker For Mac VM
#!/usr/bin/env bash
# add-dns-search-domain.sh - Tell the Docker for Mac VM to add any search domains
# from the host machine's resolv.conf to its own
# resolv.conf. Must be run every time networking is
# restarted on the Docker VM, or the docker VM
# is rebooted
# Find the search domains from the host's resolv.conf
@myw
myw / scoping_c_inner.c
Last active August 29, 2015 14:26
Examples of function scoping in python, C, and JavaScript
#include <stdio.h>
int func(int, int, int);
int
main()
{
printf("%d\n", func(3, 4, 5));
return 0;
}
@myw
myw / Types.pm
Last active August 29, 2015 14:07
Common type constructs, done in Perl
package Direction;
# Simple algebraic types
sub North {
die 'Invalid type' unless @_ == 1;
bless(sub { 'North' }, shift)
}
sub South {
die 'Invalid type' unless @_ == 1;
bless(sub { 'South' }, shift)
Prelude Data.String Data.List> (delete 'h' . delete 'h') "hi there"
"i tere"
Prelude Data.String Data.List> delete 'h' . delete 'h' $ "hi there"
"i tere"
Prelude Data.String Data.List> delete 'h' . delete 'h' ( "hi there" )
<interactive>:21:14:
Couldn't match expected type `a0 -> [Char]'
with actual type `[Char]'
In the return type of a call of `delete'
@myw
myw / uber_passenger_rating.js
Last active August 29, 2015 14:04
How to get your passenger rating on Uber, via https://medium.com/@aaln/4aa1d9cc927f
if(window.Uber.pingData) {
"Name : " + window.Uber.pingData.client.firstName + " " + window.Uber.pingData.client.lastName +
"\nEmail : "+ window.Uber.pingData.client.email +
"\nPassenger Rating: "+ window.Uber.pingData.client.rating;
}
@myw
myw / ycomb.m
Created April 25, 2012 22:17
Anonymous Y Combinator Factorial Example in Matlab
Y = @(f) ...
feval( ...
@(x) f(@(v) feval(feval(x, x), v)), ...
@(x) f(@(v) feval(feval(x, x), v)));
if_ = @(pred, iftrue, iffalse) ...
[ arrayfun(@(~) iftrue(), zeros( pred())) ...
arrayfun(@(~) iffalse(), zeros(~pred())) ];
then_ = @(x) x;
@myw
myw / gist:2362085
Created April 11, 2012 20:07
More powerful anonymous functions in Matlab
ev = @(varargin) cellfun(@feval, varargin, 'UniformOutput', false);
% Ex.: super_anon = @(a, b, c) ev(...
% @() disp(a), ...
% @() plot(1:b, cos(1:b)), ...
% @() disp(c) )
@myw
myw / struct_examples.m
Created October 31, 2011 22:23
Matlab struct examples
>> j = struct()
j =
1x1 struct array with no fields.
>> j(2).b = 4
j =
@myw
myw / nestStruct.m
Created September 7, 2011 15:07
nested structures in Matlab
>> j = struct('expWLS20110910', struct('temp', 1.3, 'current', 2.3))
j =
expWLS20110910: [1x1 struct]
>> j.expWLS20110910.temp
ans =