Skip to content

Instantly share code, notes, and snippets.

View polybuildr's full-sized avatar

Vivek Ghaisas polybuildr

View GitHub Profile
@polybuildr
polybuildr / Cargo.toml
Last active December 6, 2019 16:07
Rust error message "captured variable cannot escape `FnMut` closure body"
[package]
name = "test"
version = "0.1.0"
authors = ["Foo Bar <foobar@example.com>"]
edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
hyper = "0.12"
@polybuildr
polybuildr / MIT.txt
Last active June 3, 2017 20:28
An MIT license to link to from projects.
The MIT License (MIT)
Copyright (c) 2017 Vivek Ghaisas
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
for name in then_env.borrow().get_all_keys() {
let then_type = then_env.borrow().get_type(&name).unwrap();
if else_env.borrow().get_type(&name).unwrap() != then_type {
issues.push((TypeCheckerIssue::MultipleTypesFromBranchWarning(name.clone()),
s.pos));
env.borrow_mut().set(&name, Type::Any);
} else {
env.borrow_mut().set(&name, then_type);
}
}
#[test]
fn check_reference_error() {
let result = check_and_get_result("var x = 5; y;");
let errors = result.unwrap_err();
assert_eq!(errors.len(), 1);
let &(ref error, ref span) = errors.get(0).unwrap();
assert_eq!(*error, TypeCheckerIssue::InterpreterError(InterpreterError::ReferenceError("y".to_owned())));
}
0.000000 execve("/home/vivek/.nvm/versions/node/v6.7.0/bin/npm", ["npm", "config", "get", "prefix"], [/* 74 vars */]) = 0
0.001610 brk(NULL) = 0x2334000
0.000293 access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
0.000237 mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fe90a598000
0.000243 access("/etc/ld.so.preload", R_OK) = -1 ENOENT (No such file or directory)
0.000178 open("/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
0.000167 fstat(3, {st_mode=S_IFREG|0644, st_size=109256, ...}) = 0
0.000163 mmap(NULL, 109256, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7fe90a57d000
0.000151 close(3) = 0
0.000155 access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)

npm config get prefix

On boot

[vivek@matrix] ~ $ time npm config get prefix
/home/vivek/.nvm/versions/node/v6.7.0
npm config get prefix  1.44s user 0.49s system 5% cpu 33.127 total
[vivek@matrix] ~ $ zprof
num calls time self name
-----------------------------------------------------------------------------------
1) 1 70188.91 70188.91 97.33% 69952.67 69952.67 97.00% nvm_die_on_prefix
2) 1 72111.58 72111.58 100.00% 1546.75 1546.75 2.14% nvm_auto
3) 3 292.23 97.41 0.41% 292.23 97.41 0.41% nvm_has
4) 1 70564.83 70564.83 97.85% 283.53 283.53 0.39% nvm
5) 1 36.44 36.44 0.05% 32.49 32.49 0.05% nvm_ensure_version_installed
6) 1 3.95 3.95 0.01% 3.95 3.95 0.01% nvm_is_version_installed
7) 1 0.81 0.81 0.00% 0.81 0.81 0.00% nvm_supports_source_options
num calls time self name
-----------------------------------------------------------------------------------
1) 1 6873.17 6873.17 88.36% 6822.90 6822.90 87.71% nvm_die_on_prefix
2) 1 7776.01 7776.01 99.96% 513.44 513.44 6.60% nvm_auto
3) 1 7262.58 7262.58 93.36% 275.00 275.00 3.54% nvm
4) 1 111.38 111.38 1.43% 97.92 97.92 1.26% nvm_ensure_version_installed
5) 3 53.54 17.85 0.69% 53.54 17.85 0.69% nvm_has
6) 1 13.46 13.46 0.17% 13.46 13.46 0.17% nvm_is_version_installed
7) 1 1.46 1.46 0.02% 1.46 1.46 0.02% nvm_supports_source_options
8) 2 0.46 0.23 0.01% 0.46 0.23 0.01% title
#lang racket
(define IF
(lambda (test)
(lambda (then)
(lambda (else)
((test then) else)))))
(define true
(lambda (x)
function color_my_prompt {
local __user_and_host="\[\033[01;m\]\u@\h"
local __cur_location="\[\033[01;34m\]\w"
local __git_branch_color="\[\033[01;31m\]"
#local __git_branch="\`ruby -e \"print (%x{git branch 2> /dev/null}.grep(/^\*/).first || '').gsub(/^\* (.+)$/, '(\1) ')\"\`"
local __git_branch='`git branch 2> /dev/null | grep -e ^* | sed -E s/^\\\\\*\ \(.+\)$/\(\\\\\1\)\ /`'
local __prompt_tail="\[\033[00m\]$"
local __last_color="\[\033[00m\]"
export PS1="$__user_and_host $__cur_location $__git_branch_color$__git_branch$__prompt_tail$__last_color "
}