Skip to content

Instantly share code, notes, and snippets.

View tarvos21's full-sized avatar
🏠
Working from blackhole

bing tarvos21

🏠
Working from blackhole
View GitHub Profile
@tarvos21
tarvos21 / node-and-npm-in-30-seconds.sh
Created February 3, 2017 13:35 — forked from isaacs/node-and-npm-in-30-seconds.sh
Use one of these techniques to install node and npm without having to sudo. Discussed in more detail at http://joyeur.com/2010/12/10/installing-node-and-npm/ Note: npm >=0.3 is *safer* when using sudo.
echo 'export PATH=$HOME/local/bin:$PATH' >> ~/.bashrc
. ~/.bashrc
mkdir ~/local
mkdir ~/node-latest-install
cd ~/node-latest-install
curl http://nodejs.org/dist/node-latest.tar.gz | tar xz --strip-components=1
./configure --prefix=~/local
make install # ok, fine, this step probably takes more than 30 seconds...
curl https://www.npmjs.org/install.sh | sh
#!/usr/bin/env python
from datetime import datetime as dt
from datetime import timedelta as td
from calendar import monthrange
import calendar
# Put your birthday here
birthday = dt(1970, 1, 1)
@tarvos21
tarvos21 / current-dir-in-iterm-tab-title.sh
Created March 3, 2017 02:39 — forked from phette23/current-dir-in-iterm-tab-title.sh
Set the iTerm tab title to the current directory, not full path.
# put this in your .bash_profile
if [ $ITERM_SESSION_ID ]; then
export PROMPT_COMMAND='echo -ne "\033];${PWD##*/}\007"; ':"$PROMPT_COMMAND";
fi
# Piece-by-Piece Explanation:
# the if condition makes sure we only screw with $PROMPT_COMMAND if we're in an iTerm environment
# iTerm happens to give each session a unique $ITERM_SESSION_ID we can use, $ITERM_PROFILE is an option too
# the $PROMPT_COMMAND environment variable is executed every time a command is run
# see: ss64.com/bash/syntax-prompt.html
@tarvos21
tarvos21 / dummy-web-server.py
Created March 15, 2017 10:53 — forked from bradmontgomery/dummy-web-server.py
a minimal http server in python. Responds to GET, HEAD, POST requests, but will fail on anything else.
#!/usr/bin/env python
"""
Very simple HTTP server in python.
Usage::
./dummy-web-server.py [<port>]
Send a GET request::
curl http://localhost
@tarvos21
tarvos21 / web-servers.md
Created May 19, 2017 15:55 — forked from willurd/web-servers.md
Big list of http static server one-liners

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000
@tarvos21
tarvos21 / sample_route.py
Created May 26, 2017 17:54 — forked from johnschimmel/sample_route.py
Sample of Flask receiving JSON
# If /json route receives header "application/json"
@app.route("/json", methods=['GET','POST'])
def json():
app.logger.debug("JSON received...")
app.logger.debug(request.json)
if request.json:
mydata = request.json # will be
## you may need sudo permission to execute some commands or swith to root
# if installed old version by yum, remove it first
sudo yum remove tmux libevent libevent-devel libevent-headers
# install deps
sudo yum install gcc kernel-devel make ncurses-devel
# create temp dir
mkdir /tmp/for-latest-tmux
@tarvos21
tarvos21 / alexa.js
Created September 30, 2017 15:33 — forked from chilts/alexa.js
Getting the Alexa top 1 million sites directly from the server, unzipping it, parsing the csv and getting each line as an array.
var request = require('request');
var unzip = require('unzip');
var csv2 = require('csv2');
request.get('http://s3.amazonaws.com/alexa-static/top-1m.csv.zip')
.pipe(unzip.Parse())
.on('entry', function (entry) {
entry.pipe(csv2()).on('data', console.log);
})
;
@tarvos21
tarvos21 / _prime_nn.rb
Created January 4, 2018 14:27 — forked from JoshCheek/_prime_nn.rb
Overfit neural network to find prime numbers
def is_prime?(n)
bits = 8.times.map { |i| n[i] }
[[[-8.8, 3.0, 9.2, 5.0, -4.8, 5.6, -5.8, 6.1, -6.1],
[-1.8, 2.3, -2.6, -5.6, 0.1, 6.0, -4.7, -5.7, -3.0],
[-3.6, -4.1, 6.5, -0.6, -2.8, -2.6, 2.4, -2.3, 1.0],
[ 2.4, -9.1, -3.1, 7.8, -3.7, -8.9, -2.8, 5.6, 6.3],
[-2.0, 4.0, 11.0, 3.3, -6.0, 0.7, -7.0, 1.6, -3.0],
[ 0.7, -7.2, 2.8, 4.5, -3.6, -1.5, 2.7, -0.1, -3.5],
[-8.9, 5.5, 4.8, -4.1, 5.6, 4.8, 5.5, -4.0, -6.4],
[-4.0, -6.7, -3.6, 5.5, 2.5, -6.9, 7.8, -4.1, -0.4],
@tarvos21
tarvos21 / emoji.json
Created November 25, 2019 17:14 — forked from leechannl/emoji.json
iOS input emoji mapping
{"墨鏡":{"emoji":["😎"]},
"泰國":{"emoji":["🇹🇭"]},
"南苏丹共和国":{"emoji":["🇸🇸"]},
"让利":{"emoji":["🈹️"]},
"男性":{"emoji":["🚹"]},
"向日葵":{"emoji":["🌻"]},
"營":{"emoji":["🈺️"]},
"斯里兰卡":{"emoji":["🇱🇰"]},
"兔子脸":{"emoji":["🐰"]},
"虫子":{"emoji":["🐛","🐜"]},