Skip to content

Instantly share code, notes, and snippets.

@zealinux
zealinux / index.js
Created June 9, 2017 15:05 — forked from jfensign/index.js
NodeJS User Registration and Authentication
//index.js
var express = require('express'),
app = module.exports = express.createServer(),
mongoose = require('mongoose');
mongoose.connect('mongodb://localhost/nodeAuth');
//configure app
app.configure(function() {
app.set('views', __dirname + '/views');
@zealinux
zealinux / cuda.env
Created August 10, 2017 13:40 — forked from knzm/cuda.env
install CUDA 7.0 and cuDNN 6.5 v2 on CentOS 7.0
export CUDA_HOME=/usr/local/cuda
export NVIDIA_HOME=/usr/local/nvidia
export PATH=${CUDA_HOME}/bin:${PATH}
export LD_LIBRARY_PATH=${CUDA_HOME}/lib64:${LD_LIBRARY_PATH}
@zealinux
zealinux / tmux_ubuntu14.04.sh
Created August 11, 2017 13:34 — forked from VladSem/tmux_ubuntu14.04.sh
install tmux 2.0 on Ubuntu 14.04
sudo apt-get update
sudo apt-get install -y python-software-properties software-properties-common
sudo add-apt-repository -y ppa:pi-rho/dev
sudo apt-get update
sudo apt-get install -y tmux=2.0-1~ppa1~t
@zealinux
zealinux / sleeping-barber-problem.clj
Created August 21, 2017 23:10 — forked from kachayev/sleeping-barber-problem.clj
Resolve "Sleeping barber problem" with Clojure
(def open-for-business? (atom true))
(def haircut-count (agent 0))
(def waiting-room (ref []))
(def waiting-room-size 3)
(defn open-shop [duration]
(do (Thread/sleep duration) (swap! open-for-business? not)))
(defn add-customers []
(future
require 'faraday'
field_file_url = 'http://localhost/blah'
file_to_upload = 'test.txt'
connection = Faraday.new(field_file_url) do |builder|
builder.request :multipart
builder.request :url_encoded
builder.adapter :net_http
end
@zealinux
zealinux / .dockerignore
Created September 16, 2017 08:12 — forked from davidderus/.dockerignore
Docker + Rails + Puma + Postgres + Nginx
.git
.gitignore
doc
.yardoc
coverage
jsdoc
tmp
log
README.md
public/uploads/
@zealinux
zealinux / java_for_rubyists.md
Created October 16, 2017 06:11 — forked from nilbus/java_for_rubyists.md
Some Java basics for Rubyists
  1. Java uses static, declared typing:

    String hello = "Hello, World!";
    List<String> phrases = new ArrayList<String>;
    phrases.add(hello);
    phrases.add(null);
    phrases.add(123); // Compile error! Not a string.
@zealinux
zealinux / 01-safe-download.rb
Created November 22, 2017 05:52 — forked from janko/01-safe-download.rb
A safe way in Ruby to download a file to disk using open-uri (with/without comments)
require "open-uri"
require "net/http"
Error = Class.new(StandardError)
DOWNLOAD_ERRORS = [
SocketError,
OpenURI::HTTPError,
RuntimeError,
URI::InvalidURIError,
@zealinux
zealinux / send_data-send_file-remote-images-download
Created November 22, 2017 05:55 — forked from maxivak/send_data-send_file-remote-images-download
Rails. Download remote image as attachment in browser
# in controller
# for local files
send_file '/path/to/file', :type => 'image/jpeg', :disposition => 'attachment'
# for remote files
require 'open-uri'
url = 'http://someserver.com/path/../filename.jpg'
data = open(url).read
send_data data, :disposition => 'attachment', :filename=>"photo.jpg"
@zealinux
zealinux / gist:c54d79740fd5e1194596583f105efb4b
Created January 9, 2018 05:38 — forked from mtigas/gist:952344
Mini tutorial for configuring client-side SSL certificates.

Client-side SSL

For excessively paranoid client authentication.

Using self-signed certificate.

Create a Certificate Authority root (which represents this server)

Organization & Common Name: Some human identifier for this server CA.

openssl genrsa -des3 -out ca.key 4096
openssl req -new -x509 -days 365 -key ca.key -out ca.crt