Skip to content

Instantly share code, notes, and snippets.

@aesteve
aesteve / AuthorizationLogic.java
Created December 15, 2015 13:18
centralize auth logic
public static authorize(JsonObject authInfo, Handler<User> onAuthorized, Handler<Throwable> onFailure) {
return res -> {
if (res.succeeded()) {
User user = res.result();
user.isAuthorised("newsletter:edit:13", res2 -> {
if (res2.succeeded()) {
boolean hasPermission = res2.result();
if(hasPermission){
onAuthorized.handle(user);
}
@nivertech
nivertech / aws_signature_v4.py
Created December 15, 2014 12:00
sign AWS Lambda HTTP API request - using AWS Version 4 signature
# AWS Version 4 signing example
# taken from:
# http://docs.aws.amazon.com/general/latest/gr/sigv4-signed-request-examples.html
# Lambda API (InvokeAsync)
# http://docs.aws.amazon.com/lambda/latest/dg/API_InvokeAsync.html
# See: http://docs.aws.amazon.com/general/latest/gr/sigv4_signing.html
# This version makes a POST request and passes request parameters
# in the body (payload) of the request. Auth information is passed in
@maurizi
maurizi / ansible-galaxy.bat
Last active May 21, 2024 02:10
Running Ansible on Windows
@echo off
cygwin-shim.bat /bin/ansible-galaxy %*
@dermesser
dermesser / rope.cpp
Last active November 5, 2023 00:10
A simple rope implementation in C++ – should work well enough.
// Licensed under MIT license.
// (c) Lewin Bormann 2014
# include <string>
# include <iostream>
# include <list>
# include <cstring>
# include <algorithm>
using std::string;
@prabirshrestha
prabirshrestha / .bash_profile
Last active May 19, 2024 08:06
my terminal settings for windows
# curl -Lk https://gist.githubusercontent.com/prabirshrestha/279d8b179d9353fe8694/raw/.bash_profile -o ~/.bash_profile
[[ -s ~/.nvm/nvm.sh ]] && . ~/.nvm/nvm.sh # This loads NVM
export PATH="$HOME/.cargo/bin:$HOME/go/bin:$HOME/Library/Python/3.7/bin:$PATH"
export PATH="$HOME/.config/nvim/plugins/vim-themis/bin:$PATH"
stty -ixon
alias pbcopy='xsel --clipboard --input'
alias pbpaste='xsel --clipboard --output'
@tsiege
tsiege / The Technical Interview Cheat Sheet.md
Last active May 19, 2024 17:40
This is my technical interview cheat sheet. Feel free to fork it or do whatever you want with it. PLEASE let me know if there are any errors or if anything crucial is missing. I will add more links soon.

ANNOUNCEMENT

I have moved this over to the Tech Interview Cheat Sheet Repo and has been expanded and even has code challenges you can run and practice against!






\

@patelm5
patelm5 / self-signed-trust-cert
Created February 5, 2014 10:31
Example of overridding self signed cert process in spring.
@Component
@Profile("untrusted")
public class SelfSignedTrustCertConfigurer {
private final static Logger logger = LoggerFactory.getLogger(SelfSignedTrustCertConfigurer.class.getName());
@PostConstruct
public void allowUntrustedCerts() {
HostnameVerifier hv = new HostnameVerifier() {
public boolean verify(String urlHostName, SSLSession session) {
@mbostock
mbostock / .block
Last active March 1, 2024 06:07
The Gist to Clone All Gists
license: gpl-3.0
@LeszekSwirski
LeszekSwirski / inout.cpp
Last active March 25, 2020 06:48
C++ out/inout parameters
#include <algorithm>
template <typename T>
class out_ {
public:
explicit out_(T& val) : pval(&val) {}
explicit out_() : pval(nullptr) {}
void operator=(const T& newval) {
if (pval) {
@bricef
bricef / AES.c
Last active May 11, 2024 21:15
A simple example of using AES encryption in Java and C.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
/*
* MCrypt API available online:
* http://linux.die.net/man/3/mcrypt
*/
#include <mcrypt.h>