Skip to content

Instantly share code, notes, and snippets.

package main
import (
"github.com/ory-am/hydra/sdk"
"log"
)
const clientID = "150e7592-8b54-47f9-80fc-ba2af28762f3"
const clientSecret = ""
const state = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"

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.
@michaeldelorenzo
michaeldelorenzo / 00-setup.sql
Last active October 16, 2015 07:20
Tree structure query with PostgreSQL
-- Create tables
CREATE TABLE groups (id serial NOT NULL, name character varying NOT NULL);
CREATE TABLE network_group_members (pid integer, cid integer NOT NULL);
-- Insert the groups
INSERT INTO groups (name) VALUES ('GROUP 1'),('GROUP 2'),('GROUP 3'),('GROUP 4'),('GROUP 5'),('GROUP 6'),('GROUP 7'),('GROUP 8'),('GROUP 9'),('GROUP 10'),('GROUP 11'),('GROUP 12'),('GROUP 13');
-- Build the "Network"
INSERT INTO network_group_members(pid,cid) VALUES (1,2),(1,3),(1,4),(2,5),(5,6),(5,7),(7,8),(3,9),(4,10),(4,11),(11,12),(12,13);
CREATE OR REPLACE FUNCTION generate_object_id() RETURNS varchar AS $$
DECLARE
time_component bigint;
machine_id int := FLOOR(random() * 16777215);
process_id int;
seq_id bigint := FLOOR(random() * 16777215);
result varchar:= '';
BEGIN
SELECT FLOOR(EXTRACT(EPOCH FROM clock_timestamp())) INTO time_component;
SELECT pg_backend_pid() INTO process_id;
def process_logo_data_uri
if self.logo_data_uri && !self.logo_data_uri.split(",").last.nil?
data = StringIO.new(Base64.decode64(self.logo_data_uri))
data.class_eval do
attr_accessor :content_type, :original_filename
end
data.content_type = self.logo_data_uri.match(/image\/[a-z]{3,}/i).to_s
data.original_filename = "image_name.#{data.content_type.to_s}"
<?xml version="1.0" encoding="UTF-8"?>
<Error>
<Code>HttpVersionNotSupported</Code>
<Message>The HTTP version specified is not supported.</Message>
<RequestId>7B165C5A5D92CAAC</RequestId>
<HostId>ZTIdb2aSv0zuQL+lE7uCV5U/2Db2ifYyRNoXm56xJAuJ1x6c0+pyJjFNd3qZ0jpvqHw3HtzhYisoqO7UmeyAPE8mqmfYGtJw</HostId>
</Error>

OS X Screencast to animated GIF

This gist shows how to create a GIF screencast using only free OS X tools: QuickTime, ffmpeg, and gifsicle.

Screencapture GIF

Instructions

To capture the video (filesize: 19MB), using the free "QuickTime Player" application:

// create an index with an analyzer "myindex"
curl -X PUT localhost:9200/myindex -d '
{
"settings" : {`
"index":{
"number_of_replicas":0,
"number_of_shards":1,
"analysis":{
"analyzer":{
"first":{
server:
type: simple
applicationContextPath: /singularity
connector:
type: http
port: 8081
requestLog:
appenders:
- type: file
currentLogFilename: ../logs/access.log
cookbook 'docker', '~> 0.36.0'