Skip to content

Instantly share code, notes, and snippets.

View betapcode's full-sized avatar

Phạm Ngọc Minh betapcode

  • tamtay.vn
  • Hà Nội - Việt Nam
View GitHub Profile
@betapcode
betapcode / certbot-renew.sh
Last active September 4, 2018 02:36
Simple Certbot (Let's Encrypt) script for auto-renewal certificates
#!/bin/bash
# Source
# https://gist.github.com/betapcode/fb906d2757bad1c071cbf71e5586bfe8
# Make sure this is added to the crontab, ie:
# sudo crontab -e
# MAILTO="[email protected]"
# 30 2 * */3 * /opt/certbot-renew.sh
# Config
web_service="nginx";
@betapcode
betapcode / pullJSON.js
Created July 14, 2018 06:29 — forked from varun-raj/pullJSON.js
Google App Script To Fetch Data From JSON Webservice and Write them to google spreadsheet.
function pullJSON() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheets = ss.getSheets();
var sheet = ss.getActiveSheet();
var url="http://example.com/feeds?type=json"; // Paste your JSON URL here
var response = UrlFetchApp.fetch(url); // get feed
var dataAll = JSON.parse(response.getContentText()); //
@betapcode
betapcode / google-img-resize.mdown
Created May 17, 2018 04:56
Google’s authentication-less on-the-fly image resizing service

Google's authentication-less on-the-fly image resizing service

I found it while poking around the Google+ HTML. Jotting down some notes felt like a good idea, so here goes. If you know more about this API, let me know, please!

(Word of warning: I spent ~30 minutes on both my experimentation and this here write-up, so it might not be the most thought-provoking, brilliant thing you read today.)

@betapcode
betapcode / simpleimage.php
Created April 21, 2018 10:40 — forked from miguelfrmn/simpleimage.php
SimpleImage PHP Class
<?php
/**
* File: SimpleImage.php
* Author: Simon Jarvis
* Modified by: Miguel Fermín
* Based in: http://www.white-hat-web-design.co.uk/articles/php-image-resizing.php
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
user apache;
worker_processes 4;
error_log logs/error.log;
pid /var/run/nginx.pid;
events {
worker_connections 2048;
}
@betapcode
betapcode / nginx.service
Created December 28, 2017 10:43
ubuntu 16 nginx.service
[Unit]
Description=The NGINX HTTP and reverse proxy server
After=syslog.target network.target remote-fs.target nss-lookup.target
[Service]
Type=forking
PIDFile=/var/run/nginx.pid
ExecStartPre=/usr/sbin/nginx -t
ExecStart=/usr/sbin/nginx
ExecReload=/bin/kill -s HUP $MAINPID
#! /bin/sh
### BEGIN INIT INFO
# Provides: nginx
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: nginx init.d dash script for Ubuntu or other *nix.
# Description: nginx init.d dash script for Ubuntu or other *nix.
### END INIT INFO
yum install libmpc-devel mpfr-devel gmp-devel
cd /usr/src/
curl ftp://ftp.mirrorservice.org/sites/sourceware.org/pub/gcc/releases/gcc-4.9.3/gcc-4.9.3.tar.bz2 -O
tar xvfj gcc-4.9.3.tar.bz2
cd gcc-4.9.3
./configure --disable-multilib --enable-languages=c,c++
make -j `grep processor /proc/cpuinfo | wc -l`
make install
@betapcode
betapcode / gist:a4dbbdd95185a2637f81534cc3338bb7
Created December 23, 2017 17:45 — forked from craigminihan/gist:b23c06afd9073ec32e0c
Build GCC 4.9.2 for C/C++ on CentOS 7
sudo yum install libmpc-devel mpfr-devel gmp-devel
cd ~/Downloads
curl ftp://ftp.mirrorservice.org/sites/sourceware.org/pub/gcc/releases/gcc-4.9.2/gcc-4.9.2.tar.bz2 -O
tar xvfj gcc-4.9.2.tar.bz2
cd gcc-4.9.2
./configure --disable-multilib --enable-languages=c,c++
make -j 4
make install