Skip to content

Instantly share code, notes, and snippets.

View gatspy's full-sized avatar

CG.gatspy gatspy

View GitHub Profile
@gatspy
gatspy / rotate_slice.go
Created February 28, 2020 05:13 — forked from marz619/rotate_slice.go
Rotate a slice
package aoc
import (
"errors"
"reflect"
)
// rotate rotates the values of a slice by rotate positions, preserving the
// rotated values by wrapping them around the slice
func rotate(slice interface{}, rotate int) error {
@gatspy
gatspy / 1-sleep-es7.js
Created January 13, 2020 11:52 — forked from danharper/1-sleep-es7.js
ES7's async/await syntax.
// ES7, async/await
function sleep(ms = 0) {
return new Promise(r => setTimeout(r, ms));
}
(async () => {
console.log('a');
await sleep(1000);
console.log('b');
})()
@gatspy
gatspy / gorm_joins.go
Created January 10, 2020 00:17 — forked from kavirajk/gorm_joins.go
Understanding Joins in gorm
package main
import (
"fmt"
"log"
"github.com/jinzhu/gorm"
_ "github.com/lib/pq"
)
@gatspy
gatspy / axios.refresh_token.js
Created July 15, 2019 10:50 — forked from Godofbrowser/axios.refresh_token.1.js
Axios interceptor for refresh token when you have multiple parallel requests
// for multiple requests
let isRefreshing = false;
let failedQueue = [];
const processQueue = (error, token = null) => {
failedQueue.forEach(prom => {
if (error) {
prom.reject(error);
} else {
prom.resolve(token);
@gatspy
gatspy / aescmd.go
Created June 6, 2019 07:39 — forked from josephspurrier/aescmd.go
Golang - Encrypt, Decrypt, File Read, File Write, Readline
package main
import (
"bufio"
"crypto/aes"
"crypto/cipher"
"crypto/rand"
"fmt"
"io"
"io/ioutil"
@gatspy
gatspy / asymmetric.go
Created June 4, 2019 20:18 — forked from cryptix/LICENSE
example of using JWT for http authentication in go
package main
// using asymmetric crypto/RSA keys
import (
"crypto/rsa"
"fmt"
"io/ioutil"
"log"
"net/http"
@gatspy
gatspy / save_screenshot.py
Created April 7, 2019 16:40 — forked from fabtho/save_screenshot.py
make full screenshot with selenium in python
#!/usr/bin/python
from selenium import webdriver
from PIL import Image
from cStringIO import StringIO
verbose = 1
browser = webdriver.Firefox()
browser.get('http://stackoverflow.com/questions/37906704/taking-a-whole-page-screenshot-with-selenium-marionette-in-python')
{"schema_version": "3.0.0", "repositories": ["https://bitbucket.org/jjones028/p4sublime/raw/tip/packages.json", "https://bitbucket.org/klorenz/sublime_packages/raw/tip/packages.json", "https://packagecontrol.io/packages_2.json", "https://packagecontrol.io/repository.json", "https://packages.monokai.pro/packages.json", "https://raw.githubusercontent.com/20Tauri/DoxyDoxygen/master/DoxyDoxygen.json", "https://raw.githubusercontent.com/Andr3as/Sublime-SurroundWith/master/packages.json", "https://raw.githubusercontent.com/FichteFoll/sublime_packages/master/package_control.json", "https://raw.githubusercontent.com/Floobits/floobits-sublime/master/packages.json", "https://raw.githubusercontent.com/Harrison-M/indent.txt-sublime/master/packages.json", "https://raw.githubusercontent.com/Hexenon/FoxCode/master/packages.json", "https://raw.githubusercontent.com/Kaizhi/SublimeUpdater/master/packages.json", "https://raw.githubusercontent.com/Kasoki/FancyProjects/master/packages.json", "https://raw.githubusercontent.com/Mat
@gatspy
gatspy / SlackController.java
Created March 28, 2019 07:47 — forked from dogeared/SlackController.java
application/x-www-form-urlencoded to POJO like a boss - HttpMessageConverter approach
@RestController
@RequestMapping("/api/v1")
public class SlackController {
private static final Logger log = LoggerFactory.getLogger(SlackController.class);
@RequestMapping(
value = "/slack", method = RequestMethod.POST,
consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE, produces = MediaType.APPLICATION_JSON_VALUE
)
@gatspy
gatspy / Nginx-minio-static.md
Created March 13, 2019 16:39 — forked from harshavardhana/nginx-minio-static.md
How to configure nginx+minio static website?

Ubuntu 16.04

  1. Install nginx
  2. Install minio
  3. Install mc client
  4. Create a bucket:
$ mc mb myminio/static
Bucket created successfully ‘myminio/static’.