Skip to content

Instantly share code, notes, and snippets.

View ThatsAMorais's full-sized avatar

Alex Morais ThatsAMorais

View GitHub Profile
(defstruct path :state :previous :cost-so-far :total-cost)
(defn path-to-string
[path]
(format "Path to %s, cost %s" (:state path) (:total-cost path)))
(defn make-path
"Create a new path object"
[state previous cost-so-far total-cost]
(struct path state previous cost-so-far total-cost))
@ciaranarcher
ciaranarcher / example.go
Created July 27, 2014 06:53
Wrapping a ResponseWriter to capture the status code
// Create our own MyResponseWriter to wrap a standard http.ResponseWriter
// so we can store the status code.
type MyResponseWriter struct {
status int
http.ResponseWriter
}
func NewMyResponseWriter(res http.ResponseWriter) *MyResponseWriter {
// Default the status code to 200
return &MyResponseWriter{200, res}
@banterCZ
banterCZ / JsfRedirectStrategy.java
Last active May 15, 2021 15:26
InvalidSessionStrategy when session expired and ajax request is done.
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.security.web.session.InvalidSessionStrategy;
import org.springframework.util.StringUtils;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
@coopermaruyama
coopermaruyama / disable-netflix-pauses.js
Last active July 18, 2021 19:16
Netflix: Disable "Are you still watching?" pauses
// copy/paste into chrome console (alt+cmd+J) after the video starts playing.
setInterval(function() {
var possibleButtons = document.getElementsByClassName('continue-playing');
if (possibleButtons.length) {
for (var i = 0; i < possibleButtons.length; i++) {
if (/Continue Playing/.test(possibleButtons[i].textContent)) {
var event = document.createEvent('HTMLEvents');
event.initEvent('click', true, false);
possibleButtons[i].dispatchEvent(event);
}
@sskoopa
sskoopa / docker-run-redis.md
Created January 9, 2017 21:41
Start redis in Docker with a open port at localhost:6379

docker run --name recorder-redis -p 6379:6379 -d redis:alpine

<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>SoundCloud OAuth 2 User Agent Authentication Flow Demo</title>
<script type="text/javascript" charset="utf-8" src="javascript/jquery-1.4.2.js"></script>
<script type="text/javascript" charset="utf-8">
$(function () {
var extractToken = function(hash) {
@perfecto25
perfecto25 / default.j2
Last active July 27, 2023 19:05
Python function to send email using a Jinja HTML template
<style type="text/css">
@font-face {
font-family: 'Open Sans';
font-style: normal;
font-weight: 300;
src: local('Open Sans Light'), local('OpenSans-Light'), url(http://fonts.gstatic.com/s/opensans/v13/DXI1ORHCpsQm3Vp6mXoaTa-j2U0lmluP9RWlSytm3ho.woff2) format('woff2');
unicode-range: U+0460-052F, U+20B4, U+2DE0-2DFF, U+A640-A69F;
}
.body {
width: 90%;
@JeffBelback
JeffBelback / docker-destroy-all.sh
Last active December 12, 2023 17:47
Destroy all Docker Containers and Images
#!/bin/bash
# Stop all containers
containers=`docker ps -a -q`
if [ -n "$containers" ] ; then
docker stop $containers
fi
# Delete all containers
containers=`docker ps -a -q`
if [ -n "$containers" ]; then
docker rm -f -v $containers
@lizthegrey
lizthegrey / attributes.rb
Last active February 24, 2024 14:11
Hardening SSH with 2fa
default['sshd']['sshd_config']['AuthenticationMethods'] = 'publickey,keyboard-interactive:pam'
default['sshd']['sshd_config']['ChallengeResponseAuthentication'] = 'yes'
default['sshd']['sshd_config']['PasswordAuthentication'] = 'no'
@LeCoupa
LeCoupa / redis_cheatsheet.bash
Last active March 18, 2024 09:08
Redis Cheatsheet - Basic Commands You Must Know --> UPDATED VERSION --> https://github.com/LeCoupa/awesome-cheatsheets
# Redis Cheatsheet
# All the commands you need to know
redis-server /path/redis.conf # start redis with the related configuration file
redis-cli # opens a redis prompt
# Strings.