Skip to content

Instantly share code, notes, and snippets.

View jamesbee's full-sized avatar
😘

James Become jamesbee

😘
View GitHub Profile
@jamesbee
jamesbee / web-servers.md
Created September 13, 2022 07:42 — 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
@jamesbee
jamesbee / .gemrc
Created July 19, 2015 15:46
Gem resource configure file.
---
:backtrace: false
:bulk_threshold: 1000
:sources:
- https://ruby.taobao.org/
:update_sources: true
:verbose: true
benchmark: false
gem: "--no-document"
#! /bin/bash
sudo -i
echo "Create '/swapfile'"
fallocate -l "$1G" /swapfile
chmod 600 /swapfile
mkswap /swapfile
swapon /swapfile
echo ""
@jamesbee
jamesbee / awe.rb
Created June 3, 2015 08:18
ping urls
class PingPool
def initialize(count)
@count = count
DATA.each_line do |line|
line = line.strip
next if line.start_with? '#'
next if line == ''
if line.index("#(")
self.batch /#(\(.*\))/, line
elsif line.index("#[")
@jamesbee
jamesbee / init.sh
Last active August 29, 2015 14:21
Ubuntu init up
#! /bin/bash
cd ~
su -c "echo 'export LC_ALL=en_US.UTF-8' >> /etc/profile"
source /etc/profile
sudo apt-get update
sudo apt-get install git curl build-essential openssh-server libmysqlclient-dev libpython2.7-dev \
python-pip zsh
# sudo pip install ipython
curl -L install.ohmyz.sh|bash
@jamesbee
jamesbee / conn.ex
Last active August 29, 2015 14:16
Elixir connect to mysql example
defmodule Conn do
def test do
stat = "select * from users limit 10;"
:emysql.add_pool :demo_pool, [
size: 1,
user: 'root',
password: 'root',
database: 'demo',
encoding: :utf8 # you will need this
@jamesbee
jamesbee / conn.ex
Last active October 6, 2016 22:23
Elixir connect to cassandra example
defmodule Conn do
def test do
{ok, client} = :cqerl.new_client({})
{ok, result} = :cqerl.run_query(client, "SELECT * FROM demodb.users;")
rows = :cqerl.all_rows(result)
end
end