Skip to content

Instantly share code, notes, and snippets.

Avatar

JRichardsz jrichardsz

View GitHub Profile
View log controller web, log view, java.java
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.nio.file.StandardOpenOption;
import java.util.Map;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
@jrichardsz
jrichardsz / go to slide on click - google app script presentation - v1.0.0.js
Created Jun 30, 2022
go to slide on click - google app script presentation
View go to slide on click - google app script presentation - v1.0.0.js
function configureOnclickCustomEvents() {
const slides = SlidesApp.getActivePresentation().getSlides();
var slidesById = {};
for(var slide of slides){
var rawNote = getRawNote(slide);
var slideData = rawStringToObject(rawNote);
slidesById[slideData.id] = slide;
}
@jrichardsz
jrichardsz / google app script - presentation
Last active Jun 30, 2022
google app script - presentation
View google app script - presentation
https://developers.google.com/apps-script/reference/slides
https://developers.google.com/apps-script/reference/slides/shape
https://github.com/googleworkspace/apps-script-samples/blob/master/advanced/slides.gs
https://gist.github.com/tanaikech/aa0a03ba3c440ca72fc1d7e02f038f7c
https://gist.github.com/tanaikech/aa0a03ba3c440ca72fc1d7e02f038f7c
View print div html.js
function printDiv(divName) {
var printContents = document.getElementById(divName).innerHTML;
var originalContents = document.body.innerHTML;
document.body.innerHTML = printContents;
window.print();
document.body.innerHTML = originalContents;
}
View google app script as http rest api - hello world.md
function doGet(e) {
    var response = {
      "code": 200,
      "message": "hell world google app script"
    };
    return ContentService.createTextOutput(JSON.stringify(response)).setMimeType(ContentService.MimeType.JSON);
}

function doGet(e) {
View linux shell snippets : restart on freeze.sh
now=$(date '+%Y-%m-%d_%H-%M-%S')
free_ram=$(free -h | awk '/^Mem:/{print $4}')
cpu_usage=$(grep 'cpu ' /proc/stat | awk '{usage=($2+$4)*100/($2+$4+$5)} END {print usage "%"}')
response_code=$(curl -s -o /dev/null -w "%{http_code}" localhost:8080/login)
if [[ "$response_code" -ne "200" ]]; then
echo "$now foo http is down with code:$response_code free_ram:$free_ram cpu_usage:$cpu_usage " >> /home/ubuntu/restart.log
shutdown -r
else
echo "$now foo http is up with code:$response_code free_ram:$free_ram cpu_usage:$cpu_usage" >> /home/ubuntu/restart.log
fi
View nodejs shell exec.js
// scriptString = scriptString.replace(new RegExp('\n$'), '');
// scriptString = scriptString.replace(/\n/g, " && ");
// if (process.env.ENABLE_LOG === "true") {
// console.log(scriptString);
// }
//
// var child = require('child_process').exec(scriptString)
// // child.stdout.pipe(process.stdout)
//
View multiline script.sh
for n in {1..100}
do
echo "$n"
sleep 1
done
View AWSElasticBeanstalkFullAccess.json
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"elasticbeanstalk:*",
"ec2:*",
"ecs:*",
"ecr:*",
@jrichardsz
jrichardsz / upload file nodejs.md
Last active Jun 9, 2022
upload http file snippets
View upload file nodejs.md

server.js

var os = require('os');
var express = require('express');
const app = express();
var path = require('path')
var fs = require('fs')
var xssEscape = require('xss-escape');