Skip to content

Instantly share code, notes, and snippets.

@jtzero
jtzero / unc_path.rb
Created October 3, 2012 16:21
Ruby realpath returns the unc path if available for mapped drive
# * *author* : jtzero
# * *version* : 1.2.3
# * *description* : returns the unc path of a file when using realdir
#
require 'win32api'
class IO
WNetGetConnection = begin
Win32API.new("mpr.dll", "WNetGetConnection", ['P','P','P'], 'L')
rescue #if not windows just return 0
lambda {|locate, remote, size| remote = local; next 0 }
@jtzero
jtzero / ruby.nanorc
Last active March 7, 2019 06:23
a better ruby.nanorc /usr/share/nano/ruby.nanorc
## Here is an example for Ruby.
##
syntax "ruby" "(Gemfile|Rakefile|\.(rb|rake|gemspec|ru|simplecov))$"
header "^#!.*(env\s|\/)ruby[-0-9._]*"
## Asciibetical list of reserved words
color yellow "\<(BEGIN|END|alias|and|begin|break|case|class|def|defined\?|do|else|elsif|end|ensure|false|for|if|in|lambda|module|next|nil|not|or|redo|rescue|retry|return|self|super|then|true|undef|unless|until|when|while|yield)\>"
## Constants
color brightblue "(\$|@|@@)?\<[A-Z]+[0-9A-Z_a-z]*"
@jtzero
jtzero / gist:7456626
Created November 13, 2013 21:22
@metajack's post saved from codexon Category: Internet, Programming, Python The recent server benchmark posted here comparing Erlang, Haskell, and Python understandably upset many people. Today we will move away from polarizing benchmarks and more about features. Even though Erlang may not be the fastest language, it still has at least one grea…
import os
import time
import socket
import sys
import fcntl
import _multiprocessing
from multiprocessing import Pipe
# global pipe variable
pipe = None

cd ~/Downloads

wget http://repo.zabbix.com/zabbix/3.2/ubuntu/pool/main/z/zabbix-release/zabbix-release_3.2-1+xenial_all.deb

dpkg -i zabbix-release_3.2-1+xenial_all.deb

apt-get update

should add /etc/apt/sources.list.d/zabbix.list

pre 0.9.0

shell# echo '
[sshd]
enabled = true
filter = sshd
action = iptables-multiport
logpath = /var/log/auth.log
maxretry = 3
def const_source_location(const)
if method_name = const.instance_methods.sort.find {|m| const.instance_method(m).owner == const }
const.instance_method(method_name).source_location
else
raise "`#{const}' has no uninherited/mixed in instance methods"
end
end
@jtzero
jtzero / object.rb
Last active March 1, 2019 05:20
elixir like pipes in ruby
# asdf
#=> nil
# [3] pry(main)> 'asdf' >> pipeto(:puts, 'asdff')
# asdf
# asdff
#=> nil
# [4] pry(main)> 'asdf' >>
# -> x { x + 'q' } >>
# -> x { x + 'w' }
# asdfqw
@jtzero
jtzero / Jupyter command find_spark_home.py not found
Last active May 28, 2020 04:35
Jupyter command `jupyter-/home/jtzero/.local/share/virtualenvs/ml-.../bin/find_spark_home.py` not found.
```
(email_ml) jtzero:~/Documents/ml$ PYSPARK_DRIVER_PYTHON=jupyter PYSPARK_DRIVER_PYTHON_OPTS='notebook' pyspark
Traceback (most recent call last):
File "/home/jtzero/.local/share/virtualenvs/ml-PBkX3P8r/bin/jupyter", line 8, in <module>
sys.exit(main())
File "/home/jtzero/.local/share/virtualenvs/ml-PBkX3P8r/lib/python3.7/site-packages/jupyter_core/command.py", line 247, in main
command = _jupyter_abspath(subcommand)
File "/home/jtzero/.local/share/virtualenvs/ml-PBkX3P8r/lib/python3.7/site-packages/jupyter_core/command.py", line 134, in _jupyter_abspath
'Jupyter command `{}` not found.'.format(jupyter_subcommand)
Exception: Jupyter command `jupyter-/home/jtzero/.local/share/virtualenvs/ml-PBkX3P8r/bin/find_spark_home.py` not found.
### Keybase proof
I hereby claim:
* I am jtzero on github.
* I am behrensrkyle (https://keybase.io/behrensrkyle) on keybase.
* I have a public key ASDqn5MwgQE_HtMfs9-SOkFMq5PEdr621S30b73pVBQJ_Ao
To claim this, I am signing this object:
### Keybase proof
I hereby claim:
* I am jtzero on github.
* I am jtzero (https://keybase.io/jtzero) on keybase.
* I have a public key ASCj7tmuy-kpBaObL7J8_-EjqUGyVL4wZVdU9OVOyayaIAo
To claim this, I am signing this object: