Skip to content

Instantly share code, notes, and snippets.

#!/bin/bash
bundle check || bundle install --jobs 4 --retry 5
pids=( server.pid realtime_updater.pid )
for file in "${pids[@]}"
do
path="tmp/pids/$file"
if [ -f $path ]; then
rm $path
fi
1c2eac3a1b8c0fcde485125c363c753f
1c2eac3a1b8c0fcde485125c363c753f
@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
#!/bin/bash
set -eux
# https://linode.com/docs/databases/redis/install-and-configure-redis-on-centos-7/
sudo yum -y install epel-release
sudo yum update
sudo yum -y install redis
sudo systemctl start redis
sudo systemctl enable redis
@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 / 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,
#import <Foundation/Foundation.h>
NSDictionary *headers = @{ @"content-type": @"multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW",
@"cache-control": @"no-cache",
@"postman-token": @"184d155d-451d-bd9c-06f2-ae6274c61509" };
NSArray *parameters = @[ @{ @"name": @"file", @"fileName": @"/Users/wqn/Downloads/img-test/ym-1.jpeg" } ];
NSString *boundary = @"----WebKitFormBoundary7MA4YWxkTrZu0gW";
NSError *error;
NSMutableString *body = [NSMutableString string];
#
# A fatal error has been detected by the Java Runtime Environment:
#
# SIGILL (0x4) at pc=0x00007fff6899b3ea, pid=59001, tid=0x0000000000001b03
#
# JRE version: Java(TM) SE Runtime Environment (8.0_92-b14) (build 1.8.0_92-b14)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (25.92-b14 mixed mode bsd-amd64 compressed oops)
# Problematic frame:
# C [libsystem_c.dylib+0x5d3ea] __abort+0xb1
#
@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.