Skip to content

Instantly share code, notes, and snippets.

@nathan-ca
nathan-ca / samplerest.js
Created October 25, 2020 03:41 — forked from joshbirk/samplerest.js
Sample of using passport w/ mult strategies
var fs = require("fs")
var ssl_options = {
key: fs.readFileSync('privatekey.pem'),
cert: fs.readFileSync('certificate.pem')
};
var port = process.env.PORT || 3000;
var express = require('express');
var ejs = require('ejs');
var passport = require('passport')
@nathan-ca
nathan-ca / demo_kill.py
Created October 19, 2018 18:19
Python catch signal
#!/usr/bin/env python
import os
import signal
import time
# Reference:
# https://stackoverflow.com/questions/18499497/how-to-process-sigterm-signal-gracefully
# What signals to catch?
# $ kill -l
# 2) SIGINT 3) SIGQUIT 15) SIGTERM
@nathan-ca
nathan-ca / nginx
Created May 4, 2017 06:26 — forked from tejasbubane/nginx
nginx logrotate script for centOS. Location: /etc/logrotate.d/nginx. Later change /etc/logrotate.conf add daily and change or comment "rotate" number (preferably comment to keep all log files -> symlinked to /mnt so no space issue)
/opt/nginx/logs/*.log {
daily
missingok
rotate 52
compress
delaycompress
notifempty
create 640 root adm
sharedscripts
postrotate
@nathan-ca
nathan-ca / example.html
Created March 15, 2017 22:07 — forked from evansims/example.html
Embedding or sharing a image or photo uploaded to Google Drive.
<a href="https://drive.google.com/uc?export=view&id=XXX"><img src="https://drive.google.com/uc?export=view&id=XXX" style="width: 500px; max-width: 100%; height: auto" title="Click for the larger version." /></a>
@nathan-ca
nathan-ca / MainAcitivity.java
Created November 20, 2016 03:35 — forked from shakil807g/MainAcitivity.java
Multiple Image Upload Using okhttp3 android
@OnClick(R.id.fabupload)
public void upload(){
Toast.makeText(MainActivity.this, "click", Toast.LENGTH_SHORT).show();
RequestBody requestBody = new MultipartBody.Builder()
.setType(MultipartBody.FORM)
.addFormDataPart("title", "Square Logo")
.addFormDataPart("image0","upload",
import android.content.Context;
import android.content.SharedPreferences;
import android.text.TextUtils;
import android.util.Log;
import java.io.*;
import java.net.CookieStore;
import java.net.HttpCookie;
import java.net.URI;
import java.net.URISyntaxException;