Skip to content

Instantly share code, notes, and snippets.

View nonbeing's full-sized avatar
💭
Busy: may be slow to respond.

Ambar nonbeing

💭
Busy: may be slow to respond.
View GitHub Profile
@nonbeing
nonbeing / docker
Created August 9, 2024 10:59 — forked from petruisfan/docker
Docker init.d daemon script
#!/usr/bin/env bash
###############
# SysV Init Information
# description: docker daemon.
### BEGIN INIT INFO
# Provides: me
# Required-Start:
# Required-Stop:
# Default-Start: 2 3 5
@nonbeing
nonbeing / site-to-site.md
Created July 26, 2023 14:26 — forked from kosyfrances/site-to-site.md
Steps to set up one tunnel IPSec Site to site VPN on AWS and a VM on another cloud provider (Packet) running Strongswan
@nonbeing
nonbeing / CameraAnchor.cs
Created October 24, 2022 15:04 — forked from fadookie/CameraAnchor.cs
Screen-relative anchoring component for Unity3D. Find more Unity code at http://www.eliotlash.com/2015/01/unity3d-components-and-code-snippets/
/***
* This script will anchor a GameObject to a relative screen position.
* This script is intended to be used with ViewportHandler.cs by Marcel Căşvan, available here: http://gamedev.stackexchange.com/a/89973/50623
* It is also copied in this gist below.
*
* Note: For performance reasons it's currently assumed that the game resolution will not change after the game starts.
* You could not make this assumption by periodically calling UpdateAnchor() in the Update() function or a coroutine, but is left as an exercise to the reader.
*/
/* The MIT License (MIT)
@nonbeing
nonbeing / default.j2
Created August 26, 2020 17:45 — forked from perfecto25/default.j2
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%;
@nonbeing
nonbeing / serverless.yml
Created August 14, 2020 10:50 — forked from fideliocc/serverless.yml
A serverless project template to deploy Quicksight URL Resolver
service: quicksight-resolver-service
app: quicksight-resolver-app
# TIP: I prefer to use a secret file for sensitive information as a security practice
custom:
secrets: ${file(./secrets.json)}
quickSightEmbedRoleArn:
Fn::GetAtt: [quickSightEmbedRole, Arn]
provider:
@nonbeing
nonbeing / getDashboardUrl.js
Created August 14, 2020 10:50 — forked from fideliocc/getDashboardUrl.js
Lambda function hooked to API Gateway GET endpoint to attend: role assuming, registering for QuickSight and dashboard URL resolving for web app embedding feature
'use strict'
// IMPORTANT: Replace environment variables with your current values
const aws = require('aws-sdk')
aws.config.region = process.env.REGION
const sts = new aws.STS({apiVersion: '2011-06-15'})
module.exports.handler = (event, context, callback) => {
console.log('User email', event.queryStringParameters.email)

How to setup AWS lambda function to talk to the internet and VPC

I'm going to walk you through the steps for setting up a AWS Lambda to talk to the internet and a VPC. Let's dive in.

So it might be really unintuitive at first but lambda functions have three states.

  1. No VPC, where it can talk openly to the web, but can't talk to any of your AWS services.
  2. VPC, the default setting where the lambda function can talk to your AWS services but can't talk to the web.
  3. VPC with NAT, The best of both worlds, AWS services and web.
@nonbeing
nonbeing / bench.py
Created July 10, 2020 06:59 — forked from methane/bench.py
Benchmarking MySQL drivers (Python 3.4)
from __future__ import print_function
import time
def query_10k(cur):
t = time.time()
for _ in range(10000):
cur.execute("SELECT 1,2,3,4,5")
res = cur.fetchall()
assert len(res) == 1
assert res[0] == (1,2,3,4,5)
@nonbeing
nonbeing / README.md
Created January 3, 2020 11:37 — forked from BoGnY/README.md
[WINDOWS] How to enable auto-signing Git commits with GnuPG for programs that don't support it natively

[WINDOWS] How to enable auto-signing Git commits with GnuPG for programs that don't support it natively

This is a step-by-step guide on how to enable auto-signing Git commits with GPG for every applications that don't support it natively (eg. GitHub Desktop, Eclipse, Git Tower, ...)

Requirements

  • Install GPG4Win: this software is a bundle with latest version of GnuPG v2, Kleopatra v3 certificate manager, GNU Privacy Assistant (GPA) v0.9 which is a GUI that uses GTK+, GpgOL and GpgEX that are respectively an extension for MS Outlook and an extension for Windows Explorer shell
  • Install Git for Windows: so you can have a *nix based shell, this software is a bundle with latest version of Git which use MINGW environment, a Git bash shell, a Git GUI and an extension for Windows Explorer shell (Make sure your local version of Git is at least 2.0, otherwise Git don't have support for automatically sign your commits)
  • Verify
@nonbeing
nonbeing / winterm-callout.ahk
Last active December 20, 2019 16:14 — forked from wizcas/winterm-callout.ahk
AHK Script for Calling Out Windows Terminal
; How much height of screen size the terminal window takes.
VRatio := 0.8
; The path to the Windows Terminal exe file.
WtPath = "%LOCALAPPDATA%\Microsoft\WindowsApps\wt.exe"
; my change: toggle on F1 keypress
f1::ToggleTerminal()
ShowAndPositionTerminal()
{